Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import time
- from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
- lcd = Adafruit_CharLCDPlate()
- while 1:
- lcd.clear()
- p = subprocess.Popen("ping -c 1 64.114.87.90", shell=True, stdout=subprocess.PIPE)
- out, err = p.communicate()
- if not err:
- r = out.split('\n') [4].split(', ')[2]
- if r == '0% packet loss':
- msg = "NAS Online\n"
- else:
- msg = 'NAS Offline\n'
- p = subprocess.Popen("df -h | awk 'NR==9{print $5}'", shell=True, stdout=subprocess.PIPE)
- out, err = p.communicate()
- if not err:
- msg += out.strip() + " space used"
- lcd.message(msg)
- lcd.backlight(lcd.TEAL)
- n = time.time()
- while time.time() - n < 60:
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement