Skip to content

Commit

Permalink
Initial Publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan committed Jun 9, 2017
0 parents commit 2b5f5ae
Show file tree
Hide file tree
Showing 10 changed files with 703 additions and 0 deletions.
32 changes: 32 additions & 0 deletions autostart/osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Setup upsmon launchd for autostart on OSX slave

# check if root/sudo
if [ "$EUID" -ne 0 ]
then echo "Must be run as root"
exit
fi

# create launchd plist for upsmon
cat << EOF > /Library/LaunchDaemons/org.networkupstools.upsmon.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>org.networkupstools.upsmon</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/upsmon</string>
<string>-D</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF

# load launchd plist
/bin/launchctl load /Library/LaunchDaemons/org.networkupstools.upsmon.plist
10 changes: 10 additions & 0 deletions master/nut.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Network UPS Tools: Master nut.conf
# ============================================================================
# Original: https://github.com/networkupstools/nut/blob/master/conf/nut.conf.sample
#
# The MODE determines which part of the NUT is to be started, and which
# configuration files must be modified.
#
# ============================================================================

MODE=netserver
101 changes: 101 additions & 0 deletions master/ups.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Network UPS Tools: Master ups.conf
# ============================================================================
# Original: https://github.com/networkupstools/nut/blob/master/conf/ups.conf.sample
#
# This is where you configure all the UPSs that this system will be
# monitoring directly. Serial, USB, and SNMP devices are supported.
#
# This file is used by upsdrvctl to start and stop the NUT UPS driver(s), and
# is also used by upsd to determine which drivers to monitor. The
# drivers themselves also read this file for configuration directives.
#
#
# The general form is:
#
# [upsname]
# driver=<drivername>
# port=<portname>
# sdorder=<number>
# desc="<UPS description>"
#
# The section header ([upsname]) can be just about anything as long as
# it is a single word inside brackets; upsd uses this to uniquely
# identify a UPS on this system.
#
# driver: REQUIRED. Specify the program to run to talk to this UPS.
# apcsmart, bestups, and sec are some examples.
# See http://networkupstools.org/stable-hcl.html
#
# port: REQUIRED. The serial port where your UPS is connected.
# /dev/ttyS0 is usually the first port on Linux boxes, for example.
# When using an USB-managed UPS, use auto.
# When using a SNMP-managed UPS, use the UPS IP address.
#
# sdorder: optional. When you have multiple UPSes on your system, you
# usually need to turn them off in a certain order. upsdrvctl
# shuts down all the 0s, then the 1s, 2s, and so on. To exclude
# a UPS from the shutdown sequence, set this to -1. Default is 0.
#
# To find out if your driver supports any extra settings, start it with
# the -h option and/or read the driver's documentation.
# ============================================================================

[UPS-ES-03]
driver = snmp-ups
port = 10.30.1.212
community = public
snmp_version = v1
desc = "Model: Tripplite SU3000RTXL3U; Location: ES server room"

[UPS-ES-04]
driver = usbhid-ups
port = auto
desc = "Model: APC SMX750; Location: ES server room (GCI)"
serial = AS1339219759

[UPS-ES-05]
driver = usbhid-ups
port = auto
desc = "Model: Tripplite SU3000RTXL3U; Location: ES server room"
serial = 2351LLCPS719400169

[UPS-ES-06]
driver = usbhid-ups
port = auto
desc = "Model: Tripplite SU3000RTXL3U; Location: ES server room"
serial = 2351LLCPS719400172

[UPS-ES-07]
driver = snmp-ups
port = 10.30.1.211
community = public
snmp_version = v1
desc = "Model: Tripplite SU3000RTXL3U; Location: ES server room"

[UPS-HS-01]
driver = snmp-ups
port = 10.30.1.213
community = public
snmp_version = v1
desc = "Model: Tripplite SU3000RTXL2U; Location: HS server room"

[UPS-HS-02]
driver = snmp-ups
port = 10.30.1.214
community = public
snmp_version = v1
desc = "Model: Tripplite SU3000RTXL2U; Location: HS server room"

[UPS-HS-03]
driver = snmp-ups
port = 10.30.1.215
community = public
snmp_version = v1
desc = "Model: Tripplite SU3000RTXL2U; Location: HS server room"

