Page 1 of 1

How-to check E.F.A.-Version (with a monitoring tool)

Posted: 06 Mar 2015 10:47
by DaN
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

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";
}
 
?>
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):

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$'
	}
service definition (e.g. EFA-Server.cfg):

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
	}
:?: [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".

Re: How-to check E.F.A.-Version (with a monitoring tool)

Posted: 06 Mar 2015 21:57
by darky83
:text-goodpost:

Nice post, that is a good idea :)

Re: How-to check E.F.A.-Version (with a monitoring tool)

Posted: 24 Mar 2016 16:15
by DaN
update:
/etc/EFA-Version (3.0.0.9) has a space/blank at the end

Re: How-to check E.F.A.-Version (with a monitoring tool)

Posted: 29 Mar 2016 07:59
by pdwalker
or you could change

Code: Select all

$localEFAVersion = file_get_contents($localVersionFile);
to

Code: Select all

$localEFAVersion = trim(file_get_contents($localVersionFile));
and not worry about it.

Re: How-to check E.F.A.-Version (with a monitoring tool)

Posted: 29 Mar 2016 08:34
by DaN
edited, thanks

Re: How-to check E.F.A.-Version (with a monitoring tool)

Posted: 09 May 2016 06:49
by DaN
new version with additional "trim"

Re: How-to check E.F.A.-Version (with a monitoring tool)

Posted: 07 Dec 2016 01:13
by BDKaatz
Greetings,

I have another update for you...

If you are running the E.F.A. server with https, enter the following command definition into 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$' --onredirect=follow
   }
Since the http request will get a 302 response to redirect to https, you want to follow it to the EFA-Version-Check.php page. Of course, you can use the "sticky' directive instead of 'follow', if you wish.

HTH. And, thanks again for this, DaN.

Re: How-to check E.F.A.-Version (with a monitoring tool)

Posted: 28 Mar 2017 14:44
by DaN
@BDKaatz - thx for the update


For those of you who get error 403 (Access denied) with the new integrated mod_security (EFA <= 3.0.1.9)

could add

Code: Select all

SecRuleRemoveById 960015
to
/etc/httpd/conf.d/mod_security.conf
at the end before last </IfModule>

to work around the problem.