Advertisement
hd1

hd1/pingmonitor

hd1
May 17th, 2015
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. #!/usr/bin/python
  2. import csv
  3. import datetime
  4. import logging
  5. import subprocess
  6. from subprocess import CalledProcessError
  7.  
  8. logging.basicConfig(level=logging.DEBUG)
  9. cmd = ['/usr/local/bin/fping', '8.8.8.8']
  10. while True:
  11.     try:
  12.         our_output = subprocess.check_output(cmd)
  13.     except CalledProcessError, e:
  14.         logging.debug(our_output)
  15.         with open('/Users/hdiwan/Desktop/network.csv', 'a') as fout:
  16.             writer = csv.writer(fout)
  17.             writer.writerow([datetime.datetime.now().strftime('%s')])
  18.             logging.warning('Internet is down')
  19.             raw_input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement