-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·156 lines (130 loc) · 3.69 KB
/
install.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/bash
install_nagios(){
#install package
tar xvf nagios-4.1.1.tar.gz
cd nagios-4.1.1
./configure --with-nagios-group=nagios --with-command-group=nagcmd
make all
make install
make install-commandmode
make install-init
make install-config
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf
rm -r nagios-4.1.1
}
install_nagios_plugin(){
tar xvf nagios-plugins-2.1.1.tar.gz
pushd nagios-plugins-2.1.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
make
make install
popd
rm -r nagios-plugins-2.1.1
}
install_nrpe(){
tar xvf nrpe-2.15.tar.gz
pushd nrpe-2.15
./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu
make all
make install
make install-xinetd
make install-daemon-config
popd
rm -r nrpe-2.15
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
}
install_postfix(){
apt-get install postfix:w
}
install_server(){
pushd package
install_nagios
install_nagios_plugin
install_nrpe
popd
}
install_client(){
pushd package
install_nagios_plugin
install_nrpe
popd
#copy configure
cp conf/nrpe.cfg /usr/local/nagios/etc -f
chown nagios:nagios /usr/local/nagios/etc/nrpe.cfg
#set xinetd service
cp conf/nrpe /etc/xinetd.d
service xinetd restart
echo "*******************notice, this is very import***********************
df -h
and according to dev name ,modify the /usr/local/nagios/etc/nrpe.cfg
check_disk .... -p /dev/sda
after you modify the configuration, restart the nrpe daemon process
*********************************************************************"
}
if [ `id -u` != 0 ]
then
echo "you must run this by root"
fi
if [ $# == 0 ];then
echo "Usage : $0 {server | client }"
fi
#1. install dep
apt-get install build-essential libgd2-xpm-dev openssl libssl-dev xinetd apache2-utils unzip
#2. user and group
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www-data
#3. install server or install client
if [ $1 == 'server' ];then
echo "install server"
install_server
elif [ $1 == 'client' ];then
echo "install client"
install_client
fi
exit
a2enmod rewrite
a2enmod cgi
#copy passwd
cp htpasswd.users /usr/local/nagios/etc/
ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
service nagios start
service apache2 restart
service nagios-nrpe-server restart
get_remote_nagios(){
#get nagios, first find it local, and then remote
find . -name "nagios-4*.tar.gz" | if read s;
then
echo "find nagios package $s"
else
echo "not find nagios"
curl -L -O https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz
fi
}
get_remote_nagiosplugin(){
find . -name "nagios-plugins-2*.tar.gz" | if read s;
then
stat -s $s
if [ st_size != 0 ]
then
echo "find nagios-plugin package $s"
else
curl -L -O http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
fi
else
echo "not find nagios-plugin"
curl -L -O http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
fi
}
get_remote_nrpe(){
#get nrpe
find . -name "nrpe-2*.tar.gz" | if read s;
then
echo "find nrpe package $s"
else
echo "not find nrpe"
curl -L -O http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
fi
}