Hello,
I wanted to create something in my Zabbix monitoring model so that the interfaces automatically come up and are pinged to determine if they are on or off.
So, I tried several schemes and tutorials on the internet, but without a solution (using preconfigured templates, AI, etc.). For example, when I tried Zabbix discovery items, I had an excessive number of interfaces coming up, and I only want to monitor the interfaces that come up in the Windows system.
So, I ended up trying this:
First, I create an item in my model. Name: Network Interface Discovery Type: Zabbix Agent Key: system.run[powershell -NoProfile -ExecutionPolicy Bypass -File 'C:\Program Files\Zabbix Agent 2\Interface.ps1'] Update Interval: 5s Here is the Interface.ps1 script:
$results = Get-NetAdapter | Where-Object { $.Status -eq 'Up' } | ForEach-Object { $adapter = $ $ip = Get-NetIPAddress -InterfaceIndex $adapter.ifIndex -AddressFamily IPv4 | Select-Object -First 1 [PSCustomObject]@{ "{#INTERFACENAME}" = $adapter.Name "{#STATUS}" = $adapter.Status "{#IPADDRESS}" = $ip.IPAddress } } ConvertTo-Json -InputObject $results
Once this item is created, I create a discovery rule. Name: Agent Availability Type: Zabbix Agent Key: zabbix[host,active_agent,available] Update Interval: 5s
Next, I create an element prototype. Name: {#INTERFACENAME} Type: Dependent Item Key: icmpping[{#IPADDRESS}] Master Item: Windows-Infra: Network Interface Discovery
I'm not sure if I don't understand how Zabbix works or if it's something else.
Thank you in advance; I'm open to any alternative solutions. I just want to clarify that for the ping, I want to use a method that doesn't depend on the agent (to differentiate when the agent is not working and when the interface is not working).
I wanted to create something in my Zabbix monitoring model so that the interfaces automatically come up and are pinged to determine if they are on or off.
So, I tried several schemes and tutorials on the internet, but without a solution (using preconfigured templates, AI, etc.). For example, when I tried Zabbix discovery items, I had an excessive number of interfaces coming up, and I only want to monitor the interfaces that come up in the Windows system.
So, I ended up trying this:
First, I create an item in my model. Name: Network Interface Discovery Type: Zabbix Agent Key: system.run[powershell -NoProfile -ExecutionPolicy Bypass -File 'C:\Program Files\Zabbix Agent 2\Interface.ps1'] Update Interval: 5s Here is the Interface.ps1 script:
$results = Get-NetAdapter | Where-Object { $.Status -eq 'Up' } | ForEach-Object { $adapter = $ $ip = Get-NetIPAddress -InterfaceIndex $adapter.ifIndex -AddressFamily IPv4 | Select-Object -First 1 [PSCustomObject]@{ "{#INTERFACENAME}" = $adapter.Name "{#STATUS}" = $adapter.Status "{#IPADDRESS}" = $ip.IPAddress } } ConvertTo-Json -InputObject $results
Once this item is created, I create a discovery rule. Name: Agent Availability Type: Zabbix Agent Key: zabbix[host,active_agent,available] Update Interval: 5s
Next, I create an element prototype. Name: {#INTERFACENAME} Type: Dependent Item Key: icmpping[{#IPADDRESS}] Master Item: Windows-Infra: Network Interface Discovery
I'm not sure if I don't understand how Zabbix works or if it's something else.
Thank you in advance; I'm open to any alternative solutions. I just want to clarify that for the ping, I want to use a method that doesn't depend on the agent (to differentiate when the agent is not working and when the interface is not working).