How-to check E.F.A.-Version (with a monitoring tool)
Posted: 06 Mar 2015 10:47
This is a simple and dirty way to check the local E.F.A. version number against the newest available version with a monitoring tool like nagios, icinga, Shinken, or ...
It's usefull if you don't use the auto update mechanism of E.F.A.
Don't use the script if the webserver is reachable from the internet.
E.F.A.-Server:
EFA-Version-Check.php in /var/www/html
is available via https://[E.F.A. servername or IP]/EFA-Version-Check.php
Monitoring Server:
command definition (e.g. http.cfg or commands.cfg):
service definition (e.g. EFA-Server.cfg):
[Monitoring tool] calls the php-file, php-file compares version files, the output is a string, the string is checked. If this string doesn't contain "up-to-date" the status should be "CRITICAL".
It's usefull if you don't use the auto update mechanism of E.F.A.
Don't use the script if the webserver is reachable from the internet.
E.F.A.-Server:
EFA-Version-Check.php in /var/www/html
Code: Select all
<?php
/***
* Simple and dirty php script to check if the local E.F.A. (http://efa-project.org/) version is up to date.
* This script only works on the E.F.A. server (/var/www/html).
* Do not use this script if this E.F.A. webserver is reachable from the internet.
* Do not use this script every 10 minutes. Done twice per workday is more than enough! Configure your monitoring tool correct!
*
* CC BY-SA
*
* @version: 0.3
*
* @author: DaN@EFA, pdwalker
*
* @changelog:
* 0.1:initial version
* 0.2:trim-fix from pdwalker
* 0.3:additional trim-fix
*
***/
/***
* CONFIGURATION
*
* localVersionFile: set the full path to the "EFA-Version" file
* remoteVersionUrl: set the link to the "EFA-Version" file from the E.F.A update server
* To test the output from "file_get_contents" just uncomment the echos (line 28 and 32), test and comment it out again
***/
$localVersionFile = "/etc/EFA-Version";
$remoteVersionUrl = "http://dl.EFA-project.org/update/EFA-Version";
// get local E.F.A. Version
$localEFAVersion = trim(file_get_contents($localVersionFile));
// echo "Local: $localEFAVersion";
// get remote E.F.A. Version
$remoteEFAVersion = trim(file_get_contents($remoteVersionUrl));
// echo "Remote: $remoteEFAVersion";
// compare and return info
if ($localEFAVersion == $remoteEFAVersion) {
echo "local version $localEFAVersion is up-to-date";
exit (2);
}
else {
echo "a new version is available: $remoteEFAVersion";
}
?>
Monitoring Server:
command definition (e.g. http.cfg or commands.cfg):
Code: Select all
# 'check_http_with_string' command definition
define command{
command_name check_http_with_string
command_line /usr/lib/nagios/plugins/check_http -H '$HOSTADDRESS$' -u '$ARG1$' -s '$ARG2$'
}
Code: Select all
define service{
use generic-service ; Name of service template to use
host_name EFA-Server
check_period workhours
check_interval 300
service_description E.F.A.-Version
check_command check_http_with_string!/EFA-Version-Check.php!up-to-date
}
