Created
July 2, 2018 14:42
-
-
Save jackinloadup/910e595f69dc09e5eba981c366580eff to your computer and use it in GitHub Desktop.
Script to get modem correctables and uncorrectables for i3blocks
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 | |
DIR="/var/run/vpnc/defaultroute" | |
# IF VPN is running | |
if [ -a $DIR ]; then | |
STATUS=$(ssh 10.16.1.251 curl -s http://192.168.100.1/cgi-bin/status) | |
else | |
STATUS=$(curl -s http://192.168.100.1/cgi-bin/status) | |
fi | |
if [ -z "$STATUS" ]; then | |
exit | |
fi | |
UN=$(echo "$STATUS" | pup 'form center:nth-of-type(1) tr:not(:nth-of-type(2)) td:nth-last-of-type(1) json{}' | jq -r '.[].text' | jq -s add) | |
C=$(echo "$STATUS" | pup 'form center:nth-of-type(1) tr:not(:nth-of-type(2)) td:nth-last-of-type(2) json{}' | jq -r '.[].text' | jq -s add) | |
# C = Correctables, UN = Uncorrectables | |
echo "C:$C U:$UN" | |
echo "C:$C U:$UN" | |
if [ "$UN" -gt 0 ]; then | |
echo "#FF0000" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment