forked from rafael747/zabbix-postfix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_postfix_template_zabbix.sh
63 lines (39 loc) · 1.67 KB
/
install_postfix_template_zabbix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -e
# Installation script for zabbix-postfix client scripts and configuration
# Based on: https://github.com/gatespb/zabbix_templates
echo -e "\n#### Installing zabbix-postfix client scripts and configs ####\n"
cd /usr/local/sbin
echo -n "Downloading scripts..."
wget -q -N https://raw.githubusercontent.com/rafael747/zabbix-postfix/master/zabbix_postfix.sh >/dev/null
wget -q -N https://raw.githubusercontent.com/rafael747/zabbix-postfix/master/pygtail.py > /dev/null
echo "OK!"
chmod +x pygtail.py
chmod +x zabbix_postfix.sh
# sudoers rule to allow zabbix-client runnung required commands
cd /etc/sudoers.d/
echo -n "Downloading sudoers rules..."
wget -q -N https://raw.githubusercontent.com/rafael747/zabbix-postfix/master/zabbix_postfix >/dev/null
echo "OK!"
chmod 440 zabbix_postfix
# Zabbix client configuration (mailq command, postfix queue size)
# For Debian/Ubuntu
[ -d /etc/zabbix/zabbix_agentd.conf.d/ ] && cd /etc/zabbix/zabbix_agentd.conf.d/
# For RHEL/Centos
[ -d /etc/zabbix/zabbix_agentd.d/ ] && cd /etc/zabbix/zabbix_agentd.d/
echo -n "Downloading zabbix agent configuration..."
wget -q -N https://raw.githubusercontent.com/rafael747/zabbix-postfix/master/zabbix_postfix.conf >/dev/null
echo "OK!"
echo -n "Restarting services..."
service sudo restart >/dev/null
service zabbix-agent restart >/dev/null
echo "OK!"
echo '# Install the following packages'
echo '# Debian/Ubuntu'
echo 'apt install pflogsumm bc zabbix-sender'
echo ''
echo '# RHEL/Centos'
echo 'yum install postfix-perl-scripts bc zabbix-sender'
echo -e "\nAdd the following crontab entry:\n"
echo '# Zabbix check'
echo '*/5 * * * * /usr/local/sbin/zabbix_postfix.sh 1>/dev/null 2>/dev/null'