Monitor the Joomla version via Nagios
Here you can find the new script.
After researching the Internet for a long time and not finding a suitable Nagios scratch, I decided to write a Nagios script myself, which checks the versions of Joomla. The Nagios script is a script that checks the Joomla versions 1.5.x, 2.5.x and 3.x.
Since I have installed several versions, the Nagios script should be easily adapted to the different folders.
Overview:
With this Nagios script it is possible to check different installations and Joomla versions, whether they are up to date. For example, if version 2.5.14 is installed, the script indicates that there is Joomla version 2.1.16. The script is based on bash and was designed under Ubuntu 12.04. The script can be easily stored in the plugin folder of Nagios. This is located at a Nagios 3 installation under /usr/lib/nagios/plugins/. The script is later integrated into the commands.cfg of Nagios. http://update.joomla.org/core/list.xml Read it out.
You can also simply test the script on the shell: ./check_joomla_version.sh <folder>
The installation directory of Joomla is specified as a folder. e.g. /var/www/joomla. If you have several installations under the /var/www/ folder, you can also simply insert them into the script: JOOMLANEWFILE=/var/www/$APP/libraries/cms/version/version.php Then you only need to specify ./check_joomla_version.sh joomla. The path for JOOMLAOLDFILE must be adjusted.
The Script
check_joomla_version.sh:
#!/bin/bash
###
# Simple bash script to check if Joomla up to date.
# version: 1.0
# author: Bastian Schmoll
# mail: info@bastcom.de
# changelog: initial version
####
# Config section APP=$1 JOOMLANEWFILE=$APP/libraries/cms/version/version.php JOOMLAOLDFILE=$APP/libraries/joomla/version.php # function section function return { # compare and return info if [ "$iflocalversion" -lt "$ifremoteversion" ]; then echo "A new version is available: $remoteversion. Our Version $localversion is out of date." exit 2 else echo "Your current Version $localversion is up to date" fi } function getlocalversion { # get local Joomla Version localversion=`cat $JOOMLANEWFILE | grep public | head -n3 | sed -e '1d' | sed 's/(.*)..$/1/' | awk '{print $4}' | sed 's/^.// ' | sed 'N;s/n/./'` iflocalversion=`echo $localversion | sed 's/.//g'` } if [ -f $JOOMLANEWFILE ]; then whichversion=`cat $JOOMLANEWFILE | grep public | head -n2 | sed -e '1d' | awk '{print $4}' | sed 's/(.*)....$/1/' | sed 's/^.// '` #if Version 2.5 x or 3.x if [ "$whichversion" == 2 ]; then # get local Joomla Version getlocalversion # get Remot Joomla Version RESULT="`wget -qO- http://update.joomla.org/core/list.xml`" remoteversion=`echo $RESULT | awk '{print $10}' | sed 's/(.*).$/1/' | sed 's/^.........//'` ifremoteversion=`echo $remoteversion | sed 's/.//g'` # compare and return info return elif [ "$whichversion" == 3 ]; then # get local Joomla Version getlocalversion # get Remot Joomla Version RESULT="`wget -qO- http://update.joomla.org/core/list.xml`" remoteversion=`echo $RESULT | awk '{print $42}' | sed 's/(.*).$/1/' | sed 's/^.........//'` ifremoteversion=`echo $remoteversion | sed 's/.//g'` # compare and return info return else echo "Sorry there is no Joomla installation" fi elif [ -f $JOOMLAOLDFILE ]; then # get local Joomla Version localversion=`cat $JOOMLAOLDFILE | grep var | grep -E 'RELEASE|DEV_LEVEL' | awk '{print $4}' | sed 's/(.*)..$/1/' | sed 's/^.//' | sed 'N;s/n/./'` iflocalversion=`echo $localversion | sed 's/.//g'` # get Remot Joomla Version remoteversion="1.5.26" ifremoteversion=`echo $remoteversion | sed 's/.//g'` # compare and return info return else echo "Sorry there is no Joomla installation" fi
Commands.cfg
The integration into the commands.cfg is simple. I have inserted the script in the file at the bottom:
# 'check_joomla' command definition
define command{
command_name check_joomla_version
command_line /bin/bash $USER1$/check_joomla_version.sh $ARG1$
}
Integrate service
Finally, only the check has to be integrated into the services.cfg file.
define service{
use local-service
host_name localhost
service_description Joomla Version
check_command check_joomla_version!<Ordner>
}
