Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import json
  4. import httplib
  5. from socket import gethostname;
  6. import sys
  7. import os
  8. import commands
  9. import string
  10.  
  11. host = gethostname()
  12. host = host[0:host.find(".")]
  13.  
  14. checkkernlog = commands.getstatusoutput("cat /var/log/syslog |grep -c 'ASIC hang happened'")
  15. #print checkkernlog
  16. hasBadGpu = int(checkkernlog[1])
  17.  
  18. if hasBadGpu > 0:
  19.     container = {}
  20.     container['host'] = host
  21.     container['error'] = str(hasBadGpu) + " gpu(s) froze."
  22.  
  23.     con = httplib.HTTPConnection("myhostname.com", 80)
  24.     con.request("GET", "/reporting/error.php", json.dumps(container))
  25.     response = con.getresponse().read()
  26.     print response
  27.    
  28.     # reboot system
  29.     commands.getstatusoutput("/sbin/shutdown -r now")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement