monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Check if my IP address has changed ?


From: Callum Macdonald
Subject: Re: Check if my IP address has changed ?
Date: Fri, 15 Feb 2013 12:15:22 +0700

If you want a fast solution, use this:

check program ipverify with path "/root/ipverify.sh"
        if status != 0 then exec "ifconfig whatever whatever"

Then create /root/ipverify.sh like so:

#!/bin/bash
ifconfig eth0 | grep 10.1.1.151

Grep will exit with a non-zero status code if no match is found, which
will in turn trigger monit to run your exec statement, which will do
whatever you want to set your IP.

I thought also about connection testing and so on, you can try that, but
if anything else on the network takes that IP, then your tests will
pass, even if your IP is not up on that machine. Plus there are probably
other subtle failure scenarios not covered by the connection test.

I'd suggest the above approach if you want a quick hack to get this
working while you figure out the OS ip issues.

Love & joy - Callum.

On Fri, 2013-02-15 at 03:15 +0000, Stephen Butler wrote:
> I was wondering if I could use a connection test.
> 
> 
> I have monit running on the server in question to keep an eye on samba
> and openssh.
> I've enabled the httpd for remote gui access.
> 
> 
> Could I not just do a connection test, the servers lan ip address is
> 10.1.1.151 and it has the port 2812 open for the httpd part of monit.
> 
> 
> Can i do some kind of test with monit to check that ip address, and if
> there is no return ping then run a shell script that will sort out my
> ip address ?
> 
> 
> PS I know this is a problem to fix in the OS or some other running
> program, and I'm looking into that, however I need a quick patch asap.
> 
> 
> Here is my /etc/monitrc file.
> 
> 
> ---------------------
> set daemon  60              # check services at 1-minute intervals
> 
> 
> set logfile syslog facility log_daemon
> 
> 
> set httpd port 2812 and
>     use address 10.1.1.152  # only accept connection from localhost
>     allow 0.0.0.0/0.0.0.0        # allow localhost to connect to the
> server and
>     allow admin:monit      # require user 'admin' with password
> 'monit'
> 
> 
> check process smbd with pidfile /var/run/smbd.pid
>  start program = "/usr/local/etc/init.d/samba start"
>  stop program = "/usr/local/etc/init.d/samba stop"
> 
> 
> check process sshd with pidfile /var/run/sshd.pid
>  start program = "/usr/local/etc/init.d/openssh start"
>  stop program = "/usr/local/etc/init.d/openssh stop"
> ---------------------
> 
> 
> Thanks all.
> Stephen.
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general





reply via email to

[Prev in Thread] Current Thread [Next in Thread]