-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor.cgi
More file actions
65 lines (58 loc) · 2.29 KB
/
monitor.cgi
File metadata and controls
65 lines (58 loc) · 2.29 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl -w
$ENV{'PATH'}='/bin:/sbin:/usr/bin:/usr/sbin:/usr/lib/nagios/plugins:/usr/local/bin';
$statUp = 'up';
$statDown = 'down';
$iconsDir = "../icons/monitor/";
#@symmetrix = {'979', '098'};
@hosts = ( ['unix', 'hercules1', 'hercules2', 'titan1', 'titan2', 'hercules', 'apollo', 'lotus'],
['windows', 'tsdrp01', 'tsdrp02', 'tsdrp03', 'tsdrp04', 'solodrp01', 'dc1drp', 'rasdrp01', 'emcsrv02'],
['mcdata', 'kf-mcdata', 'drp-mcdata'],
['cisco', 'kf-cisco', 'drp-cisco', 'drp-server-sw'] );
my @errors;
my @operates;
for ($i=0;$i<=$#hosts;$i++) {
for ($j=0;$j<=$#{$hosts[$i]};$j++) {
if ($j == 0) {
$type = $hosts[$i][$j];
$j++;
}
if (($type =~ /\bunix\b/) && (chkHost($hosts[$i][$j], 23) > 0) || (pingHost($hosts[$i][$j]) > 0)) {
print "$hosts[$i][$j] <img src=$iconsDir$type$statDown.jpg>";
} elsif ($type =~ /\bunix\b/) {
print "$hosts[$i][$j] <img src=$iconsDir$type$statUp.jpg>";
}
if (($type =~ /\bwindows\b/) && (chkHost($hosts[$i][$j], 3389) > 0) || (pingHost($hosts[$i][$j]) > 0)) {
print "$hosts[$i][$j] <img src=$iconsDir$type$statDown.jpg>";
} elsif ($type =~ /\bwindows\b/) {
print "$hosts[$i][$j] <img src=$iconsDir$type$statUp.jpg>";
}
if (($type =~ /\bmcdata\b/) || ($type =~ /\bcisco\b/) && (pingHost($hosts[$i][$j]) > 0)) {
print "$hosts[$i][$j] <img src=$iconsDir$type$statDown.jpg>";
} elsif (($type =~ /\bmcdata\b/) || ($type =~ /\bcisco\b/)) {
print "$hosts[$i][$j] <img src=$iconsDir$type$statUp.jpg>";
}
print "<br>";
}
}
sub chkHost {
($host, $port) = @_;
system("check_tcp -p $port -H $host >/dev/null");
return $?;
}
sub pingHost {
$host = shift;
system ("check_icmp -H $host >/dev/null");
return $?;
}
print "Content-type: text/html\n\n";
print <<"EOF";
<HTML>
<HEAD>
<TITLE>Monitor DRP</TITLE>
</HEAD>
<BODY>
EOF
print <<"EOF";
</BODY>
</HTML>
EOF