Ad Widget

Collapse

Problem with External Scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lflaimer
    Junior Member
    • Oct 2009
    • 13

    #1

    Problem with External Scripts

    Gentlement,

    Recently I was trying to create a script that gets the value of active calls one week behind.
    My script looks like:
    (Please disconsider the simplicity of the script, Im no bash expert)

    #!/bin/bash
    declare -i timestamp=`date +"%s"`;
    let "timestamp=$timestamp - 604800";
    let "timestamp=$timestamp - 4800";
    let "start=$timestamp - 30";
    let "stop=$timestamp + 30";
    variable=`
    mysql -sN -u root --password=password << eof
    use zabbix;
    select history_uint.value from history_uint where ((history_uint.clock BETWEEN $start AND $stop) AND (history_uint.itemid = '$1'));
    eof`
    echo $variable;
    ------------------------------------------------------------------
    When I run the script AS ZABBIX USER in the shell, it works fine, it returns the query result, so I presume that has no permission problems.
    zabbix@EUA-MIA-NAP-ZABBIX01-004:/etc/zabbix/externalscripts> ./last_week.sh 22496
    15

    But when I configure zabbix to run External Scripts, it wont work, and returns 0 value. I cant figure it out why this is happening.
    My zabbix conf follows in the JPG file attached.


    Please help.

    Best Regards
    Luis Fernando Laimer
    Attached Files
  • lflaimer
    Junior Member
    • Oct 2009
    • 13

    #2
    It shows, not supported, script returned nothing.

    What am I doing wrong ?

    Best Regards
    Luis Fernando Laimer

    Comment

    • alixen
      Senior Member
      • Apr 2006
      • 474

      #3
      Hi,

      Your parameter is not in $1.
      Check http://www.zabbix.com/documentation/...xternal_checks in Zabbix manual:

      Your script is called as:
      Code:
      last_week.sh hostname 22496
      Hope this helps
      Alixen
      http://www.alixen.fr/zabbix.html

      Comment

      • lflaimer
        Junior Member
        • Oct 2009
        • 13

        #4
        Hi Alixen,

        Thanks for you reply.
        I didnt get it, how should I call my script then ?
        How can I invoke the parameter inside the script ?
        I should call it with $2 ?

        Thank you
        Luis Fernando Laimer

        Comment

        • lflaimer
          Junior Member
          • Oct 2009
          • 13

          #5
          I try to call it with $2, once $1 would be the hostname...still not working
          Any ideia ?

          Comment

          Working...