/[mon-modules]/sap.monitor
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /sap.monitor

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Wed Jul 10 08:31:21 2002 UTC (21 years, 9 months ago) by dpavlin
Branch: MAIN
Changes since 1.1: +3 -0 lines
added credits

1 #!/usr/bin/perl -w
2 # File: sap.monitor
3 # Author: Dobrica Pavlinusic, dpavlin@rot13.org
4 # Description: monitor sap servers using sapinfo from RFCSDK
5
6 use strict;
7
8 my @config;
9 open(C,"/usr/local/etc/sap-mon.conf") || die "sap-mon.conf: $!";
10 @config = <C>;
11 close(C);
12
13 my @failed;
14 my @ok;
15 my $fail_msg = "";
16
17 # sap info leaves trace files, so create dir without write permission
18 # and chdir to it!
19 mkdir "/tmp/sap$$",0555 || die "can't make /tmp/sap$$: $!";
20 chdir "/tmp/sap$$" || die "can't chdir in /tmp/sap$$: $!";
21
22 foreach (@config) {
23 chomp;
24 s/#.+$//g; # nuke comments
25 s/^\s+$//g; # remove empty lines
26 my ($ashost,$sysnr) = split(/\t+/,$_,2);
27 if ($ashost && $ashost ne "" && $sysnr && $sysnr ne "") {
28 my $output = `/usr/local/bin/sapinfo trace=0 ashost=$ashost sysnr=$sysnr`;
29 $output =~ m/System ID\s+(\w+)/;
30 my $sys_id = $1 || "";
31 if ($? != 0) {
32 push @failed, "$ashost ($sysnr)";
33 $fail_msg .= $output;
34 } else {
35 push @ok, "$ashost ($sys_id)";
36 }
37 }
38 }
39
40 my $exit = 0;
41
42 if (@failed) {
43 print "FAILED HOSTS: ",join(", ",@failed),"\n\n";
44 print "$fail_msg\n";
45 $exit = 1;
46 }
47
48 print "CHECKED HOSTS (which are OK): ",join(", ",@ok),"\n\n";
49
50 rmdir "/tmp/sap$$" || die "can't rmdir in /tmp/sap$$: $!";
51
52 exit $exit;

  ViewVC Help
Powered by ViewVC 1.1.26