viernes, 5 de mayo de 2017

webserver tomcat check nrpe nagios

#!/usr/bin/php
ini_set('default_socket_timeout', 10);.
date_default_timezone_set('Africa/Lagos');

$url = 'http://3.1.1.137/test/webliq/main1.jsp';
$data = array('cuil' => 'user', 'password' => 'psswrd', 'Submit2' => 'ENTRAR', 'vorigen' => 'B');

$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);
$context  = stream_context_create($options);

$date = new DateTime( 'NOW' );
$result = @file_get_contents($url, false, $context);
$date2 = new DateTime( 'NOW' );
$s= (int)$date2->getTimestamp() - $date->getTimestamp();
if ($result === FALSE).

$state="CRITICAL";
if ($s<6 p="" state="OK">
$resp="TOMCAT17 $state - time= $s segundos\n\n";
echo $resp;
switch ($state) {
case $state=='OK': exit(0);
case $state=='WARNING': exit(1);
case $state=='CRITICAL':
    shell_exec('/usr/local/bin/tomcat-restart');
    exit(2);
}
?>

No hay comentarios: