forked from centreon/centreon-archived
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-poller.sh
executable file
·197 lines (161 loc) · 6.35 KB
/
install-poller.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
########################################################################
# Install script for Centreon 3 Poller on CentOS 6 (RH 6)
########################################################################
# Install base packages
yum install -y gcc curl wget git ntpdate
# To prevent restored VM having a bad date
ntpdate pool.ntp.org
# Add Centreon repos (CES + internal dev)
cat << EOF > /etc/yum.repos.d/ces-standard.repo
[ces-standard]
name=Centreon Enterprise Server RPM repository for ces \$releasever
baseurl=http://yum.centreon.com/standard/3.0/stable/\$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CES
[ces-standard-noarch]
name=Centreon Enterprise Server RPM repository for ces \$releasever
baseurl=http://yum.centreon.com/standard/3.0/stable/noarch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CES
[ces-standard-deps]
name=Centreon Enterprise Server dependencies RPM repository for ces \$releasever
baseurl=http://yum.centreon.com/standard/3.0/stable/dependencies/\$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CES
[ces-standard-deps-noarch]
name=Centreon Enterprise Server dependencies RPM repository for ces \$releasever
baseurl=http://yum.centreon.com/standard/3.0/stable/dependencies/noarch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CES
[ces-standard-devel]
name=Centreon Enterprise Server development RPM repository for ces \$releasever
baseurl=http://yum.centreon.com/standard/3.0/stable/devel/\$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CES
[ces-standard-devel-noarch]
name=Centreon Enterprise Server development RPM repository for ces \$releasever
baseurl=http://yum.centreon.com/standard/3.0/stable/devel/noarch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CES
EOF
cat << EOF > /etc/yum.repos.d/centreon3-dev.repo
[centreon3-dev-noarch]
name=Centreon 3 Devel noarch
baseurl=http://srvi-ces-repository.merethis.net/repos/centreon3-dev/el\$releasever/noarch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CES
enabled=1
[centreon3-dev]
name=Centreon 3 Devel
baseurl=http://srvi-ces-repository.merethis.net/repos/centreon3-dev/el\$releasever/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CES
enabled=1
EOF
wget http://yum.centreon.com/standard/3.0/stable/RPM-GPG-KEY-CES -O /etc/pki/rpm-gpg/RPM-GPG-KEY-CES
# Broker
# Note "*" is important to install modules
# /!\ No need to install all broker packages on pollers (otherwise cbd will be executed)
yum install -y centreon-broker-cbd
service cbd start
# Engine
yum install -y centreon-engine
chown centreon-engine.centreon-engine /etc/centreon-engine
chmod 775 /etc/centreon-engine
# FIXME, default conf/layout not good
rm -rf /etc/centreon-engine/objects/*
service centengine start
# Configure sudo
cat << EOF > /etc/sudoers.d/centreon
## BEGIN: CENTREON SUDO
#Add by CENTREON installation script
User_Alias CENTREON=apache,nagios,centreon,centreon-engine,centreon-broker
Defaults:CENTREON !requiretty
## Centreontrapd Restart
CENTREON ALL = NOPASSWD: /etc/init.d/centreontrapd restart
## CentStorage
CENTREON ALL = NOPASSWD: /etc/init.d/centstorage *
# Centengine Restart
CENTREON ALL = NOPASSWD: /etc/init.d/centengine restart
# Centengine stop
CENTREON ALL = NOPASSWD: /etc/init.d/centengine start
# Centengine stop
CENTREON ALL = NOPASSWD: /etc/init.d/centengine stop
# Centengine reload
CENTREON ALL = NOPASSWD: /etc/init.d/centengine reload
# Centengine test config
CENTREON ALL = NOPASSWD: /usr/sbin/centengine -v *
# Centengine test for optim config
CENTREON ALL = NOPASSWD: /usr/sbin/centengine -s *
# Broker Central restart
CENTREON ALL = NOPASSWD: /etc/init.d/cbd restart
# Broker Central reload
CENTREON ALL = NOPASSWD: /etc/init.d/cbd reload
# Broker Central start
CENTREON ALL = NOPASSWD: /etc/init.d/cbd start
# Broker Central stop
CENTREON ALL = NOPASSWD: /etc/init.d/cbd stop
## END: CENTREON SUDO
EOF
chmod 440 /etc/sudoers.d/centreon
# Install SNMP
yum install -y perl-Net-SNMP.noarch net-snmp-perl.x86_64 net-snmp.x86_64 net-snmp-utils.x86_64
cat << EOF > /etc/snmp/snmpd.conf
####
# First, map the community name "public" into a "security name"
# sec.name source community
com2sec notConfigUser default public
####
# Second, map the security name into a group name:
# groupName securityModel securityName
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
####
# Third, create a view for us to let the group have rights to:
# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
view centreon included .1.3.6.1
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
####
# Finally, grant the group read-only access to the systemview view.
# group context sec.model sec.level prefix read write notif
access notConfigGroup "" any noauth exact centreon none none
access notConfigGroup "" any noauth exact systemview none none
includeAllDisks 10%
EOF
service snmpd start
# Install centreon-plugins
git clone https://github.com/centreon/centreon-plugins.git /usr/lib/nagios/plugins/centreon-plugins/
chmod 755 /usr/lib/nagios/plugins/centreon-plugins/centreon_plugins.pl
chown root /usr/lib/nagios/plugins/check_icmp
chmod u+s /usr/lib/nagios/plugins/check_icmp
# Check and create group/user centreon
getent group centreon &>/dev/null || groupadd -r centreon
getent passwd centreon &>/dev/null || useradd -g centreon -m -d /var/lib/centreon -r centreon
# Add group dependancy for many users
usermod -a -G centreon,centreon-engine nagios
usermod -a -G centreon,centreon-engine,nagios centreon-broker
usermod -a -G centreon,centreon-broker,nagios centreon-engine
usermod -a -G centreon-engine,centreon-broker centreon
# Start services
# Nothing to do, they should already be running due to previous steps
# Activate services on boot
chkconfig --level 2345 centengine on
chkconfig --level 2345 snmpd on
# Create RRD paths
mkdir /var/lib/centreon
mkdir /var/lib/centreon/metrics
mkdir /var/lib/centreon/status
mkdir /var/lib/centreon/centplugins
chown -R centreon-broker /var/lib/centreon/metrics
chown -R centreon-broker /var/lib/centreon/status
chown -R centreon-engine /var/lib/centreon/centplugins
# End of script