On Tue, Jul 01, 2003 at 09:07:58PM +0200, Heinrich Langos wrote:
> 
> hi jim
> 
> 
> 
> On Tue, Jul 01, 2003 at 11:16:20AM -0700, Jim Trocki wrote:
> > On Tue, 1 Jul 2003 [EMAIL PROTECTED] wrote:
> > 
> > > I would like to put multiple monitor checks under one service entry.
> > > Is that possible at all ??
> > > I havn't found anthing contrary on the man page.
> > 
> > can't do that. only one of each parameter is allowed in the service
> > definition, except for periods.
> 
> does that mean that multiple "depends" statemants are also not possible?? 
> if that is true, i think mon should check such configurations and (at least)
> give a warning about it.
> 
> > 
> > > Situation:
> > > I have to check a group of hosts that listen on a certain port and
> > > one host that happens to listen on another port. The service they run is the
> > > same. therefore I would like to keep them together in the checking.
> > 
> > the way to tackle this problem is to make changes to tcp.monitor to figure
> > out which ports to use for which hosts, via reading a separate config file
> > or parsing a hostname as "hostname:port". for example:
> > 
> > 
> > hostgroup somehosts host1 host2 host3:9999 anotherhost:29999
> > 
> > watch somehosts
> >     service port-listening
> >         interval 10m
> >         monitor tcp.monitor
> 
> 
> yeap .. that sounds pretty reasonably. I'll get back to you with a patch
> tomorrow.
> 

Here's the patch. I tried to keep the summary reporting compatible to the
old format and only changed the details to indicate the port when it was 
supplied by the new host:port notation.

feel free to change anything you want.

best regards
-henrik
--- tcp.monitor_backup  Wed Jul  2 15:10:56 2003
+++ tcp.monitor Wed Jul  2 15:57:30 2003
@@ -50,18 +50,27 @@
        die "could not create socket: $!\n";
     }
 
+    my ($thishost,$thisport) = split(/:/, $host, 2);
+    my $port;
+    if ($thisport) {
+       $host=$thishost;
+       $port=$thisport;
+    }else{
+        $port=$PORT;
+    }
+
     my $a = inet_aton ($host);
     if (!defined $a) {
        push @failures, $host;
-       push @detail, "$host could not inet_aton";
+       push @detail, "$host".(defined($thisport)?":$port":"")." could not inet_aton";
        close (S);
        next;
     }
 
-    my $sin = sockaddr_in ($PORT, $a);
+    my $sin = sockaddr_in ($port, $a);
     if (!defined $sin) {
        push @failures, $host;
-       push @detail, "$host could not sockaddr_in";
+       push @detail, "$host".(defined($thisport)?":$port":"")." could not 
sockaddr_in";
        close (S);
        next;
     }
@@ -82,10 +91,10 @@
        push @failures, $host;
 
        if ($@ eq "alarm\n") {
-           push @detail, "$host timeout";
+           push @detail, "$host".(defined($thisport)?":$port":"")." timeout";
 
        } else {
-           push @detail, "$host interrupted syscall: $!";
+           push @detail, "$host".(defined($thisport)?":$port":"")." interrupted 
syscall: $!";
        }
 
        close (S);
@@ -94,14 +103,14 @@
 
     if (!defined $r) {
        push @failures, $host;
-       push @detail, "$host could not connect: $!";
+       push @detail, "$host".(defined($thisport)?":$port":"")." could not connect: 
$!";
        close (S);
        next;
     }
 
     if (!defined close (S)) {
        push @failures, $host;
-       push @detail, "$host could not close socket: $!";
+       push @detail, "$host".(defined($thisport)?":$port":"")." could not close 
socket: $!";
        next;
     }
 }
_______________________________________________
mon mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/mon

Reply via email to