So, I have been drawing the ASCII file structure tree by hand lately… and that is dumb and time consuming. After digging around, I found a great way to do so.
First, if you don’t have Homebrew, install it first.
Run the following command to install the
brew install tree
Now, you can run the following command to create a tree:-
│ ├── lib
│ └── web.xml
I have APC Smart-UPS SMT1500. It contains a SmartSlot that accepts a network management card that allows the UPS to be connected to the switch (or router) instead of plugging the USB cable from the UPS to a computer. That said, I also have APC AP9630 UPS Network Management Card 2.
My goal is to configure my UPS to shutdown all my Macs (MacBook Pros and Mac Mini) during a power failure.
This is how I do it…
- After installing the network management card to the UPS, plug the network cable from the network management card to the switch (or router). An IP address will be automatically assigned to the card. Let’s just say, the resolved IP address is 192.168.0.100.
- Plug the Mac’s power plug to the UPS.
- Download Apcupsd and install it on your Mac.
- At the end of the installation, you will see
/etc/apcupsd/apcupsd.conf file on your screen. Do not click on the “restart” button yet.
- In that file, change the following lines:-
DEVICE value is
IP:PORT:VENDOR:COMMUNITY, all you need is to change the IP address and leave the rest of to be the same.
Based on the documentation,
TIMEOUT work in conjunction… basically, the first that occurs will cause the initiation of a shutdown. So, since I want my Mac to shutdown right away during a power failure, I set my
BATTERYLEVEL at 95%. When the UPS’s battery level drops before that mark, it will initiate the shutdown process.
- Save this file and reboot your machine.
- After rebooting the machine, to ensure the Apcupsd daemon is getting signals from the UPS, run this command:-
You should see your Apcupsd configuration and the UPS information, like this:-
APC : 001,050,1249
DATE : 2013-09-24 20:09:37 -0500
HOSTNAME : goliath
VERSION : 3.14.10 (13 September 2011) darwin
UPSNAME : APCUPS
CABLE : Ethernet Link
DRIVER : SNMP UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2013-09-24 18:29:28 -0500
MODEL : Smart-UPS 1500
STATUS : TRIM ONLINE
LINEV : 125.0 Volts
LOADPCT : 0.0 Percent Load Capacity
BCHARGE : 100.0 Percent
TIMELEFT : 335.0 Minutes
MBATTCHG : 95 Percent
MINTIMEL : 150 Minutes
MAXTIME : 0 Seconds
MAXLINEV : 126.0 Volts
MINLINEV : 125.0 Volts
OUTPUTV : 110.0 Volts
SENSE : High
DWAKE : 000 Seconds
DSHUTD : 000 Seconds
DLOWBATT : 10 Minutes
LOTRANS : 106.0 Volts
HITRANS : 127.0 Volts
RETPCT : -1073742588.0 Percent
ITEMP : 28.0 C Internal
ALARMDEL : No alarm
BATTV : 27.0 Volts
LINEFREQ : 60.0 Hz
LASTXFER : Line voltage notch or spike
NUMXFERS : 0
TONBATT : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : OK
STESTI : OFF
STATFLAG : 0x0700000A Status Flag
MANDATE : 06/17/2013
SERIALNO : AS1325121222
BATTDATE : 06/17/2013
NOMOUTV : 120 Volts
NOMBATTV : 3221224708.0 Volts
HUMIDITY : 3221224708.0 Percent
AMBTEMP : 3221224708.0 C
EXTBATTS : -1073742588
BADBATTS : -1073742588
FIRMWARE : UPS 08.3 / MCU 14.0
END APC : 2013-09-24 20:10:00 -0500
- Finally, pull the UPS plug from the wall to simulate a power failure. Once the battery level drops below your threshold, your machine will begin to shutdown in a minute or so.
If you tweak the Apcupsd configuration in
/etc/apcupsd/apcupsd.conf file, you will need to restart Apcupsd daemon:-
sudo /Library/StartupItems/apcupsd/apcupsd restart