NUTUPSMonitor: Difference between revisions

From DrewWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
1. Install network ups tool;
1. Install network ups tool;
<pre># yum install nut nut-client</pre>
<syntaxhighlight lang=bash>
# yum install nut nut-client
</syntaxhighlight>




2. Change mode from none -> standalone in /etc/ups/nut.conf
2. Change mode from none -> standalone in /etc/ups/nut.conf
<pre>
<syntaxhighlight lang=bash>
#MODE = none
#MODE = none
MODE = standalone
MODE = standalone
</pre>
</syntaxhighlight>




3. Add a UPS device in /etc/ups/ups.conf;
3. Add a UPS device in /etc/ups/ups.conf;
* Use auto for port if USB
* Use auto for port if USB
<pre>
<syntaxhighlight lang=bash>
[drewups]
[drewups]
         driver=usbhid-ups
         driver=usbhid-ups
         port = auto
         port = auto
         desc = "Office UPS"
         desc = "Office UPS"
</pre>
</syntaxhighlight>




4. Create a master to use to communicate with nut in /etc/ups/upsd.users;
4. Create a master to use to communicate with nut in /etc/ups/upsd.users;
<pre>[amasteruser]
<syntaxhighlight lang=bash>
[amasteruser]
       password = anawesomepassword
       password = anawesomepassword
       upsmon master</pre>
       upsmon master
</syntaxhighlight>




5. Create a user on the system to monitor;
5. Create a user on the system to monitor;
<pre> # useradd -s /sbin/nologin -g nut nutmon</pre>
<syntaxhighlight lang=bash>
# useradd -s /sbin/nologin -g nut nutmon
</syntaxhighlight>


Configure /etc/ups/upsmon.conf to monitor drewups as amasteruser, run a script when an action occurs, as well as alert;
Configure /etc/ups/upsmon.conf to monitor drewups as amasteruser, run a script when an action occurs, as well as alert;
<pre[root@drewserv ~]# grep -v ^$ /etc/ups/upsmon.conf | grep -v ^#
<syntaxhighlight lang=bash>
[root@drewserv ~]# grep -v ^$ /etc/ups/upsmon.conf | grep -v ^#
MINSUPPLIES 1
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
SHUTDOWNCMD "/sbin/shutdown -h +0"
Line 54: Line 61:
NOTIFYFLAG NOCOMM      SYSLOG+EXEC+WALL
NOTIFYFLAG NOCOMM      SYSLOG+EXEC+WALL
NOTIFYFLAG NOPARENT    SYSLOG+EXEC+WALL
NOTIFYFLAG NOPARENT    SYSLOG+EXEC+WALL
</pre>
</syntaxhighlight>




6. upspager.sh script;
6. upspager.sh script;
<pre>#!/bin/bash
<syntaxhighlight lang=bash>
echo "$*" | mail -s "drewups alert" [email protected]</pre>
#!/bin/bash
echo "$*" | mail -s "drewups alert" [email protected]
</syntaxhighlight>


7. Start nut at boot and fire it up;
7. Start nut at boot and fire it up;
<pre># chkconfig ups on
<syntaxhighlight lang=bash>
# /etc/init.d/ups start</pre>
# chkconfig ups on
# /etc/init.d/ups start
</syntaxhighlight>

Latest revision as of 01:34, 25 January 2018

1. Install network ups tool;

# yum install nut nut-client


2. Change mode from none -> standalone in /etc/ups/nut.conf

#MODE = none
MODE = standalone


3. Add a UPS device in /etc/ups/ups.conf;

  • Use auto for port if USB
[drewups]
        driver=usbhid-ups
        port = auto
        desc = "Office UPS"


4. Create a master to use to communicate with nut in /etc/ups/upsd.users;

[amasteruser]
       password = anawesomepassword
       upsmon master


5. Create a user on the system to monitor;

# useradd -s /sbin/nologin -g nut nutmon

Configure /etc/ups/upsmon.conf to monitor drewups as amasteruser, run a script when an action occurs, as well as alert;

[root@drewserv ~]# grep -v ^$ /etc/ups/upsmon.conf | grep -v ^#
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
RUN_AS_USER nutmon
MONITOR drewups 1 drew mypassword master
NOTIFYCMD /mnt/raid5/drew/backup/cron/upspager.sh
NOTIFYFLAG ONLINE       SYSLOG+EXEC+WALL
NOTIFYFLAG ONBATT       SYSLOG+EXEC+WALL
NOTIFYFLAG LOWBATT      SYSLOG+EXEC+WALL
NOTIFYFLAG FSD          SYSLOG+EXEC+WALL
NOTIFYFLAG COMMOK       SYSLOG+EXEC+WALL
NOTIFYFLAG COMMBAD      SYSLOG+EXEC+WALL
NOTIFYFLAG SHUTDOWN     SYSLOG+EXEC+WALL
NOTIFYFLAG REPLBATT     SYSLOG+EXEC+WALL
NOTIFYFLAG NOCOMM       SYSLOG+EXEC+WALL
NOTIFYFLAG NOPARENT     SYSLOG+EXEC+WALL


6. upspager.sh script;

#!/bin/bash
echo "$*" | mail -s "drewups alert" [email protected]

7. Start nut at boot and fire it up;

# chkconfig ups on
# /etc/init.d/ups start