File: rrd-dump

package info (click to toggle)
cricket 1.0.5-9
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,480 kB
  • ctags: 390
  • sloc: perl: 8,287; sh: 920; ansic: 318; makefile: 62; sql: 16
file content (92 lines) | stat: -rwxr-xr-x 1,900 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/local/bin/perl -w 
# -*- perl -*-

# this is a little script to exercise RRD::File -- useful
# when I was developing it, and possibly useful now too

BEGIN {
	my $programdir = (($0 =~ m:^(.*/):)[0] || "./") . "..";
	eval "require '$programdir/cricket-conf.pl'";
	eval "require '/usr/local/etc/cricket-conf.pl'"
					unless $Common::global::gInstallRoot;
	$Common::global::gInstallRoot ||= $programdir;
}

use lib "$Common::global::gInstallRoot/lib";
use RRD::File;

my($rrd) = new RRD::File ( -file => $ARGV[0] );

$rrd->open();
if ($rrd->loadHeader()) {
	my(@info) = ($rrd->ds_cnt(), $rrd->rra_cnt(), $rrd->pdp_step());
	print "Header info: ", join(",", @info), "\n";

} else {
	print STDERR "Could not read RRD file: $RRD::File::gErr\n";
	exit 1;
};

print "\n";

foreach $i (0 .. $rrd->ds_cnt()-1) {
	print "DS $i:\t";
	print join(",", %{$rrd->ds_def($i)}), "\n";
}
print "\n";

foreach $i (0 .. $rrd->rra_cnt()-1) {
	print "RRA $i:\t";
	print join(",", %{$rrd->rra_def($i)}), "\n";
}
print "\n";

print "Live header:\n";
print "\tlast update time: ", $rrd->last_up();
print "\n\n";

foreach $i (0 .. $rrd->ds_cnt()-1) {
	print "PDP $i:\t";
	print join(",", %{$rrd->pdp($i)}), "\n";
}
print "\n";

print "CDP's:\n";
foreach $i (0 .. $rrd->rra_cnt()-1) {
	print "rra=$i\n";
	foreach $j (0 .. $rrd->ds_cnt()-1) {
		print "\tds=$j:\t";
		print join(",", %{$rrd->cdp($rrd->ds_cnt() * $i + $j)}), "\n";
	}
}
print "\n";

print "RRA ptrs\n";
foreach $i (0 .. $rrd->rra_cnt()-1) {
	print " $i: ", $rrd->rra_ptr($i), "\n";
}
print "\n";

print "Current values\n";
foreach $i (0 .. $rrd->ds_cnt()-1) {
	print " $i: ", $rrd->getDSCurrentValue($i), "\n";
}
print "\n";

$rrd->close();

print "Metadata:\n";
$meta = $rrd->getMeta();

my($k);
foreach $k (keys(%{$meta})) {
	print "\t$k: $meta->{$k}\n";

	# for testing setMeta
#	if ($k eq "last-inst") {
#		$meta->{$k}++;
#	}
}

#$rrd->setMeta($meta);