mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
BIN
html/images/icons/greyscale/ipmi.png
Normal file
BIN
html/images/icons/greyscale/ipmi.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 566 B |
BIN
html/images/icons/ipmi.png
Normal file
BIN
html/images/icons/ipmi.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 623 B |
16
html/includes/device-ipmi-edit.inc.php
Normal file
16
html/includes/device-ipmi-edit.inc.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
$ipmi_hostname = mres($_POST['ipmi_hostname']);
|
||||
$ipmi_username = mres($_POST['ipmi_username']);
|
||||
$ipmi_password = mres($_POST['ipmi_password']);
|
||||
|
||||
#FIXME needs more sanity checking! and better feedback
|
||||
|
||||
if ($ipmi_hostname != '') { set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); } else { del_dev_attrib($device, 'ipmi_hostname'); }
|
||||
if ($ipmi_username != '') { set_dev_attrib($device, 'ipmi_username', $ipmi_username); } else { del_dev_attrib($device, 'ipmi_username'); }
|
||||
if ($ipmi_password != '') { set_dev_attrib($device, 'ipmi_password', $ipmi_password); } else { del_dev_attrib($device, 'ipmi_password'); }
|
||||
|
||||
$update_message = "Device IPMI data updated.";
|
||||
$updated = 1;
|
||||
|
||||
?>
|
@@ -320,12 +320,12 @@ function humanspeed($speed)
|
||||
|
||||
function print_error($text)
|
||||
{
|
||||
echo('<table class="errorbox" cellpadding="3"><tr><td><img src="/images/15/exclamation.png" align="absmiddle">'.$text.'</td></tr></table>');
|
||||
echo('<table class="errorbox" cellpadding="3"><tr><td><img src="/images/15/exclamation.png" align="absmiddle"> '.$text.'</td></tr></table>');
|
||||
}
|
||||
|
||||
function print_message($text)
|
||||
{
|
||||
echo('<table class="messagebox" cellpadding="3"><tr><td><img src="/images/16/tick.png" align="absmiddle">'.$text.'</td></tr></table>');
|
||||
echo('<table class="messagebox" cellpadding="3"><tr><td><img src="/images/16/tick.png" align="absmiddle"> '.$text.'</td></tr></table>');
|
||||
}
|
||||
|
||||
function devclass($device)
|
||||
|
@@ -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();
|
||||
|
||||
|
59
html/pages/device/edit/ipmi.inc.php
Normal file
59
html/pages/device/edit/ipmi.inc.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
if($_POST['editing']) {
|
||||
if($_SESSION['userlevel'] > "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);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<table cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td>
|
||||
<form id="edit" name="edit" method="post" action="">
|
||||
<input type=hidden name="editing" value="yes">
|
||||
<table width="500" border="0">
|
||||
<tr>
|
||||
<td width="150"><div align="right">IPMI/BMC Hostname</div></td>
|
||||
<td colspan="3"><input name="ipmi_hostname" size="32" value="<?php echo get_dev_attrib($device,'ipmi_hostname'); ?>"></input></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align="right">IPMI/BMC Username</div></td>
|
||||
<td colspan="3"><input name="ipmi_username" size="32" value="<?php echo get_dev_attrib($device,'ipmi_username'); ?>"></input></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align="right">IPMI/BMC Password</div></td>
|
||||
<td colspan="3"><input name="ipmi_password" size="32" value="<?php echo get_dev_attrib($device,'ipmi_password'); ?>"></input></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td colspan="3">
|
||||
<br />
|
||||
<input type="submit" name="Submit" value="Save" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
To disable IPMI polling, please clear the setting fields and click <b>Save</b>.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
</form>
|
||||
</td>
|
||||
<td width="50"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
@@ -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');
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user