forked from mmitch/rrd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunrrd.pl
executable file
·41 lines (37 loc) · 870 Bytes
/
runrrd.pl
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
#!/usr/bin/perl
#
# RRD script stub to run all configured modules
# 2011 (c) by Tobias Diedrich <[email protected]>
# Licensed under GNU GPL.
#
use strict;
use warnings;
use RRDs;
# parse configuration file
my %conf;
#my $return = do "/root/.rrd-conf.pl"; # does not work?!?
#print "return=$return run_modules=";
#print $conf{RUN_MODULES};
eval `/bin/cat ~/.rrd-conf.pl`;
# whoami?
my $hostname = `/bin/hostname`;
chomp $hostname;
my @modules = @{$conf{RUN_MODULES}};
foreach my $module (@modules) {
my $time = time();
my $content;
# my $pid = fork();
# if ($pid == 0) {
print "Running module $module: ";
open FH, "<", "modules/$module";
read FH, $content, 9999999;
eval $content;
close FH;
$time = time() - $time;
print "$time seconds\n";
# exit(0);
# }
}
my $pid;
while (($pid = wait()) != -1) { print "pid $pid done\n"};
print "Done.\n";