/[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

Diff of /sap.monitor

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by dpavlin, Wed Jul 10 12:36:57 2002 UTC revision 1.6 by dpavlin, Wed Jul 17 10:18:14 2002 UTC
# Line 14  use Getopt::Std; Line 14  use Getopt::Std;
14  # change paths here if you want to  # change paths here if you want to
15  my $CONFIG = "/usr/local/etc/sap-mon.conf";  my $CONFIG = "/usr/local/etc/sap-mon.conf";
16  my $SAPINFO = "/usr/local/bin/sapinfo";  my $SAPINFO = "/usr/local/bin/sapinfo";
17    # number of tries to repeat sapinfo if it fails first time
18    my $repeat = 3;
19    
20  my %opts;  my %opts;
21  getopt('h:s:H:S:', \%opts);  getopt('h:s:H:S:', \%opts);
# Line 42  foreach (@config) { Line 44  foreach (@config) {
44                  (($opts{s} && $sysnr  =~ m/$opts{s}/) || not $opts{s}) &&                  (($opts{s} && $sysnr  =~ m/$opts{s}/) || not $opts{s}) &&
45                  (($opts{H} && $ashost !~ m/$opts{H}/) || not $opts{H}) &&                  (($opts{H} && $ashost !~ m/$opts{H}/) || not $opts{H}) &&
46                  (($opts{S} && $sysnr  !~ m/$opts{S}/) || not $opts{S}) ) {                  (($opts{S} && $sysnr  !~ m/$opts{S}/) || not $opts{S}) ) {
47                  my $output = `$SAPINFO trace=0 ashost=$ashost sysnr=$sysnr`;                  my $ret = 1;
48                    my $loop = 0;
49                    my $output;
50                    for(my $i=0; $i<$repeat; $i++) {
51                            $output = `$SAPINFO trace=0 ashost=$ashost sysnr=$sysnr`;
52                            $ret &= $?;
53    #                       print "$loop: $ashost $sysnr $ret\n";
54                            last if ($ret == 0);
55                            $loop++;
56                            sleep 5;
57                    }
58                  $output =~ m/System ID\s+(\w+)/;                  $output =~ m/System ID\s+(\w+)/;
59                  my $sys_id = $1 || "";                  my $sys_id = $1 || "";
60                  if ($? != 0) {                  if ($ret != 0) {
61                          push @failed, "$ashost ($sysnr)";                          push @failed, "$ashost ($sysnr)";
62                          $fail_msg .= $output;                          $fail_msg .= $output;
63                  } else {                  } else {
# Line 57  foreach (@config) { Line 69  foreach (@config) {
69  my $exit = 0;  my $exit = 0;
70    
71  if (@failed) {  if (@failed) {
72          print "FAILED HOSTS: ",join(", ",@failed),"\n\n";          print join(", ",@failed)," FAILED\n\n";
73          print "$fail_msg\n";          print "$fail_msg\n";
74          $exit = 1;          $exit = 1;
75  }  }
76    
77  print "CHECKED HOSTS (which are OK): ",join(", ",@ok),"\n\n";  print "ALL OK\nCHECKED HOSTS (which are OK): ",join(", ",@ok),"\n\n";
78    
79  rmdir "/tmp/sap$$"              || die "can't rmdir in /tmp/sap$$: $!";  rmdir "/tmp/sap$$"              || die "can't rmdir in /tmp/sap$$: $!";
80    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.26