<?php

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

require_once '/usr/local/emhttp/plugins/ipmi/include/ipmi_options.php';
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;