Ad Widget

Collapse

python alert script not work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sysadm01
    Junior Member
    • Sep 2015
    • 19

    #1

    python alert script not work

    Script is work in terminal.
    But zabbix alert is not work so I Attachement log

    I using below script on zabbix. but didn't send alert.

    ===============python script
    #!/bin/env python

    import asyncio

    import hangups

    import sys

    CONVERSATION_ID = sys.argv[1]
    TEMPTEXT = sys.argv[2]
    MESSAGE = sys.argv[3]

    REFRESH_TOKEN_PATH = '/root/.cache/hangups/refresh_token.txt'


    @asyncio.coroutine
    def send_message(client):
    request = hangups.hangouts_pb2.SendChatMessageRequest(
    request_header=client.get_request_header(),
    event_request_header=hangups.hangouts_pb2.EventReq uestHeader(
    conversation_id=hangups.hangouts_pb2.ConversationI d(
    id=CONVERSATION_ID
    ),
    client_generated_id=client.get_client_generated_id (),
    ),
    message_content=hangups.hangouts_pb2.MessageConten t(
    segment=[hangups.ChatMessageSegment(MESSAGE).serialize()],
    ),
    )
    yield from client.send_chat_message(request)
    yield from client.disconnect()


    def main():
    cookies = hangups.auth.get_auth_stdin(REFRESH_TOKEN_PATH)
    client = hangups.Client(cookies)
    client.on_connect.add_observer(lambda: asyncio.async(send_message(client)))
    loop = asyncio.get_event_loop()
    loop.run_until_complete(client.connect())


    if __name__ == '__main__':
    main()

    ============================this is error log-------
    15800:20160202:094104.585 In zbx_popen() command:'/usr/lib/zabbix/alertscripts/send_hangout.py 'UgzbOh1a7vVgbiT2zJh4AaABAag' '' '/home001/mirror is unmounted''
    15800:20160202:094104.585 End of zbx_popen():7
    24635:20160202:094104.585 zbx_popen(): executing script
    15800:20160202:094104.633 In zbx_waitpid()
    15800:20160202:094104.633 zbx_waitpid() exited, status:1
    15800:20160202:094104.633 End of zbx_waitpid():24635
    15800:20160202:094104.633 send_hangout.py output:
    File "/usr/lib/zabbix/alertscripts/send_hangout.py", line 30
    yield from client.send_chat_message(request)
    ^
    SyntaxError: invalid syntax
    Last edited by sysadm01; 02-02-2016, 05:09.
  • Atsushi
    Senior Member
    • Aug 2013
    • 2028

    #2
    Do not install multiple versions of Python?
    Please try to specify the Python of the path you want to use in the first line of the script.

    ex.
    Code:
    #!/usr/local/bin/python

    Comment

    • sysadm01
      Junior Member
      • Sep 2015
      • 19

      #3
      Script is work in terminal, But zabbix alert is not work

      Originally posted by Atsushi
      Do not install multiple versions of Python?
      Please try to specify the Python of the path you want to use in the first line of the script.

      ex.
      Code:
      #!/usr/local/bin/python
      Script is work in terminal.
      But zabbix alert is not work so I Attachement log

      Comment

      • Atsushi
        Senior Member
        • Aug 2013
        • 2028

        #4
        Which user using did you run in the terminal?

        Do not you have different the environment variables for that user and zabbix user?
        Please especially check the settings of the path.

        Comment

        Working...