[UPS-DO-03]
driver = snmp-ups
port = 10.30.1.216
community = public
snmp_version = v1
desc = "Model: Tripplite SU3000RTXL2U; Location: DO wiring rack"
16 changes: 16 additions & 0 deletions master/upsd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Network UPS Tools: Master upsd.conf
# ============================================================================
# Original: https://github.com/networkupstools/nut/blob/master/conf/upsd.conf.sample
#
# This file contains access control data.
#
# You may specify each interface IP address or name that you want upsd to
# listen on for connections, optionally with a port number.
#
# You may need this if you have multiple interfaces on your machine and
# you don't want upsd to listen to all interfaces (for instance on a
# firewall, you may not want to listen to the external interface).
# ============================================================================

LISTEN 0.0.0.0

40 changes: 40 additions & 0 deletions master/upsd.users
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Network UPS Tools: Master upsd.users
# ============================================================================
# Original: https://github.com/networkupstools/nut/blob/master/conf/upsd.users.sample
#
# This file sets the permissions for upsd - the UPS network daemon.
# Users are defined here, are given passwords, and their privileges are
# controlled here too.
#
# Each user gets a section. To start a section, put the username in
# brackets on a line by itself. To set something for that user, specify
# it under that section heading. The username is case-sensitive, so
# admin and AdMiN are two different users.
#
# The general form is:
#
# [<username>]
# password = <password>
# actions = <action>
# instcmds = <commands>
#
# password: The user's password. This is case-sensitive.
#
# actions: Let the user do certain things with upsd. Valid actions are:
# SET - change the value of certain variables in the UPS
# FSD - set the "forced shutdown" flag in the UPS
#
# instcmds: Let the user initiate specific instant commands. Use "ALL"
# to grant all commands automatically. There are many possible
# commands, so use 'upscmd -l' to see what your hardware supports.
# ============================================================================

[upsmaster]
password = <masterpassword>
actions = SET
instcmds = ALL
upsmon master

[upsslave]
password = <slavepassword>
upsmon slave
182 changes: 182 additions & 0 deletions master/upsmon.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Network UPS Tools: Master upsmon.conf
# ============================================================================
# Original: https://github.com/networkupstools/nut/blob/master/conf/upsmon.conf.sample.in
# ============================================================================

# By default, upsmon splits into two processes. One stays as root and
# waits to run the SHUTDOWNCMD. The other one switches to another userid
# and does everything else.

RUN_AS_USER root

# --------------------------------------------------------------------------

# List systems you want to monitor. Not all of these may supply power
# to the system running upsmon, but if you want to watch it, it has to
# be in this section.
#
# The general form is:
# MONITOR <system> <powervalue> <username> <password> "master"/"slave""
#
# system: UPS identifier in the form <upsname>@<hostname>[:<port>]
# The UPS names like "ups01" are set in your ups.conf in [brackets]
# which identify a section for a particular driver.
#
# powervalue: an integer - the number of power supplies that this UPS
# feeds on this system. Most personal computers only have one power supply,
# so this value is normally set to 1, while most modern servers have at least
# two. You can also set this to 0 for a system that doesn't take any power
# from the MONITORed supply, which you still want to monitor. Use 0 when you
# want to hear about changes for a given UPS without shutting.
#
# username and password: must match an entry in that system's
# upsd.users.
#
# master: means this system will shutdown last, allowing the slaves
# time to shutdown first.
#
# slave: means this system shuts down immediately when power goes critical.

MONITOR UPS-ES-07@localhost 0 upsmaster <masterpassword> master

# --------------------------------------------------------------------------

# Give the number of power supplies that must be receiving power to keep
# this system running. Most systems have one power supply, so you would
# put "1" in this field. Server type systems usually have more, and can run with
# a few missing. The HP NetServer LH4 can run with 2 out of 4, for example,
# so you'd set that to 2.

MINSUPPLIES 1

# --------------------------------------------------------------------------

# upsmon runs this command when the system needs to be brought down.

SHUTDOWNCMD "/sbin/shutdown -h +0"

# --------------------------------------------------------------------------

