Advertisement
Guest User

asdasda

a guest
Nov 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #!/usr/bin/python3.4
  2. import mysql.connector
  3. import time
  4. import subprocess
  5. import getopt
  6. import sys
  7.  
  8.  
  9. def main():
  10. try:
  11. opts, args = getopt.getopt(sys.argv[1:], "ho:l:v", ["help", "outfile=", "load="])
  12. except getopt.GetoptError as err:
  13. print (str(err))
  14. usage()
  15. sys.exit(2)
  16. outfile = None
  17. verbose = False
  18. for o, a in opts:
  19. if o == '-v':
  20. verbose = True
  21. elif o in ("-h", "--help"):
  22. usage()
  23. sys.exit()
  24. elif o in ("-o", "--outfile"):
  25. outfile = a
  26. elif o in ("-l", "--loadlimit"):
  27. loadlimit = a
  28. else:
  29. assert False, "bip boop error with args"
  30. print(outfile)
  31. print(loadlimit)
  32.  
  33. cnx = mysql.connector.connect(user='root', password='1234', host='localhost')
  34. cursor = cnx.cursor()
  35.  
  36. while True:
  37. cursor.execute("show full processlist")
  38. result=cursor.fetchall()
  39. print(result)
  40. subprocess.Popen("uptime")
  41. time.sleep(1);
  42.  
  43. cursor.close()
  44. cnx.close()
  45.  
  46. if __name__ == "__main__":
  47. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement