Nagios/Mediawiki

-->Nagios/Mediawiki

host definiton example
define host{ use                    linux-server host_name              wiktionary alias                  en.wiktionary.org alias                  rr.knams.wikimedia.org address                91.198.174.2 } define host{ use                    linux-server host_name              geist alias                  geist.s23.org address                84.16.233.231 }

service definitions example

 * 1) SERVICE DEFINITIONS
 * 2) WIKI
 * 1) WIKI

define service{ use				s23-service host_name			geist service_description		WIKI S23 check_command			check_wiki!s23.org notifications_enabled		1 }

define service{ use				friend-service host_name			wiktionary service_description		English Wiktionary check_command			check_wiki!en.wiktionary.org notifications_enabled          1 }

check_wiki command
"; $chkstr_en="Main Page"; $chkstr_de="Hauptseite"; $chkstr_pos=" ";

$buffer=file_get_contents($url);

$statuscode=explode(" ",$http_response_header[0]); $statuscode=$statuscode[1];

$ok_codes=array("200","301","302");

if (!in_array($statuscode,$ok_codes)) { echo "CRITICAL. $HOSTADDRESS Wiki Main_Page down. - HTTP: $statuscode\n"; exit (2); } else {

$pieces=explode($chkstr_pre,$buffer); $pieces=explode($chkstr_pos,$pieces[1]);

$pieces=explode(":",$pieces[0]);
 * 1) fix to make sure it works on different mediawiki versions (different html source)

if ($pieces[1]!="") { $result=$pieces[1]; } else { $result=$pieces[0]; }

if ($result==$chkstr_en OR $result==$chkstr_de) { echo "OK. $HOSTADDRESS Wiki Main_Page is up. - PARSE: $result - HTTP: $statuscode\n"; exit (0); } else { echo "WARNING. $HOSTADDRESS Wiki Main_Page - PARSE: $result - HTTP: $statuscode\n"; exit (1); } } echo "UNKNOWN. Problem with check script. - PARSE: $result - HTTP: $statuscode\n"; exit (3);
 * 1) echo "result: $result \n";
 * 2) echo "compar: $chkstr_en $chkstr_de ";

?>