function ipmi_get_reading($sensor, $options)
{
    $sensors_array = ipmi_sensors($options);
    foreach ($sensors_array as $sensor_array) {
        if ($sensor_array["Name"] == $sensor) {
            return $sensor_array["Reading"];
        }
    }
}
Esempio n. 2
0
require_once '/usr/local/emhttp/plugins/ipmi/include/ipmi_settings_fan.php';
/* ipmi settings variables*/
$seld = isset($cfg['IPMISELD']) ? $cfg['IPMISELD'] : 'disable';
$seldpoll = isset($cfg['IPMIPOLL']) ? $cfg['IPMIPOLL'] : '60';
$local = isset($cfg['LOCAL']) ? $cfg['LOCAL'] : 'disable';
$dash = isset($cfg['DASH']) ? $cfg['DASH'] : 'disable';
// check running status
$seld_run = trim(shell_exec("[ -f /proc/`cat /var/run/ipmiseld.pid 2> /dev/null`/exe ] && echo 1 || echo 0 2> /dev/null")) == 1;
$fanctrl_run = trim(shell_exec("[ -f /proc/`cat /var/run/ipmifan.pid 2> /dev/null`/exe ] && echo 1 || echo 0 2> /dev/null")) == 1;
$running = "<span class='green'>Running</span>";
$stopped = "<span class='orange'>Stopped</span>";
$seld_status = $seld_run ? $running : $stopped;
$fanctrl_status = $fanctrl_run ? $running : $stopped;
/* get sensor */
$sensors = ipmi_sensors($ignore);
$allsensors = ipmi_sensors();
$fansensors = ipmi_fan_sensors($ignore);
/* get board info */
$board_log = '/var/log/ipmiboard';
if (file_exists($board_log)) {
    $board = file_get_contents($board_log);
} else {
    $board = $ipmi || !empty($netopts) ? trim(shell_exec("ipmi-fru {$netopts} | grep 'Manufacturer' | awk -F 'r:' '{print \$2}'")) : 'unknown';
    file_put_contents($board_log, $board);
}
$board_status = array_key_exists($board, $boards);
// create a lockfile for ipmi dashboard
$dashfile = "{$plg_path}/ipmidash";
$dashlock = file_exists($dashfile);
if ($dash == 'enable') {
    if (!$dashlock) {
Esempio n. 3
0
<?php

require_once '/usr/local/emhttp/plugins/ipmi/include/ipmi_helpers.php';
require_once '/usr/local/emhttp/plugins/ipmi/include/ipmi_settings_display.php';
function format_ipmi_temp($reading, $unit, $dot)
{
    return $reading != 0 ? ($unit == 'F' ? round(9 / 5 * $reading + 32) : str_replace('.', $dot, $reading)) . "<small>&deg;{$unit}</small>" : '##';
}
$disp_sensors = [$disp_sensor1, $disp_sensor2, $disp_sensor3, $disp_sensor4];
if (!empty($disp_sensors)) {
    $readings = ipmi_sensors($ignore);
    $displays = [];
    foreach ($disp_sensors as $disp_sensor) {
        if (!empty($readings[$disp_sensor])) {
            $disp_name = $readings[$disp_sensor]['Name'];
            $disp_id = $readings[$disp_sensor]['ID'];
            $disp_reading = $readings[$disp_sensor]['Type'] == 'OEM Reserved' ? $readings[$disp_sensor]['Event'] : $readings[$disp_sensor]['Reading'];
            $LowerNR = floatval($readings[$disp_sensor]['LowerNR']);
            $LowerC = floatval($readings[$disp_sensor]['LowerC']);
            $LowerNC = floatval($readings[$disp_sensor]['LowerNC']);
            $UpperNC = floatval($readings[$disp_sensor]['UpperNC']);
            $UpperC = floatval($readings[$disp_sensor]['UpperC']);
            $UpperNR = floatval($readings[$disp_sensor]['UpperNR']);
            $Color = $disp_reading == 'N/A' ? 'blue' : 'green';
            if ($readings[$disp_sensor]['Type'] == 'Temperature') {
                // if temperature is greater than upper non-critical show critical
                if ($disp_reading > $UpperNC) {
                    $Color = 'orange';
                }
                // if temperature is greater than upper critical show non-recoverable
                if ($disp_reading > $UpperC) {
Esempio n. 4
0
require_once '/usr/local/emhttp/plugins/ipmi/include/fan_helpers.php';
$action = array_key_exists('action', $_GET) ? $_GET['action'] : '';
$hdd_temp = get_highest_temp();
if (!empty($action)) {
    $state = ['Critical' => 'red', 'Warning' => 'yellow', 'Nominal' => 'green', 'N/A' => 'blue'];
    if ($action == 'ipmisensors') {
        $return = ['Sensors' => ipmi_sensors($ignore), 'Network' => $netsvc == 'enable', 'State' => $state];
        echo json_encode($return);
    } elseif ($action == 'ipmievents') {
        $return = ['Events' => ipmi_events(), 'Network' => $netsvc == 'enable', 'State' => $state];
        echo json_encode($return);
    } elseif ($action == 'ipmiarch') {
        $return = ['Archives' => ipmi_events(true), 'Network' => $netsvc == 'enable', 'State' => $state];
        echo json_encode($return);
    } elseif ($action == 'ipmidash') {
        $return = ['Sensors' => ipmi_sensors($dignore), 'Network' => $netsvc == 'enable', 'State' => $state];
        echo json_encode($return);
    }
}
/* get highest temp of hard drives */
function get_highest_temp()
{
    $hdds = parse_ini_file('/var/local/emhttp/disks.ini', true);
    $highest_temp = 0;
    foreach ($hdds as $hdd) {
        $temp = $hdd['temp'];
        if (is_numeric($temp)) {
            $highest_temp = $temp > $highest_temp ? $temp : $highest_temp;
        }
    }
    $return = $highest_temp == 0 ? 'N/A' : $highest_temp;
<?php

require_once '/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php';
echo json_encode(ipmi_sensors($ipmitool_options));