From dacb3d22528daeac2014f5146c7589d4b10b358b Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Mon, 20 Dec 2010 12:26:26 +0000 Subject: [PATCH] Add webinterface support for IPMI poller git-svn-id: http://www.observium.org/svn/observer/trunk@1766 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/images/icons/greyscale/ipmi.png | Bin 0 -> 566 bytes html/images/icons/ipmi.png | Bin 0 -> 623 bytes html/includes/device-ipmi-edit.inc.php | 16 +++++++ html/includes/functions.inc.php | 4 +- html/pages/device/edit.inc.php | 5 ++- html/pages/device/edit/ipmi.inc.php | 59 +++++++++++++++++++++++++ includes/discovery/ipmi.inc.php | 5 ++- includes/functions.php | 16 ++++--- 8 files changed, 94 insertions(+), 11 deletions(-) create mode 100644 html/images/icons/greyscale/ipmi.png create mode 100644 html/images/icons/ipmi.png create mode 100644 html/includes/device-ipmi-edit.inc.php create mode 100644 html/pages/device/edit/ipmi.inc.php diff --git a/html/images/icons/greyscale/ipmi.png b/html/images/icons/greyscale/ipmi.png new file mode 100644 index 0000000000000000000000000000000000000000..8c416d6307b823dea65234d93c583bcd4fe06c6c GIT binary patch literal 566 zcmV-60?GY}P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02y>eSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+$tiu~XJ00E{+L_t(IPt8%eYC=&E)ygJ~Abx?QQE>r9 zMcnsYp9@%6Xz_&L5^MwuE$vd-2a9|`niP^UkV3Guvq`#ug^iNOWX{DR29va2INW(N z=bV{4Po=uJqgJa8j5gzr@o)rU%wv)Syr+wE>gqtPeO>2$W~bb5^% zIN+Wb9mNy3+r1nN2K#=$PxJYl*hBzvuh%2a@10KPlKGPp6aKhyxm+vmq_kQs`U~xL zTd~{iD`>MbW>l}&4_d8u0WAz}gTde?m&;K& z92R2S@pzmfkqG&GKJt3K0*FydCX>WdY@mg~eX&^FMWay)g+kKgBxZata9`m00{mL|jvq$IKmY&$07*qoM6N<$ Eg6UB6+yDRo literal 0 HcmV?d00001 diff --git a/html/images/icons/ipmi.png b/html/images/icons/ipmi.png new file mode 100644 index 0000000000000000000000000000000000000000..bf99c770eca287138a0bbc20dfe9f73fb36c78b0 GIT binary patch literal 623 zcmV-#0+9WQP)sg;>{xXk z2t|P)9%2bYl!w%8VF87us8bPQL1IQQF!F~mc4lA=VqhpD^bcr($dOWGDm;j`Y*L_uTV+SN9bO!w}~Q4(E&r#qYVR#BJgRkz3_#VvlGOU;bv0B(^e{ z%)MHzcCA<}<`hL?IgH2SNw?dzJDtww!C>%)QrpCY&G9P(R`{%5uWz+lt-7XZ*>brY zHw=TD&1PJsQi=P%ua`=t%ZtULV49{*^`D5@FN4Rl>H{h)IgTTc2)$kp^Z9%U>$4oe z=kxg-ndp{f1*GdRgX_AkKW{V|<;`|m_^7JzPEMA>mFN`JYBe&QPS^VVe!}y-56s{p zt$rs6g0=UOgr|mqw;YEl8Mv;CqoXmM!32)u(%8rT{#P;&c~KNO%QA=T8gJ2_)8vX7 zZRdq7O zm6E{X*aOeUNSGo6WeGD_UoRn<)Fh^51_}0{+U diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 1e5d69579..ae11c0b1d 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -320,12 +320,12 @@ function humanspeed($speed) function print_error($text) { - echo('
'.$text.'
'); + echo('
'.$text.'
'); } function print_message($text) { - echo('
'.$text.'
'); + echo('
'.$text.'
'); } function devclass($device) diff --git a/html/pages/device/edit.inc.php b/html/pages/device/edit.inc.php index 155c582d4..ad4a818db 100644 --- a/html/pages/device/edit.inc.php +++ b/html/pages/device/edit.inc.php @@ -6,9 +6,10 @@ if($_SESSION['userlevel'] < '7') { $panes = array('device' => 'Device Settings', - 'ports' => 'Port Settings', + 'ports' => 'Port Settings', 'apps' => 'Applications', - 'services' => 'Services'); + 'services' => 'Services', + 'ipmi' => 'IPMI'); print_optionbar_start(); diff --git a/html/pages/device/edit/ipmi.inc.php b/html/pages/device/edit/ipmi.inc.php new file mode 100644 index 000000000..1ce0a49fb --- /dev/null +++ b/html/pages/device/edit/ipmi.inc.php @@ -0,0 +1,59 @@ + "7") { + include("includes/device-ipmi-edit.inc.php"); + } +} + +$device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'")); +$descr = $device['purpose']; + +if($updated && $update_message) { + print_message($update_message); +} elseif ($update_message) { + print_error($update_message); +} + +?> + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
IPMI/BMC Hostname
IPMI/BMC Username
IPMI/BMC Password
+
+ +
+ To disable IPMI polling, please clear the setting fields and click Save. +
+
+
+
diff --git a/includes/discovery/ipmi.inc.php b/includes/discovery/ipmi.inc.php index 92430ba14..a96ca5286 100644 --- a/includes/discovery/ipmi.inc.php +++ b/includes/discovery/ipmi.inc.php @@ -10,15 +10,16 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname')) $ipmi['user'] = get_dev_attrib($device,'ipmi_username'); $ipmi['password'] = get_dev_attrib($device,'ipmi_password'); - $results = shell_exec("ipmitool -H " . $ipmi['host'] . " -U " . $ipmi['user'] . " -P " . $ipmi['password'] . " sensor"); + $results = shell_exec("ipmitool -H " . $ipmi['host'] . " -U " . $ipmi['user'] . " -P " . $ipmi['password'] . " sensor|sort"); foreach (explode("\n",$results) as $sensor) { # BB +1.1V IOH | 1.089 | Volts | ok | na | 1.027 | 1.054 | 1.146 | 1.177 | na list($desc,$current,$unit,$state,$low_nonrecoverable,$low_limit,$low_warn,$high_warn,$high_limit,$high_nonrecoverable) = explode('|',$sensor); + $index++; if (trim($current) != "na" && $ipmi_unit[trim($unit)]) { - discover_sensor($valid_sensor, $ipmi_unit[trim($unit)], $device, trim($desc), $index++, 'ipmi', trim($desc), '1', '1', + discover_sensor($valid_sensor, $ipmi_unit[trim($unit)], $device, trim($desc), $index, 'ipmi', trim($desc), '1', '1', (trim($low_limit) == 'na' ? NULL : trim($low_limit)), (trim($low_warn) == 'na' ? NULL : trim($low_warn)), (trim($high_warn) == 'na' ? NULL : trim($high_warn)), (trim($high_limit) == 'na' ? NULL : trim($high_limit)), $current, 'ipmi'); diff --git a/includes/functions.php b/includes/functions.php index 6c441acc5..36ae3f431 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -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);