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

Questions and answers about how to do stuff
Post Reply
DaN
Posts: 240
Joined: 19 Nov 2014 10:04
Location: Earth

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

Post 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".
Last edited by DaN on 28 Mar 2017 14:51, edited 7 times in total.
User avatar
darky83
Site Admin
Posts: 540
Joined: 30 Sep 2012 11:03
Location: eFa
Contact:

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

Post by darky83 »

:text-goodpost:

Nice post, that is a good idea :)
Version eFa 4.x now available!
DaN
Posts: 240
Joined: 19 Nov 2014 10:04
Location: Earth

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

Post by DaN »

update:
/etc/EFA-Version (3.0.0.9) has a space/blank at the end
Last edited by DaN on 29 Mar 2016 08:34, edited 1 time in total.
User avatar
pdwalker
Posts: 1553
Joined: 18 Mar 2015 09:16

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

Post 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.
User avatar
BDKaatz
Posts: 3
Joined: 30 Aug 2016 23:14

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

Post 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.
________________________

"I do not feel obliged to believe that the same God who has endowed us with
sense, reason, and intellect has intended us to forgo their use."

-- Galileo Galilei
DaN
Posts: 240
Joined: 19 Nov 2014 10:04
Location: Earth

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

Post 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.
Post Reply