move nut plugin to separate repo
This commit is contained in:
parent
22c25d84ad
commit
db2b39db09
|
@ -1 +0,0 @@
|
||||||
MODE=standalone
|
|
|
@ -1,36 +0,0 @@
|
||||||
Menu="NUTsettings"
|
|
||||||
Title="NUT Details"
|
|
||||||
---
|
|
||||||
<?PHP
|
|
||||||
/* Copyright 2005-2016, Lime Technology
|
|
||||||
* Copyright 2015, Dan Landon.
|
|
||||||
* Copyright 2015, Bergware International.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<script>
|
|
||||||
function getNUTstatus() {
|
|
||||||
$.get('/plugins/nut/include/nut_status.php',{all:'true'},function(data) {
|
|
||||||
if (data) {
|
|
||||||
data = data.split(/\n/);
|
|
||||||
$('#nut_summary').html(data[0]);
|
|
||||||
$('#nut_status').html(data[1]);
|
|
||||||
}
|
|
||||||
<?if ($update):?>
|
|
||||||
setTimeout(getUPSstatus,<?=max(abs($display['refresh']),15000)?>);
|
|
||||||
<?endif;?>
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$(getNUTstatus);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<table class="tablesorter shift">
|
|
||||||
<thead><tr><th style="width:15%">Key</th><th style="width:35%">Value</th><th style="width:15%">Key</th><th style="width:35%">Value</th></tr></thead>
|
|
||||||
<tbody id="nut_status"><tr><td colspan="4" style="text-align:center"><i class="fa fa-spinner fa-spin icon"></i><em>Please wait, retrieving UPS information...</em></td></tr></tbody>
|
|
||||||
</table>
|
|
|
@ -1,10 +0,0 @@
|
||||||
SERVICE="disable"
|
|
||||||
DRIVER="custom"
|
|
||||||
SERIAL="none"
|
|
||||||
PORT="auto"
|
|
||||||
MODE="standalone"
|
|
||||||
SHUTDOWN="sec_timer"
|
|
||||||
BATTERYLEVEL="20"
|
|
||||||
SECONDS="240"
|
|
||||||
TIMEOUT="240"
|
|
||||||
UPSKILL="disable"
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB |
|
@ -1,71 +0,0 @@
|
||||||
<?PHP
|
|
||||||
/* Copyright 2017, Derek Macias.
|
|
||||||
* Copyright 2005-2016, Lime Technology
|
|
||||||
* Copyright 2015, Dan Landon.
|
|
||||||
* Copyright 2015, Bergware International.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<?
|
|
||||||
$state = [
|
|
||||||
'TRIM ONLINE' => 'Online (trim)',
|
|
||||||
'BOOST ONLINE' => 'Online (boost)',
|
|
||||||
'OL' => 'Online',
|
|
||||||
'ONBATT' => 'On battery',
|
|
||||||
'COMMLOST' => 'Lost communication',
|
|
||||||
'NOBATT' => 'No battery detected'
|
|
||||||
];
|
|
||||||
|
|
||||||
$red = "class='red-text'";
|
|
||||||
$green = "class='green-text'";
|
|
||||||
$orange = "class='orange-text'";
|
|
||||||
$status = array_fill(0,6,"<td>-</td>");
|
|
||||||
$all = $_GET['all']=='true';
|
|
||||||
$result = [];
|
|
||||||
|
|
||||||
if (file_exists('/var/run/upsmon.pid')) {
|
|
||||||
exec('/usr/bin/upsc ups 2>/dev/null', $rows);
|
|
||||||
for ($i=0; $i<count($rows); $i++) {
|
|
||||||
$row = array_map('trim', explode(':', $rows[$i], 2));
|
|
||||||
$key = $row[0];
|
|
||||||
$val = strtr($row[1], $state);
|
|
||||||
switch ($key) {
|
|
||||||
case 'ups.status':
|
|
||||||
$status[0] = $val ? (stripos($val,'online')===false ? "<td $red>$val</td>" : "<td $green>$val</td>") : "<td $orange>Refreshing...</td>";
|
|
||||||
break;
|
|
||||||
case 'battery.charge':
|
|
||||||
$status[1] = strtok($val,' ')<=10 ? "<td $red>$val</td>" : "<td $green>$val</td>";
|
|
||||||
break;
|
|
||||||
case 'battery.runtime':
|
|
||||||
$val = $val/60;
|
|
||||||
$status[2] = strtok($val,' ')<=5 ? "<td $red>$val</td>" : "<td $green>$val</td>";
|
|
||||||
break;
|
|
||||||
case 'ups.realpower.nominal':
|
|
||||||
$power = strtok($val,' ');
|
|
||||||
$status[3] = $power==0 ? "<td $red>$val</td>" : "<td $green>$val</td>";
|
|
||||||
break;
|
|
||||||
case 'ups.load':
|
|
||||||
$load = strtok($val,' ');
|
|
||||||
$status[5] = $load>=90 ? "<td $red>$val</td>" : "<td $green>$val</td>";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ($all) {
|
|
||||||
if ($i%2==0) $result[] = "<tr>";
|
|
||||||
$result[]= "<td><strong>$key</strong></td><td>$val</td>";
|
|
||||||
if ($i%2==1) $result[] = "</tr>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($all && count($rows)%2==1) $result[] = "<td></td><td></td></tr>";
|
|
||||||
if ($power && $load) $status[4] = ($load>=90 ? "<td $red>" : "<td $green>").intval($power*$load/100)." Watts</td>";
|
|
||||||
}
|
|
||||||
if ($all && !$rows) $result[] = "<tr><td colspan='4' style='text-align:center'>No information available</td></tr>";
|
|
||||||
|
|
||||||
echo "<tr>".implode('', $status)."</tr>";
|
|
||||||
if ($all) echo "\n".implode('', $result);
|
|
||||||
?>
|
|
|
@ -1,30 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# NUT NOTIFYCMD script macester macecapri@gmail.com
|
|
||||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
|
|
||||||
|
|
||||||
BATTERYLEVEL=20
|
|
||||||
|
|
||||||
trap "exit 0" SIGTERM
|
|
||||||
if [ "$NOTIFYTYPE" = "ONLINE" ]
|
|
||||||
then
|
|
||||||
echo $0: power restored | wall
|
|
||||||
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is no longer on battery" -i "normal"
|
|
||||||
# Cause all instances of this script to exit.
|
|
||||||
killall -s SIGTERM `basename $0`
|
|
||||||
fi
|
|
||||||
if [ "$NOTIFYTYPE" = "ONBATT" ]
|
|
||||||
then
|
|
||||||
echo $0: System shuts down when battery reaches $BATTERYLEVEL % | wall
|
|
||||||
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is on battery" -i "alert"
|
|
||||||
# Loop with one second interval to allow SIGTERM reception.
|
|
||||||
timer=$( /usr/bin/upsc ups|grep battery.charge:|awk '{print $2}' )
|
|
||||||
while [ $timer -gt $BATTERYLEVEL ]
|
|
||||||
do
|
|
||||||
sleep 1
|
|
||||||
timer=$( /usr/bin/upsc ups|grep battery.charge:|awk '{print $2}' )
|
|
||||||
done
|
|
||||||
echo $0: commencing shutdown | wall
|
|
||||||
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is shutting down unRAID" -i "alert"
|
|
||||||
upsmon -c fsd
|
|
||||||
fi
|
|
|
@ -1,30 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# NUT NOTIFYCMD script macester macecapri@gmail.com
|
|
||||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
|
|
||||||
|
|
||||||
SECONDS=240
|
|
||||||
|
|
||||||
trap "exit 0" SIGTERM
|
|
||||||
if [ "$NOTIFYTYPE" = "ONLINE" ]
|
|
||||||
then
|
|
||||||
echo $0: power restored | wall
|
|
||||||
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is no longer on battery" -i "normal"
|
|
||||||
# Cause all instances of this script to exit.
|
|
||||||
killall -s SIGTERM `basename $0`
|
|
||||||
fi
|
|
||||||
if [ "$NOTIFYTYPE" = "ONBATT" ]
|
|
||||||
then
|
|
||||||
echo $0: System shuts down when there is $SECONDS seconds left on the battery... | wall
|
|
||||||
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is on battery" -i "alert"
|
|
||||||
# Loop with one second interval to allow SIGTERM reception.
|
|
||||||
timer=$( /usr/bin/upsc ups|grep battery.runtime:|awk '{print $2}' )
|
|
||||||
while [ $timer -gt $SECONDS ]
|
|
||||||
do
|
|
||||||
sleep 1
|
|
||||||
timer=$( /usr/bin/upsc ups|grep battery.runtime:|awk '{print $2}' )
|
|
||||||
done
|
|
||||||
echo $0: commencing shutdown | wall
|
|
||||||
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is shutting down unRAID" -i "alert"
|
|
||||||
upsmon -c fsd
|
|
||||||
fi
|
|
|
@ -1,30 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# NUT NOTIFYCMD script macester macecapri@gmail.com
|
|
||||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
|
|
||||||
|
|
||||||
TIMEOUT=240
|
|
||||||
|
|
||||||
trap "exit 0" SIGTERM
|
|
||||||
if [ "$NOTIFYTYPE" = "ONLINE" ]
|
|
||||||
then
|
|
||||||
echo $0: power restored | wall
|
|
||||||
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is no longer on battery" -i "normal"
|
|
||||||
# Cause all instances of this script to exit.
|
|
||||||
killall -s SIGTERM `basename $0`
|
|
||||||
fi
|
|
||||||
if [ "$NOTIFYTYPE" = "ONBATT" ]
|
|
||||||
then
|
|
||||||
echo $0: $TIMEOUT seconds till system powers down... | wall
|
|
||||||
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is on battery" -i "alert"
|
|
||||||
# Loop with one second interval to allow SIGTERM reception.
|
|
||||||
let "n = $TIMEOUT"
|
|
||||||
while [ $n -ne 0 ]
|
|
||||||
do
|
|
||||||
sleep 1
|
|
||||||
let "n--"
|
|
||||||
done
|
|
||||||
echo $0: commencing shutdown | wall
|
|
||||||
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is shutting down unRAID" -i "alert"
|
|
||||||
upsmon -c fsd
|
|
||||||
fi
|
|
|
@ -1,14 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# This file is part of Network UPS Tools build for Slackware Linux.
|
|
||||||
# It should be sourced in /etc/rc.d/rc.0 as part of the poweroff sequence.
|
|
||||||
# Here, we signal the UPS to shut off the power.
|
|
||||||
# Reference: http://www.mail-archive.com/nut-upsdev@lists.alioth.debian.org/msg01099.html
|
|
||||||
# To be sourced after the genpowerd block and before the actual halt.
|
|
||||||
if [ -f /etc/ups/flag/killpower ]; then
|
|
||||||
echo "----------------------------------------Shutting down UPS power!"
|
|
||||||
/usr/sbin/upsdrvctl shutdown
|
|
||||||
sleep 40
|
|
||||||
echo "The UPS was not shut off properly, or the power came back in the"
|
|
||||||
echo "middle of the shutdown process, or USB communication failed."
|
|
||||||
sleep 10
|
|
||||||
fi
|
|
|
@ -1,11 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# This file is part of Network UPS Tools build for Slackware Linux.
|
|
||||||
# It should be sourced in /etc/rc.d/rc.0 as part of the poweroff sequence.
|
|
||||||
# Here, we restart udev so that the system is able to kill off the UPS inverter.
|
|
||||||
# Reference: http://www.mail-archive.com/nut-upsdev@lists.alioth.debian.org/msg01099.html
|
|
||||||
# To be sourced after the rootfs has been remounted read-only.
|
|
||||||
if [ -f /etc/ups/flag/killpower ]; then
|
|
||||||
echo "Restarting udev to be able to shut the UPS inverter off..."
|
|
||||||
/etc/rc.d/rc.udev start
|
|
||||||
sleep 10
|
|
||||||
fi
|
|
|
@ -1,4 +0,0 @@
|
||||||
if [ -f /usr/local/emhttp/plugins/nut/scripts/nut_kill_inverter ]; then
|
|
||||||
. /usr/local/emhttp/plugins/nut/scripts/nut_kill_inverter
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user