Even if it's not possible to do this directly in Monit, you should be
able to hook into the interface management scripts (I believe a post
ifup hook should be able to check whether the IP address is what you
expect, and take whatever corrective action is deemed suitable; how to
do this is utterly dependent on your distro).
However, why are you needing to do this? If you're using a static IP,
then this shouldn't be an issue to begin with, unless there's something
wrong with your system's interface management scripts--and if you're
using DHCP, then assigning a "static" IP is the responsibility of the
DHCP server, not the client.
Enterprise-class routers support static leases, where the DHCP
server compares the MAC address to a fixed list and, if found,
assigns the IP address in the list, rather than the usual
round-robin approach. Typically, these "fixed" addresses are outside
the normal DHCP range. Very handy when you want the convenience of
DHCP, with the utility of fixed addresses (I use DHCP almost
exclusively at home, with a short lease time; if I need to change
network infrastructure--DNS, NTP, etc--I just reconfigure the DHCP
server and it will hand out the new information when the leases are
renewed, while preserving fixed IP addresses).
I *never* configure network-critical servers this way; they are
/always/ statically configured, but I only have one /critical/
server in each of the networks I am responsible for (small
networks).
If you're using a home or home-office router, then you're
/generally/ out of luck (commercially, this is considered a
"premium" feature), unless you replace the firmware with something
like OpenWRT (as I've done). If you decide to do this, check
carefully that OpenWRT is compatible with your router hardware first.
Or, run a standalone DHCP server that supports it; /dnsmasq/ handles
this quite nicely if I recall (same software that OpenWRT uses, I
think).
On 02/11/2013 07:34 PM, Stephen Butler wrote:
> Is it possible to get monit to check my ip address, and if its not
> what its supposed to be, get it to run a sh script that changes the ip
> address to what It should be ?
>
> Thanks,
> Stephen.
>
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general