Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Another way to manage your APC BACK-UPS HS 500

APC BACK-UPS HS 500 is a nice UPS with remote control via web. It has three sockets and you can set them on, off or reboot with web-interface.

So, I created a script to do it simply from the command line. You can use it in small networks for rebooting remote devices, or anything you can imagine, for example, making toasts :-)

How to config

Please install cURL before using(script works with web-interface of UPS):

sudo apt-get install curl

Change config in shell file - set IP of your device, login and encrypted password. You can encrypt password with webtool in this project.

UPS="192.168.0.81"
LOGIN="apc"
PASSWORD="55-55-55-55-55-55"

Also, you can add aliases to inputs to make work with script more comfortable

OUTPUT1="router"
OUTPUT2="server"
OUTPUT3="coffeemachine"

How to use

Run it with options:

# This is how you can call your device via shell:
./apc.sh [--status] [--output1=on,off,reboot] [--output2=on,off,reboot] [--output3=on,off,reboot]

# This will output statuses of outputs
./apc.sh --status

# This will reboot device out output1
./apc.sh --output1=reboot

# This will reboot server and turn on coffemachine(if you are using aliases)
./apc.sh --server=reboot --coffemachine=on

Be awared!

  • Use only letters in password, details on APC Discussion Forums
  • Use Back-UPS HS v1.0.0 Management Tool to assign IP address to your UPS. Unfortunately, it works with Windows 98-XP only, and i don't know if there are possible ways to assign IP via linux/macos/anything else

Another example of using

I use this script to switch routers of internet providers with not stable internet connection. This is how I do this:

# Site to ping
SITE="8.8.8.8"
# Count of packets to send
PINGCOUNT=10

# This will give count of received packets
RECEIVED=`ping -qc $PINGCOUNT $SITE | tail -n 2 | head -n 1 | awk '/[0-9]/ { print $4 }'`

# Now you devide what to do, if all/not all/zero packets received
if [[ -z $RECEIVED ]] || [[ $RECEIVED == "0" ]]; then {
	echo "No internet connection, switching";
	./apc.sh inet1=toggle inet2=toggle
}
elif [[ $RECEIVED -eq $PINGCOUNT ]]; then
	echo "Internet connection is stable.";
else
	echo "Internet connection is unstable, `echo "100*$RECEIVED/$PINGCOUNT" | bc`% packet loss.";
fi

Just add this script to cron and you will have good internet connection every day :-)

Copyright

This was developed at dontgiveafish.com by Anton Bagayev in 2011

About

Script to control remote APC UPS from command line

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages