Update of /cvsroot/mon/mon
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16117
Modified Files:
mon
Log Message:
updated some changes from mon-1.2.0
Index: mon
===================================================================
RCS file: /cvsroot/mon/mon/mon,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** mon 13 Jul 2006 12:03:39 -0000 1.22
--- mon 15 Jul 2007 13:21:48 -0000 1.23
***************
*** 1133,1141 ****
if (defined $2) {
if ($2 =~ /y(es)?/i) {
! $2 = 1;
} elsif ($2 =~ /n(o)?/i) {
! $2 = 0;
! }
! if ($2 eq "0" || $2 eq "1") {
$UNACK_SUMMARY = $2;
} else {
--- 1133,1140 ----
if (defined $2) {
if ($2 =~ /y(es)?/i) {
! $UNACK_SUMMARY = 1;
} elsif ($2 =~ /n(o)?/i) {
! $UNACK_SUMMARY = 0;
! } elsif ($2 eq "0" || $2 eq "1") {
$UNACK_SUMMARY = $2;
} else {
***************
*** 2888,2911 ****
}
! if (@notfound == 0)
{
foreach my $h (@hosts)
{
! if (my $g=host_singleton_group($h) ) {
disen_watch($g, 0);
- $stchanged++;
mysystem("$CF{MONREMOTE} disable watch $g") if ($CF{MONREMOTE});
- } else {
- disen_host ($h, 0);
- $stchanged++;
- mysystem("$CF{MONREMOTE} disable host $h") if ($CF{MONREMOTE});
}
}
sock_write ($fh, "220 disable host completed\n");
}
- else
- {
- sock_write ($fh, "520 disable host failed, @notfound does not exist\n");
- }
} else {
--- 2887,2915 ----
}
! if (@notfound)
! {
! sock_write ($fh, "520 disable host failed, host(s) @notfound do not exist\n");
! }
!
! else
{
foreach my $h (@hosts)
{
! #
! # disable a watch if there is a group with this host
! # as its only member. this prevents warning messages
! # about monitors not being run on empty host groups
! #
! foreach my $g (host_singleton_group($h)) {
disen_watch($g, 0);
mysystem("$CF{MONREMOTE} disable watch $g") if ($CF{MONREMOTE});
}
+
+ disen_host ($h, 0);
+ $stchanged++;
+ mysystem("$CF{MONREMOTE} disable host $h") if ($CF{MONREMOTE});
}
sock_write ($fh, "220 disable host completed\n");
}
} else {
***************
*** 2913,2917 ****
}
-
#
# enable watch, service or host
--- 2917,2920 ----
***************
*** 2952,2964 ****
} elsif ($cmd eq "host") {
foreach my $h (split (/\s+/, $args)) {
! if (my $g=host_singleton_group($h) ) {
disen_watch($g, 1);
mysystem("$CF{MONREMOTE} enable watch $g") if ($CF{MONREMOTE});
- $stchanged++;
- } else {
- disen_host ($h, 1);
- mysystem("$CF{MONREMOTE} enable host $h") if ($CF{MONREMOTE});
- $stchanged++;
}
}
sock_write ($fh, "220 enable completed\n");
--- 2955,2966 ----
} elsif ($cmd eq "host") {
foreach my $h (split (/\s+/, $args)) {
! foreach my $g (host_singleton_group($h)) {
disen_watch($g, 1);
mysystem("$CF{MONREMOTE} enable watch $g") if ($CF{MONREMOTE});
}
+
+ disen_host ($h, 1);
+ mysystem("$CF{MONREMOTE} enable host $h") if ($CF{MONREMOTE});
+ $stchanged++;
}
sock_write ($fh, "220 enable completed\n");
***************
*** 3796,3814 ****
}
sub host_singleton_group {
my $host = shift;
! my $found;
foreach my $g (keys %groups) {
! if (grep (/^$host$/, @{$groups{$g}}) &&
scalar(@{$groups{$g}}) == 1)
{
! $found = $g;
! last;
}
}
! $found;
}
--- 3798,3823 ----
}
+
+
+ #
+ # given a host, search groups and return an array of group
+ # names which have that host as their only member. return
+ # an empty array if no group found
+ #
+ #
sub host_singleton_group {
my $host = shift;
! my @found;
foreach my $g (keys %groups) {
! if (grep (/^\*?$host$/, @{$groups{$g}}) &&
scalar(@{$groups{$g}}) == 1)
{
! push (@found, $g);
}
}
! return (@found);
}
|