Ad Widget

Collapse

Problems with Custom Discovery Template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • clahti
    Senior Member
    • Jan 2007
    • 126

    #1

    Problems with Custom Discovery Template

    To all:

    I am trying to implement a custom discovery template to be run on windows hosts. We have a custom application that can run multiple instances, each on a port ranging from 24022 to 24522. I need to write a custom discovery template that captures each "installed" instance and it's port, then create items and triggers to see if the application process is running. I have written the following vbs script located at "c:\Program Files\Zabbix Agent\zbxdiscover-ls.vbs" that returns the valid JSON list that a discovery process expects:

    Code:
    Const HKLM = &h80000002
    Const StartKey    = "SYSTEM\CurrentControlSet\services"
    Const SearchValue = "ImagePath"
    Const MatchData   = "C:\Program Files (x86)\ShotSpotter\FireDaemon\FireDaemon.exe -s"
    Const Quote = """"
    
    Set reg = GetObject("winmgmts://./root/default:StdRegProv")
    Set objSortedList = CreateObject( "System.Collections.Sortedlist" )
    
    FindKey HKLM, StartKey, SearchValue, MatchData
    
    If objSortedList.Count Then
    	WScript.echo("{")
    	WScript.echo("	" & Quote & "data" & Quote & ":[")
    	For i = 0 To objSortedList.Count - 1
    		WScript.echo("	{")
    		WScript.echo("		" & Quote & "#LSNAME}" & Quote & ":" & Quote & objSortedList.GetKey(i) & Quote & ",")
    		WScript.echo("		" & Quote & "#LSPORT}" & Quote & ":" & Quote & objSortedList.GetByIndex(i) & Quote)
    		WScript.echo("	}")
    		WScript.echo("	,")
    	Next
    	WScript.echo("	]")
    	WScript.echo("}")
    End If
    
    Sub FindKey(root, key, value, data)
    	reg.EnumValues HKLM, key, names, types
    	If Not IsNull(names) Then
    		For Each name In names
    			If name = value Then
    				reg.GetStringValue HKLM, key, name, regdata
    				If regdata = data Then
    					LSInstance = Replace(key,"SYSTEM\CurrentControlSet\services\","")
    					If LSInstance <> "RestartLocServers" AND LSInstance <> "Watchdog" Then
    						'WScript.echo("found:" & LSInstance)
    						eKey = "HKEY_LOCAL_MACHINE\" & key & "\Parameters\Environment"
    						eValue = ReadMString(eKey)
    						If (eValue) Then
    							objSortedList.Add LSInstance, eValue
    						End If
    						'WScript.echo("test:" & eKey)
    					End If
    				End If
    			End If
    		Next
    	End If
    
    	'value not found in current key => continue search in subkeys
    	reg.EnumKey root, key, subkeys
    	If Not IsNull(subkeys) Then
    	For Each sk In subkeys
    	  FindKey root, key & "\" & sk, value, data
    	Next
    	End If
    End Sub
    
    Function ReadMString (strKey)
        Dim WSHShell, value
        On Error Resume Next
        Set WSHShell = CreateObject("WScript.Shell")
        vals = WSHShell.RegRead(strKey)
        For i = 0 To UBound(vals)
    		If InStr(vals(i),"SSTTcpBindings") Then
    			ReadMString = Replace(vals(i),"SSTTcpBindings=0.0.0.0:","")
    			'WScript.echo("ReadMString:" & ReadMString)
    		End If
        Next
    End Function
    when I run this from a command prompt it returns what I would expect:
    Code:
    c:\Program Files\Zabbix Agent>cscript //nologo c:\progra~1\zabbix~1\zbxdiscover-ls.vbs
    {
            "data":[
            {
                    "#LSNAME}":"CambridgeMA",
                    "#LSPORT}":"24023"
            }
            ,
            {
                    "#LSNAME}":"ChelseaMA",
                    "#LSPORT}":"24024"
            }
            ,
            {
                    "#LSNAME}":"DetroitMI",
                    "#LSPORT}":"24029"
            }
            ,
            {
                    "#LSNAME}":"EverettMA",
                    "#LSPORT}":"24025"
            }
            ,
            {
                    "#LSNAME}":"RevereMA",
                    "#LSPORT}":"24026"
            }
            ,
            {
                    "#LSNAME}":"SomervilleMA",
                    "#LSPORT}":"24027"
            }
            ,
            {
                    "#LSNAME}":"WilmingtonDE",
                    "#LSPORT}":"24028"
            }
            ,
            ]
    }
    All good so far, now when I try to test this from the server side I get ZBX_UNSUPPORTED no matter what I do, even with a custom UserParameter entry (yes I restarted the agent)
    Code:
    //custom UserParameter entry
    [root@zabbix ~]# zabbix_get -s ssi-eastern-04 -k discovery.locserver
    ZBX_NOTSUPPORTED
    
    //try running the script with system.run
    [root@zabbix ~]# zabbix_get -s ssi-eastern-04 -k system.run[cscript //nologo c:\\progra~1\\zabbix~1\\zbxdiscover-ls.vbs]
    ZBX_NOTSUPPORTED
    
    //try to run with a batch file wrapper to the command
    zabbix_get -s ssi-eastern-04 -k system.run[c:\progra~1\zabbix~1\zbxdiscover-ls.bat]
    ZBX_NOTSUPPORTED
    I am out of ideas to get this to work, can anyone help?
  • clahti
    Senior Member
    • Jan 2007
    • 126

    #2
    More Information

    I cranked up the debug level to 4 on the agent, restarted. Nothing useful. I also went ahead and wrote the template discovery rule and one item

    Code:
    Discovery Rule Name: Discover LocServer Instances
    Discovery Rule Key: system.run[cscript //nologo c:\\progra~1\\zabbix~1\\zbxdiscover-ls.vbs]
    
    Item Name: LocServer-{#LSNAME}:{#LSPORT}
    Item Type: Simple Check
    Item Key: net.tcp.service[http,,#LSPORT]
    This immediately turns to UNSUPPORTED as soon as the template is applied to the server. I am stumped at this point, maximum logging on both the server and client yeilds absolutely no useful information that I can see.

    Also EnableRemoteCommands=1 is set in the zabbix agent configuration, agent version is 2.2.3
    Last edited by clahti; 24-03-2015, 00:32.

    Comment

    • clahti
      Senior Member
      • Jan 2007
      • 126

      #3
      Even More Info

      The zabbix agent service was setup to run as system, so I ran this to see what user the script was executing under:
      Code:
      [root@zabbix ~]# zabbix_get -s ssi-eastern-04 -k system.run[whoami]
      nt authority\system
      Ok, it is a possible permissions issue, so I reconfigure service to run as local administrator, then restart the service. Now when I run the whoami from the zabbix server I get:
      Code:
      [root@zabbix ~]# zabbix_get -s ssi-eastern-04 -k system.run[whoami]
      ssi-eastern-04\administrator
      and I try running my custom script:
      Code:
      [root@zabbix ~]# zabbix_get -s ssi-eastern-04 -k system.run[cscript //nologo c:\\progra~1\\zabbix~1\\zbxdiscover-ls.vbs]
      ZBX_NOTSUPPORTED
      So it seem permissions is not the issue since the script is being executed as .\Administrator. The problem persists unfortunately.

      Comment

      • danrog
        Senior Member
        • Sep 2009
        • 164

        #4
        Your JSON is not valid (based on the first post).


        PHP Code:
        {
                
        "data":[
                {
                        
        "#LSNAME}":"CambridgeMA",
                        
        "#LSPORT}":"24023"
                
        }
                ,
                {
                        
        "#LSNAME}":"ChelseaMA",
                        
        "#LSPORT}":"24024" 
        Should be:

        PHP Code:
        {
                
        "data":[
                {
                        
        "{#LSNAME}":"CambridgeMA",
                        
        "{#LSPORT}":"24023"
                
        }
                ,
                {
                        
        "{#LSNAME}":"ChelseaMA",
                        
        "{#LSPORT}":"24024" 
        P.S. You look like you are right around me (in MA).

        Comment

        • clahti
          Senior Member
          • Jan 2007
          • 126

          #5
          well that is just plain embarrassing LOL. Let me fix the glaring missing brackets and try this again, thanks for pointing that out.

          Comment

          • clahti
            Senior Member
            • Jan 2007
            • 126

            #6
            Ok, I had to completely refactor the VBS script, there was something zabbix did not like in the original. This one works (with fixed JSON output):

            Code:
            option explicit
            
            Const HKLM = &h80000002
            Const MatchData   = "C:\Program Files (x86)\ShotSpotter\FireDaemon\FireDaemon.exe -s"
            Const QQ = """"
            
            dim oReg
            dim strKeyPath
            dim objSortedList
            dim arrSubKeys
            dim strSubkey
            dim strSubKeyPath
            dim arrValueNames
            dim arrTypes
            dim strValueName
            dim strValue
            dim strEKeyPath
            dim strEValueName
            dim arrEValues
            dim i
            
            strKeyPath = "SYSTEM\CurrentControlSet\services"
            strValueName = "ImagePath"
            
            Set oReg = GetObject("winmgmts://./root/default:StdRegProv")
            Set objSortedList = CreateObject( "System.Collections.Sortedlist" )
            
            oReg.EnumKey HKLM, strKeyPath, arrSubKeys
            For Each strSubkey In arrSubKeys
            	'toss out ones we don't want
            	If strSubkey <> "RestartLocServers" AND strSubkey <> "Watchdog" Then
            		strSubKeyPath = strKeyPath & "\" & strSubkey
            		oReg.GetStringValue HKLM,strSubKeyPath,strValueName,strValue
            		If IsNull(strValue) Then
            			'do nothing
            		Else
            			'see if it is a firedaemon path
            			If strValue = MatchData Then
            				'get port, if found then add to objSortedList
            				strEKeyPath = strKeyPath & "\" & strSubkey & "\Parameters"
            				strEValueName = "Environment"
            				oReg.GetMultiStringValue HKLM, strEKeyPath, strEValueName, arrEValues
            				If IsNull(arrEValues) Then
            					'do nothing
            				Else
            					For i = 0 To UBound(arrEValues)
            						If InStr(arrEValues(i),"SSTTcpBindings") Then
            							objSortedList.Add strSubkey, Replace(arrEValues(i),"SSTTcpBindings=0.0.0.0:","")
            						End If
            					Next
            				End If
            			End If
            		End If
            	End If
            Next
            
            If objSortedList.Count Then
            	WScript.echo("{")
            	WScript.echo("	" & QQ & "data" & QQ & ":[")
            	For i = 0 To objSortedList.Count - 1
            		WScript.echo("	{")
            		WScript.echo("		" & QQ & "{#LSNAME}" & QQ & ":" & QQ & objSortedList.GetKey(i) & QQ & ",")
            		WScript.echo("		" & QQ & "{#LSPORT}" & QQ & ":" & QQ & objSortedList.GetByIndex(i) & QQ)
            		WScript.echo("	}")
            		WScript.echo("	,")
            	Next
            	WScript.echo("	]")
            	WScript.echo("}")
            End If
            Now I can at least get the JSON via zabbix_get:

            Code:
            [root@zabbix ~]# zabbix_get -s ssi-eastern-04 -k system.run["cscript //nologo c:\progra~1\zabbix~1\zbxdiscover-ls.vbs"]
            {
            	"data":[
            	{
            		"{#LSNAME}":"CambridgeMA",
            		"{#LSPORT}":"24023"
            	}
            	,
            	{
            		"{#LSNAME}":"ChelseaMA",
            		"{#LSPORT}":"24024"
            	}
            	,
            	{
            		"{#LSNAME}":"DetroitMI",
            		"{#LSPORT}":"24029"
            	}
            	,
            	{
            		"{#LSNAME}":"EverettMA",
            		"{#LSPORT}":"24025"
            	}
            	,
            	{
            		"{#LSNAME}":"RevereMA",
            		"{#LSPORT}":"24026"
            	}
            	,
            	{
            		"{#LSNAME}":"SomervilleMA",
            		"{#LSPORT}":"24027"
            	}
            	,
            	{
            		"{#LSNAME}":"WilmingtonDE",
            		"{#LSPORT}":"24028"
            	}
            	,
            	]
            }
            The remaining problem is NOW my discovery template gets a red X and the error is "Value should be a JSON object." Is there still an issue with the JSON output? It looks right to me...

            Comment

            • aib
              Senior Member
              • Jan 2014
              • 1615

              #7
              You now, Zabbix sometimes is like a Big Bad Boss.
              In your JSON he (zabbix) doesn't like the last "comma".
              Code:
              	"{#LSNAME}":"WilmingtonDE",
              		"{#LSPORT}":"24028"
              	}
              [U]	,[/U]
              	]
              }
              Please, refactor your script again and remove that "comma", or Zabbix will never use your output.

              PS Zabbix rules about JSON objects changed last year and after that many scripts became obsolete because of "last comma before the end of output".

              Sorry.
              Sincerely yours,
              Aleksey

              Comment

              • clahti
                Senior Member
                • Jan 2007
                • 126

                #8
                This is what my script now outputs:

                Code:
                [
                    {
                        "data": [
                	{
                		"{#LSNAME}":"CambridgeMA",
                		"{#LSPORT}":"24023"
                	}
                	,
                	{
                		"{#LSNAME}":"ChelseaMA",
                		"{#LSPORT}":"24024"
                	}
                	,
                	{
                		"{#LSNAME}":"DetroitMI",
                		"{#LSPORT}":"24029"
                	}
                	,
                	{
                		"{#LSNAME}":"EverettMA",
                		"{#LSPORT}":"24025"
                	}
                	,
                	{
                		"{#LSNAME}":"RevereMA",
                		"{#LSPORT}":"24026"
                	}
                	,
                	{
                		"{#LSNAME}":"SomervilleMA",
                		"{#LSPORT}":"24027"
                	}
                	,
                	{
                		"{#LSNAME}":"WilmingtonDE",
                		"{#LSPORT}":"24028"
                	}
                        ]
                    }
                ]
                This passes the JSONLint validator http://jsonlint.com

                This is the log snippet from the agent:

                Code:
                  2072:20150324:140433.250 Run remote command [cscript //nologo c:\progra~1\zabbix~1\zbxdiscover-ls.vbs] Result [467] [{
                
                	"data":[
                
                	{
                
                		]...
                  2072:20150324:140433.250 Sending back [{
                
                	"data":[
                
                	{
                
                		"{#LSNAME}":"CambridgeMA",
                
                		"{#LSPORT}":"24023"
                
                	}
                
                	,
                
                	{
                
                		"{#LSNAME}":"ChelseaMA",
                
                		"{#LSPORT}":"24024"
                
                	}
                
                	,
                
                	{
                
                		"{#LSNAME}":"DetroitMI",
                
                		"{#LSPORT}":"24029"
                
                	}
                
                	,
                
                	{
                
                		"{#LSNAME}":"EverettMA",
                
                		"{#LSPORT}":"24025"
                
                	}
                
                	,
                
                	{
                
                		"{#LSNAME}":"RevereMA",
                
                		"{#LSPORT}":"24026"
                
                	}
                
                	,
                
                	{
                
                		"{#LSNAME}":"SomervilleMA",
                
                		"{#LSPORT}":"24027"
                
                	}
                
                	,
                
                	{
                
                		"{#LSNAME}":"WilmingtonDE",
                
                		"{#LSPORT}":"24028"
                
                	}
                
                	,
                
                	]
                
                }]
                If I paste that into the validator, it seems that zabbix agent has inserted a final comma after the WilmingtonDE block, and THAT does not pass validation. Why would the agent add anything to the return value of my script? This is head scratching and somewhat annoying.

                Comment

                • aib
                  Senior Member
                  • Jan 2014
                  • 1615

                  #9
                  I told you, that Zabbix is more strict than any JSON validator.

                  In your script there are a loop:
                  If objSortedList.Count Then
                  Code:
                  	WScript.echo("{")
                  	WScript.echo("	" & QQ & "data" & QQ & ":[")
                  	For i = 0 To objSortedList.Count - 1
                  		WScript.echo("	{")
                  		WScript.echo("		" & QQ & "{#LSNAME}" & QQ & ":" & QQ & objSortedList.GetKey(i) & QQ & ",")
                  		WScript.echo("		" & QQ & "{#LSPORT}" & QQ & ":" & QQ & objSortedList.GetByIndex(i) & QQ)
                  		WScript.echo("	}")
                  [U]		WScript.echo("	,")[/U]
                  	Next
                  	WScript.echo("	]")
                  	WScript.echo("}")
                  End If
                  Underlined command echoing " ," even if it is the last element from the list.
                  To be on safe side, it's better to change a loop to
                  Code:
                  If objSortedList.Count Then
                  	WScript.echo("{")
                  	WScript.echo("	" & QQ & "data" & QQ & ":[")
                  
                  	WScript.echo("	{")
                  	WScript.echo("		" & QQ & "{#LSNAME}" & QQ & ":" & QQ & objSortedList.GetKey(0) & QQ & ",")
                  	WScript.echo("		" & QQ & "{#LSPORT}" & QQ & ":" & QQ & objSortedList.GetByIndex(0) & QQ)
                  	WScript.echo("	}")
                  
                  	For i = 1 To objSortedList.Count - 1
                  		WScript.echo("	,")
                  		WScript.echo("	{")
                  		WScript.echo("		" & QQ & "{#LSNAME}" & QQ & ":" & QQ & objSortedList.GetKey(i) & QQ & ",")
                  		WScript.echo("		" & QQ & "{#LSPORT}" & QQ & ":" & QQ & objSortedList.GetByIndex(i) & QQ)
                  		WScript.echo("	}")
                  	Next
                  	WScript.echo("	]")
                  	WScript.echo("}")
                  End If
                  - print first element
                  - start loop
                  - print "comma"
                  - print current element
                  - end loop
                  Sincerely yours,
                  Aleksey

                  Comment

                  • clahti
                    Senior Member
                    • Jan 2007
                    • 126

                    #10
                    sorry I didn't paste my last iteration of the script:

                    Code:
                    option explicit
                    
                    Const HKLM = &h80000002
                    Const MatchData   = "C:\Program Files (x86)\ShotSpotter\FireDaemon\FireDaemon.exe -s"
                    Const QQ = """"
                    
                    dim oReg
                    dim strKeyPath
                    dim objSortedList
                    dim arrSubKeys
                    dim strSubkey
                    dim strSubKeyPath
                    dim arrValueNames
                    dim arrTypes
                    dim strValueName
                    dim strValue
                    dim strEKeyPath
                    dim strEValueName
                    dim arrEValues
                    dim i
                    dim nUpper
                    
                    strKeyPath = "SYSTEM\CurrentControlSet\services"
                    strValueName = "ImagePath"
                    
                    Set oReg = GetObject("winmgmts://./root/default:StdRegProv")
                    Set objSortedList = CreateObject( "System.Collections.Sortedlist" )
                    
                    oReg.EnumKey HKLM, strKeyPath, arrSubKeys
                    For Each strSubkey In arrSubKeys
                    	'toss out ones we don't want
                    	If strSubkey <> "RestartLocServers" AND strSubkey <> "Watchdog" Then
                    		strSubKeyPath = strKeyPath & "\" & strSubkey
                    		oReg.GetStringValue HKLM,strSubKeyPath,strValueName,strValue
                    		If IsNull(strValue) Then
                    			'do nothing
                    		Else
                    			'see if it is a firedaemon path
                    			If strValue = MatchData Then
                    				'get port, if found then add to objSortedList
                    				strEKeyPath = strKeyPath & "\" & strSubkey & "\Parameters"
                    				strEValueName = "Environment"
                    				oReg.GetMultiStringValue HKLM, strEKeyPath, strEValueName, arrEValues
                    				If IsNull(arrEValues) Then
                    					'do nothing
                    				Else
                    					For i = 0 To UBound(arrEValues)
                    						If InStr(arrEValues(i),"SSTTcpBindings") Then
                    							objSortedList.Add strSubkey, Replace(arrEValues(i),"SSTTcpBindings=0.0.0.0:","")
                    						End If
                    					Next
                    				End If
                    			End If
                    		End If
                    	End If
                    Next
                    
                    If objSortedList.Count Then
                    	WScript.echo("[")
                    	WScript.echo("    {")
                    	WScript.echo("        " & QQ & "data" & QQ & ": [")
                    
                    	nUpper = objSortedList.Count - 1
                    	For i = 0 To nUpper
                    		WScript.echo("	{")
                    		WScript.echo("		" & QQ & "{#LSNAME}" & QQ & ":" & QQ & objSortedList.GetKey(i) & QQ & ",")
                    		WScript.echo("		" & QQ & "{#LSPORT}" & QQ & ":" & QQ & objSortedList.GetByIndex(i) & QQ)
                    		WScript.echo("	}")
                    		If i <> nUpper Then
                    			WScript.echo("	,")
                    		End If
                    	Next
                    	WScript.echo("        ]")
                    	WScript.echo("    }")
                    	WScript.echo("]")
                    End If
                    I am skipping the last comma (nUpper check), using zabbix_get from the zabbix server, the resulting JSON passes validation, but zabbix is still unhappy about something. Probably stupid and glaringly obvious, but my feeble mind is throbbing with no solution

                    Comment

                    • aib
                      Senior Member
                      • Jan 2014
                      • 1615

                      #11
                      OK, now it looks good.
                      You can change Update interval for discovery to 1 second. It will starts almost immediately and you will see if it replace red cross to green.

                      I think you still have red cross because the result wasn't updated from last check before you changed a script.
                      Sincerely yours,
                      Aleksey

                      Comment

                      • clahti
                        Senior Member
                        • Jan 2007
                        • 126

                        #12
                        ok, the definitive test script, error persists. I am explicitly not adding the last comma here, but I am getting the same problem in zabbix. You can test with this script below to reproduce the issue:

                        Code:
                        Const QQ = """"
                        WScript.echo("[")
                        WScript.echo("    {")
                        WScript.echo("        " & QQ & "data" & QQ & ": [")
                        WScript.echo("	{")
                        WScript.echo("		" & QQ & "{#LSNAME}" & QQ & ":" & QQ & "VAL1" & QQ & ",")
                        WScript.echo("		" & QQ & "{#LSPORT}" & QQ & ":" & QQ & "12345" & QQ)
                        WScript.echo("	}")
                        WScript.echo("	,")
                        WScript.echo("	{")
                        WScript.echo("		" & QQ & "{#LSNAME}" & QQ & ":" & QQ & "VAL2" & QQ & ",")
                        WScript.echo("		" & QQ & "{#LSPORT}" & QQ & ":" & QQ & "12346" & QQ)
                        WScript.echo("	}")
                        WScript.echo("	,")
                        WScript.echo("	{")
                        WScript.echo("		" & QQ & "{#LSNAME}" & QQ & ":" & QQ & "VAL3" & QQ & ",")
                        WScript.echo("		" & QQ & "{#LSPORT}" & QQ & ":" & QQ & "12347" & QQ)
                        WScript.echo("	}")
                        WScript.echo("        ]")
                        WScript.echo("    }")
                        WScript.echo("]")
                        I don't know what I am missing, can someone confirm if the above test code works for them? Maybe I need a more recent agent version, I am running 2.2.3

                        Comment

                        • clahti
                          Senior Member
                          • Jan 2007
                          • 126

                          #13
                          you can drop the above test code on any windows box, then you can see the output via zabbix_get:

                          Code:
                          zabbix_get -s <winhostname> -k system.run["cscript //nologo c:\progra~1\zabbix~1\test.vbs"]
                          the hard coded output is:
                          Code:
                          [
                              {
                                  "data": [
                          	{
                          		"{#LSNAME}":"VAL1",
                          		"{#LSPORT}":"12345"
                          	}
                          	,
                          	{
                          		"{#LSNAME}":"VAL2",
                          		"{#LSPORT}":"12346"
                          	}
                          	,
                          	{
                          		"{#LSNAME}":"VAL3",
                          		"{#LSPORT}":"12347"
                          	}
                                  ]
                              }
                          ]
                          Passes JSON validation however zabbix server error is still "Value should be a JSON object." I don't see any problem with the JSON now...

                          Comment

                          • aib
                            Senior Member
                            • Jan 2014
                            • 1615

                            #14
                            One more note - now zabbix_agent returns .xml file without any spaces to reduce the size of traffic.
                            This is one example:
                            Code:
                            # [B]zabbix_get -s localhost -k vfs.fs.discovery[/B]
                            {"data":[{"{#FSNAME}":"/","{#FSTYPE}":"rootfs"},{"{#FSNAME}":"/proc","{#FSTYPE}":"proc"},{"{#FSNAME}":"/sys","{#FSTYPE}":"sysfs"},{"{#FSNAME}":"/dev","{#FSTYPE}":"devtmpfs"},{"{#FSNAME}":"/dev/pts","{#FSTYPE}":"devpts"},{"{#FSNAME}":"/dev/shm","{#FSTYPE}":"tmpfs"},{"{#FSNAME}":"/","{#FSTYPE}":"ext4"},{"{#FSNAME}":"/proc/bus/usb","{#FSTYPE}":"usbfs"},{"{#FSNAME}":"/boot","{#FSTYPE}":"ext4"},{"{#FSNAME}":"/home","{#FSTYPE}":"xfs"},{"{#FSNAME}":"/proc/sys/fs/binfmt_misc","{#FSTYPE}":"binfmt_misc"}]}
                            #
                            May be it doesn't work because it doesn't like spaces and TAB's?

                            PS I completely forgot to ask you - Which version of Zabbix do you use? Mine is 2.4.4
                            Sincerely yours,
                            Aleksey

                            Comment

                            • clahti
                              Senior Member
                              • Jan 2007
                              • 126

                              #15
                              unfortunately that did not solve the problem, revised test code:

                              Code:
                              WScript.Stdout.Write("[")
                              WScript.Stdout.Write("{")
                              WScript.Stdout.Write(""  &  """"  &  "data"  &  """"  &  ":[")
                              WScript.Stdout.Write("{")
                              WScript.Stdout.Write("" & """" & "{#LSNAME}" & """" & ":" & """" & "VAL1" & """" & ",")
                              WScript.Stdout.Write("" & """" & "{#LSPORT}" & """" & ":" & """" & "12345" & """")
                              WScript.Stdout.Write("}")
                              WScript.Stdout.Write(",")
                              WScript.Stdout.Write("{")
                              WScript.Stdout.Write("" & """" & "{#LSNAME}" & """" & ":" & """" & "VAL2" & """" & ",")
                              WScript.Stdout.Write("" & """" & "{#LSPORT}" & """" & ":" & """" & "12346" & """")
                              WScript.Stdout.Write("}")
                              WScript.Stdout.Write(",")
                              WScript.Stdout.Write("{")
                              WScript.Stdout.Write("" & """" & "{#LSNAME}" & """" & ":" & """" & "VAL3" & """" & ",")
                              WScript.Stdout.Write("" & """" & "{#LSPORT}" & """" & ":" & """" & "12347" & """")
                              WScript.Stdout.Write("}")
                              WScript.Stdout.Write("]")
                              WScript.Stdout.Write("}")
                              WScript.Stdout.Write("]")
                              this outputs:
                              Code:
                              [{"data":[{"{#LSNAME}":"VAL1","{#LSPORT}":"12345"},{"{#LSNAME}":"VAL2","{#LSPORT}":"12346"},{"{#LSNAME}":"VAL3","{#LSPORT}":"12347"}]}]
                              JSON seems valid, server rejects with same error. I am going to upgrade the zabbix agent to a more recent version and see what happens

                              Comment

                              Working...