mirror of
https://github.com/aljazceru/zabbix.git
synced 2025-12-17 18:44:20 +01:00
postfix
This commit is contained in:
@@ -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
|
||||
|
||||
11
postfix/README.md
Normal file
11
postfix/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
Zabbix for Postfix 3.2
|
||||
=====
|
||||
|
||||
Install agent
|
||||
-----
|
||||
|
||||
# yum install -y logcheck
|
||||
|
||||
# mkdir -p /srv/zabbix/libexec
|
||||
|
||||
|
||||
63
postfix/postfix
Normal file
63
postfix/postfix
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
##################################################
|
||||
# AUTHOR: Neo <netkiller@msn.com>
|
||||
# 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} <module> <item>"
|
||||
echo "<queue> <active|deferred>"
|
||||
echo "<status> <active|deferred|sent|bounced|expired>"
|
||||
echo "<log> <active|deferred|sent|bounced|expired|string>"
|
||||
echo "<code> <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
|
||||
11
postfix/userparameter_postfix.conf
Normal file
11
postfix/userparameter_postfix.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
############################################################
|
||||
# Postfix - statistics
|
||||
#
|
||||
# Author: Neo Chen <netkiller@msn.com>
|
||||
# Website: http://www.netkiller.cn
|
||||
############################################################
|
||||
|
||||
# Discovery
|
||||
UserParameter=postfix.discovery,/srv/zabbix/libexec/postfix discovery
|
||||
# Return statistics
|
||||
UserParameter=postfix[*],/srv/zabbix/libexec/postfix $1 $2
|
||||
Reference in New Issue
Block a user