Ad Widget

Collapse

External scripts not working post upgrade

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zabbixfk
    Senior Member
    • Jun 2013
    • 256

    #1

    External scripts not working post upgrade

    Hi All,

    I just upgraded to 3.0.13, and it seems all of my external scripts broken.
    I had this configurations.
    under '/etc/zabbix/externalscripts' and '/usr/local/share/zabbix/externalscripts' i had some scripts which are basically shell script wrappers intern calls expect ( tcl) scripts to go into devices and pull some data.
    For example.
    cat /usr/local/share/zabbix/externalscripts/rf_index
    Code:
    #!/bin/bash
    val=$(/usr/bin/expect '/usr/local/etc/scripts/rf_index.exp' $1  | grep 'Index =' | cut -d'=' -f3 | sed -e's/\s//g') 
    echo "$val"
    and cat /usr/local/etc/scripts/rf_index.exp has
    Code:
    #!/usr/bin/expect
    set host "XXX.XXX.XXX.XX"
    set uname "XXXXX"
    set pwd "XXXXX"
    set prompt "#|>|:|\\\$";
    set val ""
    set domain [lindex $argv 0]
    log_user 0
    set timeout -1
    spawn /usr/bin/ssh "$uname@$host"
    expect "$uname@$host's password:"
    send "$pwd\n"
    sleep 1
    #expect -re "$prompt"
    expect ">"
    sleep 1
    send "show wireless rf-domain statistics detail on $domain | grep Index\r"
    sleep 1
    expect  ">"
    set val $expect_out(buffer)
    send "exit\n"
    puts $val
    This use to work with below paramerts on item configurations.
    Code:
    Name : RF-Index - DOMAIN_NAME
    Type: External Check
    Key : rf_index["DOMAIN_NAME"]
    Host interface: IP:PORT  ( this does not matter as i am going to monitor this via zabbix_proxy, and this will be running in zabbix_porxy)
    Type of information: Numeric(unsigned)
    Data type: Decimal
    Now, when i see items page, i am seeing timeout errors. - 'Timeout while executing a shell script' and log does show getting this script called, and sends
    Code:
    30398:20180203:144406.037 In substitute_key_macros() data:'rf_index[" DOMAIN_NAME"]'
     30398:20180203:144406.037 End of substitute_key_macros():SUCCEED data:'rf_index["DOMAIN_NAME"]'
     30398:20180203:144406.037 In get_value() key:'rf_index["DOMAIN_NAME"]'
     30398:20180203:144406.037 In get_value_external() key:'rf_index["DOMAIN_NAME"]'
     30398:20180203:144406.037 In zbx_popen() command:'/usr/local/share/zabbix/externalscripts/rf_index "DOMAIN_NAME"'
     30398:20180203:144406.038 End of zbx_popen():6
     25513:20180203:144406.038 zbx_popen(): executing script
    30473:20180203:144433.026 Item [HOST_NAME:rf_index["DOMAIN_NAME"]] error: Timeout while executing a shell script.
     30473:20180203:144433.026 End of get_value():NOTSUPPORTED
    Some has below error as well
    Code:
     30406:20180203:144433.027 End of get_value_external():NOTSUPPORTED
     30406:20180203:144433.027 Item [HOST_NAMR:rf_index["DOMAIN_NAME"]] error: Received value [send: spawn id exp3 not open    while executing"send "$pwd\n""    (file "/usr/local/etc/scripts/rf_index.exp" line 12)] is not suitable for value type [Numeric (unsigned)] and data type [Decimal]
     30406:20180203:144433.027 End of get_value():NOTSUPPORTED

    Basically all i wanted is, run some scripts and display outputs - because using SNMP or via zabbx_agent as i can't either install zabbix_agent on those machines (routers/diff OS), or SNMP gets not supported.

    Any pointers to solve this greatly helpful.

    Thanks.
  • zabbixfk
    Senior Member
    • Jun 2013
    • 256

    #2
    Please help

    *bump*

    Can someplease reply here - majority of my items which are monitored via external scripts are broken. Not able to figure out where and what is the issue.

    Thanks

    Comment

    • Atsushi
      Senior Member
      • Aug 2013
      • 2028

      #3
      Code:
       30473:20180203:144433.026 Item [HOST_NAME:rf_index["DOMAIN_NAME"]] error: Timeout while executing a shell script.
      Has timeout occurred in script execution?
      Please tell me how many seconds it takes to execute the script.

      If it is the default, it will time out in 3 seconds, so please specify a longer time to 'Timeout' in the setting file(zabbix_server.conf).

      Comment

      • zabbixfk
        Senior Member
        • Jun 2013
        • 256

        #4
        Thanks for the reply.
        I am not sure why/how timeouts are occurring. My time outs are set 30s from config file.
        Any pointers are greatly helpful.

        Thanks

        Comment

        • Atsushi
          Senior Member
          • Aug 2013
          • 2028

          #5
          Have you upgraded Zabbix on the same server that was working previously?
          Have you manually executed the script and got the value?

          Perhaps you are building a new version of Zabbix environment on another server?
          If you built it on another server, did you connect using the ssh command and added it to known_hosts?

          Comment

          • zabbixfk
            Senior Member
            • Jun 2013
            • 256

            #6
            Thanks for the reply.
            Yes, i upgraded the servers, and all other things works just fine on the same machine.
            Well i had exectuted on the previouse version ( 2.2.12) and got the value. But after you ask, i run it again. Seeing this error
            Calling the wrapper shell script which is added as item in zabbix , which goes to some kind of loop.
            Code:
            [root@zbx-proxy2 ~]# su - zabbix /usr/local/etc/scripts/rf_index DOMAIN_NAME
            ^C[root@zbx-proxy2 ~]# 
            [root@zbx-proxy2 ~]#
            Then i called the inside expect(tcl) script which gives me the exact value, but looks like its not working either.
            Code:
            [root@zbx-proxy2 ~]# 
            [root@zbx-proxy2 ~]# su - zabbix /usr/bin/expect /usr/local/etc/scripts/rf_index.exp 
            /usr/bin/expect: /usr/bin/expect: cannot execute binary file
            [root@zbx-proxy2 ~]#
            But when i run them as root it gives me values, something is changed or strange which i am not able to figure out.
            Any pointers are greatly helpful.
            Thanks.

            Comment

            • zabbixfk
              Senior Member
              • Jun 2013
              • 256

              #7
              External scripts not working

              *Bump*

              Can some please reply here. I am stuck with these external script problems.
              Any pointers are greatly appreciated.

              Thanks

              Comment

              • zabbixfk
                Senior Member
                • Jun 2013
                • 256

                #8
                External scripts not working

                *Bump*

                Can some please reply here. I am stuck with these external script problems.
                Any pointers are greatly appreciated.

                Thanks

                Comment

                • zabbixfk
                  Senior Member
                  • Jun 2013
                  • 256

                  #9
                  External scripts broken

                  *bump*

                  Interesting as in even after 200 views to this thread, none has reply.
                  Zabbix team, please help. Most of my items are of external scripts stuff and they are broken.

                  Please share any pointers.

                  Thanks.

                  Comment

                  • zabbixfk
                    Senior Member
                    • Jun 2013
                    • 256

                    #10
                    External scripts not working

                    *Bump*

                    Can some please reply here. I am stuck with these external script problems.
                    Any pointers are greatly appreciated.

                    Thanks

                    Comment

                    • SBO
                      Zabbix Certified Specialist
                      Zabbix Certified Specialist
                      • Sep 2015
                      • 226

                      #11
                      Hi,

                      The thing is, this is a system error, not a zabbix error, that's why you don't get that many answers.
                      If your script runs as root but not as zabbix, there's some permission issue somewhere.

                      Did you try to run the script with your user, to check if it's still working well ?

                      Comment

                      • zabbixfk
                        Senior Member
                        • Jun 2013
                        • 256

                        #12
                        Thank you very much for the reply. Hope you have gone through the thread.
                        Do you see any abnormality in calling external scripts?
                        All the scripts , system executables such as expect, sed, cut have execute and read permissions.
                        Do you see any issue with permissions? What's the starting point for debug?
                        This use to work when i was in 2.2.12 build, now its upgraded to 3.0.13 and i am having issues ( timeout occurred - coz as a zabbix user its not possible to call external script which is having expect.)

                        Any pointers are greatly helpful.

                        Thanks

                        Comment

                        • zabbixfk
                          Senior Member
                          • Jun 2013
                          • 256

                          #13
                          *bump*
                          Can someone point out where's the error? Majoriry of my items are external scripts - and they seem to be broken.

                          Comment

                          • zabbixfk
                            Senior Member
                            • Jun 2013
                            • 256

                            #14
                            *bump*
                            Any pointers to debug this is greatly helpful.
                            Thanks

                            Comment

                            • kloczek
                              Senior Member
                              • Jun 2006
                              • 1771

                              #15
                              Instead fighting with external script you can use "SSH agent" item type.
                              http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
                              https://kloczek.wordpress.com/
                              zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
                              My zabbix templates https://github.com/kloczek/zabbix-templates

                              Comment

                              Working...