This is a little Powershell script that fetch metric's values from Microsoft WSUS Server.
Actual release 1.3.1
Tested on:
- Production mode: Windows Server 2008 R2 SP1, WSUS 3.0 SP1, Powershell 2;
- Non-production mode: Windows Server 2012 R2, WSUS 6, Powershell 4.
Support objects:
- Info - WSUS informaton;
- Status - WSUS status (number of Approved/Declined/Expired/etc updates, full/partially/unsuccess updated clients and so);
- Database - WSUS database related info;
- Configuration - WSUS configuration info;
- ComputerGroup - Virtual object to taking computer group statistic;
- LastSynchronization - Last Synchronization data;
- SynchronizationProcess - Synchronization process info.
Actions:
- Discovery - Make Zabbix's LLD JSON;
- Get - Get object metric's value;
- Count - Take number of objects in collection (selected with ComputerGroup's ComputersUpToDate virtual key, for example).
Zabbix's LLD available to:
- ComputerGroup.
Virtual keys for ComputerGroup object is:
- ComputerTargetsWithUpdateErrors - Computers updated with errors;
- ComputerTargetsNeedingUpdates - Partially updated computers;
- ComputersUpToDate - Full updated computers;
- ComputerTargetsUnknown - Computers without update information.
Virtual keys for LastSynchronization object is:
- NotSyncInDays - Now much days was not running Synchronization process.
Virtual keys for SynchronizationProcess object:
- Status - Synchronization process status
# Show all metrics of 'Configuration' object and see verbose messages
powershell -NoProfile -ExecutionPolicy "RemoteSigned" -File "wsus_miner.ps1" -Action "Get" -Object "Configuration" -Verbose
# Make Zabbix's LLD JSON for 'ComputerGroup' object. Group names contains Russian Cyrillic symbols
... "wsus_miner.ps1" -Action "Discovery" -Object "ComputerGroup" -consoleCP CP866
# Get number of days passed since the last synchronization
... "wsus_miner.ps1" -Action "Get" -Object "LastSynchronization" -Key "NotSyncInDays"
# Get number of computers that have update errors and placed in ComputerGroup with ID=e4b8b165-4e29-42ec-ac40-66178600ca9b
..."wsus_miner.ps1" -Action "Count" -Object "ComputerGroup" -Key "ComputerTargetsWithUpdateErrors" -Id "e4b8b165-4e29-42ec-ac40-66178600ca9b"
- Just include zbx_wsus_miner.conf to Zabbix Agent config;
- Put wsus_miner.ps1 to C:\zabbix\scripts dir. If you want to place script to other directory, you must edit zbx_wsus_miner.conf to properly set script's path;
- Set Zabbix Agent's / Server's Timeout to more that 3 sec (may be 10 or 30);
- Import template to Zabbix Server;
- Make sure that Zabbix Agent worked in Active mode - in template used 'Zabbix agent(active)' poller type. Otherwise - change its to 'Zabbix agent' and increase value of server's StartPollers parameter;
- Enjoy.
Note Do not try import Zabbix v2.4 template to Zabbix pre v2.4. You need to edit .xml file and make some changes at discovery_rule - filter tags area and change # to <> in trigger expressions. I will try to make template to old Zabbix.
- To see available metrics, run script without "-Key" option: ... "wsus_miner.ps1" -Action "Get" -Object "Status";
- To get on Zabbix Server side properly UTF-8 output when have non-english (for example Russian Cyrillic) symbols in Computer Group's names, use -consoleCP your_native_codepage command line option. For example to convert from Russian Cyrillic codepage (CP866): ... "wsus_miner.ps1" ... -consoleCP CP866;
- If u need additional symbol escaping in LLD JSON - just add one or more symbols to $EscapedSymbols array in PrepareTo-Zabbix function;
- Running the script with PowerShell 3 and above may be require to enable PowerShell 2 compatible mode;
- To measure script runtime use Verbose command line switch,
Beware: frequent connections to WSUS may be nuke host server, make over 9000% CPU utilization and yours requests will be processeed slowly. To avoid it - don't use small update intervals with Zabbix's Data Items and disable unused.