Mount Points Monitoring
The following two tabs change content below.
Hi, I have written and developed this site to share my experience and ideas with other colleagues. I also started to prepare interview questions and answers for job seekers. I hope it will help you a lot.

Today we are going to discuss about window mount points monitoring in zabbix.  As we know we can monitor File system in zabbix using SNMP (OID – 1.3.6.1.2.1.25.2.3.1) but unfortunatily we don’t have OID to monitor mount points.

Many user or server team wants to monitor mount points but how we can achive it?

Solution is very simple using zabbix agent we can full fill this requirement. Beside the agent we should know the script in window who can give us list of mount points and their utilization and free size.

Let’s discuss about all these step by step.

 

  1. First write the powershell script to get the list of all mount points and their other property also like used size, volume name, free space etc. As we know according to demand other window server may have different number of mount points so at the zabbix side we need to write LLD(Low level discovery rule) to make it dynamic and should work for all window server. So writing powershell script which will return response in json format.
$colItems = Get-WmiObject Win32_Volume -Property DeviceID,DriveType,Name,Label,FreeSpace,Capacity,__CLASS,SerialNumber |
 Where-Object { $_.__CLASS -eq 'Win32_Volume' -and $_.Label -ne 'Recovery' -and $_.DriveType -ne 5 }
$i=0

# Output the JSON header
write-host "{"
write-host " `"data`":["
write-host

foreach ($objItem in $colItems) {
 $i++

if ($i -lt $colItems.Count){
 $line = " { `"{#DEVICEID}`":`"" + ($objItem.DeviceID -replace "\\","\\") + "`" , `"{#NAME}`":`"" + ($objItem.Name -replace "\\","\\") + "`" , `"{#SERIAL}`":`"" + $objItem.SerialNumber + "`" , `"{#LABEL}`":`"" + $objItem.Label + "`" , `"{#CAPACITY}`":`"" + $objItem.Capacity + "`" },"
 write-host $line
 }
 else{
 $line = " { `"{#DEVICEID}`":`"" + ($objItem.DeviceID -replace "\\","\\") + "`" , `"{#NAME}`":`"" + ($objItem.Name -replace "\\","\\") + "`" , `"{#SERIAL}`":`"" + $objItem.SerialNumber + "`" , `"{#LABEL}`":`"" + $objItem.Label + "`" , `"{#CAPACITY}`":`"" + $objItem.Capacity + "`" }"
 write-host $line
 }
}

# Close the JSON message
write-host
write-host " ]"
write-host "}"
write-host

we saved this script with named discover-windows-mount-points.ps1 when we run this script will get the output like below

