In this blog I will provide you a how-to for configuring agentless monitoring for Microsoft Servers or Workstations via WMI.
What is WMI? Windows Management Instrumentation (WMI) is Microsoft’s implementation of an industry-standard approach to accessing management information in an enterprise environment. WMI uses the industry-standard Common Information Model (CIM) to represent systems, applications, networks, devices, and other managed components. CIM is developed and maintained by the Distributed Management Task Force (DMTF). [More on msdn.microsoft.com].
Here’s what we will go over in this tutorial in order to ensure that you have the right requirements to set up your WMI-based Windows server or workstation monitoring:
Note: This guide is compatible with Windows Server 2008 R2 or newer.
Verify that the WMI service is running by using the server manager, or by running “services.msc”.
Create a local or domain user to access the Windows Server remotely:
Local user definition example:
To perform monitoring, the user account needs permission to access:
To grant those permissions, assign the user to both of these system groups:
Next, we need to give our newly created user access to DCOM on localhost. In order to do this, open Component Services:
In order to remotely access the monitored machine via this user account and obtain the required data from the CIM structure via WMI, you must enable access to the WMI namespace CIMV2.
Windows Firewall Settings
Finally, verify in your firewall settings that the firewall rules are configured to allow incoming WMI requests.
Now you can test WMI via a remote call:
Local connection test:
Get-WmiObject -Namespace "root\cimv2" -Class Win32_Process -Impersonation 3 |
Connecting from the remote computer with credentials:
Get-WmiObject -Class Win32_Process -Impersonation 3 -Credential domain\neteye_wmi -Namespace "root\cimv2" -ComputerName computer.domain |
For more information on this topic as well as for troubleshooting tips, take a look at this article.
[root @neteye ] # yum --enablerepo=neteye install wmic |
Perform a test WMI call using wmic.
Example data used:
[root @neteye ~] # wmic -U net.local/neteye%secret --option="client ntlmv2 auth"=Yes //windows01 "SELECT FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3" CLASS: Win32_LogicalDisk DeviceID|FreeSpace|Name|Size C:|27660132352|C:|101897465856 D:|55664553984|D:|268432306176 E:|20483117056|E:|268432306176 |
The open source plugin check_wmi_plus is an enhancement to the check_wmi.pl script and provides an extensive list of monitoring modes implemented as WMI queries inside this check. At this moment I would like to say a big thank you to the community for its work, and invite you to visit this portal for further details: http://www.edcint.co.nz/checkwmiplus/.
Now it’s time to get ready on NetEye by installing required packages for this check:
[root @neteye ~] # yum --enablerepo=neteye install perl-Number-Format perl-Config-IniFiles |
Now download the check_wmi_plus archive and prepare the configuration. The latest version and the plugin’s related documentation can be found on the project portal:
http://www.edcint.co.nz/checkwmiplus/
On NetEye 3.x we want to install the plugin in /usr/lib64/nagios/plugins, and thus we:
Update 15.1.2019: It is suggested to set in check_wmi_plus.conf this parameter to “1”: $ignore_my_outdated_perl_module_versions=1;
[root @neteye ~] # mkdir -p /usr/lib64/nagios/plugins/check_wmi_plus/etc [root @neteye ~] # cp -r /tmp/check_wmi_plus/etc/* /usr/lib64/nagios/plugins/check_wmi_plus/etc/ [root @neteye ~] # cat /usr/lib64/nagios/plugins/check_wmi_plus/etc/check_wmi_plus/check_wmi_plus.conf (Row 16) $base_dir = '/usr/lib64/nagios/plugins' ; |
Place check_wmi_plus.pl in the plugins path and adapt the configuration path inside the check_wmi_plus.pl file:
[root @neteye ~] # cp -r /tmp/check_wmi_plus/check_wmi_plus.pl /usr/lib64/nagios/plugins/ [root @neteye ~] # vi check_wmi_plus.pl (Row 30) my $conf_file = '/usr/lib64/nagios/plugins/check_wmi_plus/etc/check_wmi_plus/check_wmi_plus.conf' ; |
Now run a preliminary check from the command line to make sure everything is working:
[root @neteye ~] # /usr/lib/nagios/plugins/check_wmi_plus.pl -H myhost -u username -p secret --extrawmicarg --option="client ntlmv2 auth"=Yes -m checkmem -w 98 -c 100 OK - Physical Memory: Total: 12GB - Used: 11.743GB (98%) - Free: 263.027MB (2%)| 'Physical Memory Used' =12608565248Bytes; 'Physical Memory Utilisation' =98%;98;100; |
Upload and import the Service Profile into Monarch:
Here you will find the Monarch service profile for download:
Update 15.1.2019: Visit my Repo on Github. Here you find:
Ready to start monitoring!
Create a host, assign the service checks, configure thresholds and … check the results:
Performance graph of disk-usage in Grafana:
Enjoy monitoring with WMI ,)