After migrating some hosts to Zabbix 2.2.3(also same on 2.3.0) got this error for custom lld:
"Value should be a JSON object."
Still works on our 2.0.0 server though.
Using this script to create JSON formatted response:
In zabbix_server.log (Debug=4):
I've tried changing script to this, but it didn't helped:
Can anyone tell me what am I doing wrong?
"Value should be a JSON object."
Still works on our 2.0.0 server though.
Using this script to create JSON formatted response:
Code:
# Powershell script to fetch a list of autostarted services via WMI and report back in a JSON
# formatted message that Zabbix will understand for Low Level Discovery purposes.
#
# First, fetch the list of auto started services
$colItems = Get-WmiObject Win32_Service | where-object { $_.StartMode -ne 'Disabled' }
# Output the JSON header
write-host "{"
write-host " `"data`":["
write-host
# For each object in the list of services, print the output of the JSON message with the object properties that we are interessted in
foreach ($objItem in $colItems) {
$exe_dir = $objItem.PathName
$exe_dir = $exe_dir -replace '"?(.+\\).+exe.*','$1'
$exe_dir = $exe_dir -replace '\\','/'
$line = " { `"{#SERVICESTATE}`":`"" + $objItem.State + "`" , `"{#SERVICEDISPLAY}`":`"" + $objItem.DisplayName + "`" , `"{#SERVICENAME}`":`"" + $objItem.Name + "`" , `"{#SERVICEDESC}`":`"" + $objItem.Description + "`" , `"{#SERVICEDIR}`":`"" + $exe_dir + "`" },"
write-host $line
}
# Close the JSON message
write-host
write-host " ]"
write-host "}"
write-host
Code:
14160:20140522:181056.951 In lld_rows_get() 14160:20140522:181056.952 End of lld_rows_get():FAIL 14160:20140522:181056.952 End of lld_process_discovery_rule()
Code:
# Powershell script to fetch a list of autostarted services via WMI and report back in a JSON
# formatted message that Zabbix will understand for Low Level Discovery purposes.
#
# First, fetch the list of auto started services
$colItems = Get-WmiObject Win32_Service | where-object { $_.StartMode -ne 'Disabled' }
# Output the JSON header
write-host "{"
write-host " `"data`":["
write-host
# For each object in the list of services, print the output of the JSON message with the object properties that we are interessted in
foreach ($objItem in $colItems) {
$i++
if ($i -lt $colItems.Count){
$exe_dir = $objItem.PathName
$exe_dir = $exe_dir -replace '"?(.+\\).+exe.*','$1'
$exe_dir = $exe_dir -replace '\\','/'
$line = " { `"{#SERVICESTATE}`":`"" + $objItem.State + "`" , `"{#SERVICEDISPLAY}`":`"" + $objItem.DisplayName + "`" , `"{#SERVICENAME}`":`"" + $objItem.Name + "`" , `"{#SERVICEDESC}`":`"" + $objItem.Description + "`" , `"{#SERVICEDIR}`":`"" + $exe_dir + "`" },"
write-host $line
}
else{
$exe_dir = $objItem.PathName
$exe_dir = $exe_dir -replace '"?(.+\\).+exe.*','$1'
$exe_dir = $exe_dir -replace '\\','/'
$line = " { `"{#SERVICESTATE}`":`"" + $objItem.State + "`" , `"{#SERVICEDISPLAY}`":`"" + $objItem.DisplayName + "`" , `"{#SERVICENAME}`":`"" + $objItem.Name + "`" , `"{#SERVICEDESC}`":`"" + $objItem.Description + "`" , `"{#SERVICEDIR}`":`"" + $exe_dir + "`" }"
write-host $line
}
}
# Close the JSON message
write-host
write-host " ]"
write-host "}"
write-host

Comment