Nagios/Icinga plugin to check Joomla Update status (passive check)

Wenn man Software von Hand und nicht aus den Repositories installiert, muss man sich auch von Hand um die Updates kuemmern. Da ich kein Plugin gefunden habe, dass mir den Joomla Update Status ueberprueft und in Nagios anzeigt, habe ich fix eines selber geschrieben. Es muss als passive Check aufgerufen werden, da es mit einer lokalen Datei auf dem Server ueberprueft, welche Version installiert ist. Das Plugin hat bei den Updates auf 2.5.7 und 2.5.8 verlaesslich angezeigt das ein Update existiert. Extensions sind nicht mit inbegriffen!

<?php
 
/***
 * Simple and dirty php script to check if the local joomla version
 * is up to date. This script only works on the server, were Joomla
 * is installed. If Nagios is not running on the same server, you 
 * possibly need to run it via NSCA or similar systems.
 *
 * @version: 0.1
 *
 * @author: jan.toenjes@intranda.com
 *
 * @changelog: initial version
 *
 ***/
 
 
/***
 * CONFIGURATION
 *
 * localVersionFile: set the full path to the version.php file from your Joomla installation
 * remoteVersionUrl: set the link to the list.xml file from the Joomla core update server
 ***/
$localVersionFile = "/var/www/joomla/libraries/cms/version/version.php";
$remoteVersionUrl = "http://update.joomla.org/core/list.xml";
 
 
// get local Joomla Version
define('_JEXEC', 1);
require "$localVersionFile";
$jversion = new JVersion;
$localJoomlaVersion = $jversion->getShortVersion();
 
 
// get remote Joomla Version
$xml = simplexml_load_file($remoteVersionUrl);
$remoteJoomlaVersion = $xml->extension['version'];
 
 
// compare and return info
if ($localJoomlaVersion < $remoteJoomlaVersion) {
        echo "A new version is available: $remoteJoomlaVersion";
        exit (2);
}
else {
        echo "Your current Version $localJoomlaVersion is up to date";
}
 
?>

prego

/me... prego!

5 Gedanken zu „Nagios/Icinga plugin to check Joomla Update status (passive check)“

  1. Perfect… genau was ich gesucht habe. Habe es als NRPE plugin mit meinem Debian Server zum laufen bekommen. Funktioniert auch mit Joomla 3.0.3.
    Vielen Dank fuers publizieren

  2. Hi,

    Thanks for the post. I’m not a PHP guy, but I found that I need to keep an eye on one of our web developer’s Joomla installs to make sure it’s being patched properly. The script as-is sees 2.5.25 as the latest and when compared against our 3.3.x version doesn’t mention an available update.

    My guess is that the http://update.joomla.org/core/list.xml feed has changed since this script was originally written. I made a quick hack to this script to get it working again:

    — check_joomla_version-198.php 2014-09-30 13:45:25.464600000 -0500
    +++ check_joomla_version.php 2014-09-30 14:19:21.257705500 -0500
    @@ -25,6 +25,13 @@
    ***/
    $localVersionFile = „/var/www/joomla/libraries/cms/version/version.php“;
    $remoteVersionUrl = „http://update.joomla.org/core/list.xml“;
    +
    +// Define the base path.
    +// http://developer.joomla.org/manual/ch01s02.html
    +//
    +// JPATH_PLATFORM – The path to the Joomla Platform (where loader.php or
    +// platform.php is located, usually in the same folder as import.php).
    +define(‚JPATH_PLATFORM‘, ‚/var/www/libraries‘);

    // get local Joomla Version
    @@ -36,7 +43,16 @@

    // get remote Joomla Version
    $xml = simplexml_load_file($remoteVersionUrl);
    -$remoteJoomlaVersion = $xml->extension[‚version‘];
    +
    +// Think ppr from Python – it prints out the structure
    +//print_r($xml);
    +
    +// Evidently the XML feed lists additional supported versions
    +// since the script was originally written. The first matching array
    +// is no longer the version we’re interested in checking against.
    +// Now we want to grab the version element from the last extension array.
    +$extension_array_count = count($xml->extension);
    +$remoteJoomlaVersion = $xml->extension[$extension_array_count-1][‚version‘];

    // compare and return info

    Here is the same content on pastebin in case the above doesn’t show cleanly:

    http://pastebin.com/94KUjmvV

  3. Sorry,
    Looking at my diff I see that I failed to update this line to match the same base path you’re using for $localVersionFile.

    This:
    define(‚JPATH_PLATFORM’’, ‚/var/www/libraries‘);
    should be:
    define(‚JPATH_PLATFORM‘, ‚/var/www/joomla/libraries‘);

    To match your script.

  4. would there be a way to check mulitple joomla installation?
    something like
    $localVersionFile = “ */cms/version/version.php“;

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.