Last active
October 29, 2021 20:06
-
-
Save hurricup/8389cedba025e5f3aa498ef5a4ac2e83 to your computer and use it in GitHub Desktop.
Script for logging voltage using UPS device and Network UPS tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
previous_filename="none" | |
previous_voltage=-1 | |
while true | |
do | |
filename=$(date "+%Y-%m-%d") | |
upsinfo=$(upsc powercom 2>/dev/null |grep 'input.voltage:') | |
voltage=${upsinfo#input.voltage: } | |
voltage=${voltage%.0} | |
if [ $previous_filename != $filename ] || [ $voltage != $previous_voltage ] | |
then | |
date=$(date "+%H:%M:%S") | |
echo -e $date"\t"$voltage >> ~/powerlogs/$filename.csv | |
previous_filename=$filename | |
previous_voltage=$voltage | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires: