File: perl-bindings

package info (click to toggle)
rrdtool 1.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,772 kB
  • sloc: ansic: 39,371; sh: 1,810; perl: 1,268; cs: 652; makefile: 573; python: 169; ruby: 61; awk: 30
file content (42 lines) | stat: -rwxr-xr-x 1,268 bytes parent folder | download
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
#!/usr/bin/perl
use strict;
use warnings;
use RRDs;
use File::Spec;

print "===== Starting Perl bindings test =====\n";

my $rrd = "perl_test.rrd";
my $png = "perl_test.png";

END {
    unlink $rrd if -e $rrd;
    unlink $png if -e $png;
}

print "--> Creating RRD via Perl bindings...\n";
RRDs::create($rrd, "--step", "60", "--start", "now-10m",
             "DS:test:GAUGE:120:0:100",
             "RRA:AVERAGE:0.5:1:10");
die "Failed to create RRD file: ".RRDs::error."\n" if RRDs::error;
print "OK: RRD file created.\n";

print "--> Updating RRD via Perl bindings...\n";
RRDs::update($rrd, "N:42");
die "Failed to update RRD file: ".RRDs::error."\n" if RRDs::error;
print "OK: RRD file updated.\n";

print "--> Fetching data via Perl bindings...\n";
my ($start, $step, $ds_names, $data) = RRDs::fetch($rrd, "AVERAGE", "--start", "now-5m");
die "Failed to fetch data: ".RRDs::error."\n" if RRDs::error;
print "OK: Data fetched.\n";

print "--> Creating graph via Perl bindings...\n";
RRDs::graph($png, "--start", "now-10m",
            "DEF:mydata=$rrd:test:AVERAGE",
            "LINE1:mydata#00FF00:test data");
die "Failed to create graph: ".RRDs::error."\n" if RRDs::error;
print "OK: Graph created.\n";

print "===== Perl bindings test PASSED =====\n";
exit 0;