Nagios Plugins
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

check_z_heat_vlv_follow 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/python3
  2. #
  3. import argparse
  4. import nagios
  5. import time
  6. from z_server import config
  7. from z_server import tcp_socket
  8. from z_server.z_protocol import server as client_prot
  9. from z_server.z_protocol import DID_FOLLOWS_HEATING_SETPOINT, DID_BATTERY_LEVEL, DID_HEARTBEAT
  10. from z_server import socket_protocol
  11. import sys
  12. if __name__ == '__main__':
  13. parser = argparse.ArgumentParser(
  14. prog='ProgramName',
  15. description='What the program does',
  16. epilog='Text at the bottom of help')
  17. parser.add_argument('-s', '--stg', required=True)
  18. parser.add_argument('-l', '--loc', required=True)
  19. parser.add_argument('-r', '--roo', required=True)
  20. args = parser.parse_args()
  21. #
  22. c = tcp_socket.tcp_client_stp('127.0.0.1', config.SOCK_PROT_PORT)
  23. sp = client_prot(c, channel_name='example_client')
  24. #
  25. data = {
  26. "stg": args.stg,
  27. "loc": args.loc,
  28. "roo": args.roo,
  29. "fun": "FUN_HEA" # <-- Const, because script is for heat_vlv only
  30. }
  31. #
  32. if sys.argv[0].endswith('check_z_heat_vlv_heartbeat'):
  33. sp.send(socket_protocol.SID_READ_REQUEST, DID_HEARTBEAT, data)
  34. sp_data = sp.receive(socket_protocol.SID_READ_RESPONSE, DID_HEARTBEAT).get_data()
  35. elif sys.argv[0].endswith('check_z_heat_vlv_follow'):
  36. sp.send(socket_protocol.SID_READ_REQUEST, DID_FOLLOWS_HEATING_SETPOINT, data)
  37. sp_data = sp.receive(socket_protocol.SID_READ_RESPONSE, DID_FOLLOWS_HEATING_SETPOINT).get_data()
  38. elif sys.argv[0].endswith('check_z_heat_vlv_battery'):
  39. sp.send(socket_protocol.SID_READ_REQUEST, DID_BATTERY_LEVEL, data)
  40. sp_data = sp.receive(socket_protocol.SID_READ_RESPONSE, DID_BATTERY_LEVEL).get_data()
  41. else:
  42. sys.stderr.write('No action for command called "%s"\n' % sys.argv[0])
  43. sys.exit(100)
  44. nagios.Nagios().exit(**sp_data)