只监控网卡
将一下内容保存为 XML 文件导入, 该文件头在 4.4.6 版本正常导入
搜索关键词Template Module Linux network interfaces by Zabbix agent active
输入一个新名称完成克隆
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>5.0</version>
<date>2020-10-10T07:07:35Z</date>
<groups>
<group>
<name>Templates/Modules</name>
</group>
</groups>
<templates>
<template>
<template>kuaicdn-network</template>
<name>kuaicdn-network</name>
<description>Known Issues:
Description: High interface utilization trigger is removed since currently it is not possible to retrieve interface speed to determine the max bandwidth.
Template tooling version used: 0.36</description>
<groups>
<group>
<name>Templates/Modules</name>
</group>
</groups>
<applications>
<application>
<name>Network interfaces</name>
</application>
</applications>
<discovery_rules>
<discovery_rule>
<name>Network interface discovery</name>
<type>ZABBIX_ACTIVE</type>
<key>net.if.discovery</key>
<delay>1h</delay>
<filter>
<evaltype>AND</evaltype>
<conditions>
<condition>
<macro>{#IFNAME}</macro>
<value>{$NET.IF.IFNAME.MATCHES}</value>
<formulaid>A</formulaid>
</condition>
<condition>
<macro>{#IFNAME}</macro>
<value>{$NET.IF.IFNAME.NOT_MATCHES}</value>
<operator>NOT_MATCHES_REGEX</operator>
<formulaid>B</formulaid>
</condition>
</conditions>
</filter>
<description>Discovery of network interfaces.</description>
<item_prototypes>
<item_prototype>
<name>Interface {#IFNAME}: Inbound packets discarded</name>
<type>ZABBIX_ACTIVE</type>
<key>net.if.in["{#IFNAME}",dropped]</key>
<delay>3m</delay>
<history>7d</history>
<application_prototypes>
<application_prototype>
<name>Interface {#IFNAME}</name>
</application_prototype>
</application_prototypes>
<preprocessing>
<step>
<type>CHANGE_PER_SECOND</type>
<params/>
</step>
</preprocessing>
</item_prototype>
<item_prototype>
<name>Interface {#IFNAME}: Inbound packets with errors</name>
<type>ZABBIX_ACTIVE</type>
<key>net.if.in["{#IFNAME}",errors]</key>
<delay>3m</delay>
<history>7d</history>
<application_prototypes>
<application_prototype>
<name>Interface {#IFNAME}</name>
</application_prototype>
</application_prototypes>
<preprocessing>
<step>
<type>CHANGE_PER_SECOND</type>
<params/>
</step>
</preprocessing>
</item_prototype>
<item_prototype>
<name>Interface {#IFNAME}: Bits received</name>
<type>ZABBIX_ACTIVE</type>
<key>net.if.in["{#IFNAME}"]</key>
<history>7d</history>
<units>bps</units>
<application_prototypes>
<application_prototype>
<name>Interface {#IFNAME}</name>
</application_prototype>
</application_prototypes>
<preprocessing>
<step>
<type>CHANGE_PER_SECOND</type>
<params/>
</step>
<step>
<type>MULTIPLIER</type>
<params>8</params>
</step>
</preprocessing>
</item_prototype>
<item_prototype>
<name>Interface {#IFNAME}: Outbound packets discarded</name>
<type>ZABBIX_ACTIVE</type>
<key>net.if.out["{#IFNAME}",dropped]</key>
<delay>3m</delay>
<history>7d</history>
<application_prototypes>
<application_prototype>
<name>Interface {#IFNAME}</name>
</application_prototype>
</application_prototypes>
<preprocessing>
<step>
<type>CHANGE_PER_SECOND</type>
<params/>
</step>
</preprocessing>
</item_prototype>
<item_prototype>
<name>Interface {#IFNAME}: Outbound packets with errors</name>
<type>ZABBIX_ACTIVE</type>
<key>net.if.out["{#IFNAME}",errors]</key>
<delay>3m</delay>
<history>7d</history>
<application_prototypes>
<application_prototype>
<name>Interface {#IFNAME}</name>
</application_prototype>
</application_prototypes>
<preprocessing>
<step>
<type>CHANGE_PER_SECOND</type>
<params/>
</step>
</preprocessing>
</item_prototype>
<item_prototype>
<name>Interface {#IFNAME}: Bits sent</name>
<type>ZABBIX_ACTIVE</type>
<key>net.if.out["{#IFNAME}"]</key>
<history>7d</history>
<units>bps</units>
<application_prototypes>
<application_prototype>
<name>Interface {#IFNAME}</name>
</application_prototype>
</application_prototypes>
<preprocessing>
<step>
<type>CHANGE_PER_SECOND</type>
<params/>
</step>
<step>
<type>MULTIPLIER</type>
<params>8</params>
</step>
</preprocessing>
</item_prototype>
<item_prototype>
<name>Interface {#IFNAME}: Operational status</name>
<type>ZABBIX_ACTIVE</type>
<key>vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"]</key>
<history>7d</history>
<trends>0</trends>
<description>Indicates the interface RFC2863 operational state as a string.
Possible values are:"unknown", "notpresent", "down", "lowerlayerdown", "testing","dormant", "up".
Reference: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net</description>
<application_prototypes>
<application_prototype>
<name>Interface {#IFNAME}</name>
</application_prototype>
</application_prototypes>
<valuemap>
<name>IF-MIB::ifOperStatus</name>
</valuemap>
<preprocessing>
<step>
<type>JAVASCRIPT</type>
<params>var newvalue;
switch(value) {
case "up":
newvalue = 1;
break;
case "down":
newvalue = 2;
break;
case "testing":
newvalue = 4;
break;
case "unknown":
newvalue = 5;
break;
case "dormant":
newvalue = 6;
break;
case "notPresent":
newvalue = 7;
break;
default:
newvalue = "Problem parsing interface operstate in JS";
}
return newvalue;</params>
</step>
</preprocessing>
<trigger_prototypes>
<trigger_prototype>
<expression>{$IFCONTROL:"{#IFNAME}"}=1 and ({last()}=2 and {diff()}=1)</expression>
<recovery_mode>RECOVERY_EXPRESSION</recovery_mode>
<recovery_expression>{last()}<>2 or {$IFCONTROL:"{#IFNAME}"}=0</recovery_expression>
<name>Interface {#IFNAME}: Link down</name>
<opdata>Current state: {ITEM.LASTVALUE1}</opdata>
<priority>AVERAGE</priority>
<description>This trigger expression works as follows:
1. Can be triggered if operations status is down.
2. {$IFCONTROL:"{#IFNAME}"}=1 - user can redefine Context macro to value - 0. That marks this interface as not important. No new trigger will be fired if this interface is down.
3. {TEMPLATE_NAME:METRIC.diff()}=1) - trigger fires only if operational status was up(1) sometime before. (So, do not fire 'ethernal off' interfaces.)
WARNING: if closed manually - won't fire again on next poll, because of .diff.</description>
</trigger_prototype>
</trigger_prototypes>
</item_prototype>
<item_prototype>
<name>Interface {#IFNAME}: Interface type</name>
<type>ZABBIX_ACTIVE</type>
<key>vfs.file.contents["/sys/class/net/{#IFNAME}/type"]</key>
<delay>1h</delay>
<history>7d</history>
<trends>0d</trends>
<description>Indicates the interface protocol type as a decimal value.
See include/uapi/linux/if_arp.h for all possible values.
Reference: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net</description>
<application_prototypes>
<application_prototype>
<name>Interface {#IFNAME}</name>
</application_prototype>
</application_prototypes>
<valuemap>
<name>Linux::Interface protocol types</name>
</valuemap>
<preprocessing>
<step>
<type>DISCARD_UNCHANGED_HEARTBEAT</type>
<params>1d</params>
</step>
</preprocessing>
</item_prototype>
</item_prototypes>
<trigger_prototypes>
<trigger_prototype>
<expression>{kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/type"].change()}<0 and {kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/type"].last()}>0
and
({kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/type"].last()}=6
or {kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/type"].last()}=1)
and
({kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"].last()}<>2)</expression>
<recovery_mode>RECOVERY_EXPRESSION</recovery_mode>
<recovery_expression>({kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/type"].change()}>0 and {kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/type"].prev()}>0) or
({kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"].last()}=2)</recovery_expression>
<name>Interface {#IFNAME}: Ethernet has changed to lower speed than it was before</name>
<opdata>Current reported speed: {ITEM.LASTVALUE1}</opdata>
<priority>INFO</priority>
<description>This Ethernet connection has transitioned down from its known maximum speed. This might be a sign of autonegotiation issues. Ack to close.</description>
<dependencies>
<dependency>
<name>Interface {#IFNAME}: Link down</name>
<expression>{$IFCONTROL:"{#IFNAME}"}=1 and ({kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"].last()}=2 and {kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"].diff()}=1)</expression>
<recovery_expression>{kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"].last()}<>2 or {$IFCONTROL:"{#IFNAME}"}=0</recovery_expression>
</dependency>
</dependencies>
</trigger_prototype>
<trigger_prototype>
<expression>{kuaicdn-network:net.if.in["{#IFNAME}",errors].min(5m)}>{$IF.ERRORS.WARN:"{#IFNAME}"}
or {kuaicdn-network:net.if.out["{#IFNAME}",errors].min(5m)}>{$IF.ERRORS.WARN:"{#IFNAME}"}</expression>
<recovery_mode>RECOVERY_EXPRESSION</recovery_mode>
<recovery_expression>{kuaicdn-network:net.if.in["{#IFNAME}",errors].max(5m)}<{$IF.ERRORS.WARN:"{#IFNAME}"}*0.8
and {kuaicdn-network:net.if.out["{#IFNAME}",errors].max(5m)}<{$IF.ERRORS.WARN:"{#IFNAME}"}*0.8</recovery_expression>
<name>Interface {#IFNAME}: High error rate ( > {$IF.ERRORS.WARN:"{#IFNAME}"} for 5m)</name>
<opdata>errors in: {ITEM.LASTVALUE1}, errors out: {ITEM.LASTVALUE2}</opdata>
<priority>WARNING</priority>
<description>Recovers when below 80% of {$IF.ERRORS.WARN:"{#IFNAME}"} threshold</description>
<dependencies>
<dependency>
<name>Interface {#IFNAME}: Link down</name>
<expression>{$IFCONTROL:"{#IFNAME}"}=1 and ({kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"].last()}=2 and {kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"].diff()}=1)</expression>
<recovery_expression>{kuaicdn-network:vfs.file.contents["/sys/class/net/{#IFNAME}/operstate"].last()}<>2 or {$IFCONTROL:"{#IFNAME}"}=0</recovery_expression>
</dependency>
</dependencies>
</trigger_prototype>
</trigger_prototypes>
<graph_prototypes>
<graph_prototype>
<name>Interface {#IFNAME}: Network traffic</name>
<graph_items>
<graph_item>
<drawtype>GRADIENT_LINE</drawtype>
<color>1A7C11</color>
<item>
<host>kuaicdn-network</host>
<key>net.if.in["{#IFNAME}"]</key>
</item>
</graph_item>
<graph_item>
<sortorder>1</sortorder>
<drawtype>BOLD_LINE</drawtype>
<color>2774A4</color>
<item>
<host>kuaicdn-network</host>
<key>net.if.out["{#IFNAME}"]</key>
</item>
</graph_item>
<graph_item>
<sortorder>2</sortorder>
<color>F63100</color>
<yaxisside>RIGHT</yaxisside>
<item>
<host>kuaicdn-network</host>
<key>net.if.out["{#IFNAME}",errors]</key>
</item>
</graph_item>
<graph_item>
<sortorder>3</sortorder>
<color>A54F10</color>
<yaxisside>RIGHT</yaxisside>
<item>
<host>kuaicdn-network</host>
<key>net.if.in["{#IFNAME}",errors]</key>
</item>
</graph_item>
<graph_item>
<sortorder>4</sortorder>
<color>FC6EA3</color>
<yaxisside>RIGHT</yaxisside>
<item>
<host>kuaicdn-network</host>
<key>net.if.out["{#IFNAME}",dropped]</key>
</item>
</graph_item>
<graph_item>
<sortorder>5</sortorder>
<color>6C59DC</color>
<yaxisside>RIGHT</yaxisside>
<item>
<host>kuaicdn-network</host>
<key>net.if.in["{#IFNAME}",dropped]</key>
</item>
</graph_item>
</graph_items>
</graph_prototype>
</graph_prototypes>
</discovery_rule>
</discovery_rules>
<macros>
<macro>
<macro>{$IF.ERRORS.WARN}</macro>
<value>2</value>
</macro>
<macro>
<macro>{$IFCONTROL}</macro>
<value>1</value>
</macro>
<macro>
<macro>{$NET.IF.IFNAME.MATCHES}</macro>
<value>^.*$</value>
</macro>
<macro>
<macro>{$NET.IF.IFNAME.NOT_MATCHES}</macro>
<value>(^Software Loopback Interface|^NULL[0-9.]*$|^[Ll]o[0-9.]*$|^[Ss]ystem$|^Nu[0-9.]*$|^veth[0-9a-z]+$|docker[0-9]+|br-[a-z0-9]{12})</value>
<description>Filter out loopbacks, nulls, docker veth links and docker0 bridge by default</description>
</macro>
</macros>
<screens>
<screen>
<name>Network interfaces</name>
<hsize>1</hsize>
<vsize>1</vsize>
<screen_items>
<screen_item>
<resourcetype>20</resourcetype>
<style>0</style>
<resource>
<name>Interface {#IFNAME}: Network traffic</name>
<host>kuaicdn-network</host>
</resource>
<width>500</width>
<height>100</height>
<x>0</x>
<y>0</y>
<colspan>1</colspan>
<rowspan>1</rowspan>
<elements>25</elements>
<valign>0</valign>
<halign>0</halign>
<dynamic>0</dynamic>
<sort_triggers>0</sort_triggers>
<url/>
<application/>
<max_columns>3</max_columns>
</screen_item>
</screen_items>
</screen>
</screens>
</template>
</templates>
<value_maps>
<value_map>
<name>IF-MIB::ifOperStatus</name>
<mappings>
<mapping>
<value>1</value>
<newvalue>up</newvalue>
</mapping>
<mapping>
<value>2</value>
<newvalue>down</newvalue>
</mapping>
<mapping>
<value>4</value>
<newvalue>unknown</newvalue>
</mapping>
<mapping>
<value>5</value>
<newvalue>dormant</newvalue>
</mapping>
<mapping>
<value>6</value>
<newvalue>notPresent</newvalue>
</mapping>
<mapping>
<value>7</value>
<newvalue>lowerLayerDown</newvalue>
</mapping>
</mappings>
</value_map>
<value_map>
<name>Linux::Interface protocol types</name>
<mappings>
<mapping>
<value>0</value>
<newvalue>from KA9Q: NET/ROM pseudo</newvalue>
</mapping>
<mapping>
<value>1</value>
<newvalue>Ethernet</newvalue>
</mapping>
<mapping>
<value>2</value>
<newvalue>Experimental Ethernet</newvalue>
</mapping>
<mapping>
<value>3</value>
<newvalue>AX.25 Level 2</newvalue>
</mapping>
<mapping>
<value>4</value>
<newvalue>PROnet token ring</newvalue>
</mapping>
<mapping>
<value>5</value>
<newvalue>Chaosnet</newvalue>
</mapping>
<mapping>
<value>6</value>
<newvalue>IEEE 802.2 Ethernet/TR/TB</newvalue>
</mapping>
<mapping>
<value>7</value>
<newvalue>ARCnet</newvalue>
</mapping>
<mapping>
<value>8</value>
<newvalue>APPLEtalk</newvalue>
</mapping>
<mapping>
<value>15</value>
<newvalue>Frame Relay DLCI</newvalue>
</mapping>
<mapping>
<value>19</value>
<newvalue>ATM</newvalue>
</mapping>
<mapping>
<value>23</value>
<newvalue>Metricom STRIP (new IANA id)</newvalue>
</mapping>
<mapping>
<value>24</value>
<newvalue>IEEE 1394 IPv4 - RFC 2734</newvalue>
</mapping>
<mapping>
<value>27</value>
<newvalue>EUI-64</newvalue>
</mapping>
<mapping>
<value>32</value>
<newvalue>InfiniBand</newvalue>
</mapping>
<mapping>
<value>256</value>
<newvalue>ARPHRD_SLIP</newvalue>
</mapping>
<mapping>
<value>257</value>
<newvalue>ARPHRD_CSLIP</newvalue>
</mapping>
<mapping>
<value>258</value>
<newvalue>ARPHRD_SLIP6</newvalue>
</mapping>
<mapping>
<value>259</value>
<newvalue>ARPHRD_CSLIP6</newvalue>
</mapping>
<mapping>
<value>260</value>
<newvalue>Notional KISS type</newvalue>
</mapping>
<mapping>
<value>264</value>
<newvalue>ARPHRD_ADAPT</newvalue>
</mapping>
<mapping>
<value>270</value>
<newvalue>ARPHRD_ROSE</newvalue>
</mapping>
<mapping>
<value>271</value>
<newvalue>CCITT X.25</newvalue>
</mapping>
<mapping>
<value>272</value>
<newvalue>Boards with X.25 in firmware</newvalue>
</mapping>
<mapping>
<value>280</value>
<newvalue>Controller Area Network</newvalue>
</mapping>
<mapping>
<value>512</value>
<newvalue>ARPHRD_PPP</newvalue>
</mapping>
<mapping>
<value>513</value>
<newvalue>Cisco HDLC</newvalue>
</mapping>
<mapping>
<value>516</value>
<newvalue>LAPB</newvalue>
</mapping>
<mapping>
<value>517</value>
<newvalue>Digital's DDCMP protocol</newvalue>
</mapping>
<mapping>
<value>518</value>
<newvalue>Raw HDLC</newvalue>
</mapping>
<mapping>
<value>519</value>
<newvalue>Raw IP</newvalue>
</mapping>
<mapping>
<value>768</value>
<newvalue>IPIP tunnel</newvalue>
</mapping>
<mapping>
<value>769</value>
<newvalue>IP6IP6 tunnel</newvalue>
</mapping>
<mapping>
<value>770</value>
<newvalue>Frame Relay Access Device</newvalue>
</mapping>
<mapping>
<value>771</value>
<newvalue>SKIP vif</newvalue>
</mapping>
<mapping>
<value>772</value>
<newvalue>Loopback device</newvalue>
</mapping>
<mapping>
<value>773</value>
<newvalue>Localtalk device</newvalue>
</mapping>
<mapping>
<value>774</value>
<newvalue>Fiber Distributed Data Interface</newvalue>
</mapping>
<mapping>
<value>775</value>
<newvalue>AP1000 BIF</newvalue>
</mapping>
<mapping>
<value>776</value>
<newvalue>sit0 device - IPv6-in-IPv4</newvalue>
</mapping>
<mapping>
<value>777</value>
<newvalue>IP over DDP tunneller</newvalue>
</mapping>
<mapping>
<value>778</value>
<newvalue>GRE over IP</newvalue>
</mapping>
<mapping>
<value>779</value>
<newvalue>PIMSM register interface</newvalue>
</mapping>
<mapping>
<value>780</value>
<newvalue>High Performance Parallel Interface</newvalue>
</mapping>
<mapping>
<value>781</value>
<newvalue>Nexus 64Mbps Ash</newvalue>
</mapping>
<mapping>
<value>782</value>
<newvalue>Acorn Econet</newvalue>
</mapping>
<mapping>
<value>783</value>
<newvalue>Linux-IrDA</newvalue>
</mapping>
<mapping>
<value>784</value>
<newvalue>Point to point fibrechannel</newvalue>
</mapping>
<mapping>
<value>785</value>
<newvalue>Fibrechannel arbitrated loop</newvalue>
</mapping>
<mapping>
<value>786</value>
<newvalue>Fibrechannel public loop</newvalue>
</mapping>
<mapping>
<value>787</value>
<newvalue>Fibrechannel fabric</newvalue>
</mapping>
<mapping>
<value>800</value>
<newvalue>Magic type ident for TR</newvalue>
</mapping>
<mapping>
<value>801</value>
<newvalue>IEEE 802.11</newvalue>
</mapping>
<mapping>
<value>802</value>
<newvalue>IEEE 802.11 + Prism2 header</newvalue>
</mapping>
<mapping>
<value>803</value>
<newvalue>IEEE 802.11 + radiotap header</newvalue>
</mapping>
<mapping>
<value>804</value>
<newvalue>ARPHRD_IEEE802154</newvalue>
</mapping>
<mapping>
<value>805</value>
<newvalue>IEEE 802.15.4 network monitor</newvalue>
</mapping>
<mapping>
<value>820</value>
<newvalue>PhoNet media type</newvalue>
</mapping>
<mapping>
<value>821</value>
<newvalue>PhoNet pipe header</newvalue>
</mapping>
<mapping>
<value>822</value>
<newvalue>CAIF media type</newvalue>
</mapping>
<mapping>
<value>823</value>
<newvalue>GRE over IPv6</newvalue>
</mapping>
<mapping>
<value>824</value>
<newvalue>Netlink header</newvalue>
</mapping>
<mapping>
<value>825</value>
<newvalue>IPv6 over LoWPAN</newvalue>
</mapping>
<mapping>
<value>826</value>
<newvalue>Vsock monitor header</newvalue>
</mapping>
</mappings>
</value_map>
</value_maps>
</zabbix_export>