append ipmi top variables, add rc scripts

This commit is contained in:
Derek Macias 2016-02-15 09:29:56 -07:00
parent 05ea73f3b2
commit 54117ed9a6
15 changed files with 653 additions and 213 deletions

View File

@ -0,0 +1,81 @@
#!/bin/sh
# start/stop/restart ipmievd daemon:
PROG="ipmievd"
DAEMON="/usr/sbin/$PROG"
LOCKFILE="/var/lock/$PROG"
PIDFILE="/var/run/$PROG.pid0"
CONFIG="/boot/config/plugins/ipmitool-plugin/ipmitool-plugin.cfg"
OPTIONS=""
# read our configuration
[ -e "$CONFIG" ] && source "$CONFIG"
# Start ipmievd:
ipmievd_start() {
# no-op if already running
if [[ ! -r "$PIDFILE" && "$IPMIEVD" == "enable" ]]; then
if [ $REMOTE == "enable" ]; then
OPTIONS="-I lanplus -H $IPADDR -U $USER -P $(echo $PASSWORD | base64 --decode)"
fi
echo "starting $PROG..."
sleep 1
nohup $DAEMON sel $OPTIONS > /dev/null 2>&1 | logger -tipmitool &
touch $LOCKFILE
TIMER=0
while [ ! -e $PIDFILE ]; do
sleep 1
let TIMER=$TIMER+1
if [ $TIMER -gt 5 ]; then
echo -n "$PIDFILE not created"
break
fi
done
else
echo "$PROG is running "
fi
}
# Stop ipmievd:
ipmievd_stop() {
# no-op if not running
if [ -r $PIDFILE ]; then
#stop ipmievd
echo "stopping $PROG..."
TIMER=0
while `killall $PROG 2>/dev/null`; do
sleep 1
TIMER=$((TIMER+1))
if [ $TIMER -ge 30 ]; then
killall -9 $PROG
sleep 1
break
fi
done
rm -f $LOCKFILE && rm -f $PIDFILE
else
echo "$PROG is stopped "
fi
}
# Restart ipmievd:
ipmievd_restart() {
ipmievd_stop
sleep 1
ipmievd_start
}
case "$1" in
'start')
ipmievd_start
;;
'stop')
ipmievd_stop
;;
'restart')
ipmievd_restart
;;
*)
echo "usage rc.ipmievd: start|stop|restart"
esac

View File

@ -0,0 +1,78 @@
#!/bin/sh
# start/stop/restart ipmitail daemon:
PROG="ipmitail"
DAEMON="/usr/sbin/$PROG"
LOCKFILE="/var/lock/$PROG"
PIDFILE="/var/run/$PROG.pid"
CONFIG="/boot/config/plugins/ipmitool-plugin/ipmitool-plugin.cfg"
OPTIONS=""
# read our configuration
[ -e "$CONFIG" ] && source "$CONFIG"
# Start ipmitail:
ipmitail_start() {
# no-op if already running
if [[ ! -r "$PIDFILE" && "$IPMIEVD" == "enable" ]]; then
echo "starting $PROG..."
sleep 1
nohup $DAEMON >/dev/null 2>&1 | echo $! > $PIDFILE &
touch $LOCKFILE
TIMER=0
while [ ! -e $PIDFILE ]; do
sleep 1
let TIMER=$TIMER+1
if [ $TIMER -gt 5 ]; then
echo -n "$PIDFILE not created"
break
fi
done
else
echo "$PROG is running "
fi
}
# Stop ipmitail:
ipmitail_stop() {
# no-op if not running
if [ -r $PIDFILE ]; then
#stop ipmitail
echo "stopping $PROG..."
TIMER=0
while `killall $PROG 2>/dev/null`; do
sleep 1
TIMER=$((TIMER+1))
if [ $TIMER -ge 30 ]; then
killall -9 $PROG
sleep 1
break
fi
done
rm -f $LOCKFILE && rm -f $PIDFILE
else
echo "$PROG is stopped "
fi
}
# Restart ipmitail:
ipmitail_restart() {
ipmitail_stop
sleep 1
ipmitail_start
}
case "$1" in
'start')
ipmitail_start
;;
'stop')
ipmitail_stop
;;
'restart')
ipmitail_restart
;;
*)
echo "usage rc.ipmitail: start|stop|restart"
esac

