Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. if __name__ == "__main__":
  2. from subprocess import check_output
  3. status = 4
  4. textout = "mysql: "
  5. active = check_output(["systemctl", "is-active", "mysql.service"]).rstrip()
  6. enabled = check_output(["systemctl", "is-enabled", "mysql.service"]).rstrip()
  7. if active == "active":
  8. textout += "active"
  9. if enabled == "enabled":
  10. textout += " and enabled"
  11. status = 0
  12. elif enabled == "disabled":
  13. textout += " BUT DISABLED"
  14. status = 2
  15. else:
  16. textout += " but unclear if enabled"
  17. status = 3
  18. elif active == "inactive":
  19. textout += "INACTIVE"
  20. if enabled == "enabled":
  21. textout += " but enabled"
  22. status = 1
  23. elif enabled == "disabled":
  24. textout += " AND DISABLED"
  25. status = 2
  26. else:
  27. textout += " but unclear if enabled"
  28. status = 2
  29. else:
  30. textout += "UNCLEAR IF ACTIVE"
  31. if enabled == "enabled":
  32. textout += " but enabled"
  33. status = 3
  34. elif enabled == "disabled":
  35. textout += " AND DISABLED"
  36. status = 2
  37. else:
  38. textout += " AND UNCLEAR IF ENABLED"
  39. status = 2
  40. print textout
  41. import sys
  42. sys.exit(status)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement