define hostextinfo{
host_name server1
notes_url http://ocsserver/ocsnagios.php?host=$HOSTNAME$
icon_image help.png
}
<?php
/*
Author: bbecker
License: GPL 2 (http://www.gnu.org/licenses/gpl.html)
Testet with ocs-inventory-ng Version 1.02
*/
// e.g. ocs-nagios.php?host=nagios-server
$host = $_GET['host'];
// http adress of you're ocs-inventory server
$ocs = "http://yourserver/ocsreports/";
// the machine.php, its may differs in you're system
$param = "machine.php?systemid=";
// alternativ http adress, if the machine is not in base
$alter = $ocs;
//mysql informations
$server = "localhost";
$user = "ocsuser";
$pw = "password";
$db = "ocsweb";
// and action
if($host!=""){
$link = mysql_connect($server,$user,$pw) or die("Connection failed");
mysql_select_db($db, $link) or die('Could not select database.');
$query = "SELECT ID FROM hardware WHERE NAME='".$host."' LIMIT 1";
$result = mysql_query($query) or die("Query failed");
$result = mysql_fetch_assoc($result);
if($result['ID'] != ""){
header("Location: ".$ocs.$param.$result['ID']);
exit;
}
else{
header("Location: ".$alter);
exit;
}
}
?>