Ad Widget

Collapse

First time external checking

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chrispcall
    Junior Member
    • Oct 2015
    • 1

    #1

    First time external checking

    I'm a new Zabbix user (yesterday) and somewhat new to Linux and an I testing out the appliance to try to see if Zabbix is a good fit.

    I edited an external check script (inside of a discovery rule) to add Brocade interfaces that are currently "UP" by modifying a script on here. The script is here:

    Code:
    #!/bin/bash
    OID_OPER_STATUS=.1.3.6.1.2.1.2.2.1.8
    OID_DESC=.1.3.6.1.2.1.31.1.1.1.1
    OID_PORTNAME=1.3.6.1.4.1.1991.1.1.3.3.5.1.17
    
    #Get the passed in host IP address:
    HOST=$1
    
    first=0
    
    echo "{"
    echo -e "\t\"data\":[\n"
    
    SNMPw="snmpwalk -v2c -c public"
    SNMPg="snmpget -v2c -c public"
    
    for item in `$SNMPw $HOST $OID_OPER_STATUS | grep up | awk '{print $1}' | awk -F'.' '{print $NF}';`
    do
      if [ $first -eq 0 ]
        then
          first=1
        else
          echo -e "\t},\n"; 
        fi   
    
        desc=`$SNMPg $HOST $OID_DESC.$item | awk -F'STRING:' '{print $NF}'`
        portname=`$SNMPg $HOST $PORTNAME.$item | awk -F'STRING:' '{print $NF}'`
        echo -e "\t{\n";
        echo -e "\t\t\"{#SNMPINDEX}\":\"$item\",\n";
        echo -e "\t\t\"{#SNMPVALUE}\":\"$desc\"\n";
        echo -e "\t\t\"{#SNMPPORTNAME}\":\"$portname\"\n";
    
    done
    
    echo -e "\t}\n";
    echo -e "\n\t]"
    echo "}"
    This returns perfect JSON when I run it outside of Zabbix. I am using the accompanying Brocade template that had "ifInOctets[{#SNMPVALUE}]" item prototypes and the template is applied to a group of hosts.

    I am not seeing the data appear anywhere and I was wondering what I needed to do to debug or troubleshoot this? I added a "DebugLevel=4" to /etc/zabbix/zabbix-agentd.conf and all my "/var/log/zabbix/zabbix-agentd.log" file reads is:
    Code:
    6075:20151005:170315.703 Starting Zabbix Agent [Zabbix server]. Zabbix 2.4.6 (revision 54796).
    6075:20151005:170315.703 using configuration file: /etc/zabbix/zabbix-agentd.conf
    6075:20151005:170315.703 agent #0 started [main process]
    6089:20151005:170315.704 agent #5 started [active checks #1]
    6088:20151005:170315.704 agent #4 started[listener #3]
    6087:20151005:170315.705 agent #3 started[listener #2]
    6086:20151005:170315.707 agent #2 started[listener #1]
    6089:20151005:170315.707 active check configuration update from [127.0.0.1:10051] started to fail (cannot connect to [[127.0.0.1]:10051]: [111] Connection refused)
    6085:20151005:170315.708 agent #1 started [collector]
    6089:20151005:170415.769 active check configuration update from [127.0.0.1:10051] is working again
    6075:20151006:225618.835 Got signal [signal:15(SIGTERM),sender_pid:1,sender_uid:0,reason:0]. Exiting ...
    6085:20151006:225618.836 Got signal [signal:15(SIGTERM),sender_pid:1,sender_uid:0,reason:0]. Exiting ...
    6086:20151006:225618.838 Got signal [signal:15(SIGTERM),sender_pid:1,sender_uid:0,reason:0]. Exiting ...
    6087:20151006:225618.838 Got signal [signal:15(SIGTERM),sender_pid:1,sender_uid:0,reason:0]. Exiting ...
    6088:20151006:225618.838 Got signal [signal:15(SIGTERM),sender_pid:1,sender_uid:0,reason:0]. Exiting ...
    6089:20151006:225618.839 Got signal [signal:15(SIGTERM),sender_pid:1,sender_uid:0,reason:0]. Exiting ...
    6075:20151006:225618.890 Zabbix Agent stopped. Zabbix 2.4.6 (revision 54796).
    Any help is greatly appreciated!
  • Linwood
    Senior Member
    • Dec 2013
    • 398

    #2
    The log is for the agent, this would run on the server.

    To get an external check to work you need a bunch of stuff:

    - zabbix_server.conf file define the right location for externalscripts

    - +x on the script and in that directory, and appropriate shebang in the file

    - the file needs to output NOTHING but the json, no prints or debug or stderr leaking

    - the file name becomes the key (no path, just the file name, but including if appropriate the extension), PLUS macros for parameters, e.g.

    dhcpDiscoveryWindows.php[{HOST.CONN1},{$SNMP_COMMUNITY}]

    That's a discovery key I am using. Not item key, the discovery key. Then you use values from it in any filters (if needed) come back from your JSON values.

    - The item prototypes then use the data coming from your JSON. Here's an example from an item from the above:

    Key: PoolPending[{#IP}]
    OID: {#PENDING}

    My JSON returns {#IP}, {#PENDING}, {#FREE}, {#USED}. Each key uses the IP to make it unique, then separate item prototypes are used for the OID's (which had been passed back from my script in the JSON of course).

    To your point, I think you can see the discovery process in debug in the poller process (you might want to look at this:

    Historically, issues that might arise when using Zabbix have not been easy to troubleshoot. Not everything that would be useful is always logged. Log level can be increased, but those who still remember the first time they saw what DebugLevel=4 can do will understand why that option usually helped more advanced users. Besides, changing the […]


    as it allows you to somewhat limit the volume of debugging information by just turning it on for one process. I've also at times just disabled every host but one while debugging to make the volume lower.

    Comment

    Working...