summaryrefslogtreecommitdiffstats
path: root/gluster-nagios-addons.spec.in
blob: 885a64123698ad15d795907f7cc7f388c2728af2 (plain)
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
%global _hardened_build 1

%global _for_fedora_koji_builds 0

%if ( 0%{?fedora} && 0%{?fedora} > 16 ) || ( 0%{?rhel} && 0%{?rhel} > 6 )
%global _with_systemd true
%endif

%if ( 0%{?fedora} && 0%{?fedora} > 17 ) || ( 0%{?rhel} && 0%{?rhel} > 6 )
%global _with_firewalld true
%endif

# From https://fedoraproject.org/wiki/Packaging:Python#Macros
%if ( 0%{?rhel} && 0%{?rhel} <= 5 )
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif

%if ( 0%{?_with_systemd:1} )
%define _init_enable()  /bin/systemctl enable %1.service ;
%define _init_disable() /bin/systemctl disable %1.service ;
%define _init_restart() /bin/systemctl restart %1.service ;
%define _init_try_restart() /bin/systemctl try-restart %1.service ;
%define _init_stop()    /bin/systemctl stop %1.service ;
%define _init_install() install -D -p -m 0644 %1 %{buildroot}%{_unitdir}/%2.service ;
%else
%define _init_enable()  /sbin/chkconfig --add %1 ;
%define _init_disable() /sbin/chkconfig --del %1 ;
%define _init_restart() /sbin/service %1 restart &>/dev/null ;
%define _init_try_restart() /sbin/service %1 condrestart &>/dev/null ;
%define _init_stop()    /sbin/service %1 stop &>/dev/null ;
%define _init_install() install -D -p -m 0755 %1 %{buildroot}%{_sysconfdir}/init.d/%2 ;
%endif
%define _start_conf_section() ### START - configuration section for gluster nrpe plugins ###
%define _end_conf_section() ### END - configuration section for gluster nrpe plugins ###
%define _remove_gluster_nagios_configs() /bin/sed -i -e "/%{_start_conf_section}/,/%{_end_conf_section}/d" %{_sysconfdir}/nagios/nrpe.cfg ;

Summary: Gluster node management add-ons for Nagios
Name:             @PACKAGE_NAME@
Version:          @PACKAGE_VERSION@
Release:          @PACKAGE_RELEASE@%{?dist}
License:          GPLv2+
Group:            Applications/System
URL:              http://www.redhat.com
Vendor:           Red Hat, Inc.
Source0:          %{name}-%{version}.tar.gz
BuildRoot:        %{_tmppath}/%{name}-%{version}-root
BuildRequires:    pyflakes
BuildRequires:    python-pep8
BuildRequires:    python-mock
BuildRequires:    python-cpopen
BuildRequires:    python-ethtool
BuildRequires:    python-inotify
BuildRequires:    python-netaddr
BuildRequires:    python-argparse
BuildRequires:    python-nose
BuildRequires:    python-devel
BuildRequires:    libselinux-python
BuildRequires:    gluster-nagios-common
%if ( 0%{?_with_systemd:1} )
BuildRequires:    systemd-units
Requires(post):   systemd-units
Requires(preun):  systemd-units
%else
Requires(post):   /sbin/service
Requires(post):   /sbin/chkconfig
Requires(preun):  /sbin/service
Requires(preun):  /sbin/chkconfig
%endif
%if ( 0%{?_with_firewalld:1} )
Requires(post):   firewalld
%else
Requires(post):   iptables
%endif
Requires:         gluster-nagios-common
Requires:         libselinux-python
Requires:         nagios-plugins-ide_smart
Requires:         nagios-plugins-procs
Requires:         nrpe
Requires:         nsca-client
Requires:         python-argparse
Requires:         python-ethtool
Requires:         python-inotify
Requires:         python-netaddr
Requires:         python-pthreading
Requires:         python-cpopen >= 1.3
Requires:         python-lockfile
Requires:         python-daemon
Requires:         sysstat

%description
Nagios plugin, scripts, configuration files etc for gluster nodes.

%package tests
Summary:          Unit/functional tests of Gluster node management add-ons for Nagios
Group:            Development/Tools
Requires:         %{name} = %{version}-%{release}
Requires:         pyflakes
Requires:         python-pep8
Requires:         python-mock
Requires:         python-nose
Requires:         python-devel