{
 "data": [
 {
 "{#DEVICEID}": "\\\\?\\Volume{0d178be5-5c8a-11e3-80b4-806e6f6e6963}\\" , "{
 #NAME
 }":"\\\\?\\Volume{
 0d178be5-5c8a-11e3-80b4-806e6f6e6963
 }\\" , "{
 #SERIAL
 }":"2184360498" , "{
 #LABEL
 }":"SystemReserved" , "{
 #CAPACITY
 }":"366997504" }, { "{
 #DEVICEID
 }":"\\\\?\\Volume{
 2675296c-410c-11ea-8102-005056936143
 }\\" , "{
 #NAME
 }":"C: \\Mounts\\Mount_0\\" , "{
 #SERIAL
 }":"2886914525" , "{
 #LABEL
 }":"Mount_0" , "{
 #CAPACITY
 }":"5365559296" }, { "{
 #DEVICEID
 }":"\\\\?\\Volume{
 26752972-410c-11ea-8102-005056936143
 }\\" , "{
 #NAME
 }":"C: \\Mounts\\Mount_1\\" , "{
 #SERIAL
 }":"1109719809" , "{
 #LABEL
 }":"Mount_1" , "{
 #CAPACITY
 }":"5365559296" }, { "{
 #DEVICEID
 }":"\\\\?\\Volume{
 0d178be6-5c8a-11e3-80b4-806e6f6e6963
 }\\" , "{
 #NAME
 }":"C: \\" , "{
 #SERIAL
 }":"1245003037" , "{
 #LABEL
 }":"" , "{
 #CAPACITY
 }":"214378213376" } ] }

 

2. Now let’s install the zabbix agent according to zabbix guidelines. I am assuming you installed agent successfully.

3. Now change the agent configuration file with following property. And add these given usen UserParameter.

Note: In UserParameter we need to give proper path of that powershell script.

UserParameter=discover.win.vol, powershell -NoProfile -ExecutionPolicy Bypass -File "C:\ZabbixAgent\zabbix_win\discover-windows-mount-points.ps1"
UserParameter=get.free.space.vol[*],powershell -nologo -command "Get-WmiObject Win32_Volume -Property DeviceID,FreeSpace | where-object { $_.DeviceID -eq '$1' } | foreach { $_.FreeSpace }"
UserParameter=get.total.space.vol[*],powershell -nologo -command "Get-WmiObject Win32_Volume -Property DeviceID,Capacity | where-object { $_.DeviceID -eq '$1' } | foreach { $_.Capacity }"

Some time above created script return some unsafe special character to zabbix which is not supported by default. So to avoid that error in agent configuration please add below property also.

UnsafeUserParameters=1

After all these changes in agent configuration please don’t forget to restart the agent. Now lets create the template to create LLD rule for zabbix and their prototype items. I have created template with the name “Window_Mount_Point_PRD_Template” copy paste below content to a notepad file and save with “Window_Mount_Point_PRD_Template.xml” name.

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
 <version>3.4</version>
 <date>2020-04-19T15:02:24Z</date>
 <groups>
 <group>
 <name>Custom Templates</name>
 </group>
 </groups>
 <templates>
 <template>
 <template>Window_Mount_Point_PRD_Template</template>
 <name>Window_Mount_Point_PRD_Template</name>
 <description/>
 <groups>
 <group>
 <name>Custom Templates</name>
 </group>
 </groups>
 <applications>
 <application>
 <name>Volume</name>
 </application>
 </applications>
 <items/>
 <discovery_rules>
 <discovery_rule>
 <name>Windows volume discovery</name>
 <type>0</type>
 <snmp_community/>
 <snmp_oid/>
 <key>discover.win.vol</key>
 <delay>30</delay>
 <status>0</status>
 <allowed_hosts/>
 <snmpv3_contextname/>
 <snmpv3_securityname/>
 <snmpv3_securitylevel>0</snmpv3_securitylevel>
 <snmpv3_authprotocol>0</snmpv3_authprotocol>
 <snmpv3_authpassphrase/>
 <snmpv3_privprotocol>0</snmpv3_privprotocol>
 <snmpv3_privpassphrase/>
 <params/>
 <ipmi_sensor/>
 <authtype>0</authtype>
 <username/>
 <password/>
 <publickey/>
 <privatekey/>
 <port/>
 <filter>
 <evaltype>0</evaltype>
 <formula/>
 <conditions/>
 </filter>
 <lifetime>30d</lifetime>
 <description>description</description>
 <item_prototypes>
 <item_prototype>
 <name>Free space on {#NAME}</name>
 <type>0</type>
 <snmp_community/>
 <snmp_oid/>
 <key>get.free.space.vol[{#DEVICEID}]</key>
 <delay>30</delay>
 <history>90d</history>
 <trends>365d</trends>
 <status>0</status>
 <value_type>3</value_type>
 <allowed_hosts/>
 <units>B</units>
 <snmpv3_contextname/>
 <snmpv3_securityname/>
 <snmpv3_securitylevel>0</snmpv3_securitylevel>
 <snmpv3_authprotocol>0</snmpv3_authprotocol>
 <snmpv3_authpassphrase/>
 <snmpv3_privprotocol>0</snmpv3_privprotocol>
 <snmpv3_privpassphrase/>
 <params/>
 <ipmi_sensor/>
 <authtype>0</authtype>
 <username/>
 <password/>
 <publickey/>
 <privatekey/>
 <port/>
 <description/>
 <inventory_link>0</inventory_link>
 <applications>
 <application>
 <name>Volume</name>
 </application>
 </applications>
 <valuemap/>
 <logtimefmt/>
 <preprocessing/>
 <jmx_endpoint/>
 <application_prototypes/>
 <master_item_prototype/>
 </item_prototype>
 <item_prototype>
 <name>Storage Utilization on {#NAME}</name>
 <type>15</type>
 <snmp_community/>
 <snmp_oid/>
 <key>get.percentage.space[{#DEVICEID}]</key>
 <delay>30</delay>
 <history>90d</history>
 <trends>365d</trends>
 <status>0</status>
 <value_type>0</value_type>
 <allowed_hosts/>
 <units>%</units>
 <snmpv3_contextname/>
 <snmpv3_securityname/>
 <snmpv3_securitylevel>0</snmpv3_securitylevel>
 <snmpv3_authprotocol>0</snmpv3_authprotocol>
 <snmpv3_authpassphrase/>
 <snmpv3_privprotocol>0</snmpv3_privprotocol>
 <snmpv3_privpassphrase/>
 <params>last(get.used.space[{#DEVICEID}])/last(&quot;get.total.space.vol[{#DEVICEID}]&quot;,#1) * 100</params>
 <ipmi_sensor/>
 <authtype>0</authtype>
 <username/>
 <password/>
 <publickey/>
 <privatekey/>
 <port/>
 <description/>
 <inventory_link>0</inventory_link>
 <applications>
 <application>
 <name>Volume</name>
 </application>
 </applications>
 <valuemap/>
 <logtimefmt/>
 <preprocessing/>
 <jmx_endpoint/>
 <application_prototypes/>
 <master_item_prototype/>
 </item_prototype>
 <item_prototype>
 <name>Total space on {#NAME}</name>
 <type>0</type>
 <snmp_community/>
 <snmp_oid/>
 <key>get.total.space.vol[{#DEVICEID}]</key>
 <delay>30</delay>
 <history>90d</history>
 <trends>365d</trends>
 <status>0</status>
 <value_type>3</value_type>
 <allowed_hosts/>
 <units>B</units>
 <snmpv3_contextname/>
 <snmpv3_securityname/>
 <snmpv3_securitylevel>0</snmpv3_securitylevel>
 <snmpv3_authprotocol>0</snmpv3_authprotocol>
 <snmpv3_authpassphrase/>
 <snmpv3_privprotocol>0</snmpv3_privprotocol>
 <snmpv3_privpassphrase/>
 <params/>
 <ipmi_sensor/>
 <authtype>0</authtype>
 <username/>
 <password/>
 <publickey/>
 <privatekey/>
 <port/>
 <description/>
 <inventory_link>0</inventory_link>
 <applications>
 <application>
 <name>Volume</name>
 </application>
 </applications>
 <valuemap/>
 <logtimefmt/>
 <preprocessing/>
 <jmx_endpoint/>
 <application_prototypes/>
 <master_item_prototype/>
 </item_prototype>
 <item_prototype>
 <name>Used Space on {#NAME}</name>
 <type>15</type>
 <snmp_community/>
 <snmp_oid/>
 <key>get.used.space[{#DEVICEID}]</key>
 <delay>30</delay>
 <history>90d</history>
 <trends>365d</trends>
 <status>0</status>
 <value_type>0</value_type>
 <allowed_hosts/>
 <units>B</units>
 <snmpv3_contextname/>
 <snmpv3_securityname/>
 <snmpv3_securitylevel>0</snmpv3_securitylevel>
 <snmpv3_authprotocol>0</snmpv3_authprotocol>
 <snmpv3_authpassphrase/>
 <snmpv3_privprotocol>0</snmpv3_privprotocol>
 <snmpv3_privpassphrase/>
 <params>last(&quot;get.total.space.vol[{#DEVICEID}]&quot;,#1) - last(&quot;get.free.space.vol[{#DEVICEID}]&quot;,#1)</params>
 <ipmi_sensor/>
 <authtype>0</authtype>
 <username/>
 <password/>
 <publickey/>
 <privatekey/>
 <port/>
 <description/>
 <inventory_link>0</inventory_link>
 <applications>
 <application>
 <name>Volume</name>
 </application>
 </applications>
 <valuemap/>
 <logtimefmt/>
 <preprocessing/>
 <jmx_endpoint/>
 <application_prototypes/>
 <master_item_prototype/>
 </item_prototype>
 </item_prototypes>
 <trigger_prototypes/>
 <graph_prototypes/>
 <host_prototypes/>
 <jmx_endpoint/>
 </discovery_rule>
 </discovery_rules>
 <httptests/>
 <macros>
 <macro>
 <macro>{$VOL_ALERT}</macro>
 <value>500M</value>
 </macro>
 </macros>
 <templates/>
 <screens/>
 </template>
 </templates>
</zabbix_export>


Once template file saved import into zabbix and link to that host which you want to monitor. Make usre agent connect green.  After 10-15 min of template linking you will be able to see the data as showing in below screenshot.

performance data

You can check the graph also.

graph

 

That’s it. I hope now you will be able to monitor window’s mount points. please share your feedback or comments if any.

248 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *