From 9b8766253e5c49865370a63eb137c462f9e0e5cb Mon Sep 17 00:00:00 2001 From: kamil Date: Wed, 12 Aug 2015 09:26:09 +0200 Subject: [PATCH] New monitoring stuff --- README.md | 15 + bin/nginx-check.sh | 64 +++ templates/Template App MySQL Slave.xml | 402 +++++++++++++++++ templates/Template App Nginx.xml | 568 +++++++++++++++++++++++++ templates/Template_App_Amavisd.xml | 82 ---- zabbix_agentd.conf.d/mysql-slave.conf | 3 + zabbix_agentd.conf.d/nginx.conf | 1 + 7 files changed, 1053 insertions(+), 82 deletions(-) create mode 100644 bin/nginx-check.sh create mode 100644 templates/Template App MySQL Slave.xml create mode 100644 templates/Template App Nginx.xml delete mode 100644 templates/Template_App_Amavisd.xml create mode 100644 zabbix_agentd.conf.d/mysql-slave.conf create mode 100644 zabbix_agentd.conf.d/nginx.conf diff --git a/README.md b/README.md index b75b26c..0ab58d5 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,21 @@ FLUSH PRIVILEGES; If you want change password, you need to edit files ```.my.cnf``` and also in file ```bin/ss_get_mysql_stats.php```. +Template App MySQL Slave +===== +Monitoring for replication in MySQL 5.5, 5.6 and 5.7. Please run SQL query: +``` +CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'ha7jqnlacwefrs'; +GRANT REPLICATION CLIENT, SELECT, PROCESS, SHOW DATABASES ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY 'ha7jqnlacwefrs'; +FLUSH PRIVILEGES; +``` + +If you want change password, you need to edit files ```.my.cnf```. + +Template App Nginx +====== +Monitoring for Nginx. It is using script ```nginx-check.sh``` written by Vincent Viallet. + Template App Brocade HBA ====== Monitoring for Network Adapters - Brocade. Template is using Discovery to create Items and Triggers. You need also add SUDO for zabbix user: ```zabbix ALL=(ALL) NOPASSWD: /usr/bin/bcu``` diff --git a/bin/nginx-check.sh b/bin/nginx-check.sh new file mode 100644 index 0000000..03a284d --- /dev/null +++ b/bin/nginx-check.sh @@ -0,0 +1,64 @@ +#!/bin/bash +################################## +# Zabbix monitoring script +# +# nginx: +# - anything available via nginx stub-status module +# +################################## +# Contact: +# vincent.viallet@gmail.com +################################## +# ChangeLog: +# 20100922 VV initial creation +################################## + +# Zabbix requested parameter +ZBX_REQ_DATA="$1" +ZBX_REQ_DATA_URL="$2" + +# Nginx defaults +NGINX_STATUS_DEFAULT_URL="http://localhost:10061/nginx_status" +WGET_BIN="/usr/bin/wget" + +# +# Error handling: +# - need to be displayable in Zabbix (avoid NOT_SUPPORTED) +# - items need to be of type "float" (allow negative + float) +# +ERROR_NO_ACCESS_FILE="-0.9900" +ERROR_NO_ACCESS="-0.9901" +ERROR_WRONG_PARAM="-0.9902" +ERROR_DATA="-0.9903" # either can not connect / bad host / bad port + +# Handle host and port if non-default +if [ ! -z "$ZBX_REQ_DATA_URL" ]; then + URL="$ZBX_REQ_DATA_URL" +else + URL="$NGINX_STATUS_DEFAULT_URL" +fi + +# save the nginx stats in a variable for future parsing +NGINX_STATS=$($WGET_BIN -q $URL -O - 2> /dev/null) + +# error during retrieve +if [ $? -ne 0 -o -z "$NGINX_STATS" ]; then + echo $ERROR_DATA + exit 1 +fi + +# +# Extract data from nginx stats +# +case $ZBX_REQ_DATA in + active_connections) echo "$NGINX_STATS" | head -1 | cut -f3 -d' ';; + accepted_connections) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f2 -d' ';; + handled_connections) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f3 -d' ';; + handled_requests) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f4 -d' ';; + reading) echo "$NGINX_STATS" | tail -1 | cut -f2 -d' ';; + writing) echo "$NGINX_STATS" | tail -1 | cut -f4 -d' ';; + waiting) echo "$NGINX_STATS" | tail -1 | cut -f6 -d' ';; + *) echo $ERROR_WRONG_PARAM; exit 1;; +esac + +exit 0 \ No newline at end of file diff --git a/templates/Template App MySQL Slave.xml b/templates/Template App MySQL Slave.xml new file mode 100644 index 0000000..3e76312 --- /dev/null +++ b/templates/Template App MySQL Slave.xml @@ -0,0 +1,402 @@ + + + 2.0 + 2015-08-12T07:18:54Z + + + Templates + + + + + + + + {Template App MySQL Slave:repIOrun.last(0)}=0 + [MySQL] IO Thread is not running + + 0 + 3 + + 0 + + + + {Template App MySQL Slave:repSBM.last(0)}>1800 + [MySQL] Slave is out of sync ({ITEM.LASTVALUE} seconds of delay) + + 0 + 2 + + 0 + + + + {Template App MySQL Slave:repSQLrun.last(0)}=0 + [MySQL] SQL Thread is not running + + 0 + 3 + + 0 + + + + + + [MySQL] Replication Thread Status + 900 + 200 + 0.0000 + 100.0000 + 0 + 0 + 0 + 1 + 0 + 0.0000 + 0.0000 + 0 + 0 + 0 + 0 + + + 0 + 0 + 009900 + 0 + 7 + 0 + + Template App MySQL Slave + repSQLrun + + + + 1 + 0 + DD0000 + 0 + 7 + 0 + + Template App MySQL Slave + repIOrun + + + + + + [MySQL] Seconds Behind Master + 900 + 200 + 0.0000 + 100.0000 + 0 + 0 + 0 + 1 + 0 + 0.0000 + 0.0000 + 0 + 0 + 0 + 0 + + + 0 + 0 + 009900 + 0 + 7 + 0 + + Template App MySQL Slave + repSBM + + + + + + [MySQL] SQL Delay + 900 + 200 + 0.0000 + 100.0000 + 1 + 1 + 0 + 1 + 0 + 0.0000 + 0.0000 + 1 + 0 + 0 + 0 + + + 0 + 5 + 0000BB + 0 + 2 + 0 + + Template App MySQL Slave + repSQLDelay + + + + 1 + 5 + AA00AA + 0 + 2 + 0 + + Template App MySQL Slave + repSQLRemDelay + + + + + + diff --git a/templates/Template App Nginx.xml b/templates/Template App Nginx.xml new file mode 100644 index 0000000..a38b543 --- /dev/null +++ b/templates/Template App Nginx.xml @@ -0,0 +1,568 @@ + + + 2.0 + 2015-08-12T07:20:46Z + + + Templates + + + + + + + + {Template App Nginx:chkconfig[nginx].last(0)}=0 + Nginx is not enabled in autostart + + 0 + 2 + + 0 + + + + {Template App Nginx:proc.num[nginx].last(0)}=0 + Nginx is not running + + 0 + 4 + Nginx is not running. + + It has been stopped / shutdown or has crashed. + Check on the server for more details: + - w / last + - dmesg logs + - /var/log/messages + - nginx error logs + 0 + + + + + + Nginx - Connections and Requests status + 900 + 200 + 0.0000 + 100.0000 + 0 + 0 + 0 + 1 + 0 + 0.0000 + 0.0000 + 1 + 0 + 0 + 0 + + + 0 + 1 + FF9999 + 0 + 4 + 0 + + Template App Nginx + nginx[accepted_connections] + + + + 1 + 2 + 990000 + 0 + 4 + 0 + + Template App Nginx + nginx[handled_connections] + + + + 2 + 0 + 009900 + 0 + 4 + 0 + + Template App Nginx + nginx[handled_requests] + + + + + + Nginx - Threads status + 900 + 200 + 0.0000 + 100.0000 + 0 + 0 + 1 + 1 + 0 + 0.0000 + 0.0000 + 1 + 0 + 0 + 0 + + + 0 + 1 + 990000 + 0 + 4 + 0 + + Template App Nginx + nginx[writing] + + + + 1 + 1 + 999900 + 0 + 4 + 0 + + Template App Nginx + nginx[reading] + + + + 2 + 1 + 009900 + 0 + 4 + 0 + + Template App Nginx + nginx[waiting] + + + + + + diff --git a/templates/Template_App_Amavisd.xml b/templates/Template_App_Amavisd.xml deleted file mode 100644 index cc2a7a5..0000000 --- a/templates/Template_App_Amavisd.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - 2.0 - 2015-08-12T06:52:13Z - - - Templates - - - - - - - - {Template App Amavisd:proc.num[amavisd].last(0)}=0 - Service amavis is not running - - 0 - 3 - - 0 - - - - diff --git a/zabbix_agentd.conf.d/mysql-slave.conf b/zabbix_agentd.conf.d/mysql-slave.conf new file mode 100644 index 0000000..1ddb18c --- /dev/null +++ b/zabbix_agentd.conf.d/mysql-slave.conf @@ -0,0 +1,3 @@ +UserParameter=repSBM,echo "show slave status\G;" | HOME=/etc/zabbix mysql | grep 'Seconds_Behind_Master' | awk '{print $2}' +UserParameter=repIOrun,echo "show slave status\G;" | HOME=/etc/zabbix mysql | grep -c 'Slave_IO_Running: Yes' +UserParameter=repSQLrun,echo "show slave status\G;" | HOME=/etc/zabbix mysql | grep -c 'Slave_SQL_Running: Yes' \ No newline at end of file diff --git a/zabbix_agentd.conf.d/nginx.conf b/zabbix_agentd.conf.d/nginx.conf new file mode 100644 index 0000000..9a19d4f --- /dev/null +++ b/zabbix_agentd.conf.d/nginx.conf @@ -0,0 +1 @@ +UserParameter=nginx[*],/etc/zabbix/bin/nginx-check.sh "$1" "$2" \ No newline at end of file