Add webinterface support for IPMI poller

git-svn-id: http://www.observium.org/svn/observer/trunk@1766 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-12-20 12:26:26 +00:00
parent 6f4e5b5170
commit dacb3d2252
8 changed files with 94 additions and 11 deletions

View File

@@ -59,17 +59,17 @@ function logfile($string)
fclose($fd);
}
function write_dev_attrib($device_id, $attrib_type, $attrib_value)
function set_dev_attrib($device, $attrib_type, $attrib_value)
{
$count_sql = "SELECT COUNT(*) FROM devices_attribs WHERE `device_id` = '" . $device_id . "' AND `attrib_type` = '$attrib_type'";
$count_sql = "SELECT COUNT(*) FROM devices_attribs WHERE `device_id` = '" . mres($device['device_id']) . "' AND `attrib_type` = '$attrib_type'";
if (mysql_result(mysql_query($count_sql),0))
{
$update_sql = "UPDATE devices_attribs SET attrib_value = '$attrib_value' WHERE `device_id` = '$device_id' AND `attrib_type` = '$attrib_type'";
$update_sql = "UPDATE devices_attribs SET attrib_value = '$attrib_value' WHERE `device_id` = '" . mres($device['device_id']) . "' AND `attrib_type` = '$attrib_type'";
mysql_query($update_sql);
}
else
{
$insert_sql = "INSERT INTO devices_attribs (`device_id`, `attrib_type`, `attrib_value`) VALUES ('$device_id', '$attrib_type', '$attrib_value')";
$insert_sql = "INSERT INTO devices_attribs (`device_id`, `attrib_type`, `attrib_value`) VALUES ('" . mres($device['device_id'])."', '$attrib_type', '$attrib_value')";
mysql_query($insert_sql);
}
@@ -78,7 +78,7 @@ function write_dev_attrib($device_id, $attrib_type, $attrib_value)
function get_dev_attrib($device, $attrib_type)
{
$sql = "SELECT attrib_value FROM devices_attribs WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = '$attrib_type'";
$sql = "SELECT attrib_value FROM devices_attribs WHERE `device_id` = '" . mres($device['device_id']) . "' AND `attrib_type` = '$attrib_type'";
if ($row = mysql_fetch_assoc(mysql_query($sql)))
{
return $row['attrib_value'];
@@ -89,6 +89,12 @@ function get_dev_attrib($device, $attrib_type)
}
}
function del_dev_attrib($device, $attrib_type)
{
$sql = "DELETE FROM devices_attribs WHERE `device_id` = '" . mres($device['device_id']) . "' AND `attrib_type` = '$attrib_type'";
return mysql_query($sql);
}
function shorthost($hostname, $len=16)
{
$parts = explode(".", $hostname);