Ad Widget

Collapse

What should return an external chexk discover script ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pierreC
    Junior Member
    • Jun 2017
    • 13

    #1

    What should return an external chexk discover script ?

    I've wrote a script that list the objects I want to monitor via SNMP.

    I execute it in a template on a discovery rule by external check.

    Problem, I don't known what I should return to zabbix at the end of my script.

    Should I just do a 1 line print on Json format that should be like that ?

    print "{"jsonrpc": "2.0","method": "SOMETHING","data": [{"{#ID}": "1","{#INFORMATION}": "info"},{"{#ID}": "2","{#INFORMATION}": "info"},{....}]";
  • pierreC
    Junior Member
    • Jun 2017
    • 13

    #2
    Update on this thread.
    I've finish my script, it work well and here is an example of what it print when it's executed :

    Code:
    {
    	"data":[
    
    	{
    		"{#INTNAME}":"34",
    		"{#CLASSMAPNAME}":"QoS-Dom-Test-Drop-ICMP"
    		"{#IDINTCONF}":"544"
    		"{#IDCLASSMAPCONF}":"2508401"
    	}
    	{
    		"{#INTNAME}":"34",
    		"{#CLASSMAPNAME}":"AutoQos-VoIP-Control-Dscp24"
    		"{#IDINTCONF}":"544"
    		"{#IDCLASSMAPCONF}":"5771057"
    	}
    	{
    		"{#INTNAME}":"34",
    		"{#CLASSMAPNAME}":"AutoQos-VoIP-Control-Dscp26"
    		"{#IDINTCONF}":"544"
    		"{#IDCLASSMAPCONF}":"5771089"
    	}
    	]
    }
    attached to this post is how I configure my discover.

    when I apply it to a host, zabbix return me this error : value should be a JSON object

    I've try to verify how my script is called by zabbix by writting the argument which with the script is called by zabbix on a txt file but when I open this .txt, it's empty. I've test by calling the script myself and the .txt is filled. So I don't known if zabbix is really calling my script.
    The script is located on /usr/lib/zabbix/extenalscripts.

    Comment

    • batchenr
      Senior Member
      • Sep 2016
      • 440

      #3
      Originally posted by pierreC
      Update on this thread.
      I've finish my script, it work well and here is an example of what it print when it's executed :

      Code:
      {
      	"data":[
      
      	{
      		"{#INTNAME}":"34",
      		"{#CLASSMAPNAME}":"QoS-Dom-Test-Drop-ICMP"
      		"{#IDINTCONF}":"544"
      		"{#IDCLASSMAPCONF}":"2508401"
      	}
      	{
      		"{#INTNAME}":"34",
      		"{#CLASSMAPNAME}":"AutoQos-VoIP-Control-Dscp24"
      		"{#IDINTCONF}":"544"
      		"{#IDCLASSMAPCONF}":"5771057"
      	}
      	{
      		"{#INTNAME}":"34",
      		"{#CLASSMAPNAME}":"AutoQos-VoIP-Control-Dscp26"
      		"{#IDINTCONF}":"544"
      		"{#IDCLASSMAPCONF}":"5771089"
      	}
      	]
      }
      attached to this post is how I configure my discover.

      when I apply it to a host, zabbix return me this error : value should be a JSON object

      I've try to verify how my script is called by zabbix by writting the argument which with the script is called by zabbix on a txt file but when I open this .txt, it's empty. I've test by calling the script myself and the .txt is filled. So I don't known if zabbix is really calling my script.
      The script is located on /usr/lib/zabbix/extenalscripts.

      try:

      Hi, first thanks for the script. I Installed the script, the version is reported to Zabbix but the discovery are not working and I get the error "value should be a json object" When I execute the s...

      Comment

      • pierreC
        Junior Member
        • Jun 2017
        • 13

        #4
        Thank you,
        there were 2 issues in cause :
        • The lack of comma in my printing, here is my new JSON result
        • Warning printing because mibs missing. Not important when you use snmpwalk but zabbix read all the line printed, warning includes


        Code:
        {
        	"data":[
        
        	{
        		"{#INTNAME}":"GigabitEthernet3/1",
        		"{#CLASSMAPNAME}":"QoS-Dom-Test-Drop-ICMP",
        		"{#IDINTCONF}":"544",
        		"{#IDCLASSMAPCONF}":"2508401"
        	},
        	{
        		"{#INTNAME}":"GigabitEthernet3/1",
        		"{#CLASSMAPNAME}":"AutoQos-VoIP-Control-Dscp24",
        		"{#IDINTCONF}":"544",
        		"{#IDCLASSMAPCONF}":"5771057"
        	},
        	{
        		"{#INTNAME}":"GigabitEthernet3/1",
        		"{#CLASSMAPNAME}":"AutoQos-VoIP-Control-Dscp26",
        		"{#IDINTCONF}":"544",
        		"{#IDCLASSMAPCONF}":"5771089"
        	}
        	]
        }

        Comment

        Working...