From 8535856fbb8b97f3f572bc7b51e2a72de28d578b Mon Sep 17 00:00:00 2001 From: netkiller Date: Tue, 29 Nov 2016 14:03:00 +0800 Subject: [PATCH] postfix --- README.md | 2 +- elasticsearch/README.md | 2 + postfix/README.md | 11 ++++++ postfix/postfix | 63 ++++++++++++++++++++++++++++++ postfix/userparameter_postfix.conf | 11 ++++++ 5 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 postfix/README.md create mode 100644 postfix/postfix create mode 100644 postfix/userparameter_postfix.conf diff --git a/README.md b/README.md index 2ba5b08..60dd28d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# zabbix +# Netkiller zabbix templates Zabbix Plugin diff --git a/elasticsearch/README.md b/elasticsearch/README.md index f754897..0da8807 100644 --- a/elasticsearch/README.md +++ b/elasticsearch/README.md @@ -6,6 +6,8 @@ # wget https://raw.githubusercontent.com/oscm/zabbix/master/elasticsearch/userparameter_elasticsearch.conf -P /etc/zabbix/zabbix_agentd.d/ + # wget https://raw.githubusercontent.com/oscm/zabbix/master/elasticsearch/elasticsearch -P /srv/zabbix/libexec + # chmod +x /srv/zabbix/libexec/elasticsearch # /srv/zabbix/libexec/elasticsearch indices _all.total.flush.total_time_in_millis diff --git a/postfix/README.md b/postfix/README.md new file mode 100644 index 0000000..f6ad3d8 --- /dev/null +++ b/postfix/README.md @@ -0,0 +1,11 @@ +Zabbix for Postfix 3.2 +===== + +Install agent +----- + + # yum install -y logcheck + + # mkdir -p /srv/zabbix/libexec + + \ No newline at end of file diff --git a/postfix/postfix b/postfix/postfix new file mode 100644 index 0000000..3692b39 --- /dev/null +++ b/postfix/postfix @@ -0,0 +1,63 @@ +#!/bin/bash +################################################## +# AUTHOR: Neo +# WEBSITE: http://www.netkiller.cn +# Description:zabbix agent script +# Note:Zabbix 3.2 +# DateTime: 2016-11-29 +################################################## +module=$1 +item=$2 + +function usage(){ + name=$(basename $0) + echo "Postfix collect script for zabbix - http://www.netkiller.cn" + echo "${name} " + echo " " + echo " " + echo " " + echo " <200|550|421|......>" + exit +} + +if [ -z ${module} ]; then + usage +fi + +if [ ${module} == "discovery" ]; then + echo '{"data":[{"{#CODE}":"200"},{"{#CODE}":"211"},{"{#CODE}":"214"},{"{#CODE}":"220"},{"{#CODE}":"221"},{"{#CODE}":"250"},{"{#CODE}":"251"},{"{#CODE}":"252"},{"{#CODE}":"354"},{"{#CODE}":"421"},{"{#CODE}":"450"},{"{#CODE}":"451"},{"{#CODE}":"452"},{"{#CODE}":"500"},{"{#CODE}":"501"},{"{#CODE}":"502"},{"{#CODE}":"503"},{"{#CODE}":"504"},{"{#CODE}":"521"},{"{#CODE}":"530"},{"{#CODE}":"550"},{"{#CODE}":"551"},{"{#CODE}":"552"},{"{#CODE}":"553"},{"{#CODE}":"554"}]}' + exit +else + if [ -z ${item} ]; then + usage + fi +fi + +if [ ${module} == "queue" ]; then + if [ ${item} == "active" ]; then + postqueue -p | egrep -c "^[0-9A-F]{10}[*]" + fi + if [ ${item} == "deferred" ]; then + postqueue -p | egrep -c "^[0-9A-F]{10}[^*]" + fi +elif [ ${module} == "status" ]; then + status=("active" "deferred" "sent" "bounced" "expired") + for val in ${status[@]}; do + + if [ $val == $item ]; then + logtail -f /var/log/maillog -o /var/tmp/postfix.${item}.logtail | grep -c "postfix/smtp.*status=${item}" + fi + done +elif [ ${module} == "log" ]; then + if [ ${item} == "timeout" ]; then + logtail -f /var/log/maillog -o /var/tmp/postfix.timeout.logtail | grep -c "postfix/smtp.* Connection timed out" + elif [ ${item} == "unreachable" ]; then + logtail -f /var/log/maillog -o /var/tmp/postfix.unreachable.logtail | grep -c "Network is unreachable" + elif [ ${item} == "refused" ]; then + logtail -f /var/log/maillog -o /var/tmp/postfix.refused.logtail | grep -c "Connection refused" + fi +elif [ ${module} == "code" ]; then + logtail -f /var/log/maillog -o /var/tmp/postfix.${item}.logtail | grep -c "said: ${item} " +else + usage +fi diff --git a/postfix/userparameter_postfix.conf b/postfix/userparameter_postfix.conf new file mode 100644 index 0000000..a46c6a7 --- /dev/null +++ b/postfix/userparameter_postfix.conf @@ -0,0 +1,11 @@ +############################################################ +# Postfix - statistics +# +# Author: Neo Chen +# Website: http://www.netkiller.cn +############################################################ + +# Discovery +UserParameter=postfix.discovery,/srv/zabbix/libexec/postfix discovery +# Return statistics +UserParameter=postfix[*],/srv/zabbix/libexec/postfix $1 $2 \ No newline at end of file