View File

@ -1 +1,25 @@
#!/bin/sh
RC_SCRIPT="/etc/rc.d/rc.ipmievd"
RC_SCRIPT2="/etc/rc.d/rc.ipmitail"
SD_RCFILE="/etc/rc.d/rc.local_shutdown"
# Update file permissions of scripts
chmod +0755 /usr/local/emhttp/plugins/ipmitool-plugin/scripts/* \
/usr/sbin/ipmitail \
/usr/sbin/ipmifan \
$RC_SCRIPT \
$RC_SCRIPT2
###Stop Scripts###
# Add stop script to rc.local_shutdown script
if ! grep "$RC_SCRIPT" $SD_RCFILE >/dev/null 2>&1
then echo -e "\n[ -x $RC_SCRIPT ] && $RC_SCRIPT stop" >> $SD_RCFILE
fi
[ ! -x $SD_RCFILE ] && chmod u+x $SD_RCFILE
# Add stop script to rc.local_shutdown script
if ! grep "$RC_SCRIPT2" $SD_RCFILE >/dev/null 2>&1
then echo -e "\n[ -x $RC_SCRIPT2 ] && $RC_SCRIPT2 stop" >> $SD_RCFILE
fi
[ ! -x $SD_RCFILE ] && chmod u+x $SD_RCFILE

View File

@ -9,244 +9,244 @@ IPMI Fan Control:
: <select name="IPMIFAN" size="1">
<?=mk_option($ipmifan, "disable", "No")?>
<?=mk_option($ipmifan, "enable", "Yes")?>
</select>
</select><label><font class="red"><b>NOT FUNTIONAL YET</b></font></label>
&nbsp;
<?php if ($fans[0]): ?>
<?php if ($ipmi_fans[0]): ?>
<?=$fans[0];?> temperature sensor:
: <select name="FAN_<?=$fans[0];?>">
<?=$ipmi_fans[0];?> temperature sensor:
: <select name="FAN_<?=$ipmi_fans[0];?>">
<option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[0]], true);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cfg['FAN_'.$ipmi_fans[0]], true);?>
</select>
<?=$fans[0];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$fans[0];?>">
<?=$ipmi_fans[0];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$ipmi_fans[0];?>">
<option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[0]]);?>
<?=temp_get_options('LOW', $ipmi_cfg['FAN_LOW_'.$ipmi_fans[0]]);?>
</select>
<?=$fans[0];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$fans[0];?>">
<?=$ipmi_fans[0];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$ipmi_fans[0];?>">
<option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[0]]);?>
<?=temp_get_options('HIGH', $ipmi_cfg['FAN_HIGH_'.$ipmi_fans[0]]);?>
</select>
&nbsp;
<?php endif; ?>
<?php if ($fans[1]): ?>
<?php if ($ipmi_fans[1]): ?>
<?=$fans[1];?> temperature sensor:
: <select name="FAN_<?=$fans[1];?>">
<?=$ipmi_fans[1];?> temperature sensor:
: <select name="FAN_<?=$ipmi_fans[1];?>">
<option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[1]], true);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cfg['FAN_'.$ipmi_fans[1]], true);?>
</select>
<?=$fans[1];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$fans[1];?>">
<?=$ipmi_fans[1];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$ipmi_fans[1];?>">
<option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[1]]);?>
<?=temp_get_options('LOW', $ipmi_cfg['FAN_LOW_'.$ipmi_fans[1]]);?>
</select>
<?=$fans[1];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$fans[1];?>">
<?=$ipmi_fans[1];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$ipmi_fans[1];?>">
<option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[1]]);?>
<?=temp_get_options('HIGH', $ipmi_cfg['FAN_HIGH_'.$ipmi_fans[1]]);?>
</select>
&nbsp;
<?php endif; ?>
<?php if ($fans[2]): ?>
<?php if ($ipmi_fans[2]): ?>
<?=$fans[2];?> temperature sensor:
: <select name="FAN_<?=$fans[2];?>">
<?=$ipmi_fans[2];?> temperature sensor:
: <select name="FAN_<?=$ipmi_fans[2];?>">
<option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[2]], true);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cfg['FAN_'.$ipmi_fans[2]], true);?>
</select>
<?=$fans[2];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$fans[2];?>">
<?=$ipmi_fans[2];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$ipmi_fans[2];?>">
<option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[2]]);?>
<?=temp_get_options('LOW', $ipmi_cfg['FAN_LOW_'.$ipmi_fans[2]]);?>
</select>
<?=$fans[2];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$fans[2];?>">
<?=$ipmi_fans[2];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$ipmi_fans[2];?>">
<option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[2]]);?>
<?=temp_get_options('HIGH', $ipmi_cfg['FAN_HIGH_'.$ipmi_fans[2]]);?>
</select>
&nbsp;
<?php endif; ?>
<?php if ($fans[3]): ?>
<?php if ($ipmi_fans[3]): ?>
<?=$fans[3];?> temperature sensor:
: <select name="FAN_<?=$fans[3];?>">
<?=$ipmi_fans[3];?> temperature sensor:
: <select name="FAN_<?=$ipmi_fans[3];?>">
<option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[3]], true);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cfg['FAN_'.$ipmi_fans[3]], true);?>
</select>
<?=$fans[3];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$fans[3];?>">
<?=$ipmi_fans[3];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$ipmi_fans[3];?>">
<option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[3]]);?>
<?=temp_get_options('LOW', $ipmi_cfg['FAN_LOW_'.$ipmi_fans[3]]);?>
</select>
<?=$fans[3];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$fans[3];?>">
<?=$ipmi_fans[3];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$ipmi_fans[3];?>">
<option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[3]]);?>
<?=temp_get_options('HIGH', $ipmi_cfg['FAN_HIGH_'.$ipmi_fans[3]]);?>
</select>
&nbsp;
<?php endif; ?>
<?php if ($fans[4]): ?>
<?php if ($ipmi_fans[4]): ?>
<?=$fans[4];?> temperature sensor:
: <select name="FAN_<?=$fans[4];?>">
<?=$ipmi_fans[4];?> temperature sensor:
: <select name="FAN_<?=$ipmi_fans[4];?>">
<option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[4]], true);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cfg['FAN_'.$ipmi_fans[4]], true);?>
</select>
<?=$fans[4];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$fans[4];?>">
<?=$ipmi_fans[4];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$ipmi_fans[4];?>">
<option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[4]]);?>
<?=temp_get_options('LOW', $ipmi_cfg['FAN_LOW_'.$ipmi_fans[4]]);?>
</select>
<?=$fans[4];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$fans[4];?>">
<?=$ipmi_fans[4];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$ipmi_fans[4];?>">
<option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[4]]);?>
<?=temp_get_options('HIGH', $ipmi_cfg['FAN_HIGH_'.$ipmi_fans[4]]);?>
</select>
&nbsp;
<?php endif; ?>
<?php if ($fans[5]): ?>
<?php if ($ipmi_fans[5]): ?>
<?=$fans[5];?> temperature sensor:
: <select name="FAN_<?=$fans[5];?>">
<?=$ipmi_fans[5];?> temperature sensor:
: <select name="FAN_<?=$ipmi_fans[5];?>">
<option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[5]], true);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cfg['FAN_'.$ipmi_fans[5]], true);?>
</select>
<?=$fans[5];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$fans[5];?>">
<?=$ipmi_fans[5];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$ipmi_fans[5];?>">
<option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[5]]);?>
<?=temp_get_options('LOW', $ipmi_cfg['FAN_LOW_'.$ipmi_fans[5]]);?>
</select>
<?=$fans[5];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$fans[5];?>">
<?=$ipmi_fans[5];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$ipmi_fans[5];?>">
<option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[5]]);?>
<?=temp_get_options('HIGH', $ipmi_cfg['FAN_HIGH_'.$ipmi_fans[5]]);?>
</select>
&nbsp;
<?php endif; ?>
<?php if ($fans[6]): ?>
<?php if ($ipmi_fans[6]): ?>
<?=$fans[6];?> temperature sensor:
: <select name="FAN_<?=$fans[6];?>">
<?=$ipmi_fans[6];?> temperature sensor:
: <select name="FAN_<?=$ipmi_fans[6];?>">
<option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[6]], true);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cfg['FAN_'.$ipmi_fans[6]], true);?>
</select>
<?=$fans[6];?> Low temperature threshold:
: <select name="<FAN_LOW_<?=$fans[6];?>">
<?=$ipmi_fans[6];?> Low temperature threshold:
: <select name="<FAN_LOW_<?=$ipmi_fans[6];?>">
<option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[6]]);?>
<?=temp_get_options('LOW', $ipmi_cfg['FAN_LOW_'.$ipmi_fans[6]]);?>
</select>
<?=$fans[6];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$fans[6];?>">
<?=$ipmi_fans[6];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$ipmi_fans[6];?>">
<option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[6]]);?>
<?=temp_get_options('HIGH', $ipmi_cfg['FAN_HIGH_'.$ipmi_fans[6]]);?>
</select>
&nbsp;
<?php endif; ?>
<?php if ($fans[7]): ?>
<?php if ($ipmi_fans[7]): ?>
<?=$fans[7];?> temperature sensor:
: <select name="FAN_<?=$fans[7];?>">
<?=$ipmi_fans[7];?> temperature sensor:
: <select name="FAN_<?=$ipmi_fans[7];?>">
<option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[7]], true);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cfg['FAN_'.$ipmi_fans[7]], true);?>
</select>
<?=$fans[7];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$fans[7];?>">
<?=$ipmi_fans[7];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$ipmi_fans[7];?>">
<option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[7]]);?>
<?=temp_get_options('LOW', $ipmi_cfg['FAN_LOW_'.$ipmi_fans[7]]);?>
</select>
<?=$fans[7];?> High temperature threshold:
: <select name="<FAN_HIGH_<?=$fans[7];?>">
<?=$ipmi_fans[7];?> High temperature threshold:
: <select name="<FAN_HIGH_<?=$ipmi_fans[7];?>">
<option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[7]]);?>
<?=temp_get_options('HIGH', $ipmi_cfg['FAN_HIGH_'.$ipmi_fans[7]]);?>
</select>
&nbsp;
<?php endif; ?>
<?php if ($fans[8]): ?>
<?php if ($ipmi_fans[8]): ?>
<?=$fans[8];?> temperature sensor:
: <select name="FAN_<?=$fans[8];?>">
<?=$ipmi_fans[8];?> temperature sensor:
: <select name="FAN_<?=$ipmi_fans[8];?>">
<option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[8]], true);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cfg['FAN_'.$ipmi_fans[8]], true);?>
</select>
<?=$fans[8];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$fans[8];?>">
<?=$ipmi_fans[8];?> Low temperature threshold:
: <select name="FAN_LOW_<?=$ipmi_fans[8];?>">
<option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[8]]);?>
<?=temp_get_options('LOW', $ipmi_cfg['FAN_LOW_'.$ipmi_fans[8]]);?>
</select>
<?=$fans[8];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$fans[8];?>">
<?=$ipmi_fans[8];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$ipmi_fans[8];?>">
<option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[8]]);?>
<?=temp_get_options('HIGH', $ipmi_cfg['FAN_HIGH_'.$ipmi_fans[8]]);?>
</select>
&nbsp;
<?php endif; ?>
<?php if ($fans[9]): ?>
<?php if ($ipmi_fans[9]): ?>
<?=$fans[9];?> temperature sensor:
: <select name="FAN_<?=$fans[9];?>">
<?=$ipmi_fans[9];?> temperature sensor:
: <select name="FAN_<?=$ipmi_fans[9];?>">
<option value='0'>Auto</option>
<?=ipmi_get_options($sensors, 'Temperature', $cfg['FAN_'.$fans[9]], true);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cfg['FAN_'.$ipmi_fans[9]], true);?>
</select>
<?=$fans[9];?> Low temperature threshold:
: <select name="<FAN_LOW_<?=$fans[9];?>">
<?=$ipmi_fans[9];?> Low temperature threshold:
: <select name="<FAN_LOW_<?=$ipmi_fans[9];?>">
<option value='0'>Auto</option>
<?=temp_get_options('LOW', $cfg['FAN_LOW_'.$fans[9]]);?>
<?=temp_get_options('LOW', $ipmi_cfg['FAN_LOW_'.$ipmi_fans[9]]);?>
</select>
<?=$fans[9];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$fans[9];?>">
<?=$ipmi_fans[9];?> High temperature threshold:
: <select name="FAN_HIGH_<?=$ipmi_fans[9];?>">
<option value='0'>Auto</option>
<?=temp_get_options('HIGH', $cfg['FAN_HIGH_'.$fans[9]]);?>
<?=temp_get_options('HIGH', $ipmi_cfg['FAN_HIGH_'.$ipmi_fans[9]]);?>
</select>
<?php endif; ?>

View File

@ -32,5 +32,5 @@ Icon="sensorspage.png"
<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/pager/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" src="/plugins/tablesorter/js/extras/jquery.tablesorter.pager.min.js"></script>
<script type="text/javascript" src="/webGui/javascript/jquery.switchbutton.js"></script>

View File

@ -16,35 +16,35 @@ Enable Event Notifications:
Enable Remote Connection:
: <select id="REMOTE" class="ipmievd-run" name="REMOTE" title="" size="1" onChange="checkREMOTE(this.form);">
<?=mk_option($remote, "disable", "No");?>
<?=mk_option($remote, "enable", "Yes");?>
<?=mk_option($ipmi_remote, "disable", "No");?>
<?=mk_option($ipmi_remote, "enable", "Yes");?>
</select>
<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="" ><label class='ipmitool-lan'><?=$conn_check;?></label>
: <input id="IPADDR" type="text" class="ipmitool-lan ipmitool-ipaddr" name="IPADDR" maxlength="40" value="<?=$ipmi_ipaddr;?>" title="IPMI IP address" placeholder="" ><label class='ipmitool-lan'><?=$ipmi_conn_check;?></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="<?=$ipmi_user;?>" title="username for remote access IPMI" placeholder="username for remote access" >
<label class="ipmitool-lan">IPMI Password:</label>
: <input id="PASSWORD" type="password" class="ipmitool-lan" name="PASSWORD" maxlength="40" value="<?=$password;?>" title="password for remote access IPMI" placeholder="password for remote access" >
: <input id="PASSWORD" type="password" class="ipmitool-lan" name="PASSWORD" maxlength="40" value="<?=$ipmi_password;?>" title="password for remote access IPMI" placeholder="password for remote access" >
Display CPU temperature:
: <select name="CPU_TEMP">
<option value='false'>None</option>
<?=ipmi_get_options($sensors, 'Temperature', $cpu_temp);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cpu_temp);?>
</select>
Display Motherboard temperature:
: <select name="MB_TEMP">
<option value='false'>None</option>
<?=ipmi_get_options($sensors, 'Temperature', $mb_temp);?>
<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_mb_temp);?>
</select>
Display Fan speed:
: <select name="FAN_DISP">
<option value='false'>None</option>
<?=ipmi_get_options($sensors, 'Fan', $fan_disp);?>
<?=ipmi_get_options($ipmi_sensors, 'Fan', $ipmi_fan_disp);?>
</select>
<input id="DEFAULT" class="ipmievd-run" type="button" value="Default" onClick="resetDATA(this.form);">

View File

@ -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);
?>

View File

@ -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));
?>

View File

@ -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 */

