append ipmi top variables, add rc scripts
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require_once '/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php';
|
||||
$cmd = "/usr/bin/ipmitool sel ".$_GET["options"].$options;
|
||||
exec($cmd);
|
||||
|
||||
shell_exec("/usr/bin/ipmitool sel ".$_GET["options"].$ipmi_options);
|
||||
?>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
require_once '/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php';
|
||||
echo json_encode(ipmi_events($options));
|
||||
echo json_encode(ipmi_events($ipmi_options));
|
||||
?>
|
@ -1,41 +1,41 @@
|
||||
<?php
|
||||
/* ipmi tool variables*/
|
||||
$plugin = 'ipmitool-plugin';
|
||||
$cfg = parse_ini_file("/boot/config/plugins/$plugin/$plugin.cfg");
|
||||
$ipmievd = isset($cfg['IPMIEVD']) ? $cfg['IPMIEVD'] : "disable";
|
||||
$ipmifan = isset($cfg['IPMIFAN']) ? $cfg['IPMIFAN'] : "disable";
|
||||
$remote = isset($cfg['REMOTE']) ? $cfg['REMOTE'] : "disable";
|
||||
$ipmi_cfg = parse_ini_file("/boot/config/plugins/$plugin/$plugin.cfg");
|
||||
$ipmievd = isset($ipmi_cfg['IPMIEVD']) ? $ipmi_cfg['IPMIEVD'] : "disable";
|
||||
$ipmifan = isset($ipmi_cfg['IPMIFAN']) ? $ipmi_cfg['IPMIFAN'] : "disable";
|
||||
$ipmi_remote = isset($ipmi_cfg['REMOTE']) ? $ipmi_cfg['REMOTE'] : "disable";
|
||||
|
||||
//check running status
|
||||
$ipmievd_running = trim(shell_exec( "[ -f /proc/`cat /var/run/ipmievd.pid0 2> /dev/null`/exe ] && echo 1 || echo 0 2> /dev/null" ));
|
||||
$ipmifan_running = trim(shell_exec( "[ -f /proc/`cat /var/run/ipmifan.pid 2> /dev/null`/exe ] && echo 1 || echo 0 2> /dev/null" ));
|
||||
$running = "<span class='green'>Running</span>";
|
||||
$stopped = "<span class='orange'>Stopped</span>";
|
||||
$ipmievd_status = ($ipmievd_running) ? $running : $stopped;
|
||||
$ipmifan_status = ($ipmifan_running) ? $running : $stopped;
|
||||
$ipmi_running = "<span class='green'>Running</span>";
|
||||
$ipmi_stopped = "<span class='orange'>Stopped</span>";
|
||||
$ipmievd_status = ($ipmievd_running) ? $ipmi_running : $ipmi_stopped;
|
||||
$ipmifan_status = ($ipmifan_running) ? $ipmi_running : $ipmi_stopped;
|
||||
|
||||
// use save ip address or use local ipmi address
|
||||
$ipaddr = preg_match('/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/', $cfg['IPADDR']) ?
|
||||
$cfg['IPADDR'] :
|
||||
$ipmi_ipaddr = preg_match('/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/', $ipmi_cfg['IPADDR']) ?
|
||||
$ipmi_cfg['IPADDR'] :
|
||||
trim(shell_exec("/usr/bin/ipmitool lan print | grep 'IP Address ' | sed -n -e 's/^.*: //p'"));
|
||||
|
||||
$cpu_temp = isset($cfg['CPU_TEMP']) ? $cfg['CPU_TEMP'] : ""; // cpu temp display name
|
||||
$mb_temp = isset($cfg['MB_TEMP']) ? $cfg['MB_TEMP'] : ""; // mb temp display name
|
||||
$fan_disp = isset($cfg['FAN_DISP']) ? $cfg['FAN_DISP'] : ""; // fan speed display name
|
||||
$user = isset($cfg['USER']) ? $cfg['USER'] : ""; // user for remote access
|
||||
$password = isset($cfg['PASSWORD']) ? $cfg['PASSWORD'] : ""; // password for remote access
|
||||
$ipmi_cpu_temp = isset($ipmi_cfg['CPU_TEMP']) ? $ipmi_cfg['CPU_TEMP'] : ""; // cpu temp display name
|
||||
$ipmi_mb_temp = isset($ipmi_cfg['MB_TEMP']) ? $ipmi_cfg['MB_TEMP'] : ""; // mb temp display name
|
||||
$ipmi_fan_disp = isset($ipmi_cfg['FAN_DISP']) ? $ipmi_cfg['FAN_DISP'] : ""; // fan speed display name
|
||||
$ipmi_user = isset($ipmi_cfg['USER']) ? $ipmi_cfg['USER'] : ""; // user for remote access
|
||||
$ipmi_password = isset($ipmi_cfg['PASSWORD']) ? $ipmi_cfg['PASSWORD'] : ""; // password for remote access
|
||||
|
||||
// options for remote access or not
|
||||
$options = ($remote == "enable") ? "-I lanplus -H '$ipaddr' -U '$user' -P '".
|
||||
base64_decode($password)."'" : "";
|
||||
$ipmi_options = ($ipmi_remote == "enable") ? "-I lanplus -H '$ipmi_ipaddr' -U '$ipmi_user' -P '".
|
||||
base64_decode($ipmi_password)."'" : "";
|
||||
|
||||
// Get sensor info and check connection if remote enabled
|
||||
$sensors = ipmi_sensors($options);
|
||||
$fans = ipmi_get_fans($sensors);
|
||||
$ipmi_sensors = ipmi_sensors($ipmi_options);
|
||||
$ipmi_fans = ipmi_get_fans($ipmi_sensors);
|
||||
|
||||
if($remote == "enable"){
|
||||
$conn = ($sensors) ? true : false;
|
||||
$conn_check = ($conn) ? "Connection successful" : "Connection failed";
|
||||
if($ipmi_remote == "enable"){
|
||||
$ipmi_conn = ($ipmi_sensors) ? true : false;
|
||||
$ipmi_conn_check = ($ipmi_conn) ? "Connection successful" : "Connection failed";
|
||||
}
|
||||
|
||||
/* get an array of all sensors and their values */
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
require_once '/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php';
|
||||
echo json_encode(ipmi_sensors($options));
|
||||
echo json_encode(ipmi_sensors($ipmi_options));
|
||||
?>
|
@ -1,23 +1,23 @@
|
||||
<?
|
||||
require_once '/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php';
|
||||
|
||||
function ipmi_temp($reading, $unit, $dot) {
|
||||
function format_ipmi_temp($reading, $unit, $dot) {
|
||||
return ($reading>0 ? ($unit=='F' ? round(9/5*$reading+32) : str_replace('.',$dot,$reading)) : '##')." $unit";
|
||||
}
|
||||
|
||||
if ($cpu_temp || $mb_temp || $fan_disp){
|
||||
$readings = ipmi_get_reading([$cpu_temp, $mb_temp, $fan_disp], $options);
|
||||
$temps = [];
|
||||
if ($ipmi_cpu_temp || $ipmi_mb_temp || $ipmi_fan_disp){
|
||||
$ipmi_readings = ipmi_get_reading([$ipmi_cpu_temp, $ipmi_mb_temp, $ipmi_fan_disp], $ipmi_options);
|
||||
$ipmi_temps = [];
|
||||
|
||||
if ($readings[$cpu_temp])
|
||||
$temps[] = "<img src='/plugins/$plugin/icons/cpu.png' title='$cpu_temp' class='icon'>".ipmi_temp($readings[$cpu_temp], $_GET['unit'], $_GET['dot']);
|
||||
if ($ipmi_readings[$ipmi_cpu_temp])
|
||||
$ipmi_temps[] = "<img src='/plugins/$plugin/icons/cpu.png' title='$ipmi_cpu_temp' class='icon'>".format_ipmi_temp($ipmi_readings[$ipmi_cpu_temp], $_GET['unit'], $_GET['dot']);
|
||||
|
||||
if ($readings[$mb_temp])
|
||||
$temps[] = "<img src='/plugins/$plugin/icons/mb.png' title='$mb_temp' class='icon'>".ipmi_temp($readings[$mb_temp], $_GET['unit'], $_GET['dot']);
|
||||
if ($ipmi_readings[$ipmi_mb_temp])
|
||||
$ipmi_temps[] = "<img src='/plugins/$plugin/icons/mb.png' title='$ipmi_mb_temp' class='icon'>".format_ipmi_temp($ipmi_readings[$ipmi_mb_temp], $_GET['unit'], $_GET['dot']);
|
||||
|
||||
if ($readings[$fan_disp])
|
||||
$temps[] = "<img src='/plugins/$plugin/icons/fan.png' title='$fan_disp' class='icon'>".$readings[$fan_disp]." rpm";
|
||||
if ($ipmi_readings[$ipmi_fan_disp])
|
||||
$ipmi_temps[] = "<img src='/plugins/$plugin/icons/fan.png' title='$ipmi_fan_disp' class='icon'>".$ipmi_readings[$ipmi_fan_disp]." rpm";
|
||||
}
|
||||
if ($temps)
|
||||
echo "<span id='temps' style='margin-right:16px'>".implode(' ', $temps)."</span>";
|
||||
if ($ipmi_temps)
|
||||
echo "<span id='temps' style='margin-right:16px'>".implode(' ', $ipmi_temps)."</span>";
|
||||
?>
|
Reference in New Issue
Block a user