Network Connections, Stats and Bandwidth

check_public_ip.py

Description:

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

Current Version

0.3

Last Release Date

2014-01-08

Compatible With

  • Nagios 3.x

Owner

License

GPL


Project Files
Project Notes
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 = ('http://curlmyip.com','http://icanhazip.com') 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 = ('http://mysite.com/ip.php','http://curlmyip.com','http://icanhazip.com') Also in the main script replace 1.2.3.4 with your own main public IP, and replace 5.6.7.8 with your backup internet public IP. Nagios instructions: Copy check_public_ip.py to your nagios/libexec folder. add this command to commands.cfg: define command{ command_name check_failover_internet command_line $USER1$/check_public_ip.py } 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) Add a Review
thanks very useful , little issue
by clatramp, July 31, 2015

thanks for this sometime I get a email with this Notification Type: PROBLEM State: UNKNOWN Additional Info: (Service Check Timed Out) How can I fix that ? thanks



The script don't work when the first site is down
by belgotux, March 31, 2015

The script don't work when the first site is down : here curlmyip.com 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. icanhazip.com 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 http://www.monlinux.net/whatismyip. Belgotux



Warning: Null
by viettrungits, September 30, 2012

I received a warning email alert with status information is Null. :(



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4 (5)
Favorites
2
Views
67,680