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


Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
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
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.


Helpful? Yes  No 
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
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.


Helpful? Yes  No 
Warning: Null
by viettrungits, September 30, 2012
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# ./check_public.py
Internode Fiber : OK - public ip: '99.121.18.13'


1 of 1 found this review helpful.
Helpful? Yes 1 No 0
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,654