View File

@ -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));
?>

View File

@ -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)) : '##')."&thinsp;$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]."&thinsp;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]."&thinsp;rpm";
}
if ($temps)
echo "<span id='temps' style='margin-right:16px'>".implode('&nbsp;', $temps)."</span>";
if ($ipmi_temps)
echo "<span id='temps' style='margin-right:16px'>".implode('&nbsp;', $ipmi_temps)."</span>";
?>

View File

@ -1,36 +1,4 @@
#!/bin/sh
# read our configuration
DAEMON="/usr/sbin/ipmievd"
IPMITAIL="/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmitail"
LOCKFILE="/var/lock/ipmievd"
PIDFILE="/var/run/ipmievd.pid0"
CONFIG="/boot/config/plugins/ipmitool-plugin/ipmitool-plugin.cfg"
OPTIONS=""
if [ -e $CONFIG ]; then
source $CONFIG
if [ $IPMIEVD == "enable" ]; then
# no-op if already running
if [ ! -r $PIDFILE ]; then
if [ $REMOTE == "enable" ]; then
OPTIONS="-I lanplus -H $IPADDR -U $USER -P $(echo $PASSWORD | base64 --decode)"
fi
sleep 1
nohup $DAEMON sel $OPTIONS > /dev/null 2>&1 | logger -tipmitool &
touch $LOCKFILE
TIMER=0
while [ ! -e $PIDFILE ]; do
sleep 1
let TIMER=$TIMER+1
if [ $TIMER -gt 5 ]; then
echo -n "$PIDFILE not created"
break
fi
done
if [ -r $PIDFILE ]; then
nohup $IPMITAIL >/dev/null 2>&1 < /dev/null &
fi
fi
fi
fi
/etc/rc.d/rc.ipmievd start
sleep 1
/etc/rc.d/rc.ipmitail start

