Powershell script used by Zabbix to display processes


This short script is used by Zabbix monitoring system to display running processes on a Windows Server 2008. I know it’s pretty simple but, the problem with Zabbix is that it can use scripts that return results in json format. The format is quite complicated and maybe this short script will help others that use Zabbix.

$processes = Get-Process

write-host “{”
Write-Host “”data”:[”
foreach($p in $processes)
{
$proc = ” { `”{#SERVICENAME}`” : `”” +$p.Name + “`” },”
write-host $proc
}
write-host
write-host ” ]”
Write-Host “} ”
Write-Host

Powershell script

In case of a wrongly configured format, Zabbix will display the “Value should be a JSON Object” error:

Zabbix error

Best regards

Advertisements

One thought on “Powershell script used by Zabbix to display processes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s