Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1


Remember Me

Directory Tree

5 votes
Current Version
Last Release Date
Compatible With
  • Nagios 3.x
check_public_ip.pyv 0.3
ip.phpphp script to be added to remote webserver
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
This python plugin tests if your main internet or backup internet connection is active.

Tested with Nagios Core 3.3.1 and Python 2.7
Update Version 0.3:
This is a lot more robust now, it tries multiple sites, if any are overloaded it can return None, so try the next, if any are down, or don't exist it should catch this IOError and try the next site in the tuple.

There is a line in the script:
site_list = ('','')

You can add your own site to this list, preferably put it first in the above tuple, otherwise 35000 people all issuing GET requests every few minutes to the above sites may overload them.

Copy ip.php to a remote webserver, chown the file to www-data, and add your site to the above tuple:
site_list = ('','','')

Also in the main script replace with your own main public IP, and replace with your backup internet public IP.

Nagios instructions:
Copy to your nagios/libexec folder.

add this command to commands.cfg:

define command{
command_name check_failover_internet
command_line $USER1$/

add this service check to your firewall.cfg host, and change myfirewall to whatever you've named yours:

define service{
use generic-service ;
host_name myfirewall ;
service_description Active Internet Connection ;
check_command check_failover_internet
max_check_attempts 2


Reviews (3)
thanks for this

sometime I get a email with this
Notification Type: PROBLEM

Additional Info:

(Service Check Timed Out)

How can I fix that ?

Owner's reply

Hmm maybe both connections are down?
Else just run the script from command line and see what it returns.

Also don't rely on icanhazip and curlmyip, add you own ip.php to your own webserver and use that as the first element in the tuple.

Also sorry for late reply, the email ended up in my junk.

The script don't work when the first site is down : here return connection refused.
We use a proxy here and the Answer is not "None" but a reply from proxy and the script don't test the second site.
I'll post a new script soon on nagios exchange with regex check and put a topic on my blog with a new url to get ip address like

Owner's reply

These sites come and go, you should add you own site as the first in the tuple anyway.

Sorry, we don't use a proxy here, can't help with that one.

byviettrungits, September 8, 2012
1 of 1 people found this review helpful
I received a warning email alert with status information is Null. :(
Owner's reply

When you run the script from command line what do you see? this is what i see:
root@nagios:/usr/local/nagios/libexec# ./
Internode Fiber : OK - public ip: ''