View File

@ -1,30 +1,4 @@
#!/bin/sh
DAEMON="ipmievd"
TAIL="ipmitail"
LOCKFILE="/var/lock/$DAEMON"
PIDFILE="/var/run/$DAEMON.pid0"
# no-op if not running
if [ -r $PIDFILE ]; then
TIMER=0
while `killall $DAEMON 2>/dev/null`; do
sleep 1
TIMER=$((TIMER+1))
if [ $TIMER -ge 30 ]; then
killall -9 $DAEMON
sleep 1
break
fi
done
TIMER=0
while `killall $TAIL 2>/dev/null`; do
sleep 1
TIMER=$((TIMER+1))
if [ $TIMER -ge 30 ]; then
killall -9 $TAIL
sleep 1
break
fi
done
rm -f $LOCKFILE && rm -f $PIDFILE
fi
/etc/rc.d/rc.ipmievd stop
sleep 1
/etc/rc.d/rc.ipmitail stop

View File

@ -0,0 +1,292 @@
#!/usr/bin/php
<?php
##############################
###### DEAMON SECTION ######
##############################
$cron = FALSE;
$DEBUG = FALSE;
# DO NOT TOUCH
set_time_limit(0);
$prog = pathinfo(__FILE__, PATHINFO_FILENAME);
$lockfile = "/var/run/$prog.pid";
$service = __FILE__;
openlog($prog, LOG_PID | LOG_PERROR, LOG_LOCAL0);
$usage = <<<EOF
Process settings files in ipmitool-plugin config. Control fans based on the config value and [options].
Usage: $prog [options] = start daemon
-c, --cron create a cron job
-d, --debug turn on debugging
-q, --quit terminate $prog if running
-v, --verbose print all messages
--help display this help and exit
--version output version information and exit
EOF;
$shortopts = "bc:dqv";
$longopts = [
"cron:",
"debug",
"help",
"quiet",
"quit",
"verbose",
"version"
];
$args = getopt($shortopts, $longopts);
if (array_key_exists("help", $args)) {
echo $usage;
exit(1);
}
if (array_key_exists("version", $args)) {
echo "IPMI Fan Control: 1.0\n";
exit(1);
}
$cron = (array_key_exists("c", $args) || array_key_exists("cron", $args));
$DEBUG = (array_key_exists("d", $args) || array_key_exists("debug", $args));
$quit = (array_key_exists("q", $args) || array_key_exists("quit", $args));
$background = (array_key_exists("b", $args) || array_key_exists("background", $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 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
// 0x00 = smartfan mode
// 0x01 - 0x64 = 1% - 100%
$asrock = [
'CPU_FAN1' => 'AA',
'CPU_FAN2' => 'BB',
'REAR_FAN1' => 'CC',
'REAR_FAN2' => 'DD',
'FRNT_FAN1' => 'EE',
'FRNT_FAN2' => 'FF'
];
function debug($m){
global $prog, $DEBUG;
if($DEBUG){
$STDERR = fopen('php://stderr', 'w+');
fwrite($STDERR, $m."\n");
fclose($STDERR);
}
}
/*$background_args = "";
if(isset($argv)){
for ($i=0; $i <= count($argv); $i++) {
switch ($argv[$i]) {
case '--background':
$background = TRUE;
break;
case '-c':
$cron = $argv[$i+1];
$background_args .= " ${argv[$i]} ${argv[$i+1]}";
break;
case '-d':
$DEBUG = TRUE;
$background_args .= " ${argv[$i]}";
break;
}
}
}*/
# Deal with cron
if ($cron) && is_numeric($cron) && !$quit){
exec("crontab -l 2>/dev/null", $crontab);
$crontab = array_unique($crontab);
if (!$quit){
$entry = sprintf("*/%s * * * * ${service}${background_args} 1> /dev/null 2>&1", $cron);
if (! preg_grep("#${service}#", $crontab)){
$crontab[] = $entry;
debug("\nCRONTAB\n".implode("\n", $crontab)."\n");
file_put_contents("/tmp/$prog.cron", implode(PHP_EOL, $crontab));
shell_exec("crontab /tmp/$prog.cron");
unlink("/tmp/$prog.cron");
}
}
unset($crontab);
} else if ($quit){
exec("crontab -l 2>/dev/null", $crontab);
$crontab = array_unique($crontab);
if (preg_grep("#${service}#", $crontab)){
$crontab = preg_grep("#${service}#", $crontab, PREG_GREP_INVERT);
debug("\nCRONTAB\n".implode("\n", $crontab)."\n");
file_put_contents("/tmp/$prog.cron", implode(PHP_EOL, $crontab));
shell_exec("crontab /tmp/$prog.cron");
unlink("/tmp/$prog.cron");
};
unset($crontab);
}
if (is_file($lockfile)){
$lock_pid = file($lockfile, FILE_IGNORE_NEW_LINES)[0];
$pid = preg_replace("/\s+/", "", shell_exec("ps -p ${lock_pid}| grep ${lock_pid}"));
if (!$pid){
if (!$quit){
file_put_contents($lockfile, getmypid());
} else {
echo "$lock_pid is not currently running";
unlink($lockfile);
exit(0);
}
} else {
if ($quit){
syslog(LOG_INFO, "killing daemon with PID [$lock_pid]");
exec("kill $lock_pid");
unlink($lockfile);
if (function_exists('at_exit')) at_exit();
exit(0);
} else {
echo "$prog is already running [$lock_pid]".PHP_EOL;
exit(0);
}
}
} else {
if($quit){
echo "$prog not currently running".PHP_EOL;
exit(0);
} else {
file_put_contents($lockfile, getmypid());
}
}
/*if(!$background){
exec("php $service --background $background_args 1>/dev/null ".($DEBUG ? "":"2>&1 ")."&");
exit(0);
} else {
syslog(LOG_INFO, "process started. To terminate it, type: $prog -q");
}
*/
##############################
##### PROGRAM SECTION ######
##############################
$plugin = "ipmitool-plugin";
$cfg_file = "/boot/config/plugins/$plugin/$plugin.cfg";
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 get_highest_temp($hdds){
$highest_temp="0";
foreach ($hdds as $hdd) {
if (shell_exec("hdparm -C ${hdd} 2>/dev/null| grep -c standby") == 0){
$temp = preg_replace("/\s+/", "", shell_exec("smartctl -A ${hdd} 2>/dev/null| grep -m 1 -i Temperature_Celsius | awk '{print $10}'"));
$highest_temp = ($temp > $highest_temp) ? $temp : $highest_temp;
}
}
debug("Highest temp is ${highest_temp}ºC");
return $highest_temp;
}
function get_all_hdds(){
$hdds = array();
$flash = preg_replace("/\d$/", "", realpath("/dev/disk/by-label/UNRAID"));
foreach (scan_dir("/dev/") as $dev) {
if(preg_match("/[sh]d[a-z]+$/", $dev) && $dev != $flash) {
$hdds[] = $dev;
}
}
return $hdds;
}
$hdds = get_all_hdds();
while(TRUE){ while(TRUE){
#### DO YOUR STUFF HERE ####
# Load config file or die
if(is_file($cfg_file)){
$params = parse_ini_file($cfg_file);
extract($params, EXTR_OVERWRITE);
} else {
unlink($lockfile);
exit(1);
}
/*# Wait probes to become ready
if (!is_file($PWM_CONTROLLER) || ! is_file($PWM_FAN)){
sleep(15);
continue;
}*/
# Set PWM_HIGH and PWM_OFF
$PWM_HIGH = 64;
$PWM_OFF = $PWM_LOW-5;
# Disable fan mininum RPM
$FAN_RPM_MIN = file(split("_", $PWM_FAN)[0]."_min", FILE_IGNORE_NEW_LINES)[0];
$D_FAN_RPM_MIN = ($FAN_RPM_MIN > 0) ? $FAN_RPM_MIN : FALSE;
# Enable speed change on fan
/*$PWM_MODE=file("${PWM_CONTROLLER}_enable", FILE_IGNORE_NEW_LINES)[0];
if($PWM_MODE != 1){
$DEFAULT_PWM_MODE = $PWM_MODE;
file_put_contents("${PWM_CONTROLLER}_enable", 1);
}*/
# Calculate size of increments.
$TEMP_INCREMENTS = $TEMP_HIGH-$TEMP_LOW;
$PWM_INCREMENTS = round(($PWM_HIGH-$PWM_LOW)/$TEMP_INCREMENTS);
# Get current fan rpm and pwm
$CURRENT_PWM = preg_replace("/\s*/", "", file_get_contents($PWM_CONTROLLER));
$CURRENT_RPM = preg_replace("/\s*/", "", file_get_contents($PWM_FAN));
# Get current fan PWM percentage
$CURRENT_PERCENT_PWM = round(($CURRENT_PWM*100)/$PWM_HIGH);
$CURRENT_OUTPUT = "${CURRENT_PWM} (${CURRENT_PERCENT_PWM}% @ ${CURRENT_RPM}rpm)";
# Calculate a new scenario
# Get highest drive temperature
$HIGHEST_TEMP = get_highest_temp($hdds);
if ($HIGHEST_TEMP <= $TEMP_LOW){
$NEW_PWM = $PWM_OFF;
$NEW_PERCENT_PWM = 0;
} else if ($HIGHEST_TEMP >= $TEMP_HIGH){
$NEW_PWM = $PWM_HIGH;
$NEW_PERCENT_PWM = 100;
} else {
$NEW_PWM = (($HIGHEST_TEMP-$TEMP_LOW)*$PWM_INCREMENTS)+$PWM_LOW;
$NEW_PERCENT_PWM = round(($NEW_PWM*100)/$PWM_HIGH);
}
# Change the fan speed as needed
if ($CURRENT_PWM != $NEW_PWM){
file_put_contents($PWM_CONTROLLER, $NEW_PWM);
sleep(5);
$NEW_RPM = preg_replace("/\s*/", "", file_get_contents($PWM_FAN));
$NEW_PERCENT_PWM = round(($NEW_PWM*100)/$PWM_HIGH);
$NEW_OUTPUT = "${NEW_PWM} (${NEW_PERCENT_PWM}% @ ${NEW_RPM}rpm)";
syslog(LOG_INFO, "highest disk temp is ${HIGHEST_TEMP}ºC, adjusting fan PWM from: $CURRENT_OUTPUT to: $NEW_OUTPUT");
}
# PRINT VARIABLES DEBUG
$defined_vars = get_defined_vars();
foreach (array("_GET","_POST","_COOKIE","_FILES","argv","argc","_SERVER") as $i) {unset($defined_vars[$i]);}
debug("\nDECLARED VARIABLES:\n".print_r($defined_vars, true));
unset($defined_vars);
$time1 = time();
$MD5 = shell_exec("md5sum $cfg_file|awk '{print $1}'");
$MD5 = md5_file($cfg_file);
for ($i=0; $i < $INTERVAL*6 ; $i++) {
sleep(10);
if (md5_file($cfg_file) != $MD5){syslog(LOG_INFO, "config file updated, reloading."); $i=10000;}
}
debug("Sleep ".(time()-$time1)." seconds.");
###### END OF SECTION ######
};
};
?>

View File

@ -0,0 +1,23 @@
#!/bin/bash
DAEMON="ipmievd: "
LASTMSG="Waiting for events"
exec /usr/bin/tail -n 0 -F /var/log/syslog | \
while read LINE;
do
# do not notify on ipmievd start
[[ "$LINE" == *"Reading sensors"* ]] && continue
[[ "$LINE" == *"Waiting for events"* ]] && continue
# do not notify on remote communication failure
[[ "$LINE" == *"Get SEL Info command failed"* ]] && continue
# only notify when ipmievd: is in the system log
[[ "$LINE" != *$DAEMON* ]] && continue
MESSAGE=$(echo "$LINE" | sed -e 's/.*$DAEMON//')
sleep 1 |
exec /usr/local/emhttp/webGui/scripts/notify -s "Notice [$HOSTNAME]" -d "$MESSAGE" -i "warning" && continue 2
done