Is it possible to have an apk for a nut client/server?
This could be very beneficial to the community.
Regards!
Yes this is right! Thanks docmarius!+1
@macgaiver: http://www.networkupstools.org/
I had put this in discussion some time time ago:
http://forum.mikrotik.com/viewtopic.php?f=1&t=48762
But it seems that everyone understands to implement the NUT server, not the client. But you are right, nut may offer also snmp services through the nut-snmpagent wrapper.
Again, it is about the nut client. The possibility to connect to another system running the nut daemon to interrogate the UPS status and take decisions based on that data. No one said to implement nut on the router.
@jarda: having a network attached UPS starts with the false assumption that you have one.
And while supporting the APC protocol is nice, most of the UPSes out there are not APC compatible.
E.g. the blazer protocol is used by a lot of manufacturers (Ablerex, ActivePower, ARTronic, ATEK, some Belkins, Borri, Cover, Dynamix, Effekta, Ever, Fenton, GE Digital Energy, Gtec, Infosec, Ippon, Kolff, Krauler, Maxxtro, Microline, Mustek, Plexus, Powerex, Powerguard, PowerWalker, Soyntec, Sven, some Sweex, Sysgration, Tecnoware, Trust, Unitek, some Upsonic and a lot of others).
This protocol is of course not supported by MT, as if APC is the only "real" UPS manufacturer. And here comes nut into play, running on another system and offering a uniform network approach for EVERY UPS.
But for this, a network client on the router is needed.
And this is what xcom has asked.
It all depends how your ups is configured along with NUT. In my case. I have my system configured via nut to shutdown when the ups reaches critical stages.How do you start remotely your mikrotik devices when the outage is gone if you shut down them before?
No solution is perfect.This is smart. Thanks for answer. But doesn't it just prolonging the outage time? And what if not all devices went down correctly? Do you still recycle the power? Nut client could be useful in some cases, I agree. But I still would rather see mikrotik focusing on errors corrections then implementing such marginal features.
model=.1.3.6.1.2.1.33.1.1.2
version=.1.3.6.1.2.1.33.1.1.3
status=.1.3.6.1.2.1.33.1.2.1
remaining=.1.3.6.1.2.1.33.1.2.3
battery-charge=.1.3.6.1.2.1.33.1.2.4
voltage=.1.3.6.1.2.1.33.1.2.5
temperature=.1.3.6.1.2.1.33.1.2.7
model=.1.3.6.1.2.1.33.1.1.2
version=.1.3.6.1.2.1.33.1.1.3
status=.1.3.6.1.2.1.33.1.2.1
remaining=.1.3.6.1.2.1.33.1.2.3
battery-charge=.1.3.6.1.2.1.33.1.2.4
voltage=.1.3.6.1.2.1.33.1.2.5
temperature=.1.3.6.1.2.1.33.1.2.7
replace-battery=.1.3.6.1.2.1.33.1.6.2.1.2.1
low-battery=.1.3.6.1.2.1.33.1.6.2.1.2.2
overload=.1.3.6.1.2.1.33.1.6.2.1.2.3
line-voltage=.1.3.6.1.2.1.33.1.3.3.1.3
frequency=.1.3.6.1.2.1.33.1.3.3.1.2
output-voltage=.1.3.6.1.2.1.33.1.4.4.1.2
load=.1.3.6.1.2.1.33.1.4.4.1.5
snmpwalk -v 1 -c public 10.0.0.1 .1.3.6.1.2.1.33.1
iso.3.6.1.2.1.33.1.1.2.0 = STRING: "Smart-UPS SC620 "
iso.3.6.1.2.1.33.1.1.3.0 = STRING: "726.1.I"
iso.3.6.1.2.1.33.1.2.1.0 = INTEGER: 2
iso.3.6.1.2.1.33.1.2.3.0 = INTEGER: 660
iso.3.6.1.2.1.33.1.2.4.0 = INTEGER: 100
iso.3.6.1.2.1.33.1.2.5.0 = INTEGER: 13
iso.3.6.1.2.1.33.1.2.7.0 = INTEGER: 0
iso.3.6.1.2.1.33.1.3.2.0 = INTEGER: 1
iso.3.6.1.2.1.33.1.3.3.1.2.1 = INTEGER: 5000
iso.3.6.1.2.1.33.1.3.3.1.3.1 = INTEGER: 231
iso.3.6.1.2.1.33.1.4.3.0 = INTEGER: 1
iso.3.6.1.2.1.33.1.4.4.1.2.1 = INTEGER: 231
iso.3.6.1.2.1.33.1.4.4.1.5.1 = INTEGER: 58
iso.3.6.1.2.1.33.1.6.1.0 = Gauge32: 0
snmpget -v 1 -c public 10.0.0.1 .1.3.6.1.2.1.33.1.2.3
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: iso.3.6.1.2.1.33.1.2.3
snmpget -v 1 -c public 10.0.0.1 .1.3.6.1.2.1.33.1.2.3.0
iso.3.6.1.2.1.33.1.2.3.0 = INTEGER: 600
some folks i worked with - would go for anything "NUT"-labeled just "for fun", because name itselfNUT would be nice. My Eaton Power Systems all have NUT servers embedded.
However - the MikroTik guys have stated a few times that there is no problem with RouterOS losing power, it does not hurt them.
Then why did they put ANY ups support into the routers? Was it just for fun?NUT would be nice. My Eaton Power Systems all have NUT servers embedded.
However - the MikroTik guys have stated a few times that there is no problem with RouterOS losing power, it does not hurt them.
#!/bin/bash
# The result of the script execution is recorded in the mikrotik.log located in the /root directory.
LOG_FILE=/root/mikrotik.log
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>${LOG_FILE} 2>&1
data=$( date +"%Y-%m-%d %H:%M:%S" )
nutlog=/var/log/nut.log
if [ "`grep "Mikrotik" "$nutlog"`" ]; then
echo "$data -> Mikrotik router will go down."
echo "UPS is down!" | mail -s "UPS ALERT DOWN" admin@example.com -A /root/mikrotik.log
echo "UPS is down!" | mail -s "UPS ALERT DOWN" youremail@gmail.com -A /root/mikrotik.log
rm -f $nutlog
touch $nutlog
chown root:adm $nutlog
chmod 640 $nutlog
systemctl restart rsyslog
sshpass -f /root/creds ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o CheckHostIP=no -p 2244 nut@192.168.88.1 "/system shutdown; /y; /quit;"
exit
else
echo "$data -> Mikrotik router will remain powered on."
exit
fi
sudo apt install sshpass
*/2 * * * * root /root/mikrotik.sh
*/2 * * * * pi /home/pi/mikrotik.sh
:syslogtag,contains,"upsmon" /var/log/nut.log
:syslogtag,contains,"nut" /var/log/nut.log
:syslogtag,contains,"upssched" /var/log/nut.log
touch /var/log/nut.log
chown root:adm /var/log/nut.log
chmod 640 /var/log/nut.log
systemctl restart rsyslog
AT ONBATT * START-TIMER onbatt 300
AT ONLINE * CANCEL-TIMER onbatt online
AT ONBATT * START-TIMER earlyshutdown 180
AT ONLINE * CANCEL-TIMER earlyshutdown
AT LOWBATT * START-TIMER shutdowncritical 30
AT ONLINE * CANCEL-TIMER shutdowncritical
AT COMMBAD * START-TIMER commbad 30
AT COMMOK * CANCEL-TIMER commbad commok
AT REPLBATT * EXECUTE replacebatt
case $1 in
onbatt)
logger -t upssched-cmd "The UPS is on battery"
;;
online)
logger -t upssched-cmd "The UPS is back on power"
;;
commbad)
logger -t upssched-cmd "The server lost communication with UPS"
;;
commok)
logger -t upssched-cmd "The server re-establish communication with UPS"
;;
earlyshutdown)
logger -t upssched-cmd "UPS on battery too long, forced Mikrotik shutdown"
;;
shutdowncritical)
logger -t upssched-cmd "UPS on battery critical, forced shutdown"
/usr/sbin/upsmon -c fsd
;;
upsgone)
logger -t upssched-cmd "The UPS has been gone for awhile"
;;
replacebatt)
logger -t upssched-cmd "The UPS needs new battery"
;;
*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac
sudo -i
apt install ssmtp mailutils
nano /etc/ssmtp/ssmtp.conf
root=postmaster
mailhub=smtp.gmail.com:587
rewriteDomain=
hostname=yourhostname ##for example raspberrypi
UseSTARTTLS=YES
AuthUser=youremailaddress@gmail.com
AuthPass=google_mail_application_password
FromLineOverride=YES
nano emailnotify.sh
#!/bin/bash
sleep 60
IP=`hostname -i`
# Or you can comment the above and uncomment the below. In my case it presented the localhost IP address instead the IP from eth0 interface
# IP=`echo $(ifconfig eth0 | grep 'inet' | cut -d: -f2 | awk '{ print $2}')`
HOSTNAME=`hostname -f`
echo "$HOSTNAME online. IP address: $IP" > /root/email.txt
echo >> /root/email.txt
date >> /root/email.txt
mail -s "$HOSTNAME online" -r raspberrypi@localhost yourmail@example.com < /root/email.txt
mail -s "$HOSTNAME online" -r raspberrypi@localhost yourmail@gmail.com < /root/email.txt
rm -rf /root/email.txt
chmod +x emailnotify.sh
crontab -e
@reboot /root/emailnotify.sh
See my post how I performed it. Hope you will enjoy. Let me know of some video tutorial will be needed - I can make one to present how particular steps have been done.Haha I am the manual NUT in the family.
Is this another item to move to the raspberry pi?