%description tests
Unit/functional tests for Nagios plugin, scripts, configuration files etc for gluster nodes.

%prep
%setup -q

%build
%{configure}
make

%check
make check

%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}

%clean
rm -rf %{buildroot}


%post
%if ( 0%{?_with_firewalld:1} )
/bin/firewall-cmd --permanent --add-port=5666/tcp
/bin/firewall-cmd --add-port=5666/tcp
%else
/sbin/iptables -I INPUT 1 -p tcp --dport 5666 -j ACCEPT
/sbin/service iptables save
%_init_restart iptables
%endif

if grep -q "dont_blame_nrpe=0" %{_sysconfdir}/nagios/nrpe.cfg ; then
  sed -i -e 's/dont_blame_nrpe=0/dont_blame_nrpe=1/g' %{_sysconfdir}/nagios/nrpe.cfg
fi

%_remove_gluster_nagios_configs

cat >> %{_sysconfdir}/nagios/nrpe.cfg <<EOF
%{_start_conf_section}
command[check_disk_and_inode]=sudo %{_libdir}/nagios/plugins/gluster/check_disk_and_inode.py -w 80 -c 90 -l -i /boot -i /var -i /root -n --inode
command[check_memory]=%{_libdir}/nagios/plugins/gluster/memory.py -w 80 -c 90 -t 2
command[check_swap_usage]=%{_libdir}/nagios/plugins/gluster/swap.py -w 80 -c 90 -t 2
command[check_cpu_multicore]=%{_libdir}/nagios/plugins/gluster/cpu.py -w 80 -c 90 -t 2
command[check_interfaces]=%{_libdir}/nagios/plugins/gluster/network.py -e lo -e ';vdsmdummy;' -t 2
command[check_brick_usage]=sudo %{_libdir}/nagios/plugins/gluster/check_disk_and_inode.py -w 80 -c 90 -n -i \$ARG1\$
command[check_vol_utilization]=sudo %{_libdir}/nagios/plugins/gluster/check_vol_utilization.py \$ARG1\$ -w \$ARG2\$ -c \$ARG3\$
command[check_vol_status]=sudo %{_libdir}/nagios/plugins/gluster/check_volume_status.py -v \$ARG1\$ -t \$ARG2\$
command[check_proc_status]=sudo %{_libdir}/nagios/plugins/gluster/check_gluster_proc_status.py -t \$ARG1\$
command[check_brick_status]=sudo %{_libdir}/nagios/plugins/gluster/check_gluster_proc_status.py -t BRICK -v \$ARG1\$ -b \$ARG2\$
command[discoverpeers]=sudo %{_libdir}/nagios/plugins/gluster/discoverpeers.py
command[discover_volume_list]=sudo %{_libdir}/nagios/plugins/gluster/discover_volumes.py -l
command[discover_volume_info]=sudo %{_libdir}/nagios/plugins/gluster/discover_volumes.py -v \$ARG1\$
command[discoverhostparams]=sudo %{_libdir}/nagios/plugins/gluster/discoverhostparams.py
command[configure_gluster_node]=sudo %{_libdir}/nagios/plugins/gluster/configure_gluster_node.py -c \$ARG1\$ -n \$ARG2\$ -H \$ARG3\$
%{_end_conf_section}
EOF
%_init_enable nrpe
%_init_enable glusterpmd
%_init_restart crond
%_init_restart rsyslog
%_init_restart glusterpmd

%preun
if [ "$1" -eq 0 ]; then
        %_init_disable glusterpmd
        %_init_stop glusterpmd
        %_remove_gluster_nagios_configs

fi

%files
%defattr(-,root,root,-)
%attr(0755, -, -) %{_libdir}/nagios/plugins/gluster/*
%attr(0755, -, -) %{_sysconfdir}/init.d/glusterpmd
%{_sysconfdir}/cron.d/gluster-sysstat.crontab
%{_sysconfdir}/rsyslog.d/glusternagios.conf
%{_sysconfdir}/sudoers.d/nrpe
%{_sysconfdir}/nagios/nagios_server.conf
%{_sysconfdir}/init.d/glusterpmd

%files tests
%defattr(-,root,root,-)
%{_datadir}/%{name}/tests/*

%changelog
* Sat Mar 08 2014 Bala FA <barumuga@redhat.com>
- Initial build.