Ad Widget

Collapse

External script not returning what I expect

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mickey78
    Junior Member
    • Feb 2012
    • 3

    #1

    External script not returning what I expect

    Hey guys, I have an external script (TXSAlarmState.sh) that looks like this:

    Code:
    #/bin/bash
    test=$(snmpbulkwalk -v 2c -c public $1 .1.3.6.1.4.1.9986.3.14.1.7.1.1.3)
    if [[ $test =~ "INTEGER: 4" ]]; then
            echo "4"
    elif [[ $test =~ "INTEGER: 3" ]]; then
            echo "3"
    elif [[ $test =~ "INTEGER: 2" ]]; then
            echo "2"
    elif [[ $test =~ "INTEGER: 0" ]]; then
            echo "0"
    elif [[ $test =~ "INTEGER: 1" ]]; then
            echo "1"
    fi

    It test a snmpwalk variable against what it returns and is supposed to return a single digit for the error code to zabbix. I know the whole external check work because I can echo back the $test variable and I see it popping in zabbix as a text string.

    Here is what the debug gives me
    Code:
    19543:20130531:111647.912 In substitute_key_macros() data:'TXSAlarmState.sh[{HOST.IP1}]'
     19543:20130531:111647.913 End of substitute_key_macros():SUCCEED data:'TXSAlarmState.sh[10.100.2.105]'
     19543:20130531:111647.913 In get_value() key:'TXSAlarmState.sh[{HOST.IP1}]'
     19543:20130531:111647.913 In get_value_external() key:'TXSAlarmState.sh[{HOST.IP1}]'
     19543:20130531:111647.913 In zbx_popen() command:'/usr/local/share/zabbix/externalscripts/TXSAlarmState.sh "10.100.2.105"'
     19545:20130531:111648.973 In substitute_key_macros() data:'TXSAlarmState.sh[{HOST.IP1}]'
     19545:20130531:111648.973 End of substitute_key_macros():SUCCEED data:'TXSAlarmState.sh[10.100.2.106]'
     19545:20130531:111648.973 In get_value() key:'TXSAlarmState.sh[{HOST.IP1}]'
     19545:20130531:111648.974 In get_value_external() key:'TXSAlarmState.sh[{HOST.IP1}]'
     19545:20130531:111648.974 In zbx_popen() command:'/usr/local/share/zabbix/externalscripts/TXSAlarmState.sh "10.100.2.106"'
     19544:20130531:111649.013 In substitute_key_macros() data:'TXSAlarmState.sh[{HOST.IP1}]'
     19544:20130531:111649.016 End of substitute_key_macros():SUCCEED data:'TXSAlarmState.sh[10.100.2.107]'
     19544:20130531:111649.016 In get_value() key:'TXSAlarmState.sh[{HOST.IP1}]'
     19544:20130531:111649.016 In get_value_external() key:'TXSAlarmState.sh[{HOST.IP1}]'
     19544:20130531:111649.017 In zbx_popen() command:'/usr/local/share/zabbix/externalscripts/TXSAlarmState.sh "10.100.2.107"'
     19610:20130531:111658.402 In evaluate_function() function:'Sencore TXSVD2:icmpping[,,,,2000].max(1m)'
     19610:20130531:111658.404 In evaluate_function() function:'Sencore TXSVD2:icmpping[,,,,2000].max(5m)'
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 4: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 6: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 8: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 10: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 12: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 4: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 6: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 8: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 10: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 12: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 4: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 6: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 8: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 10: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found
    /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: 12: /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh: [[: not found

    The script works well from the shell:
    Code:
    lgarceau@zabbix:/etc$ /usr/local/share/zabbix/externalscripts/TXSAlarmState.sh 10.100.2.105
    1
    Any idea?
Working...