📜 ⬆️ ⬇️

Zabbix: LLD monitoring of iron under Windows on PowerShell

Changelog

The time has come for me to assemble my bike to monitor the physical state of Windows hardware. I could not find a complete solution or at least more or less working since my acquaintance with Zabbix, which is more than 3 years. And even more so that it was ... elegant or something. Personally, even in such things I want to see slimness and maximum functionality. That is why only LLD and PowerShell are discussed below. And of course, only free software.

So, monitoring of what will be done:
')

And it will all look something like this:



Totally needed:

  1. smartmontools
  2. Openhardwaremonitor
  3. NSSM
  4. 2 PS scripts below
  5. template

Template


Under the spoiler is the current template. Just save the content in xml format and import it into your Zabbix.

Template
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>3.2</version>
<date>2017-03-01T13:35:09Z</date>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>
<template>
<template>Hardware - Windows</template>
<name>Hardware - Windows</name>
<description> :&#13;
smartmontools ( Path), OHM ( )&#13;
&#13;
:&#13;
windows.hard.ps1 -&gt; C:\System\Zabbix\Scripts\&#13;
&#13;
UserParameter=ZScript[*],powershell C:\System\Zabbix\Scripts\windows.$1.ps1 &quot;$2&quot; &quot;$3&quot;</description>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<applications>
<application>
<name> </name>
</application>
<application>
<name></name>
</application>
</applications>
<items>
<item>
<name> BIOS</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hard,VBAT]</key>
<delay>300</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>V</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name></name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
</items>
<discovery_rules>
<discovery_rule>
<name> </name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
<key>ZScript[hard,discovery,fan]</key>
<delay>7200</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/>
<delay_flex/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>
<evaltype>0</evaltype>
<formula/>
<conditions/>
</filter>
<lifetime>3</lifetime>
<description/>
<item_prototypes>
<item_prototype>
<name> {#NAME}</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hard,{#ID},fan]</key>
<delay>300</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name></name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
</item_prototypes>
<trigger_prototypes>
<trigger_prototype>
<expression>{Hardware - Windows:ZScript[hard,{#ID},fan].avg(#3)}&lt;150</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name> {#NAME} {HOST.NAME}</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>3</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
</trigger_prototypes>
<graph_prototypes/>
<host_prototypes/>
</discovery_rule>
<discovery_rule>
<name> </name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
<key>ZScript[hard,discovery,temperature]</key>
<delay>7200</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/>
<delay_flex/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>
<evaltype>0</evaltype>
<formula/>
<conditions/>
</filter>
<lifetime>3</lifetime>
<description/>
<item_prototypes>
<item_prototype>
<name> {#NAME}</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hard,{#ID},temperature]</key>
<delay>120</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>°C</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name></name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
</item_prototypes>
<trigger_prototypes>
<trigger_prototype>
<expression>{Hardware - Windows:ZScript[hard,{#ID},temperature].last(#3)}&gt;60</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name> {#NAME} {HOST.NAME}!</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>4</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
<trigger_prototype>
<expression>{Hardware - Windows:ZScript[hard,{#ID},temperature].last(#3)}&gt;70</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name> {#NAME} {HOST.NAME}!</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>5</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
</trigger_prototypes>
<graph_prototypes/>
<host_prototypes/>
</discovery_rule>
<discovery_rule>
<name> </name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
<key>ZScript[hard,discovery,voltage]</key>
<delay>7200</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/>
<delay_flex/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>
<evaltype>0</evaltype>
<formula/>
<conditions/>
</filter>
<lifetime>3</lifetime>
<description/>
<item_prototypes>
<item_prototype>
<name> {#NAME}</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hard,{#ID},voltage]</key>
<delay>300</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>V</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name></name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
</item_prototypes>
<trigger_prototypes/>
<graph_prototypes/>
<host_prototypes/>
</discovery_rule>
<discovery_rule>
<name> </name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
<key>ZScript[hdd,discovery]</key>
<delay>7200</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/>
<delay_flex/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>
<evaltype>0</evaltype>
<formula/>
<conditions/>
</filter>
<lifetime>3</lifetime>
<description/>
<item_prototypes>
<item_prototype>
<name> {#DISKID} - SMART - Spin-Up Time [3]</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},3]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Reallocated Sectors Count [5]</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},5]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Seek Error Rate [7]</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},7]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Power-on Time Count [9] ()</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},9]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Spin-Up Retry Count [10]</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},10]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - G-sense error rate [191]</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},191]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - [194]</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},194]</key>
<delay>300</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>°C</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Reallocation Event Count [196]</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},196]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Current Pending Sector Count [197]</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},197]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Uncorrectable Sector Count [198]</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},198]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - UltraDMA CRC Error Count [199]</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},199]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - </name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},capacity]</key>
<delay>3600</delay>
<history>7</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - </name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},family]</key>
<delay>3600</delay>
<history>7</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - FW</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},fw]</key>
<delay>3600</delay>
<history>7</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - </name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},model]</key>
<delay>3600</delay>
<history>7</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - </name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},serial]</key>
<delay>3600</delay>
<history>7</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ZScript[hdd,{#DISKID},status]</key>
<delay>300</delay>
<history>7</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
</item_prototypes>
<trigger_prototypes>
<trigger_prototype>
<expression>{Hardware - Windows:ZScript[hdd,{#DISKID},status].regexp(^PASSED$)}=1</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name>SMART {HOST.NAME}</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>4</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
<trigger_prototype>
<expression>{Hardware - Windows:ZScript[hdd,{#DISKID},194].last()}&gt;55</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name> {HOST.NAME}</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>3</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
<trigger_prototype>
<expression>{Hardware - Windows:ZScript[hdd,{#DISKID},194].last()}&gt;60</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name> {HOST.NAME}</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>4</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
</trigger_prototypes>
<graph_prototypes/>
<host_prototypes/>
</discovery_rule>
</discovery_rules>
<httptests/>
<macros/>
<templates/>
<screens/>
</template>
</templates>
<triggers>
<trigger>
<expression>{Hardware - Windows:ZScript[hard,VBAT].last(#3)}&lt;2.9</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name> BIOS {HOST.NAME}</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>3</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger>
</triggers>
</zabbix_export>


The template was created in Zabbix version 3.2, it may work in earlier versions. The keys are standard and are of the form ZScript [script_name, parameter1, .., parameterN] . Parameters are passed directly to the script itself.

I hope the template turned out as simple and clear as possible.

PS scripts


Below are the necessary scripts. Inside, both the detection and the request of individual elements are already located. Work tested on Windows from XP SP3 to 2016. Of course, the decision with the Execution Policy is yours.

windows.hdd.ps1 -> For smartmontools
# 2017/04/12 AcidVenom v3
# Zabbix
param($1,$2)
#
# : discovery
if ($1 -eq "discovery") {
try {
$items = smartctl-nc --scan-open | where {$_ -match "/dev/sd"}
write-host -NoNewline "{"
write-host -NoNewline "`"data`":["
$n = 0
foreach ($obj in $items) {
if ((smartctl-nc -i $obj.substring(0,8) | where {$_ -match "SMART support is: Enabled"}) -ne $null) {
$n = $n + 1
If ($n -gt 1) {write-host -NoNewline ","}
$line = "{`"{#DISKID}`":`"" + ($obj.substring(5,3)) + "`"}"
write-host -NoNewline $line
}
}
write-host -NoNewline "]"
write-host -NoNewline "}"
}
catch {exit}
}
#
# :
else {
try {
if ($2 -eq "status") {
$obj = smartctl-nc -H /dev/$1 | where {$_ -match "result:"}
$obj = $obj.substring(50)
}
elseif ($2 -eq "model") {
$obj = smartctl-nc -i /dev/$1 | where {$_ -match "Device Model:"}
$obj = $obj.substring(18)
}
elseif ($2 -eq "family") {
$obj = smartctl-nc -i /dev/$1 | where {$_ -match "Model Family:"}
$obj = $obj.substring(18)
}
elseif ($2 -eq "fw") {
$obj = smartctl-nc -i /dev/$1 | where {$_ -match "Firmware Version:"}
$obj = $obj.substring(18)
}
elseif ($2 -eq "serial") {
$obj = smartctl-nc -i /dev/$1 | where {$_ -match "Serial Number:"}
$obj = $obj.substring(18)
}
elseif ($2 -eq "capacity") {
$obj = smartctl-nc -i /dev/$1 | where {$_ -match "User Capacity:"}
if ($obj -match "User Capacity:") {
$obj = $obj.Substring($obj.IndexOf("[")+1,$obj.IndexOf("]")-$obj.IndexOf("[")-1)
}
else {
$obj = "N/A"
}}
# SMART
#
else {
$obj = smartctl-nc -A /dev/$1 | where {$_ -match "^ *$2"}
try {$obj = $obj.Substring(87,$obj.IndexOf("(")-87)}
catch {$obj = $obj.Substring(87)}
}}
catch {$obj = ""}
Write-Output $obj
}
view raw windows.hdd.ps1 hosted with ❤ by GitHub


Only disks with enabled SMART are detected. Parameters are requested from the "RAW_VALUE" column. Want to monitor another parameter? Just enter his number. By default, brackets and their contents are discarded. If the drive you need does not give the parameter, then an empty field is returned.

windows.hard.ps1 -> for OHM
# 2017/02/13 AcidVenom v2
# Zabbix
param($1,$2)
# , ,
# : discovery temperature/voltage/fan
if ($1 -eq "discovery") {
$items = Get-WmiObject -Namespace Root\OpenHardwareMonitor -Class sensor | Where-Object {$_.SensorType -eq "$2" -and $_.Name -notmatch "#|VBAT" -and $_.Parent -notmatch "hdd"}
write-host -NoNewline "{"
write-host -NoNewline "`"data`":["
$n = 0
foreach ($obj in $items) {
$n = $n + 1
$line = "{`"{#ID}`":`"" + $obj.InstanceId + "`", `"{#NAME}`":`"" + $obj.Name + "`"}"
If ($n -lt $items.Count) { $line = "$line,"}
write-host -NoNewline $line
}
write-host -NoNewline "]"
write-host -NoNewline "}"
}
#
# : VBAT
elseif ($1 -eq "VBAT") {
$obj = (Get-WmiObject -Namespace Root\OpenHardwareMonitor -Class sensor | Where-Object {$_.Name -eq "$1"}).Value -replace(",",".")
Write-Host -NoNewline $obj
}
# InstaceId discovery
#
else {
if ((Get-WmiObject -Namespace Root\OpenHardwareMonitor -Class sensor | Where-Object {$_.InstanceId -eq "$1"}).SensorType -eq "Voltage") {
$obj = (Get-WmiObject -Namespace Root\OpenHardwareMonitor -Class sensor | Where-Object {$_.InstanceId -eq "$1"}).Value -replace(",",".")}
else {$obj = (Get-WmiObject -Namespace Root\OpenHardwareMonitor -Class sensor | Where-Object {$_.InstanceId -eq "$1"}).Value -replace(",.*","")}
Write-Host -NoNewline $obj
}
view raw windows.hard.ps1 hosted with ❤ by GitHub


By default, the script does not detect the names of sensors that have # . For what it is needed, see below.

Also reserved is one sensor name - Vbat. This is the voltage of the BIOS battery. Its value is rendered into a separate element for a trigger (triggered if less than 2.9V).

The temperatures and revolutions of the coolers at the output are integer, the voltages are transmitted as is.

Theoretically, it is possible to detect other indicators (loads, frequencies, ..). Use the corresponding second parameter in the key for this. For example: ZScript [hard, discovery, load] .

Zabbix agent preparation


For maximum unification, I use the following and only parameter for my scripts:

UserParameter=ZScript[*],powershell C:\System\Zabbix\Scripts\windows.$1.ps1 "$2" "$3" 

This gives maximum flexibility and uniformity. If you need to add more parameters for any scripts, you can simply add variables in quotes. This will not affect current running scripts. I use the windows prefix just in case, it's so convenient for me to store templates for guaranteed identification.

smartmontools


To monitor the status of disks, smartmontools is used (version 6.5 at the time of this writing). When installing the software, the smartctl-nc utility is installed by default - it is used in the script to facilitate the life of your server. You also need to set the bin folder in variable environments.



We simply add the path to the end of the Path variable separated by a semicolon. Default is C: \ Program Files \ smartmontools \ bin



Openhardwaremonitor


For sensors, OHM is used. Software is free with open source. Installation is trivial, but to complete the work you need to run the program as a service. For such things there is NSSM, I would still advise downloading the latest build . And here you can see the syntax.
The promised choice of sensors is ensured by the fact that the names of the sensors can be changed ! Change the names to readable (they will be used in the names of the elements), and comment on unnecessary sensors.

Do not forget to restart the program / service to use the rename.



Total


The result was a good monitoring tool. Those interested can hang their triggers on the desired prototype elements. Or completely rework the template.

2017/07/05 UPDATE : Fixed a bug in windows.hdd.ps1 - now a comma does not appear in JSON at the beginning.

Source: https://habr.com/ru/post/322668/


All Articles