Ad Widget

Collapse

Sending updates to Twitter script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mjsr
    Junior Member
    • Feb 2011
    • 15

    #1

    Sending updates to Twitter script

    Hello,

    I've been trying to find an issue that seems like this one: http://www.zabbix.com/forum/showthread.php?t=20840

    The issue is not:
    • Who is executing the script (I've executed it as zabbix user; su - zabbix)
    • The permissions of the script (chmod a+x twitter.pl)
    • Whatever you can think...


    So, what do I got?

    I've created a Media Type called Twitter of type Script and Script name twitter.pl (the script's ownership is to the zabbix user and got the execute flag activated). Plus, that script is in the same path as configured in the AlertScriptsPath defined in the zabbix_server.conf file.

    I've created an User Group that has read only access to all Host Groups.
    Created then an user in that group called ScriptRunner. That user has a Media assigned. From the dropdown box it got Twitter assigned and the sendto field is twitter (it shoved that as first argument to the script as we can see below).

    Testing it!

    Under Audit (in Administration), selecting the Actions option on the right dropdown box I can see the action-type Twitter called, recipients twitter (as defined in the sendto field of the User's Media assignation).

    The Subject and Message are exactly as I want for further parsing in the Perl script (then to truncate the message for twitters max length at will).

    The Script!

    I'm printing out the arguments the script receives. It is called by zabbix (remember I said I've tested it with zabbix user?) and drops a line on the log.
    The script's argument is:
    Code:
    twitter hostname name of the trigger -- status
    It generates the following command (both lines are printed on the log file).

    Code:
    /home/zabbix/bin/ttytter.pl -status="hostname name of the trigger -- status (timestamp)"
    Note: the timestamp is merely to ensure the same tweet is not posted twice. That is not possible.

    ttytter.pl?

    Yea, it's a pretty nice command line Perl interface for twitter. It can be configured to use OAuth so you don't have the credentials lying around on a clear text script.

    So, what's really happening here? You seem to have it all alright

    The point is that if I execute the script with zabbix's user, on the command line. BAM! The tweet shows up.
    If zabbix does it, I get a new line in the log file but no twitter update. (?!?)

    Is it possible to enable some kind of debug in zabbix so I can see when and how it tries to execute the script? I've tryed relative and absolute paths on different places... No luck.
    Does it have some kind of timeout executing scripts? Because calling the ttytter command takes a couple seconds... Maybe I should try and run it as a daemon.

    Thanks for the help. Will post the script when I get it to work.
  • efrain02
    Banned
    • Apr 2011
    • 81

    #2
    Did you get it to work?

    Comment

    • mjsr
      Junior Member
      • Feb 2011
      • 15

      #3
      Originally posted by efrain02
      Did you get it to work?
      Hi,

      Kinda switched strategy. Started to do it with Prowl to get push notifications to iPhone. They have a script you can use almost out of the box.

      Works pretty damn well and is really neat

      Dropped the idea to spam to twitter (even if a private one) as it was too much time consuming and couln't figure it out...

      Worked for a moment, then stopped... Have no idea why...

      Good luck!

      Comment

      Working...