Build precise queries to find exactly what you need
Press ESC to close
Your review has been submitted and is pending approval.
Script written in Python to check Apache2's server-status page with warning/critical threshold for req/sec
Current Version
Last Release Date
June 22, 2009
Owner
Nagios Exchange
Website
http://www.matejunkie.com/
The script (Version 1.0)
The appropriate license
Description
check_apache2.py is a Python port of my sh compliant script check_apache2.sh, providing less features at the moment. It's main use for me is to get in touch with Python, but you might find it useful. You're able to set a hostname, a port and to define warning/critical thresholds for requests per second. More features will be integrated within the next days when I find the time to do further work on the script. Version
Version 1.0, 2009, Mike Adolphs (http://www.matejunkie.com/) -h/--help Output
./check_apache2.py -h Usage: check_apache2.py -H HOSTNAME -p PORT [-w] [-c]
Options: --version show program's version number and exit -h, --help show this help message and exit -H HOSTNAME, --hostname=HOSTNAME You may define a hostname with the -H option. Default is: localhost. -p PORT, --port=PORT You may define a port with the -p option. Default is: 80.
Warning/critical thresholds: Use these options to set warning/critical thresholds for requests per second served by your Apache.
-w WARNING, --warning=WARNING Use this option if you want to use warning/critical
1. Make sure to set a critical value as 2. Default is: -1.
-c CRITICAL, --critical=CRITICAL Use this option if you want to use warning/critical
1. Make sure to set a warning value as 2. Default is: -2.
Output example
user@host $ ./check_apache2.py --version check_apache2.py 1.0 user@host $ ./check_apache2.py -H localhost -p 7001 OK: Apache serves 9.093710 requests per second. 1 busy workers, 49 idle workers. user@host $ ./check_apache2.py -H localhost -p 7001 -w 2 -c 5 CRITICAL: Apache serves 9.082950 requests per second, exceeding critical threshold! 1 busy workers, 49 idle workers. user@host $ ./check_apache2.py -H localhost -p 7001 -w 2 -c 10 WARNING: Apache serves 9.077650 requests per second, exceeding warning threshold! 1 busy workers, 49 idle workers. user@host $ ./check_apache2.py -H localhost -p 7001 -w 10 -c 20 OK: Apache serves 9.073430 requests per second. 1 busy workers, 49 idle workers. user@host $ ./check_apache2.py -H localhost -p 7001 -w 10 -c 5 UNKNOWN: When using thresholds the critical value has to be higher than the warning value. Please adjust your thresholds. user@host $ ./check_apache2.py -H localhost -p 7001 -w 5 UNKNOWN: Please also set a critical value when using warning/critical thresholds! user@host $ ./check_apache2.py -H localhost -p 7001 -c 5 UNKNOWN: Please also set a warning value when using warning/critical thresholds! user@host $ ./check_apache2.py -H localhost -p 7002 CRITICAL: Couldn't fetch the server's status page. Please check given hostname, port or Apache's configuration. We might not be allowed to access server-status due to your server's configuration. Changelog
But did not really do what I wanted: check for minimum idle workers. I want to know they are not all busy. So I added an option to check that and extended this script. It is downloadable from my github repo for plugins: https://github.com/anordby/plugins/blob/master/nagios/check_apache2.py
Optimization: No tmp file needed In retrieve_status_page() function change this: retrPage = urllib.urlretrieve(statusPage, '/tmp/server-status.log') to this one: return urllib.urlopen(statusPage) and modidy parse_status_page() function to parse_status_page(data): # file = open('/tmp/server-status.log', 'r') line = data.readline() ... line = data.readline() and finally in the main function add this line: resParse = parse_status_page(retrieve_status_page()) so comment this lines: #retrieve_status_page() #resParse = parse_status_page() Or you can see it: https://gist.github.com/kajla/bf94e9c520f5cc706eb2e831af17129c
Does exactly what it says on the tin, does a couple of things very well. My only gripe would be that if a box doesn't allow the plugin to talk to the server-status page, it should give a nice error, not the Python traceback you get at the moment. Otherwise, very very happy. Thanks for this.
SetHandler server-status Order deny,allow Deny from all Allow from 127.0.0.1 ExtendedStatus On
I had this error: Traceback (most recent call last): File "./check_apache2.py", line 189, in ? result = transform_dict(resParse) File "./check_apache2.py", line 169, in transform_dict totalAcc = int(resParse['totalAcc'].strip(" Total Accesses:")) KeyError: 'totalAcc'
You must be logged in to submit a review.
To:
From:
We’ve completely redesigned the world’s largest repository of Nagios plugins and monitoring tools. Join thousands of users sharing monitoring solutions for servers, applications, and everything in between.
Due to our redesign, all existing accounts require a password reset to access your account again.
Ready to explore 6,100+ projects and contribute to the community?
Reset Password Create Account
Happy Monitoring!