Hi Lads,

Me and my co-workers have an active-passive director setup and we
modified mon.cgi and the mon configuration file to auto detect which
host is running the mon daemon. In this way we have 1 mon.cgi for 2 mon
daemons and we always get a display of the active mon daemon. It
requires mon.monitor and mon daemon on the server serving the cgi
script. director1_hostname and director2_hostname are the dns names for
your directors running mon. Maybe somebody else finds this useful for
his/ her setup.

Here are the changes:


mon.cgi
-------------------------
146c146
<           $required_mon_client_version $css_style $zebra_table);
---
>           $required_mon_client_version $css_style $zebra_table $host);
179c179,200
< $moncgi_config_file = "/etc/mon/mon.cgi.cf";
---
> $monhost = check_host();
> $logo_link = "http://".$monhost;
> sub check_host(){
>       use vars qw(@monitoringhosts $tmph $exec $running);
>       # /usr/lib/mon/mon.d/mon.monitor
>       @monitoringhosts = ("director1_hostname","director2_hostname");
>       foreach $tmph (@monitoringhosts){
>               $ENV{"PATH"} = "";
>               $exec = "/usr/lib/mon/mon.d/mon.monitor $tmph";
>               if($exec =~ /(.*)/){
>                       $exec = $1;
>                       open(HOST,"$exec|") or die "Unable to run $exec:
$!\n";
>                       while( defined($running = <HOST>)){
>                               if($running =~ /running/){
>                                       $host = $tmph;
>                               }
>                       }
>                       close(HOST);
>               }
>       }
>         return $host;
> }
181a203
> $moncgi_config_file = "/etc/mon/mon_autodetect.cgi.cf";
-----------------------


mon.cf
-----------------------
33c33
< logo_link = http://director1_hostname
---
> # logo_link = http://director1_hostname
39c39
< monhost = director1_hostname
---
> # monhost = director1_hostname
-----------------------

Regards,

Sebastiaan Veldhuisen
Leiden University


_______________________________________________
mon mailing list
mon@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/mon

Reply via email to