added cgi-bin/nagiosstatus.sh
This commit is contained in:
22
README.md
22
README.md
@@ -1,10 +1,10 @@
|
|||||||
nagios-plugins
|
nagios-plugins
|
||||||
==============
|
==============
|
||||||
This repository contains my collection of modified and custom written check
|
This repository contains my collection of modified and custom written check
|
||||||
plugins for [Nagios](http://www.nagios.org).
|
plugins and scripts for [Nagios](http://www.nagios.org).
|
||||||
|
|
||||||
Most of these are modified versions of standard plugins or very custom so
|
Most of these are very custom solutions or modified versions of standard plugins
|
||||||
distributing them through [NagiosExchange](https://exchange.nagios.org/) is
|
so distributing them through [NagiosExchange](https://exchange.nagios.org/) is
|
||||||
not really appropriate. I am publishing them separately so that others may
|
not really appropriate. I am publishing them separately so that others may
|
||||||
benefit from these as well. Use them freely and please let me know is you
|
benefit from these as well. Use them freely and please let me know is you
|
||||||
encounter any issues or require changes.
|
encounter any issues or require changes.
|
||||||
@@ -18,7 +18,7 @@ License, see [below](#license)
|
|||||||
|
|
||||||
plugins/check_memory
|
plugins/check_memory
|
||||||
--------------------
|
--------------------
|
||||||
nagios check script to monitor the memory on Linux systems. Due to changes in
|
Nagios check script to monitor the memory on Linux systems. Due to changes in
|
||||||
the output of procps v3.3 (the changelog refers to it as modernizing it), it's
|
the output of procps v3.3 (the changelog refers to it as modernizing it), it's
|
||||||
output changed and breaks the the check_memory script as shipped with many linux
|
output changed and breaks the the check_memory script as shipped with many linux
|
||||||
distributions. This version supports both the old and the new format so that
|
distributions. This version supports both the old and the new format so that
|
||||||
@@ -26,6 +26,20 @@ is indifferent of which version of procps (to date) is used. No other changes
|
|||||||
were made to the script.
|
were made to the script.
|
||||||
|
|
||||||
|
|
||||||
|
cgi-bin/nagiosstatus.sh
|
||||||
|
-----------------------
|
||||||
|
Very simplistic CGI-BIN script that checkes whether nagios is still running and
|
||||||
|
still updating its status. It wil always return an HTTP Status 200 (OK) and a
|
||||||
|
simple text page with one of the following texts:
|
||||||
|
- STOPPED - in case the nagios process is not running
|
||||||
|
- STALLED - in case the nagios status file has not been updated for 5 minutes
|
||||||
|
- OK - when Nagios is running and updated its status file < 5 minutes ago
|
||||||
|
|
||||||
|
I wrote this script to be used with an external monitoring system, I use it with
|
||||||
|
the free subscription from [Pingdom](http://www.pingdom.com) to get alerts when
|
||||||
|
my Nagios monitoring system is no longer reachable.
|
||||||
|
|
||||||
|
|
||||||
<a name="license">License</a>
|
<a name="license">License</a>
|
||||||
-----------------------------
|
-----------------------------
|
||||||
These scripts, documentation & configration examples are free software: you can
|
These scripts, documentation & configration examples are free software: you can
|
||||||
|
|||||||
52
cgi-bin/nagiosstatus.sh
Executable file
52
cgi-bin/nagiosstatus.sh
Executable file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# nagiosstatus.sh - simple CGI-BIN script checking the Nagios process status
|
||||||
|
#
|
||||||
|
# Version 1.0, latest version, documentation and bugtracker available at:
|
||||||
|
# https://gitlab.lindenaar.net/scripts/nagios-plugins
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 Frederik Lindenaar
|
||||||
|
#
|
||||||
|
# This script is free software: you can redistribute and/or modify it under the
|
||||||
|
# terms of version 3 of the GNU General Public License as published by the Free
|
||||||
|
# Software Foundation, or (at your option) any later version of the license.
|
||||||
|
#
|
||||||
|
# This script is distributed in the hope that it will be useful but WITHOUT ANY
|
||||||
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with
|
||||||
|
# this program. If not, visit <http://www.gnu.org/licenses/> to download it.
|
||||||
|
|
||||||
|
# Default settings for Debian Linux, adjust for your system if necessary
|
||||||
|
PROGRAM=nagios3
|
||||||
|
PIDFILE=/var/run/nagios3/nagios3.pid
|
||||||
|
STATFILE=/var/cache/nagios3/status.dat
|
||||||
|
MAXAGE="5 minutes"
|
||||||
|
|
||||||
|
# First output the HTTP header
|
||||||
|
DATE=`date -R`
|
||||||
|
cat << EOH
|
||||||
|
Status: 200 OK
|
||||||
|
Content-Type: text/plain
|
||||||
|
Date: $DATE
|
||||||
|
Expires: $DATE
|
||||||
|
Last-Modified: $DATE
|
||||||
|
Cache-Control: no-cache
|
||||||
|
Connection: close
|
||||||
|
|
||||||
|
EOH
|
||||||
|
|
||||||
|
# Check whether the process is running
|
||||||
|
if [ -f "$PIDFILE" -a "$PROGRAM" = `ps --no-header -o comm -p \`cat $PIDFILE\`` ]; then
|
||||||
|
# It's running, check whether the Statfile exists and is recent
|
||||||
|
if [ -n "$STATFILE" -a -n "$MAXAGE" -a -f "$STATFILE" -a \
|
||||||
|
`stat -c %Y $STATFILE` -lt `date +%s -d "$MAXAGE ago"` ]; then
|
||||||
|
echo STALLED
|
||||||
|
else
|
||||||
|
echo OK
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo STOPPED
|
||||||
|
fi
|
||||||
|
|
||||||
Reference in New Issue
Block a user