UPS Disconnection Script

Status
Not open for further replies.

John Regan

Cadet
Joined
Sep 7, 2013
Messages
8
Hi,

Believe this is my first post and I just thought I would add in a small script I wrote which seems to fix my UPS disconnecting at very random intervals.

I have a BlueWalker PW UPS VI1000 LCD 1000VA UPS which I dont believe is in the supported list but there were other BlueWalker UPS's but could not get hold of those so went for this one. At very random intervals (can work for days) it gets disconnected and I searched the forums and saw similar posts but never any real solution.

After some random playing I wrote a small script which basically checks the UPS is alive and if not then powers off the relevant USB port and resets it and powers it on. I have been running this for months now as a cron job every couple of minutes and it restores the connection every time.

I have not seen these commands use elsewhere and they are only tested on my motherboard (ugen0.X - motherboard specific?) and am just posting to see if this can help others or spark a discussion from those who know more as to what the problem can be.

USE AT YOUR OWN RISK...

PS - I am not a coder so maybe more ellegant ways to do this :smile:

==========================================================

#!/bin/bash

if [ -f /var/db/nut/blazer_usb-ups.pid ];
then
echo "Looks good UPS is Alive!!!"
else
USBPORTNUM="$(usbconfig list | grep INNO | cut -c 7)"
USBPORT="ugen0."$USBPORTNUM
usbconfig -d $USBPORT list
service nut stop
usbconfig -d $USBPORT power_off
sleep 30
usbconfig -d $USBPORT reset
sleep 30
usbconfig -d $USBPORT power_on
sleep 30
usbconfig -d $USBPORT list
sleep 10
service nut start
fi

============================================================
 
Status
Not open for further replies.
Top