add get options for fan temps

This commit is contained in:
Derek Macias 2016-02-03 02:15:08 -07:00
parent 17287fa255
commit b93d49e871
3 changed files with 124 additions and 61 deletions

View File

@ -3,12 +3,12 @@ Title="Fan Control"
--- ---
<form markdown="1" name="ipmifan_settings" method="POST" action="/update.php" target="progressFrame"> <form markdown="1" name="ipmifan_settings" method="POST" action="/update.php" target="progressFrame">
<input type="hidden" name="#file" value="ipmitool-plugin/ipmitool-plugin.cfg" /> <input type="hidden" name="#file" value="ipmitool-plugin/ipmitool-plugin.cfg" />
<input type="hidden" id="command" name="#command" value="" /> <input type="hidden" id="FANCMD" name="#command" value="" />
IPMI Fan Control: IPMI Fan Control:
: <select name="service" size="1"> : <select name="IPMIFAN" size="1">
<?=mk_option($cfg['service'], "0", "No")?> <?=mk_option($ipmifan, "disable", "No")?>
<?=mk_option($cfg['service'], "1", "Yes")?> <?=mk_option($ipmifan, "enable", "Yes")?>
</select> </select>
&nbsp; &nbsp;
@ -16,20 +16,21 @@ IPMI Fan Control:
<?php if ($fans[0]): ?> <?php if ($fans[0]): ?>
<?=$fans[0];?> temperature sensor: <?=$fans[0];?> temperature sensor:
: <select name="<?='FAN_'.$fans[0];?>"> : <select name="FAN_<?=$fans[0];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature');?> <?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[0]], true);?>
<option value='HDD'>HDD Temperatures</option>
</select> </select>
<?=$fans[0];?> Low temperature threshold: <?=$fans[0];?> Low temperature threshold:
: <select name="<?='FAN_'.$fans[0];?>_LOW"> : <select name="FAN_LOW_<?=$fans[0];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[0]]);?>
</select> </select>
<?=$fans[0];?> High temperature threshold: <?=$fans[0];?> High temperature threshold:
: <select name="<?='FAN_'.$fans[0];?>_HIGH"> : <select name="FAN_HIGH_<?=$fans[0];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[0]]);?>
</select> </select>
&nbsp; &nbsp;
@ -39,20 +40,21 @@ IPMI Fan Control:
<?php if ($fans[1]): ?> <?php if ($fans[1]): ?>
<?=$fans[1];?> temperature sensor: <?=$fans[1];?> temperature sensor:
: <select name="<?='FAN_'.$fans[1];?>"> : <select name="FAN_<?=$fans[1];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature');?> <?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[1]], true);?>
<option value='HDD'>HDD Temperatures</option>
</select> </select>
<?=$fans[1];?> Low temperature threshold: <?=$fans[1];?> Low temperature threshold:
: <select name="<?='FAN_'.$fans[1];?>_LOW"> : <select name="FAN_LOW_<?=$fans[1];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[1]]);?>
</select> </select>
<?=$fans[1];?> High temperature threshold: <?=$fans[1];?> High temperature threshold:
: <select name="<?='FAN_'.$fans[1];?>_HIGH"> : <select name="FAN_HIGH_<?=$fans[1];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[1]]);?>
</select> </select>
&nbsp; &nbsp;
@ -62,20 +64,21 @@ IPMI Fan Control:
<?php if ($fans[2]): ?> <?php if ($fans[2]): ?>
<?=$fans[2];?> temperature sensor: <?=$fans[2];?> temperature sensor:
: <select name="<?='FAN_'.$fans[2];?>"> : <select name="FAN_<?=$fans[2];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature');?> <?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[2]], true);?>
<option value='HDD'>HDD Temperatures</option>
</select> </select>
<?=$fans[2];?> Low temperature threshold: <?=$fans[2];?> Low temperature threshold:
: <select name="<?='FAN_'.$fans[2];?>_LOW"> : <select name="FAN_LOW_<?=$fans[2];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[2]]);?>
</select> </select>
<?=$fans[2];?> High temperature threshold: <?=$fans[2];?> High temperature threshold:
: <select name="<?='FAN_'.$fans[2];?>_HIGH"> : <select name="FAN_HIGH_<?=$fans[2];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[2]]);?>
</select> </select>
&nbsp; &nbsp;
@ -85,20 +88,21 @@ IPMI Fan Control:
<?php if ($fans[3]): ?> <?php if ($fans[3]): ?>
<?=$fans[3];?> temperature sensor: <?=$fans[3];?> temperature sensor:
: <select name="<?='FAN_'.$fans[3];?>"> : <select name="FAN_<?=$fans[3];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature');?> <?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[3]], true);?>
<option value='HDD'>HDD Temperatures</option>
</select> </select>
<?=$fans[3];?> Low temperature threshold: <?=$fans[3];?> Low temperature threshold:
: <select name="<?='FAN_'.$fans[3];?>_LOW"> : <select name="FAN_LOW_<?=$fans[3];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[3]]);?>
</select> </select>
<?=$fans[3];?> High temperature threshold: <?=$fans[3];?> High temperature threshold:
: <select name="<?='FAN_'.$fans[3];?>_HIGH"> : <select name="FAN_HIGH_<?=$fans[3];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[3]]);?>
</select> </select>
&nbsp; &nbsp;
@ -108,20 +112,21 @@ IPMI Fan Control:
<?php if ($fans[4]): ?> <?php if ($fans[4]): ?>
<?=$fans[4];?> temperature sensor: <?=$fans[4];?> temperature sensor:
: <select name="<?='FAN_'.$fans[4];?>"> : <select name="FAN_<?=$fans[4];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature');?> <?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[4]], true);?>
<option value='HDD'>HDD Temperatures</option>
</select> </select>
<?=$fans[4];?> Low temperature threshold: <?=$fans[4];?> Low temperature threshold:
: <select name="<?='FAN_'.$fans[4];?>_LOW"> : <select name="FAN_LOW_<?=$fans[4];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[4]]);?>
</select> </select>
<?=$fans[4];?> High temperature threshold: <?=$fans[4];?> High temperature threshold:
: <select name="<?='FAN_'.$fans[4];?>_HIGH"> : <select name="FAN_HIGH_<?=$fans[4];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[4]]);?>
</select> </select>
&nbsp; &nbsp;
@ -131,20 +136,21 @@ IPMI Fan Control:
<?php if ($fans[5]): ?> <?php if ($fans[5]): ?>
<?=$fans[5];?> temperature sensor: <?=$fans[5];?> temperature sensor:
: <select name="<?='FAN_'.$fans[5];?>"> : <select name="FAN_<?=$fans[5];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature');?> <?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[5]], true);?>
<option value='HDD'>HDD Temperatures</option>
</select> </select>
<?=$fans[5];?> Low temperature threshold: <?=$fans[5];?> Low temperature threshold:
: <select name="<?='FAN_'.$fans[5];?>_LOW"> : <select name="FAN_LOW_<?=$fans[5];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[5]]);?>
</select> </select>
<?=$fans[5];?> High temperature threshold: <?=$fans[5];?> High temperature threshold:
: <select name="<?='FAN_'.$fans[5];?>_HIGH"> : <select name="FAN_HIGH_<?=$fans[5];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[5]]);?>
</select> </select>
&nbsp; &nbsp;
@ -154,20 +160,21 @@ IPMI Fan Control:
<?php if ($fans[6]): ?> <?php if ($fans[6]): ?>
<?=$fans[6];?> temperature sensor: <?=$fans[6];?> temperature sensor:
: <select name="<?='FAN_'.$fans[6];?>"> : <select name="FAN_<?=$fans[6];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature');?> <?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[6]], true);?>
<option value='HDD'>HDD Temperatures</option>
</select> </select>
<?=$fans[6];?> Low temperature threshold: <?=$fans[6];?> Low temperature threshold:
: <select name="<?='FAN_'.$fans[6];?>_LOW"> : <select name="<FAN_LOW_<?=$fans[6];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[6]]);?>
</select> </select>
<?=$fans[6];?> High temperature threshold: <?=$fans[6];?> High temperature threshold:
: <select name="<?='FAN_'.$fans[6];?>_HIGH"> : <select name="FAN_HIGH_<?=$fans[6];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[6]]);?>
</select> </select>
&nbsp; &nbsp;
@ -177,20 +184,21 @@ IPMI Fan Control:
<?php if ($fans[7]): ?> <?php if ($fans[7]): ?>
<?=$fans[7];?> temperature sensor: <?=$fans[7];?> temperature sensor:
: <select name="<?='FAN_'.$fans[7];?>"> : <select name="FAN_<?=$fans[7];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature');?> <?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[7]], true);?>
<option value='HDD'>HDD Temperatures</option>
</select> </select>
<?=$fans[7];?> Low temperature threshold: <?=$fans[7];?> Low temperature threshold:
: <select name="<?='FAN_'.$fans[7];?>_LOW"> : <select name="FAN_LOW_<?=$fans[7];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[7]]);?>
</select> </select>
<?=$fans[7];?> High temperature threshold: <?=$fans[7];?> High temperature threshold:
: <select name="<?='FAN_'.$fans[7];?>_HIGH"> : <select name="<FAN_HIGH_<?=$fans[7];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[7]]);?>
</select> </select>
&nbsp; &nbsp;
@ -200,20 +208,21 @@ IPMI Fan Control:
<?php if ($fans[8]): ?> <?php if ($fans[8]): ?>
<?=$fans[8];?> temperature sensor: <?=$fans[8];?> temperature sensor:
: <select name="<?='FAN_'.$fans[8];?>"> : <select name="FAN_<?=$fans[8];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature');?> <?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[8]], true);?>
<option value='HDD'>HDD Temperatures</option>
</select> </select>
<?=$fans[8];?> Low temperature threshold: <?=$fans[8];?> Low temperature threshold:
: <select name="<?='FAN_'.$fans[8];?>_LOW"> : <select name="FAN_LOW_<?=$fans[8];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[8]]);?>
</select> </select>
<?=$fans[8];?> High temperature threshold: <?=$fans[8];?> High temperature threshold:
: <select name="<?='FAN_'.$fans[8];?>_HIGH"> : <select name="FAN_HIGH_<?=$fans[8];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[8]]);?>
</select> </select>
&nbsp; &nbsp;
@ -223,20 +232,21 @@ IPMI Fan Control:
<?php if ($fans[9]): ?> <?php if ($fans[9]): ?>
<?=$fans[9];?> temperature sensor: <?=$fans[9];?> temperature sensor:
: <select name="<?='FAN_'.$fans[9];?>"> : <select name="FAN_<?=$fans[9];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature');?> <?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[9]], true);?>
<option value='HDD'>HDD Temperatures</option>
</select> </select>
<?=$fans[9];?> Low temperature threshold: <?=$fans[9];?> Low temperature threshold:
: <select name="<?='FAN_'.$fans[9];?>_LOW"> : <select name="<FAN_LOW_<?=$fans[9];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[9]]);?>
</select> </select>
<?=$fans[9];?> High temperature threshold: <?=$fans[9];?> High temperature threshold:
: <select name="<?='FAN_'.$fans[9];?>_HIGH"> : <select name="FAN_HIGH_<?=$fans[9];?>">
<option value='0'>Auto</option> <option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[9]]);?>
</select> </select>
<?php endif; ?> <?php endif; ?>
@ -246,3 +256,29 @@ IPMI Fan Control:
<input id="FAN_DEFAULT" class="ipmifan-run" type="button" value="Default" onClick="resetFANDATA(this.form);"> <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()"> : <input id="btnFANApply" type="submit" value="Apply" onClick="verifyFANDATA(this.form)"><input type="button" value="Done" onClick="done()">
</form> </form>
<script type="text/javascript">
function resetFANDATA(form) {
form.submit();
}
function checkIPMIFAN(form) {
if ("<?=$ipmifan_running;?>" == true)
{
$(".ipmifan-run").prop("disabled", true);
form.btnFANApply.disabled = "disabled";
}else{
$(".ipmifan-run").prop("disabled", false);
$("#btnFANApply").prop("disabled", false);
}
if (form.IPMIFAN.value == "enable")
form.FANCMD.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/fancontrol_start";
else {
form.FANCMD.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/fabcontrol_stop";
}
}
function verifyFANDATA(form) {
form.IPMIFAN.value = form.IPMIFAN.value.replace(/ /g,"_");
}
</script>

