Icinga / Nagios simple check para controlar el uso de la versión más actual de WordPress

check_wpversion (Dependencia curl).

check_wpversion.sh
#!/bin/bash
# check WP Version
 
wp_new=`curl -s -Lk https://wordpress.org/download/ 2>/dev/null | grep -o -P '(?<=Download&nbsp;WordPress&nbsp;).*(?=</strong>)'`
wp_local=`curl -s -Lk $1 2>/dev/null | grep -o -P '(?<="WordPress ).*(?=" />)'`
 
# Nagios exit code
 
ST_OK=0
ST_WR=1
ST_CR=2
ST_UK=3
 
if [ "$wp_new" == "" ] || [ "$wp_local" == "" ] ; then
        echo "UNKNOW - curl command failed or $1 not available"
        exit $ST_UK
fi
 
if [ "$wp_new" == "$wp_local" ]; then
        echo "OK -  Wordpress is updated ($wp_local)."
        exit $ST_OK
fi
 
if [ "$wp_new" != "$wp_local" ]; then
        echo "WARNING - WordPress (Version $wp_new) is available. Current Version $wp_local"
        exit $ST_WR
fi
/opt/nagios/libexec/check_wpversion.sh "http://www.dominio.com/blog/es/" 

Salidas (No hay Critical, Solo Warning.)

Definición del comando en Nagios (checkcommands.cfg)

define command {
                command_name                          check_wpversion
                command_line                          $USER1$/check_wpversion $ARG1$
}

Definición del servicio para el blog http://www.dominio.com/blog/es/

define service {
                service_description                   check Blog
                check_command                         check_wpversion!"http://www.dominio.com/blog/es/"
                check_period                          24x7
                notification_period                   24x7
                host_name                             www.dominio.com
                contact_groups                        +admins
                use                                   generic-service
}