Zabbix named 监控
Named 监控
-
配置 named.conf ,在options 配置节增加如下配置(同时检查/var/named 文件夹权限),然后重启named服务。
tatistics-file "/var/named/named.stats";
-
在zabbix agent目录下新增脚本 named.sh ,并执行
chmod +x named.sh
#!/bin/bash if [[ -z "$1" ]]; then exit 1; fi RNDC_BIN=/usr/sbin/rndc STATS='/var/named/named.stats' METRIC="$1" cat /dev/null > $STATS if ! $RNDC_BIN stats; then exit 1; fi if [ -s ${STATS} ]; then named_success=$(awk '/success/ {print $2}' $STATS) named_referral=$(awk '/referral/ {print $2}' $STATS) named_nxrrset=$(awk '/nxrrset/ {print $2}' $STATS) named_nxdomain=$(awk '/nxdomain/ {print $2}' $STATS) named_recursion=$(awk '/recursion/ {print $2}' $STATS) named_failure=$(awk '/failure/ {print $2}' $STATS) case "$METRIC" in "success") if ! [ -z $named_success ]; then echo $named_success; else echo 0; fi ;; "referral") if ! [ -z $named_referral ]; then echo $named_referral; else echo 0; fi ;; "nxrrset") if ! [ -z $named_nxrrset ]; then echo $named_nxrrset; else echo 0; fi ;; "nxdomain") if ! [ -z $named_nxdomain ]; then echo $named_nxdomain; else echo 0; fi ;; "recursion") if ! [ -z $named_recursion ]; then echo $named_recursion; else echo 0; fi ;; "failure") if ! [ -z $named_failure ]; then echo $named_failure; else echo 0; fi ;; *) echo "$METRIC not valid!"; exit 1; esac else echo "${STATS} does not exist!" >&2 exit 1 fi exit 0
-
zabbix_agentd 新增 UserParameter 配置,重启zabbix_agentd
UserParameter=named[*],/usr/local/zabbix327/bin/named.sh $1
UserParameter=named_udp,netstat -nua | grep -c :53
UserParameter=named_tcp,netstat -nta | grep -c :53
-
测试,在zabbix server 端使用zabbix_get 测试.
/usr/local/zabbix/bin/zabbix_get -s load-31 -p 10051 -k "named[failure]"
-
新增zabbix named 监控模板
<?xml version="1.0" encoding="UTF-8"?> <zabbix_export> <version>4.0</version> <date>2019-03-28T08:07:50Z</date> <groups> <group> <name>Templates</name> </group> </groups> <templates> <template> <template>Template_APP_Named</template> <name>Template_APP_Named</name> <description/> <groups> <group> <name>Templates</name> </group> </groups> <applications> <application> <name>Named</name> </application> </applications> <items> <item> <name>Named failure count</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>named[failure]</key> <delay>60s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <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>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> <item> <name>Named nxdomain</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>named[nxdomain]</key> <delay>60s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <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>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> <item> <name>Named nxrrset</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>named[nxrrset]</key> <delay>60s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <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>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> <item> <name>Named recursion</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>named[recursion]</key> <delay>60s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <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>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> <item> <name>Named referral</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>named[referral]</key> <delay>60s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <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>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> <item> <name>Named success</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>named[success]</key> <delay>60s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>0</value_type> <allowed_hosts/> <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>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> <item> <name>Named Failure qps</name> <type>15</type> <snmp_community/> <snmp_oid/> <key>named_failure_qps</key> <delay>60s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <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>change("named[failure]")</params> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> <item> <name>Named success qps</name> <type>15</type> <snmp_community/> <snmp_oid/> <key>named_success_qps</key> <delay>60s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <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>change("named[success]")</params> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> <item> <name>Named tcp count</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>named_tcp</key> <delay>60</delay> <history>7d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <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>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> <item> <name>Named udp count</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>named_udp</key> <delay>60</delay> <history>7d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <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>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> <item> <name>Named port check</name> <type>0</type> <snmp_community/> <snmp_oid/> <key>net.tcp.service[tcp,,53]</key> <delay>10s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <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>Named</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <timeout>3s</timeout> <url/> <query_fields/> <posts/> <status_codes>200</status_codes> <follow_redirects>1</follow_redirects> <post_type>0</post_type> <http_proxy/> <headers/> <retrieve_mode>0</retrieve_mode> <request_method>0</request_method> <output_format>0</output_format> <allow_traps>0</allow_traps> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <master_item/> </item> </items> <discovery_rules/> <httptests/> <macros/> <templates/> <screens/> </template> </templates> <triggers> <trigger> <expression>{Template_APP_Named:net.tcp.service[tcp,,53].last(0)}<1</expression> <recovery_mode>0</recovery_mode> <recovery_expression/> <name>named is not running on {HOSTNAME}</name> <correlation_mode>0</correlation_mode> <correlation_tag/> <url/> <status>0</status> <priority>5</priority> <description>named is not running Check named</description> <type>0</type> <manual_close>0</manual_close> <dependencies/> <tags/> </trigger> </triggers> <graphs> <graph> <name>Named failure query per seconds</name> <width>900</width> <height>200</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>1</show_work_period> <show_triggers>1</show_triggers> <type>0</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>0</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>5</drawtype> <color>FF7043</color> <yaxisside>0</yaxisside> <calc_fnc>4</calc_fnc> <type>0</type> <item> <host>Template_APP_Named</host> <key>named_failure_qps</key> </item> </graph_item> </graph_items> </graph> <graph> <name>Named session open</name> <width>900</width> <height>400</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>0</show_work_period> <show_triggers>0</show_triggers> <type>0</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>1</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>0</drawtype> <color>009900</color> <yaxisside>0</yaxisside> <calc_fnc>4</calc_fnc> <type>0</type> <item> <host>Template_APP_Named</host> <key>named_udp</key> </item> </graph_item> <graph_item> <sortorder>1</sortorder> <drawtype>0</drawtype> <color>0000AA</color> <yaxisside>0</yaxisside> <calc_fnc>4</calc_fnc> <type>0</type> <item> <host>Template_APP_Named</host> <key>named_tcp</key> </item> </graph_item> </graph_items> </graph> <graph> <name>Named statistics</name> <width>900</width> <height>200</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>1</show_work_period> <show_triggers>1</show_triggers> <type>0</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>0</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>0</drawtype> <color>1A7C11</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template_APP_Named</host> <key>named[nxdomain]</key> </item> </graph_item> <graph_item> <sortorder>1</sortorder> <drawtype>0</drawtype> <color>F63100</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template_APP_Named</host> <key>named[nxrrset]</key> </item> </graph_item> <graph_item> <sortorder>2</sortorder> <drawtype>0</drawtype> <color>A54F10</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template_APP_Named</host> <key>named[recursion]</key> </item> </graph_item> <graph_item> <sortorder>3</sortorder> <drawtype>0</drawtype> <color>FC6EA3</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template_APP_Named</host> <key>named[referral]</key> </item> </graph_item> <graph_item> <sortorder>4</sortorder> <drawtype>0</drawtype> <color>6C59DC</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template_APP_Named</host> <key>named[success]</key> </item> </graph_item> </graph_items> </graph> <graph> <name>Named success query per seconds</name> <width>900</width> <height>200</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>1</show_work_period> <show_triggers>1</show_triggers> <type>0</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>0</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>5</drawtype> <color>1A7C11</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template_APP_Named</host> <key>named_success_qps</key> </item> </graph_item> </graph_items> </graph> </graphs>
</zabbix_export>
```