-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall_nagiosplugins.sh
67 lines (58 loc) · 1.76 KB
/
install_nagiosplugins.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
#!/bin/bash
#
# Author: Dorance Martinez C [email protected]
# SPDX-License-Identifier: Apache-2.0
#
# Descripcion: Script para installar nagios core
# Version: 0.2.3 - 11-jul-2017
# Validado en : Debian 6+, Ubuntu 16+, Centos 6+
#
NPLUGINS_version="2.2.1"
INSTALL_PATH="/tmp/nagios_`date +%Y%m%d%H%M%S`"
NAGIOS_USER="nagios"
linux_variant() {
if [ -f "/etc/debian_version" ]; then
distro="debian"
elif [ -f "/etc/redhat-release" ]; then
distro="rh"
else
distro="unknown"
fi
}
command_exists () {
type "$1" &> /dev/null ;
}
debian() {
if ! command_exists wget ; then
apt-get install -y wget
fi
apt-get install -y perl libnet-snmp-perl &&
installar_nplugins &&
return 0
}
rh() {
if ! command_exists wget ; then
yum install wget -y
fi
yum install -y perl perl-CPAN net-snmp-perl &&
installar_nplugins &&
return 0
}
unknown() {
echo "distro no reconocida por este script :( "
exit 1
}
installar_nplugins() {
mkdir -p ${INSTALL_PATH} &&
cd ${INSTALL_PATH} && wget http://www.nagios-plugins.org/download/nagios-plugins-${NPLUGINS_version}.tar.gz && tar -zxvf nagios-plugins-${NPLUGINS_version}.tar.gz && cd nagios-plugins-${NPLUGINS_version} && ./configure --prefix=/opt/nagios/ --enable-threads=posix --with-nagios-user=${NAGIOS_USER} --with-nagios-group=${NAGIOS_USER} --with-mysql --with-gnutls --with-ipv6 --with-openssl && make && make install &&
# wget http://search.cpan.org/CPAN/authors/id/N/NA/NAGIOS/Nagios-Monitoring-Plugin-0.51.tar.gz && tar -zxvf Nagios-Monitoring-Plugin-0.51.tar.gz && cd Nagios-Monitoring-Plugin-0.51 && perl Makefile.PL ; make ; make install &&
# yes | perl -MCPAN -E 'install Nagios::Monitoring::Plugin' &&
return 0
}
run_core() {
linux_variant &&
$distro &&
return 0
}
run_core &&
exit 0