Supervision of Joomla and the Components via Nagios
Introduction
Managing and updating Joomla installations can be a challenge, especially when multiple versions and components are in use. To ensure that all Joomla versions and extensions are up-to-date, an automated review script can be helpful. This guide describes the operation and setup of a Nagios script that checks various Joomla installations and their components for updates.
The script was developed specifically for Joomla 2.5.x and 3.x and offers a reliable way to monitor the versions of Joomla and installed extensions. It displays outdated versions and informs about available updates. This solution is based on a Bash script and has been tested under Ubuntu 12.04. The script can be copied directly into the plugin folder of Nagios and integrated into the configuration files.
Installation and configuration
To run the script, upload it to the Nagios plugin directory and make sure it’s executable:
cd /usr/lib/nagios/plugins/
chmod +x check_joomla_comp_update.shThe script can be tested on the shell by specifying the Joomla installation directory:
./check_joomla_comp_update.sh <Joomla-Verzeichnis>Integration in Nagios
To include the script in Nagios, add the following entry to the commands.cfg Add:
define command{
command_name check_joomla_comp_version
command_line /bin/bash $USER1$/check_joomla_comp_update.sh $ARG1$
}Integration into the services
Finally, the check in the services.cfg to enable regular checks.
The script
Below is the Bash script to check the Joomla versions and installed components:
#!/bin/bash
###
# Simple bash script to check if Joomla and components are up to date.
# VERSION: 1.9
# author: Bastian Schmoll
# mail: info@bastcom.de
# changelog:
# 1.0: Initial release
# 1.3: Added Joomla 3.x support
# 1.8: Improved version detection
# 1.9: Fix for Joomla 3.5+ compatibility
###
# Check if argument is set
if [ "$#" -eq "0" ]
then
echo "No arguments supplied"
exit 1
fi
# Configuration section
WEBPATH=/var/www
APPS=`echo $* | sed "s/ /n/g"`
EXCLUDE="'Joomla Extension Directory', 'VirtueMart Update', 'Weblinks Update'"
# Processing Joomla installations
while read APP
do
CONFIG_FILE=$WEBPATH/$APP/configuration.php
USER=$(grep public $CONFIG_FILE | head -n14 | awk '{print $4}' | sed 's/^.//')
PASS=$(grep public $CONFIG_FILE | head -n15 | awk '{print $4}' | sed 's/^.//')
DB=$(grep public $CONFIG_FILE | head -n16 | awk '{print $4}' | sed 's/^.//')
PREFIX=$(grep public $CONFIG_FILE | head -n17 | awk '{print $4}' | sed 's/^.//')
# Fetch Joomla version
VERSION_FILE=$WEBPATH/$APP/libraries/cms/version/version.php
WHICHVERSION=$(grep public $VERSION_FILE | head -n2 | awk '{print $4}' | sed 's/^.//')
if [ "$WHICHVERSION" == "25" ]; then
LOCALVERSION=$(mysql -u $USER -p$PASS $DB -se "SELECT manifest_cache FROM ${PREFIX}extensions WHERE enabled = 1")
else
LOCALVERSION=$(mysql -u $USER -p$PASS $DB -se "SELECT manifest_cache FROM ${PREFIX}extensions WHERE enabled = 1 AND element != 'en-GB'")
fi
done <<< "$APPS"
This script checks the versions of the Joomla installation and compares them to the latest updates available. It can be integrated into Nagios or executed directly from the command line.
Conclusion
With this script it is possible to keep Joomla installations up to date efficiently and minimize potential security risks. Integration in Nagios enables continuous monitoring and ensures that Joomla updates can be detected and performed early.
