This monitoring template is done using discovery feature in Zabbix and detects if physical interface on server has carrier.
- If physical interface is up and has carrier - returns 1.
- If physical interface is has no carrier or is down - returns 0.
- Create or use already created template.
- In administration->general menu go to Regular Expressions and do following.
- Add new regular expression Physical network interface discovery.
- Use regular expression ^(em[0-9]{1,}|p[0-9]{1,}p[0-9]{1,}|eth[0-9]{1,}|ens[0-9]{1,})$.
- Add discovery rule to your template with key net.phys.if.discovery .
- Filter is {#PHYSNET}.
- Regular expression is @Physical network interface discovery.
- Add item prototype with key net.if.carrier.status[{#PHYSNET}].
- Add trigger with expression {Template OS Linux:net.if.carrier.status[{#PHYSNET}].last()}=0.
- Deploy script netif_discovery.sh from this repository to all hosts (preferably with Salt/Ansible) into path /usr/local/sbin/netif_discovery.sh.
Use following user parameters:
UserParameter=net.phys.if.discovery,/usr/local/sbin/netif_discovery.sh
UserParameter=net.if.carrier.status[*], if [ $(cat /sys/class/net/$1/operstate) = "up" ]; then cat /sys/class/net/$1/carrier; else echo "0"; fi;
http://stackoverflow.com/questions/808560/how-to-detect-the-physical-connected-state-of-a-network-cable-connector https://www.zabbix.com/documentation/3.0/manual/discovery/low_level_discovery