rename variables to support multiple daemons
This commit is contained in:
parent
1f36544657
commit
17287fa255
|
@ -6,7 +6,7 @@ Title="Event Log"
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="sorter-false filter-false"> Status </th>
|
<th class="sorter-false filter-false"> Status </th>
|
||||||
<th class="sorter-metric filter-false"> Event ID </th>
|
<th class="sorter-digit filter-false"> Event ID </th>
|
||||||
<th class="filter-time" data-placeholder="by time"> Time Stamp </th>
|
<th class="filter-time" data-placeholder="by time"> Time Stamp </th>
|
||||||
<th class="filter-name" data-placeholder="by name"> Sensor Name </th>
|
<th class="filter-name" data-placeholder="by name"> Sensor Name </th>
|
||||||
<th class="filter-desc" data-placeholder="Search..."> Description </th>
|
<th class="filter-desc" data-placeholder="Search..."> Description </th>
|
||||||
|
|
|
@ -1,113 +1,248 @@
|
||||||
Menu="IPMI:2"
|
Menu="IPMI:2"
|
||||||
Title="Fan Control"
|
Title="Fan Control"
|
||||||
---
|
---
|
||||||
<?PHP
|
<form markdown="1" name="ipmifan_settings" method="POST" action="/update.php" target="progressFrame">
|
||||||
/* Copyright 2015, Bergware International.
|
<input type="hidden" name="#file" value="ipmitool-plugin/ipmitool-plugin.cfg" />
|
||||||
*
|
<input type="hidden" id="command" name="#command" value="" />
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License version 2,
|
|
||||||
* as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* Plugin development contribution by gfjardim
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<?
|
|
||||||
$plugin = "ipmitool-plugin";
|
|
||||||
$cfg = parse_plugin_cfg($plugin);
|
|
||||||
$sName = "autofan";
|
|
||||||
$fName = "/usr/local/emhttp/plugins/$plugin/scripts/$sName";
|
|
||||||
|
|
||||||
function temp_val($val) {
|
IPMI Fan Control:
|
||||||
global $display;
|
|
||||||
return $display['unit']=='C' ? $val : round(9/5*$val+32);
|
|
||||||
}
|
|
||||||
function scan_dir($dir, $type = "") {
|
|
||||||
$out = array();
|
|
||||||
foreach (array_slice(scandir($dir), 2) as $entry){
|
|
||||||
$sep = (preg_match("/\/$/", $dir)) ? "" : "/";
|
|
||||||
$out[] = $dir.$sep.$entry ;
|
|
||||||
}
|
|
||||||
return $out;
|
|
||||||
}
|
|
||||||
function list_pwm() {
|
|
||||||
$out = array();
|
|
||||||
exec("find /sys/devices -type f -iname 'pwm[0-9]' -exec dirname \"{}\" +|uniq", $chips);
|
|
||||||
foreach ($chips as $chip) {
|
|
||||||
$name = is_file("$chip/name") ? file_get_contents("$chip/name") : "";
|
|
||||||
foreach (preg_grep("/pwm\d+$/", scan_dir($chip)) as $pwm) {
|
|
||||||
$out[] = array('chip'=>$name, 'name'=>end(split('/',$pwm)), 'sensor'=>$pwm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $out;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<script>
|
|
||||||
function detectFan() {
|
|
||||||
var pwm = $("select[name=controller] option:selected").val();
|
|
||||||
if (pwm) {
|
|
||||||
$("input[name=fan]").val('Please wait...');
|
|
||||||
$("#fan").val('Detecting ...');
|
|
||||||
$.get('/plugins/<?=$plugin;?>/include/SystemFan.php',{op:'detect', pwm:pwm},function(data) {
|
|
||||||
$("input[name=fan]").val(data);
|
|
||||||
$("#fan").val('Detect');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function detectFanLow() {
|
|
||||||
var pwm = $("select[name=controller] option:selected").val();
|
|
||||||
var fan = $("input[name=fan]").val();
|
|
||||||
if (pwm && fan) {
|
|
||||||
$("input[name=pwm]").val('Please wait...');
|
|
||||||
$("#pwm").val('Detecting ...');
|
|
||||||
$.get('/plugins/<?=$plugin;?>/include/SystemFan.php',{op:'pwm',pwm:pwm,fan:fan},function(data) {
|
|
||||||
$("input[name=pwm]").val(data);
|
|
||||||
$("#pwm").val('Detect');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$(function() {
|
|
||||||
//showStatus('<?=$sName?>');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<form markdown="1" method="POST" action="/update.php" target="progressFrame">
|
|
||||||
<input type="hidden" name="#file" value="<?=$plugin?>/<?=$plugin?>.cfg">
|
|
||||||
<input type="hidden" name="#include" value="plugins/<?=$plugin?>/include/update.autofan.php">
|
|
||||||
<input type="hidden" name="#prefix" value="controller=c&fan=f&pwm=l&low=t&high=T&interval=m">
|
|
||||||
<span class="bitstream" style="float:right;margin-right:12px"><?=exec("$fName -V")?></span>
|
|
||||||
|
|
||||||
Fan control function:
|
|
||||||
: <select name="service" size="1">
|
: <select name="service" size="1">
|
||||||
<?=mk_option($cfg['service'], "0", "Disabled")?>
|
<?=mk_option($cfg['service'], "0", "No")?>
|
||||||
<?=mk_option($cfg['service'], "1", "Enabled")?>
|
<?=mk_option($cfg['service'], "1", "Yes")?>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
PWM controller:
|
|
||||||
: <select name="controller" size="1">
|
|
||||||
<?=mk_option($cfg['controller'], "", "None")?>
|
|
||||||
<?foreach (list_pwm() as $pwm):?>
|
|
||||||
<?=mk_option($cfg['controller'], $pwm['sensor'], "{$pwm['chip']} - {$pwm['name']}")?>
|
|
||||||
<?endforeach;?>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
PWM fan:
|
<?php if ($fans[0]): ?>
|
||||||
: <input type="text" name="fan" value="<?=$cfg['fan']?>" placeholder="Click DETECT"><input type="button" value="Detect" onclick="detectFan();" id="fan" style="margin-top:0">
|
|
||||||
|
|
||||||
Minimun PWM value:
|
<?=$fans[0];?> temperature sensor:
|
||||||
: <input type="text" name="pwm" value="<?=$cfg['pwm']?>" placeholder="Click DETECT"><input type="button" value="Detect" onclick="detectFanLow();" id="pwm" style="margin-top:0">
|
: <select name="<?='FAN_'.$fans[0];?>">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature');?>
|
||||||
|
<option value='HDD'>HDD Temperatures</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
Low temperature threshold (°<?=$display['unit']?>):
|
<?=$fans[0];?> Low temperature threshold:
|
||||||
: <input type="number" min="0" max="300" name="low" value="<?=temp_val($cfg['low'])?>" class="narrow">
|
: <select name="<?='FAN_'.$fans[0];?>_LOW">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
High temperature threshold (°<?=$display['unit']?>):
|
<?=$fans[0];?> High temperature threshold:
|
||||||
: <input type="number" min="0" max="300" name="high" value="<?=temp_val($cfg['high'])?>" class="narrow">
|
: <select name="<?='FAN_'.$fans[0];?>_HIGH">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
Refresh interval (minutes):
|
|
||||||
: <input type="text" name="interval" value="<?=$cfg['interval']?>" class="narrow">
|
|
||||||
|
|
||||||
<input type="submit" name="#default" value="Default">
|
<?php endif; ?>
|
||||||
: <input type="submit" name="#apply" value="Apply"><input type="button" value="Done" onclick="done()">
|
|
||||||
|
<?php if ($fans[1]): ?>
|
||||||
|
|
||||||
|
<?=$fans[1];?> temperature sensor:
|
||||||
|
: <select name="<?='FAN_'.$fans[1];?>">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature');?>
|
||||||
|
<option value='HDD'>HDD Temperatures</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[1];?> Low temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[1];?>_LOW">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[1];?> High temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[1];?>_HIGH">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($fans[2]): ?>
|
||||||
|
|
||||||
|
<?=$fans[2];?> temperature sensor:
|
||||||
|
: <select name="<?='FAN_'.$fans[2];?>">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature');?>
|
||||||
|
<option value='HDD'>HDD Temperatures</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[2];?> Low temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[2];?>_LOW">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[2];?> High temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[2];?>_HIGH">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($fans[3]): ?>
|
||||||
|
|
||||||
|
<?=$fans[3];?> temperature sensor:
|
||||||
|
: <select name="<?='FAN_'.$fans[3];?>">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature');?>
|
||||||
|
<option value='HDD'>HDD Temperatures</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[3];?> Low temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[3];?>_LOW">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[3];?> High temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[3];?>_HIGH">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($fans[4]): ?>
|
||||||
|
|
||||||
|
<?=$fans[4];?> temperature sensor:
|
||||||
|
: <select name="<?='FAN_'.$fans[4];?>">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature');?>
|
||||||
|
<option value='HDD'>HDD Temperatures</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[4];?> Low temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[4];?>_LOW">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[4];?> High temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[4];?>_HIGH">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($fans[5]): ?>
|
||||||
|
|
||||||
|
<?=$fans[5];?> temperature sensor:
|
||||||
|
: <select name="<?='FAN_'.$fans[5];?>">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature');?>
|
||||||
|
<option value='HDD'>HDD Temperatures</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[5];?> Low temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[5];?>_LOW">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[5];?> High temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[5];?>_HIGH">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($fans[6]): ?>
|
||||||
|
|
||||||
|
<?=$fans[6];?> temperature sensor:
|
||||||
|
: <select name="<?='FAN_'.$fans[6];?>">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature');?>
|
||||||
|
<option value='HDD'>HDD Temperatures</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[6];?> Low temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[6];?>_LOW">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[6];?> High temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[6];?>_HIGH">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($fans[7]): ?>
|
||||||
|
|
||||||
|
<?=$fans[7];?> temperature sensor:
|
||||||
|
: <select name="<?='FAN_'.$fans[7];?>">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature');?>
|
||||||
|
<option value='HDD'>HDD Temperatures</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[7];?> Low temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[7];?>_LOW">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[7];?> High temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[7];?>_HIGH">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($fans[8]): ?>
|
||||||
|
|
||||||
|
<?=$fans[8];?> temperature sensor:
|
||||||
|
: <select name="<?='FAN_'.$fans[8];?>">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature');?>
|
||||||
|
<option value='HDD'>HDD Temperatures</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[8];?> Low temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[8];?>_LOW">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[8];?> High temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[8];?>_HIGH">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($fans[9]): ?>
|
||||||
|
|
||||||
|
<?=$fans[9];?> temperature sensor:
|
||||||
|
: <select name="<?='FAN_'.$fans[9];?>">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature');?>
|
||||||
|
<option value='HDD'>HDD Temperatures</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[9];?> Low temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[9];?>_LOW">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?=$fans[9];?> High temperature threshold:
|
||||||
|
: <select name="<?='FAN_'.$fans[9];?>_HIGH">
|
||||||
|
<option value='0'>Auto</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<input id="FAN_DEFAULT" class="ipmifan-run" type="button" value="Default" onClick="resetFANDATA(this.form);">
|
||||||
|
: <input id="btnFANApply" type="submit" value="Apply" onClick="verifyFANDATA(this.form)"><input type="button" value="Done" onClick="done()">
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
Menu="IPMI:2"
|
||||||
|
Title="Fan Control"
|
||||||
|
---
|
||||||
|
<?
|
||||||
|
$plugin = "ipmitool-plugin";
|
||||||
|
$cfg = parse_plugin_cfg($plugin);
|
||||||
|
$sName = "autofan";
|
||||||
|
$fName = "/usr/local/emhttp/plugins/$plugin/scripts/$sName";
|
||||||
|
|
||||||
|
function temp_val($val) {
|
||||||
|
global $display;
|
||||||
|
return $display['unit']=='C' ? $val : round(9/5*$val+32);
|
||||||
|
}
|
||||||
|
function scan_dir($dir, $type = "") {
|
||||||
|
$out = array();
|
||||||
|
foreach (array_slice(scandir($dir), 2) as $entry){
|
||||||
|
$sep = (preg_match("/\/$/", $dir)) ? "" : "/";
|
||||||
|
$out[] = $dir.$sep.$entry ;
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
function list_pwm() {
|
||||||
|
$out = array();
|
||||||
|
exec("find /sys/devices -type f -iname 'pwm[0-9]' -exec dirname \"{}\" +|uniq", $chips);
|
||||||
|
foreach ($chips as $chip) {
|
||||||
|
$name = is_file("$chip/name") ? file_get_contents("$chip/name") : "";
|
||||||
|
foreach (preg_grep("/pwm\d+$/", scan_dir($chip)) as $pwm) {
|
||||||
|
$out[] = array('chip'=>$name, 'name'=>end(split('/',$pwm)), 'sensor'=>$pwm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form markdown="1" method="POST" action="/update.php" target="progressFrame">
|
||||||
|
<input type="hidden" name="#file" value="<?=$plugin?>/<?=$plugin?>.cfg">
|
||||||
|
<input type="hidden" name="#include" value="plugins/<?=$plugin?>/include/update.autofan.php">
|
||||||
|
<input type="hidden" name="#prefix" value="controller=c&fan=f&pwm=l&low=t&high=T&interval=m">
|
||||||
|
<span class="bitstream" style="float:right;margin-right:12px"><?=exec("$fName -V")?></span>
|
||||||
|
|
||||||
|
Fan control function:
|
||||||
|
: <select name="service" size="1">
|
||||||
|
<?=mk_option($cfg['service'], "0", "Disabled")?>
|
||||||
|
<?=mk_option($cfg['service'], "1", "Enabled")?>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
PWM controller:
|
||||||
|
: <select name="controller" size="1">
|
||||||
|
<?=mk_option($cfg['controller'], "", "None")?>
|
||||||
|
<?foreach (list_pwm() as $pwm):?>
|
||||||
|
<?=mk_option($cfg['controller'], $pwm['sensor'], "{$pwm['chip']} - {$pwm['name']}")?>
|
||||||
|
<?endforeach;?>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
PWM fan:
|
||||||
|
: <input type="text" name="fan" value="<?=$cfg['fan']?>" placeholder="Click DETECT"><input type="button" value="Detect" onclick="detectFan();" id="fan" style="margin-top:0">
|
||||||
|
|
||||||
|
Minimun PWM value:
|
||||||
|
: <input type="text" name="pwm" value="<?=$cfg['pwm']?>" placeholder="Click DETECT"><input type="button" value="Detect" onclick="detectFanLow();" id="pwm" style="margin-top:0">
|
||||||
|
|
||||||
|
Low temperature threshold (°<?=$display['unit']?>):
|
||||||
|
: <input type="number" min="0" max="300" name="low" value="<?=temp_val($cfg['low'])?>" class="narrow">
|
||||||
|
|
||||||
|
High temperature threshold (°<?=$display['unit']?>):
|
||||||
|
: <input type="number" min="0" max="300" name="high" value="<?=temp_val($cfg['high'])?>" class="narrow">
|
||||||
|
|
||||||
|
Refresh interval (minutes):
|
||||||
|
: <input type="text" name="interval" value="<?=$cfg['interval']?>" class="narrow">
|
||||||
|
|
||||||
|
<input type="submit" name="#default" value="Default">
|
||||||
|
: <input type="submit" name="#apply" value="Apply"><input type="button" value="Done" onclick="done()">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function detectFan() {
|
||||||
|
var pwm = $("select[name=controller] option:selected").val();
|
||||||
|
if (pwm) {
|
||||||
|
$("input[name=fan]").val('Please wait...');
|
||||||
|
$("#fan").val('Detecting ...');
|
||||||
|
$.get('/plugins/<?=$plugin;?>/include/SystemFan.php',{op:'detect', pwm:pwm},function(data) {
|
||||||
|
$("input[name=fan]").val(data);
|
||||||
|
$("#fan").val('Detect');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function detectFanLow() {
|
||||||
|
var pwm = $("select[name=controller] option:selected").val();
|
||||||
|
var fan = $("input[name=fan]").val();
|
||||||
|
if (pwm && fan) {
|
||||||
|
$("input[name=pwm]").val('Please wait...');
|
||||||
|
$("#pwm").val('Detecting ...');
|
||||||
|
$.get('/plugins/<?=$plugin;?>/include/SystemFan.php',{op:'pwm',pwm:pwm,fan:fan},function(data) {
|
||||||
|
$("input[name=pwm]").val(data);
|
||||||
|
$("#pwm").val('Detect');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(function() {
|
||||||
|
//showStatus('<?=$sName?>');
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -33,5 +33,4 @@ Icon="sensorspage.png"
|
||||||
<script type="text/javascript" src="/plugins/ipmitool-plugin/js/jquery.ipmitool-plugin.js"></script>
|
<script type="text/javascript" src="/plugins/ipmitool-plugin/js/jquery.ipmitool-plugin.js"></script>
|
||||||
<script type="text/javascript" src="/plugins/tablesorter/js/jquery.tablesorter.combined.min.js"></script>
|
<script type="text/javascript" src="/plugins/tablesorter/js/jquery.tablesorter.combined.min.js"></script>
|
||||||
<script type="text/javascript" src="/plugins/tablesorter/js/pager/jquery.tablesorter.pager.js"></script>
|
<script type="text/javascript" src="/plugins/tablesorter/js/pager/jquery.tablesorter.pager.js"></script>
|
||||||
<script type="text/javascript" src="/plugins/tablesorter/js/parsers/parser-metric.min.js"></script>
|
|
||||||
<script type="text/javascript" src="/webGui/javascript/jquery.switchbutton.js"></script>
|
<script type="text/javascript" src="/webGui/javascript/jquery.switchbutton.js"></script>
|
||||||
|
|
|
@ -3,7 +3,6 @@ Title="Settings"
|
||||||
---
|
---
|
||||||
<?php
|
<?php
|
||||||
require_once '/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php';
|
require_once '/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php';
|
||||||
$sName = "ipmievd";
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript" src="/plugins/ipmitool-plugin/js/jquery.mask.js"></script>
|
<script type="text/javascript" src="/plugins/ipmitool-plugin/js/jquery.mask.js"></script>
|
||||||
|
@ -13,19 +12,19 @@ $sName = "ipmievd";
|
||||||
<input type="hidden" id="command" name="#command" value="" />
|
<input type="hidden" id="command" name="#command" value="" />
|
||||||
|
|
||||||
Enable Event Notifications:
|
Enable Event Notifications:
|
||||||
: <select id="SERVICE" name="SERVICE" size="1" onChange="checkRUNNING(this.form);">
|
: <select id="IPMIEVD" name="IPMIEVD" size="1" onChange="checkIPMIEVD(this.form);">
|
||||||
<?=mk_option($service, "disable", "No");?>
|
<?=mk_option($ipmievd, "disable", "No");?>
|
||||||
<?=mk_option($service, "enable", "Yes");?>
|
<?=mk_option($ipmievd, "enable", "Yes");?>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
Enable Remote Connection:
|
Enable Remote Connection:
|
||||||
: <select id="REMOTE" class="ipmitool-run" name="REMOTE" title="" size="1" onChange="checkREMOTE(this.form);">
|
: <select id="REMOTE" class="ipmievd-run" name="REMOTE" title="" size="1" onChange="checkREMOTE(this.form);">
|
||||||
<?=mk_option($remote, "disable", "No");?>
|
<?=mk_option($remote, "disable", "No");?>
|
||||||
<?=mk_option($remote, "enable", "Yes");?>
|
<?=mk_option($remote, "enable", "Yes");?>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<label class="ipmitool-lan">IPMI IP Address:</label>
|
<label class="ipmitool-lan">IPMI IP Address:</label>
|
||||||
: <input id="IPADDR" type="text" class="ipmitool-lan ipmitool-ipaddr" name="IPADDR" maxlength="40" value="<?=$ipaddr;?>" title="IPMI IP address" placeholder="" >
|
: <input id="IPADDR" type="text" class="ipmitool-lan ipmitool-ipaddr" name="IPADDR" maxlength="40" value="<?=$ipaddr;?>" title="IPMI IP address" placeholder="" ><label class='ipmitool-lan'><?=$conn_check;?></label>
|
||||||
|
|
||||||
<label class="ipmitool-lan">IPMI User Name:</label>
|
<label class="ipmitool-lan">IPMI User Name:</label>
|
||||||
: <input id="USER" type="text" class="ipmitool-lan" name="USER" maxlength="40" value="<?=$user;?>" title="username for remote access IPMI" placeholder="username for remote access" >
|
: <input id="USER" type="text" class="ipmitool-lan" name="USER" maxlength="40" value="<?=$user;?>" title="username for remote access IPMI" placeholder="username for remote access" >
|
||||||
|
@ -35,20 +34,23 @@ Enable Remote Connection:
|
||||||
|
|
||||||
Display CPU temperature:
|
Display CPU temperature:
|
||||||
: <select name="CPU_TEMP">
|
: <select name="CPU_TEMP">
|
||||||
<?=ipmi_get_options($cpu, 'Temperature', $options);?>
|
<option value='false'>None</option>
|
||||||
|
<?=ipmi_get_options($sensors, 'Temperature', $cpu);?>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
Display Motherboard temperature:
|
Display Motherboard temperature:
|
||||||
: <select name="MB_TEMP">
|
: <select name="MB_TEMP">
|
||||||
<?=ipmi_get_options($mb, 'Temperature', $options);?>
|
<option value='false'>None</option>
|
||||||
</select>
|
<?=ipmi_get_options($sensors, 'Temperature', $mb);?>
|
||||||
|
</select>
|
||||||
|
|
||||||
Display Fan speed:
|
Display Fan speed:
|
||||||
: <select name="IPMI_FAN">
|
: <select name="IPMI_FAN">
|
||||||
<?=ipmi_get_options($fan, 'Fan', $options);?>
|
<option value='false'>None</option>
|
||||||
</select>
|
<?=ipmi_get_options($sensors, 'Fan', $fan);?>
|
||||||
|
</select>
|
||||||
|
|
||||||
<input id="DEFAULT" class="ipmitool-run" type="button" value="Default" onClick="resetDATA(this.form);">
|
<input id="DEFAULT" class="ipmievd-run" type="button" value="Default" onClick="resetDATA(this.form);">
|
||||||
: <input id="btnApply" type="submit" value="Apply" onClick="verifyDATA(this.form)"><input type="button" value="Done" onClick="done()">
|
: <input id="btnApply" type="submit" value="Apply" onClick="verifyDATA(this.form)"><input type="button" value="Done" onClick="done()">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -57,7 +59,7 @@ $(function(){
|
||||||
$('.tabs')
|
$('.tabs')
|
||||||
.append("<span class='status'>Fan Control: <?=$ipmifan_status;?> </span>")
|
.append("<span class='status'>Fan Control: <?=$ipmifan_status;?> </span>")
|
||||||
.append("<span class='status'>Event Notification: <?=$ipmievd_status;?> </span>");
|
.append("<span class='status'>Event Notification: <?=$ipmievd_status;?> </span>");
|
||||||
checkRUNNING(document.ipmitool_settings);
|
checkIPMIEVD(document.ipmitool_settings);
|
||||||
checkREMOTE(document.ipmitool_settings);
|
checkREMOTE(document.ipmitool_settings);
|
||||||
decData(document.ipmitool_settings);
|
decData(document.ipmitool_settings);
|
||||||
//ip address input mask
|
//ip address input mask
|
||||||
|
@ -72,16 +74,16 @@ function resetDATA(form) {
|
||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkRUNNING(form) {
|
function checkIPMIEVD(form) {
|
||||||
if ("<?=$ipmievd_running;?>" == "yes")
|
if ("<?=$ipmievd_running;?>" == true)
|
||||||
{
|
{
|
||||||
$(".ipmitool-run").prop("disabled", true);
|
$(".ipmievd-run").prop("disabled", true);
|
||||||
form.btnApply.disabled = "disabled";
|
form.btnApply.disabled = "disabled";
|
||||||
}else{
|
}else{
|
||||||
$(".ipmitool-run").prop("disabled", false);
|
$(".ipmievd-run").prop("disabled", false);
|
||||||
$("#btnApply").prop("disabled", false);
|
$("#btnApply").prop("disabled", false);
|
||||||
}
|
}
|
||||||
if (form.SERVICE.value == "enable")
|
if (form.IPMIEVD.value == "enable")
|
||||||
form.command.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/start";
|
form.command.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/start";
|
||||||
else {
|
else {
|
||||||
form.command.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/stop";
|
form.command.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/stop";
|
||||||
|
@ -97,13 +99,13 @@ function checkREMOTE(form) {
|
||||||
$(".ipmitool-lan").hide();
|
$(".ipmitool-lan").hide();
|
||||||
else
|
else
|
||||||
$(".ipmitool-lan").show();
|
$(".ipmitool-lan").show();
|
||||||
$(".ipmitool-lan").prop("disabled", (form.SERVICE.value == "enable"));
|
$(".ipmitool-lan").prop("disabled", (form.IPMIEVD.value == "enable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function verifyDATA(form) {
|
function verifyDATA(form) {
|
||||||
form.SERVICE.value = form.SERVICE.value.replace(/ /g,"_");
|
form.IPMIEVD.value = form.IPMIEVD.value.replace(/ /g,"_");
|
||||||
form.REMOTE.value = form.REMOTE.value.replace(/ /g,"_");
|
form.REMOTE.value = form.REMOTE.value.replace(/ /g,"_");
|
||||||
form.USER.value = form.USER.value.replace(/ /g,"_");
|
form.USER.value = form.USER.value.replace(/ /g,"_");
|
||||||
form.PASSWORD.value = btoa(form.PASSWORD.value);
|
form.PASSWORD.value = btoa(form.PASSWORD.value);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -2,13 +2,17 @@
|
||||||
/* ipmi tool variables*/
|
/* ipmi tool variables*/
|
||||||
$plugin = 'ipmitool-plugin';
|
$plugin = 'ipmitool-plugin';
|
||||||
$cfg = parse_ini_file("/boot/config/plugins/$plugin/$plugin.cfg");
|
$cfg = parse_ini_file("/boot/config/plugins/$plugin/$plugin.cfg");
|
||||||
$service = isset($cfg['SERVICE']) ? $cfg['SERVICE'] : "disable";
|
$ipmievd = isset($cfg['IPMIEVD']) ? $cfg['IPMIEVD'] : "disable";
|
||||||
$remote = isset($cfg['REMOTE']) ? $cfg['REMOTE'] : "disable";
|
$ipmifan = isset($cfg['IPMIFAN']) ? $cfg['IPMIFAN'] : "disable";
|
||||||
$ipmievd_running = trim(shell_exec( "[ -f /proc/`cat /var/run/ipmievd.pid0 2> /dev/null`/exe ] && echo 'yes' || echo 'no' 2> /dev/null" ));
|
$remote = isset($cfg['REMOTE']) ? $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>";
|
$running = "<span class='green'>Running</span>";
|
||||||
$stopped = "<span class='orange'>Stopped</span>";
|
$stopped = "<span class='orange'>Stopped</span>";
|
||||||
$ipmievd_status = ($ipmievd_running == "yes") ? $running : $stopped;
|
$ipmievd_status = ($ipmievd_running) ? $running : $stopped;
|
||||||
$ipmifan_status = ($ipmifan_running == "yes") ? $running : $stopped;
|
$ipmifan_status = ($ipmifan_running) ? $running : $stopped;
|
||||||
|
|
||||||
// use save ip address or use local ipmi address
|
// 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']) ?
|
$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']) ?
|
||||||
|
@ -20,24 +24,32 @@ $mb = isset($cfg['MB_TEMP']) ? $cfg['MB_TEMP'] : ""; // mb temp display
|
||||||
$fan = isset($cfg['IPMI_FAN']) ? $cfg['IPMI_FAN'] : ""; // fan speed display name
|
$fan = isset($cfg['IPMI_FAN']) ? $cfg['IPMI_FAN'] : ""; // fan speed display name
|
||||||
$user = isset($cfg['USER']) ? $cfg['USER'] : ""; // user for remote access
|
$user = isset($cfg['USER']) ? $cfg['USER'] : ""; // user for remote access
|
||||||
$password = isset($cfg['PASSWORD']) ? $cfg['PASSWORD'] : ""; // password for remote access
|
$password = isset($cfg['PASSWORD']) ? $cfg['PASSWORD'] : ""; // password for remote access
|
||||||
$sensors = [$cpu, $mb, $fan];
|
|
||||||
|
|
||||||
// options for remote access or not
|
// options for remote access or not
|
||||||
$options = ($remote == "enable") ? "-I lanplus -H '$ipaddr' -U '$user' -P '".
|
$options = ($remote == "enable") ? "-I lanplus -H '$ipaddr' -U '$user' -P '".
|
||||||
base64_decode($password)."'" : "";
|
base64_decode($password)."'" : "";
|
||||||
|
|
||||||
|
// Get sensor info and check connection if remote enabled
|
||||||
|
$sensors = ipmi_sensors($options);
|
||||||
|
$fans = ipmi_get_fans($sensors);
|
||||||
|
|
||||||
|
if($remote == "enable"){
|
||||||
|
$conn = ($sensors) ? true : false;
|
||||||
|
$conn_check = ($conn) ? "Connection successful" : "Connection failed";
|
||||||
|
}
|
||||||
|
|
||||||
/* get an array of all sensors and their values */
|
/* get an array of all sensors and their values */
|
||||||
function ipmi_sensors($options) {
|
function ipmi_sensors($options) {
|
||||||
$cmd = "/usr/bin/ipmitool -vc sdr $options -N 1 -R 1 2>/dev/null";
|
$cmd = "/usr/bin/ipmitool -vc sdr $options -N 1 -R 1 2>/dev/null"; // N seconds R retries
|
||||||
exec($cmd, $output, $return);
|
exec($cmd, $output, $return);
|
||||||
|
|
||||||
if ($return)
|
if ($return)
|
||||||
return [];
|
return []; // return empty array if error
|
||||||
|
|
||||||
// key names for ipmitool sensor output
|
// key names for ipmitool sensor output
|
||||||
$keys = ['Name','Reading','Units','Status','Entity','Location','Type','Nominal',
|
$keys = ['Name','Reading','Units','Status','Entity','Location','Type','Nominal',
|
||||||
'NormalMin','NormalMax','UpperNonRec','UpperCritical','UpperNonCritical','LowerNonRec',
|
'NormalMin','NormalMax','UpperNonRec','UpperCritical','UpperNonCrit','LowerNonRec',
|
||||||
'LowerCritical','LowerNonCritical','MinRange','MaxRange'];
|
'LowerCritical','LowerNonCrit','MinRange','MaxRange'];
|
||||||
|
|
||||||
$sensors = [];
|
$sensors = [];
|
||||||
|
|
||||||
|
@ -54,11 +66,11 @@ function ipmi_sensors($options) {
|
||||||
|
|
||||||
/* get array of events and their values */
|
/* get array of events and their values */
|
||||||
function ipmi_events($options=null){
|
function ipmi_events($options=null){
|
||||||
$cmd = "/usr/bin/ipmitool -c sel elist $options -N 1 -R 1 2>/dev/null";
|
$cmd = "/usr/bin/ipmitool -c sel elist $options -N 1 -R 1 2>/dev/null"; // N seconds R retries
|
||||||
exec($cmd, $output, $return);
|
exec($cmd, $output, $return);
|
||||||
|
|
||||||
if ($return)
|
if ($return)
|
||||||
return [];
|
return []; // return empty array if error
|
||||||
|
|
||||||
// key names for ipmitool event output
|
// key names for ipmitool event output
|
||||||
$keys = array('Event','Datestamp','Timestamp','Sensor','Description','Status');
|
$keys = array('Event','Datestamp','Timestamp','Sensor','Description','Status');
|
||||||
|
@ -76,9 +88,8 @@ function ipmi_events($options=null){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get select options for a given sensor type */
|
/* get select options for a given sensor type */
|
||||||
function ipmi_get_options($selected, $type, $options){
|
function ipmi_get_options($sensors, $type, $selected=null){
|
||||||
$sensors = ipmi_sensors($options=null);
|
$options = "";
|
||||||
$options = "<option value='false'>No</option>\n";
|
|
||||||
foreach($sensors as $sensor){
|
foreach($sensors as $sensor){
|
||||||
if ($sensor["Type"] == $type && $sensor["Status"] != "ns"){
|
if ($sensor["Type"] == $type && $sensor["Status"] != "ns"){
|
||||||
$name = $sensor["Name"];
|
$name = $sensor["Name"];
|
||||||
|
@ -88,7 +99,7 @@ function ipmi_get_options($selected, $type, $options){
|
||||||
if ($selected == $name)
|
if ($selected == $name)
|
||||||
$options .= " selected";
|
$options .= " selected";
|
||||||
|
|
||||||
$options .= ">$name</option>\n";
|
$options .= ">$name</option>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $options;
|
return $options;
|
||||||
|
@ -97,23 +108,29 @@ function ipmi_get_options($selected, $type, $options){
|
||||||
/* get reading for a given sensor by name */
|
/* get reading for a given sensor by name */
|
||||||
function ipmi_get_reading($names, $options=null) {
|
function ipmi_get_reading($names, $options=null) {
|
||||||
$readings = [];
|
$readings = [];
|
||||||
$cmd = "/usr/bin/ipmitool -c sdr $options -N 1 -R 1 2>/dev/null";
|
$cmd = "/usr/bin/ipmitool -c sdr $options -N 1 -R 1 2>/dev/null"; // N seconds R retries
|
||||||
exec($cmd, $output, $return);
|
exec($cmd, $output, $return);
|
||||||
|
|
||||||
if ($return)
|
if ($return)
|
||||||
return [];
|
return []; // return empty array if error
|
||||||
|
|
||||||
for ($i = 0; $i < sizeof($names); $i++) {
|
for ($i = 0; $i < sizeof($names); $i++) {
|
||||||
|
|
||||||
foreach($output as $sensor){
|
foreach($output as $line){
|
||||||
$sensors = explode(",", $sensor);
|
$sensor = explode(",", $line);
|
||||||
|
|
||||||
if ($sensors[0] == $names[$i]) // check name
|
if ($sensor[0] == $names[$i]) // check name
|
||||||
$readings[$names[$i]] = $sensors[1]; // reading
|
$readings[$names[$i]] = $sensor[1]; // get reading by name from readings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $readings; // reading
|
return $readings; // reading
|
||||||
}
|
}
|
||||||
//echo json_encode(ipmi_get_reading($sensors, $options));
|
|
||||||
//echo json_encode(ipmi_sensors($options));
|
function ipmi_get_fans($sensors){
|
||||||
?>
|
foreach($sensors as $sensor){
|
||||||
|
if ($sensor['Type'] == 'Fan' && $sensor['Status'] != 'ns')
|
||||||
|
$fans[] = str_replace(' ', '_', $sensor['Name']);
|
||||||
|
}
|
||||||
|
return $fans;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
|
@ -6,7 +6,7 @@ function ipmi_temp($reading, $unit, $dot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cpu || $mb || $fan){
|
if ($cpu || $mb || $fan){
|
||||||
$readings = ipmi_get_reading($sensors, $options);
|
$readings = ipmi_get_reading([$cpu, $mb, $fan], $options);
|
||||||
$temps = [];
|
$temps = [];
|
||||||
|
|
||||||
if ($readings[$cpu])
|
if ($readings[$cpu])
|
||||||
|
@ -20,4 +20,4 @@ if ($cpu || $mb || $fan){
|
||||||
}
|
}
|
||||||
if ($temps)
|
if ($temps)
|
||||||
echo "<span id='temps' style='margin-right:16px'>".implode(' ', $temps)."</span>";
|
echo "<span id='temps' style='margin-right:16px'>".implode(' ', $temps)."</span>";
|
||||||
?>
|
?>
|
|
@ -58,7 +58,7 @@ $(function(){
|
||||||
//sensor refresh
|
//sensor refresh
|
||||||
function sensorRefresh() {
|
function sensorRefresh() {
|
||||||
sensorArray(true);
|
sensorArray(true);
|
||||||
setTimeout(sensorRefresh, 3000);
|
setTimeout(sensorRefresh, 5000);
|
||||||
};
|
};
|
||||||
|
|
||||||
//load ipmi sensor table
|
//load ipmi sensor table
|
||||||
|
@ -70,42 +70,42 @@ function sensorArray(Refresh){
|
||||||
var Reading = parseFloat(data[i].Reading);
|
var Reading = parseFloat(data[i].Reading);
|
||||||
var LowerNonRec = parseFloat(data[i].LowerNonRec);
|
var LowerNonRec = parseFloat(data[i].LowerNonRec);
|
||||||
var LowerCritical = parseFloat(data[i].LowerCritical);
|
var LowerCritical = parseFloat(data[i].LowerCritical);
|
||||||
var LowerNonCritical = parseFloat(data[i].LowerNonCritical);
|
var LowerNonCrit = parseFloat(data[i].LowerNonCrit);
|
||||||
var UpperNonCritical = parseFloat(data[i].UpperNonCritical);
|
var UpperNonCrit = parseFloat(data[i].UpperNonCrit);
|
||||||
var UpperCritical = parseFloat(data[i].UpperCritical);
|
var UpperCritical = parseFloat(data[i].UpperCritical);
|
||||||
var UpperNonRec = parseFloat(data[i].UpperNonRec);
|
var UpperNonRec = parseFloat(data[i].UpperNonRec);
|
||||||
var Color = "green";
|
var Color = "green";
|
||||||
|
|
||||||
// replace illegal characters
|
// replace invalid characters
|
||||||
var Name = data[i].Name.replace('+', 'plus_').replace('-', 'minus_').replace(' ', '_').replace('.', '_');
|
var Name = data[i].Name.replace('+', 'plus_').replace('-', 'minus_').replace(' ', '_').replace('.', '_');
|
||||||
|
|
||||||
if (data[i].Type=="Voltage"){
|
if (data[i].Type=="Voltage"){
|
||||||
|
|
||||||
// if voltage is less than lower non-critical
|
// if voltage is less than lower non-critical
|
||||||
// or voltage is greater than upper non-critical show orange
|
// or voltage is greater than upper non-critical show critical
|
||||||
if (Reading < LowerNonCritical && Reading > UpperNonCritical)
|
if (Reading < LowerNonCrit && Reading > UpperNonCrit)
|
||||||
Color = "orange";
|
Color = "orange";
|
||||||
|
|
||||||
// if voltage is less than lower critical
|
// if voltage is less than lower critical
|
||||||
// or voltage is greater than upper critical show red
|
// or voltage is greater than upper critical show non-recoverable
|
||||||
if (Reading < LowerCritical || Reading > UpperCritical)
|
if (Reading < LowerCritical || Reading > UpperCritical)
|
||||||
Color = "red";
|
Color = "red";
|
||||||
|
|
||||||
} else if (data[i].Type=="Fan"){
|
} else if (data[i].Type=="Fan"){
|
||||||
|
|
||||||
// if Fan RPMs are less than lower non-critical
|
// if Fan RPMs are less than lower non-critical
|
||||||
if (Reading < LowerNonCritical || Reading < LowerCritical || Reading < LowerNonRec)
|
if (Reading < LowerNonCrit || Reading < LowerCritical || Reading < LowerNonRec)
|
||||||
Color = "red";
|
Color = "red";
|
||||||
|
|
||||||
} else if (data[i].Type=="Temperature"){
|
} else if (data[i].Type=="Temperature"){
|
||||||
|
|
||||||
// if Temperature is greater than upper non-critical
|
// if Temperature is greater than upper non-critical
|
||||||
if (Reading > UpperNonCritical || Reading > UpperCritical || Reading > UpperNonRec)
|
if (Reading > UpperNonCrit || Reading > UpperCritical || Reading > UpperNonRec)
|
||||||
Color = "red";
|
Color = "red";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Refresh) {
|
if (Refresh) {
|
||||||
$("#" + Name + " td.reading").html("<font color='" + Color + "'>" + Reading + "</font>");
|
$("#" + Name + " td.reading").html("<font color='"+ Color + "'>" + Reading + "</font>");
|
||||||
} else {
|
} else {
|
||||||
$("#tblSensor tbody")
|
$("#tblSensor tbody")
|
||||||
.append("<tr id='"+Name+"'>"+
|
.append("<tr id='"+Name+"'>"+
|
||||||
|
@ -113,10 +113,10 @@ function sensorArray(Refresh){
|
||||||
"<td>"+data[i].Name+"</td>"+ //sensor name
|
"<td>"+data[i].Name+"</td>"+ //sensor name
|
||||||
"<td class='advanced'>"+ data[i].LowerNonRec +"</td>"+
|
"<td class='advanced'>"+ data[i].LowerNonRec +"</td>"+
|
||||||
"<td class='advanced'>"+ data[i].LowerCritical +"</td>"+
|
"<td class='advanced'>"+ data[i].LowerCritical +"</td>"+
|
||||||
"<td class='advanced'>"+ data[i].LowerNonCritical +"</td>"+
|
"<td class='advanced'>"+ data[i].LowerNonCrit +"</td>"+
|
||||||
"<td class='reading "+ Color +"-text'>"+ Reading +"</td>"+ //sensor reading
|
"<td class='reading'>"+ "<font color='"+ Color + "'>" + Reading + "</font></td>"+ //sensor reading
|
||||||
"<td>"+data[i].Units+"</td>"+ //sensor units
|
"<td>"+data[i].Units+"</td>"+ //sensor units
|
||||||
"<td class='advanced'>"+ data[i].UpperNonCritical +"</td>"+
|
"<td class='advanced'>"+ data[i].UpperNonCrit +"</td>"+
|
||||||
"<td class='advanced'>"+ data[i].UpperCritical +"</td>"+
|
"<td class='advanced'>"+ data[i].UpperCritical +"</td>"+
|
||||||
"<td class='advanced'>"+ data[i].UpperNonRec +"</td>"+
|
"<td class='advanced'>"+ data[i].UpperNonRec +"</td>"+
|
||||||
"</tr>");
|
"</tr>");
|
||||||
|
@ -165,16 +165,33 @@ function eventArray(){
|
||||||
};
|
};
|
||||||
|
|
||||||
function Delete(Row) {
|
function Delete(Row) {
|
||||||
var Confirm = (Row == "all") ? confirm("Are your sure you want to remove all events!?"): true;
|
if (Row == "all"){
|
||||||
if (Confirm){
|
swal({
|
||||||
var Method = (Row == "all") ? "clear " : "delete ";
|
title: "Are you sure?",
|
||||||
var EventId = (Row == "all") ? "" : Row;
|
text: "Are your sure you want to remove all events!?",
|
||||||
$.getJSON("/plugins/ipmitool-plugin/include/ipmi_event_delete.php", {options: Method + EventId}, function(data) {
|
type: "warning",
|
||||||
if (Row == "all")
|
showCancelButton: true,
|
||||||
$("#tblEvent tbody").empty(); // empty table
|
closeOnConfirm: true,
|
||||||
else
|
}, function() {
|
||||||
$('#'+Row).remove(); //remove table row
|
$.get("/plugins/ipmitool-plugin/include/ipmi_event_delete.php", {options: "clear"}, function() {
|
||||||
}
|
$("#tblEvent tbody").empty(); // empty table
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$.get("/plugins/ipmitool-plugin/include/ipmi_event_delete.php", {options: "delete " + Row}, function() {
|
||||||
|
slideRow($('#'+Row)); //remove table row
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function slideRow(td) {
|
||||||
|
td
|
||||||
|
.children('td')
|
||||||
|
.animate({ padding: 0 })
|
||||||
|
.wrapInner('<div />')
|
||||||
|
.children()
|
||||||
|
.slideUp(function() { td.remove(); });
|
||||||
|
$("#tblEvents").trigger("update")
|
||||||
|
};
|
||||||
|
|
|
@ -29,9 +29,9 @@ Usage: $prog [options] = start daemon
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
$shortopts = "cquv";
|
$shortopts = "bc:dqv";
|
||||||
$longopts = [
|
$longopts = [
|
||||||
"cron",
|
"cron:",
|
||||||
"debug",
|
"debug",
|
||||||
"help",
|
"help",
|
||||||
"quiet",
|
"quiet",
|
||||||
|
@ -51,23 +51,23 @@ if (array_key_exists("version", $args)) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$argcr = (array_key_exists("c", $args) || array_key_exists("cron", $args));
|
$cron = (array_key_exists("c", $args) || array_key_exists("cron", $args));
|
||||||
$argd = (array_key_exists("d", $args) || array_key_exists("debug", $args));
|
$DEBUG = (array_key_exists("d", $args) || array_key_exists("debug", $args));
|
||||||
$argq = (array_key_exists("q", $args) || array_key_exists("quit", $args));
|
$quit = (array_key_exists("q", $args) || array_key_exists("quit", $args));
|
||||||
$argu = (array_key_exists("u", $args) || array_key_exists("uninstall", $args));
|
$background = (array_key_exists("b", $args) || array_key_exists("background", $args));
|
||||||
$argv = (array_key_exists("v", $args) || array_key_exists("verbose", $args));
|
$argv = (array_key_exists("v", $args) || array_key_exists("verbose", $args));
|
||||||
|
|
||||||
// ipmitool raw 0x3a 0x01 0xAA 0xBB 0xCC 0xDD 0xEE 0xFF 0xGG 0xHH
|
// ipmitool raw 0x3a 0x01 0xAA 0xBB 0xCC 0xDD 0xEE 0xFF 0xGG 0xHH
|
||||||
//ipmitool raw 0x3a 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
//ipmitool raw 0x3a 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||||
// 0x00 = smartfan mode
|
// 0x00 = smartfan mode
|
||||||
// 0x01 - 0x64 = 1% - 100%
|
// 0x01 - 0x64 = 1% - 100%
|
||||||
$asrock_array = [
|
$asrock = [
|
||||||
'CPU_FAN1' => 'AA',
|
'CPU_FAN1' => 'AA',
|
||||||
'CPU_FAN2' => 'BB',
|
'CPU_FAN2' => 'BB',
|
||||||
'REAR_FAN1' => 'CC',
|
'REAR_FAN1' => 'CC',
|
||||||
'REAR_FAN2' => 'DD',
|
'REAR_FAN2' => 'DD',
|
||||||
'FRNT_FAN1' => 'EE',
|
'FRNT_FAN1' => 'EE',
|
||||||
'FRNT_FAN2' => 'FF'
|
'FRNT_FAN2' => 'FF'
|
||||||
];
|
];
|
||||||
|
|
||||||
function debug($m){
|
function debug($m){
|
||||||
|
@ -79,7 +79,7 @@ function debug($m){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$background_args = "";
|
/*$background_args = "";
|
||||||
if(isset($argv)){
|
if(isset($argv)){
|
||||||
for ($i=0; $i <= count($argv); $i++) {
|
for ($i=0; $i <= count($argv); $i++) {
|
||||||
switch ($argv[$i]) {
|
switch ($argv[$i]) {
|
||||||
|
@ -94,20 +94,15 @@ if(isset($argv)){
|
||||||
$DEBUG = TRUE;
|
$DEBUG = TRUE;
|
||||||
$background_args .= " ${argv[$i]}";
|
$background_args .= " ${argv[$i]}";
|
||||||
break;
|
break;
|
||||||
case '-h':
|
|
||||||
case '--help':
|
|
||||||
echo $usage;
|
|
||||||
exit(0);
|
|
||||||
# Especific switches:
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
# Deal with cron
|
# Deal with cron
|
||||||
if ($cron) && is_numeric($cron) && !$argq){
|
if ($cron) && is_numeric($cron) && !$quit){
|
||||||
exec("crontab -l 2>/dev/null", $crontab);
|
exec("crontab -l 2>/dev/null", $crontab);
|
||||||
$crontab = array_unique($crontab);
|
$crontab = array_unique($crontab);
|
||||||
if (!$argq){
|
if (!$quit){
|
||||||
$entry = sprintf("*/%s * * * * ${service}${background_args} 1> /dev/null 2>&1", $cron);
|
$entry = sprintf("*/%s * * * * ${service}${background_args} 1> /dev/null 2>&1", $cron);
|
||||||
if (! preg_grep("#${service}#", $crontab)){
|
if (! preg_grep("#${service}#", $crontab)){
|
||||||
$crontab[] = $entry;
|
$crontab[] = $entry;
|
||||||
|
@ -118,7 +113,7 @@ if ($cron) && is_numeric($cron) && !$argq){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($crontab);
|
unset($crontab);
|
||||||
} else if ($argq){
|
} else if ($quit){
|
||||||
exec("crontab -l 2>/dev/null", $crontab);
|
exec("crontab -l 2>/dev/null", $crontab);
|
||||||
$crontab = array_unique($crontab);
|
$crontab = array_unique($crontab);
|
||||||
if (preg_grep("#${service}#", $crontab)){
|
if (preg_grep("#${service}#", $crontab)){
|
||||||
|
@ -133,9 +128,9 @@ if ($cron) && is_numeric($cron) && !$argq){
|
||||||
|
|
||||||
if (is_file($lockfile)){
|
if (is_file($lockfile)){
|
||||||
$lock_pid = file($lockfile, FILE_IGNORE_NEW_LINES)[0];
|
$lock_pid = file($lockfile, FILE_IGNORE_NEW_LINES)[0];
|
||||||
$pid_running=preg_replace("/\s+/", "", shell_exec("ps -p ${lock_pid}| grep ${lock_pid}"));
|
$pid = preg_replace("/\s+/", "", shell_exec("ps -p ${lock_pid}| grep ${lock_pid}"));
|
||||||
if (!$pid_running){
|
if (!$pid){
|
||||||
if (!$argq){
|
if (!$quit){
|
||||||
file_put_contents($lockfile, getmypid());
|
file_put_contents($lockfile, getmypid());
|
||||||
} else {
|
} else {
|
||||||
echo "$lock_pid is not currently running";
|
echo "$lock_pid is not currently running";
|
||||||
|
@ -143,19 +138,19 @@ if (is_file($lockfile)){
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($argq){
|
if ($quit){
|
||||||
syslog(LOG_INFO, "killing daemon with PID [${lock_pid}]");
|
syslog(LOG_INFO, "killing daemon with PID [$lock_pid]");
|
||||||
exec("kill $lock_pid");
|
exec("kill $lock_pid");
|
||||||
unlink($lockfile);
|
unlink($lockfile);
|
||||||
if (function_exists('at_exit')) at_exit();
|
if (function_exists('at_exit')) at_exit();
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
echo "$prog is already running [${lock_pid}]".PHP_EOL;
|
echo "$prog is already running [$lock_pid]".PHP_EOL;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if($argq){
|
if($quit){
|
||||||
echo "$prog not currently running".PHP_EOL;
|
echo "$prog not currently running".PHP_EOL;
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
prog="ipmievd: "
|
DAEMON="ipmievd: "
|
||||||
|
LASTMSG="Waiting for events"
|
||||||
exec /usr/bin/tail -n 0 -F /var/log/syslog | \
|
exec /usr/bin/tail -n 0 -F /var/log/syslog | \
|
||||||
|
|
||||||
while read LINE;
|
while read LINE;
|
||||||
|
@ -14,7 +14,8 @@ do
|
||||||
[[ "$LINE" == *"Get SEL Info command failed"* ]] && continue
|
[[ "$LINE" == *"Get SEL Info command failed"* ]] && continue
|
||||||
|
|
||||||
# only notify when ipmievd: is in the system log
|
# only notify when ipmievd: is in the system log
|
||||||
[[ "$LINE" != *$prog* ]] && continue
|
[[ "$LINE" != *$DAEMON* ]] && continue
|
||||||
|
MESSAGE=$(echo "$LINE" | sed -e 's/.*$DAEMON//')
|
||||||
sleep 1 |
|
sleep 1 |
|
||||||
exec /usr/local/emhttp/webGui/scripts/notify -s "Notice [$HOSTNAME]" -d "$(echo "$LINE" | sed -e 's/.*$prog//')" -i "warning" && continue 2
|
exec /usr/local/emhttp/webGui/scripts/notify -s "Notice [$HOSTNAME]" -d "$MESSAGE" -i "warning" && continue 2
|
||||||
done
|
done
|
|
@ -1,17 +1,15 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# read our configuration
|
# read our configuration
|
||||||
prog="ipmievd"
|
DAEMON="/usr/sbin/ipmievd"
|
||||||
prog2="ipmitail"
|
IPMITAIL="/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmitail"
|
||||||
IPMIEVD="/usr/sbin/$prog"
|
LOCKFILE="/var/lock/ipmievd"
|
||||||
IPMITAIL="/usr/local/emhttp/plugins/ipmitool-plugin/scripts/$prog2"
|
PIDFILE="/var/run/ipmievd.pid0"
|
||||||
LOCKFILE="/var/lock/$prog"
|
|
||||||
PIDFILE="/var/run/$prog.pid0"
|
|
||||||
CONFIG="/boot/config/plugins/ipmitool-plugin/ipmitool-plugin.cfg"
|
CONFIG="/boot/config/plugins/ipmitool-plugin/ipmitool-plugin.cfg"
|
||||||
OPTIONS=""
|
OPTIONS=""
|
||||||
|
|
||||||
if [ -e $CONFIG ]; then
|
if [ -e $CONFIG ]; then
|
||||||
source $CONFIG
|
source $CONFIG
|
||||||
if [ $SERVICE == "enable" ]; then
|
if [ $IPMIEVD == "enable" ]; then
|
||||||
# no-op if already running
|
# no-op if already running
|
||||||
if [ ! -r $PIDFILE ]; then
|
if [ ! -r $PIDFILE ]; then
|
||||||
if [ $REMOTE == "enable" ]; then
|
if [ $REMOTE == "enable" ]; then
|
||||||
|
@ -19,7 +17,7 @@ if [ -e $CONFIG ]; then
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
nohup $IPMIEVD sel $OPTIONS > /dev/null 2>&1 | logger -tipmitool &
|
nohup $DAEMON sel $OPTIONS > /dev/null 2>&1 | logger -tipmitool &
|
||||||
touch $LOCKFILE
|
touch $LOCKFILE
|
||||||
TIMER=0
|
TIMER=0
|
||||||
while [ ! -e $PIDFILE ]; do
|
while [ ! -e $PIDFILE ]; do
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
prog="ipmievd"
|
DAEMON="ipmievd"
|
||||||
prog2="ipmitail"
|
TAIL="ipmitail"
|
||||||
LOCKFILE="/var/lock/$prog"
|
LOCKFILE="/var/lock/$DAEMON"
|
||||||
PIDFILE="/var/run/$prog.pid0"
|
PIDFILE="/var/run/$DAEMON.pid0"
|
||||||
|
|
||||||
# no-op if not running
|
# no-op if not running
|
||||||
if [ -r $PIDFILE ]; then
|
if [ -r $PIDFILE ]; then
|
||||||
TIMER=0
|
TIMER=0
|
||||||
while `killall $prog 2>/dev/null`; do
|
while `killall $DAEMON 2>/dev/null`; do
|
||||||
sleep 1
|
sleep 1
|
||||||
TIMER=$((TIMER+1))
|
TIMER=$((TIMER+1))
|
||||||
if [ $TIMER -ge 30 ]; then
|
if [ $TIMER -ge 30 ]; then
|
||||||
killall -9 $prog
|
killall -9 $DAEMON
|
||||||
sleep 1
|
sleep 1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
TIMER=0
|
TIMER=0
|
||||||
while `killall $prog2 2>/dev/null`; do
|
while `killall $TAIL 2>/dev/null`; do
|
||||||
sleep 1
|
sleep 1
|
||||||
TIMER=$((TIMER+1))
|
TIMER=$((TIMER+1))
|
||||||
if [ $TIMER -ge 30 ]; then
|
if [ $TIMER -ge 30 ]; then
|
||||||
killall -9 $prog2
|
killall -9 $TAIL
|
||||||
sleep 1
|
sleep 1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user