Created
September 22, 2014 14:18
-
-
Save donalod/2e8df14f7d74b2c30f23 to your computer and use it in GitHub Desktop.
APCUPSLogsToGNUPlot
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
#!/usr/bin/env bash | |
grep -i "UPS:" ./u > u1 | |
statehigh="" | |
statelow="" | |
while read line; do | |
#echo "$line" | |
cleanline=$(echo $line|tr -s ' ') | |
#echo "$cleanline" | |
date=$(echo $cleanline| cut -f1 -d" ") | |
#echo $date | |
reversedate=$(echo $date|awk -F'/' '{print $3"-"$1"-"$2"_"}') | |
#echo $reversedate | |
time=$(echo $cleanline| cut -f2 -d" "| sed 's/:/\./g') | |
#echo $time | |
minustime=$(echo $time|awk -F'.' '{print $1 "." $2 "." $3-1 }') | |
#echo $minustime | |
state=$(echo $cleanline| cut -f3- -d" " | sed 's/UPS\: Compensating for a high input voltage\./5/;s/UPS\: No longer compensating for a high input voltage\./1/;s/UPS\: .*Battery.*/10/') | |
if [[ $state = "5" ]]; then | |
echo "${reversedate}${time} ${state}" | |
echo "${reversedate}${minustime} 1" | |
elif [[ $state = "1" ]]; then | |
echo "${reversedate}${time} ${state}" | |
echo "${reversedate}${minustime} 5" | |
else | |
echo "${reversedate}${time} ${state}" | |
fi | |
done < u1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment