root/resmon

Revision 9adf5e86f48122c081b0557248285f968efd7e52, 1.1 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 17 years ago)

INODES monitor and setsid/fork support

git-svn-id: https://labs.omniti.com/resmon/trunk@6 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

  • Property mode set to 100755
Line 
1 #!/usr/bin/perl
2
3 push @INC, '/opt/resmon';
4
5 use strict;
6 use Time::HiRes qw( gettimeofday tv_interval sleep );
7 use POSIX qw( setsid );
8 use vars qw($opt_c $opt_d $opt_f $list);
9
10 require 'getopts.pl';
11 require 'resmon_conf.pl';
12 require 'resmon_code.pl';
13
14 Getopts('c:df:');
15
16 $opt_c ||= 'resmon.conf';
17 die "Cannot open configuration file: $opt_c" unless (-r $opt_c);
18
19 sub configure {
20   $list = parse_config($opt_c);
21   set_statusfile($opt_f) if($opt_f);
22 }
23 unless($opt_d) {
24   fork && exit;
25   setsid;
26 }
27 configure();
28 $SIG{'HUP'} = \&configure;
29 while(1) {
30   foreach my $monobj (@$list) {
31     my $coderef = fetch_monitor($monobj->{'type'});
32     unless($coderef) {
33       $coderef = fetch_monitor($monobj->{'type'});
34     }
35     if($coderef) {
36       print_statusfile($monobj->{'object'}."(".$monobj->{'type'}
37                         .") :: ".$coderef->($monobj)."\n");
38     } else {
39       print_statusfile($monobj->{'object'}."(".$monobj->{'type'}
40                         .") :: BAD(no monitor available)\n");
41     }
42   }
43   close_statusfile();
44   wait_interval();
45   print "\n---- ".localtime(time)."----------\n"
46     unless open_statusfile();
47 }
48
Note: See TracBrowser for help on using the browser.