Categorieën
Geen categorie

WordPress monitoring with Zabbix

In want to be able to see if WordPress needs to be updated on a specific webhost.

I have several WordPress sites and it would be nice to see which ones need to be updated.

First, I place a small file in the root directory of every WordPress instance that I call “zabbix-check.php”. Warning: choose your own filename! You don’t want hackers to scriptsearch for hackable WordPress instances!

Anyway, after this short disclaimer we continue with placing the following php code in said file:

<?PHP
# script to test remotely if wordpress update is needed
# tested on WordPress 3.6
# 1.0 J.Baten september 17, 2013
# License: GPLv2

ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

require('wp-load.php');
require('wp-admin/includes/update.php');
print "Currently: ".$wp_version;

$updates = get_core_updates();
if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
echo ', no update needed';
} else {
echo ', update needed';
}
?>

All I need to do now is add a scenario to Zabbix that checks for the text “no update needed”. It also shows the version number if you like.

I hope this script is usefull to you.