# upsmon calls this to send messages when things happen
# This command is called with the full text of the message as one argument.
# The environment string NOTIFYTYPE will contain the type string of
# whatever caused this event to happen.
# Note that this is only called for NOTIFY events that have EXEC set with
# NOTIFYFLAG. See NOTIFYFLAG below for more details.
# Making this some sort of shell script might not be a bad idea. For more
# information and ideas, see docs/scheduling.txt

NOTIFYCMD "/etc/nut/notifycmd"

# --------------------------------------------------------------------------

# Polling frequency of monitors for normal activities, measured in seconds.
# for a local unit 1-2 second is fine, for network 5-10 should be ok.

POLLFREQ 10

# --------------------------------------------------------------------------

# Polling frequency of monitors while UPS on battery, measured in seconds.

POLLFREQALERT 5

# --------------------------------------------------------------------------

# How long upsmon will wait before giving up on another upsmon.
# The master upsmon process uses this number when waiting for slaves to
# disconnect once it has set the forced shutdown (FSD) flag. If they
# don't disconnect after this many seconds, it goes on without them.
# A slave upsmon processes will wait up to this interval for the
# master upsmon to set FSD when a UPS they are monitoring goes critical.
# If the master doesn't do its job, the slaves will shut down anyway.

HOSTSYNC 15

# --------------------------------------------------------------------------

# Interval to wait before declaring a stale ups "dead"
# A dead UPS that was last known to be on battery is assumed to have gone
# to a low battery condition. This may force a shutdown if it is providing
# a critical amount of power to your system.
#
# DEADTIME should be a multiple of POLLFREQ and POLLFREQALERT.
# Otherwise you'll have "dead" UPSes simply because upsmon isn't polling
# them quickly enough. Rule of thumb: take the larger of the two
# POLLFREQ values, and multiply by 3.

DEADTIME 30

# --------------------------------------------------------------------------

# Flag file for forcing UPS shutdown on the master system
# upsmon will create a file with this name in master mode when it's time
# to shut down the load. You should check for this file's existence in
# your shutdown scripts and run 'upsdrvctl shutdown' if it exists.

POWERDOWNFLAG /etc/killpower

# --------------------------------------------------------------------------

# Messages sent by upsmon when certain events occur
# format of the massages that the monitor can send to wall, syslog or script
# Note that %s is replaced with the identifier of the UPS in question.

NOTIFYMSG ONLINE "UPS %s on line power"
NOTIFYMSG ONBATT "UPS %s on battery"
NOTIFYMSG LOWBATT "UPS %s battery is low"
NOTIFYMSG FSD "UPS %s: forced shutdown in progress"
NOTIFYMSG COMMOK "Communications with UPS %s established"
NOTIFYMSG COMMBAD "Communications with UPS %s lost"
NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding"
NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced"
NOTIFYMSG NOCOMM "UPS %s is unavailable"
NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible"

# --------------------------------------------------------------------------

# Behavior of upsmon when NOTIFY events occur
# SYSLOG - Write the message in the syslog
# WALL - Write the message to all users on the system
# EXEC - Execute NOTIFYCMD (see above) with the message
# IGNORE - Don't do anything. Wont use any other flags on the same line.

NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL

# --------------------------------------------------------------------------

# upsmon will normally warn you about a battery that needs to be replaced
# every 43200 seconds, which is 12 hours. It does this by triggering a
# NOTIFY_REPLBATT which is then handled by the usual notify structure
# defined above.

RBWARNTIME 43200

# --------------------------------------------------------------------------

# upsmon will let you know through the usual notify system defined above if it
# can't talk to any of the UPS entries that are defined in this file. It will
# trigger a NOTIFY_NOCOMM by default every 300 seconds unless you
# change the interval with this directive.

NOCOMMWARNTIME 600

# --------------------------------------------------------------------------

# last delay interval before shutting down the system
# On a master, upsmon will wait this long after sending the NOTIFY_SHUTDOWN
# before executing your SHUTDOWNCMD. If you need to do something in between
# those events, increase this number.
# Note: If FINALDELAY on the slave is greater than HOSTSYNC on the master,
# the master will give up waiting for the slave to disconnect.

FINALDELAY 5
Loading

0 comments on commit 2b5f5ae

Please sign in to comment.