View File

@ -9,7 +9,7 @@ require_once '/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers
<form markdown="1" name="ipmitool_settings" method="POST" action="/update.php" target="progressFrame"> <form markdown="1" name="ipmitool_settings" method="POST" action="/update.php" target="progressFrame">
<input type="hidden" name="#file" value="ipmitool-plugin/ipmitool-plugin.cfg" /> <input type="hidden" name="#file" value="ipmitool-plugin/ipmitool-plugin.cfg" />
<input type="hidden" id="command" name="#command" value="" /> <input type="hidden" id="COMMAND" name="#command" value="" />
Enable Event Notifications: Enable Event Notifications:
: <select id="IPMIEVD" name="IPMIEVD" size="1" onChange="checkIPMIEVD(this.form);"> : <select id="IPMIEVD" name="IPMIEVD" size="1" onChange="checkIPMIEVD(this.form);">
@ -45,7 +45,7 @@ Display Motherboard temperature:
</select> </select>
Display Fan speed: Display Fan speed:
: <select name="IPMI_FAN"> : <select name="DISP_FAN">
<option value='false'>None</option> <option value='false'>None</option>
<?=ipmi_get_options($sensors, 'Fan', $fan);?> <?=ipmi_get_options($sensors, 'Fan', $fan);?>
</select> </select>
@ -60,6 +60,7 @@ $(function(){
.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>");
checkIPMIEVD(document.ipmitool_settings); checkIPMIEVD(document.ipmitool_settings);
//checkIPMIFAN(document.ipmifan_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
@ -71,6 +72,9 @@ function resetDATA(form) {
form.IPADDR.value = ""; form.IPADDR.value = "";
form.USER.value = ""; form.USER.value = "";
form.PASSWORD.value = ""; form.PASSWORD.value = "";
form.CPU_TEMP.selectedIndex = 0;
form.MB_TEMP.selectedIndex = 0;
form.DISP_FAN.selectedIndex = 0;
form.submit(); form.submit();
} }
@ -84,9 +88,9 @@ function checkIPMIEVD(form) {
$("#btnApply").prop("disabled", false); $("#btnApply").prop("disabled", false);
} }
if (form.IPMIEVD.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";
} }
} }
@ -108,4 +112,5 @@ function verifyDATA(form) {
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>

View File

@ -88,7 +88,9 @@ 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($sensors, $type, $selected=null){ function ipmi_get_options($sensors, $type, $selected=null, $hdd=null){
if ($hdd)
$sensors[] = ['Name' => 'HDD Temperature', 'Type' => 'Temperature', 'Status' => 'ok'];
$options = ""; $options = "";
foreach($sensors as $sensor){ foreach($sensors as $sensor){
if ($sensor["Type"] == $type && $sensor["Status"] != "ns"){ if ($sensor["Type"] == $type && $sensor["Status"] != "ns"){
@ -105,6 +107,25 @@ function ipmi_get_options($sensors, $type, $selected=null){
return $options; return $options;
} }
// get options for high or low temp thresholds
function temp_get_options($range, $selected=null){
$temps = [20,25,30,35,40,45,50,55,60,65,70,75,80];
if ($range == 'HIGH')
rsort($temps);
$options = "";
foreach($temps as $temp){
$options .= "<option value='$temp'";
// set saved option as selected
if ($selected == $temp)
$options .= " selected";
$options .= ">$temp</option>";
}
return $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 = [];
@ -133,4 +154,5 @@ function ipmi_get_fans($sensors){
} }
return $fans; return $fans;
} }
?>
?>