-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerlin.spec.in
More file actions
214 lines (177 loc) · 6.35 KB
/
Copy pathmerlin.spec.in
File metadata and controls
214 lines (177 loc) · 6.35 KB
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
%define mod_path /opt/monitor/op5/merlin
%define nagios_cfg /opt/monitor/etc/nagios.cfg
%define debug_package %{nil}
# prevent stripping of binaries
%define __spec_install_post /usr/lib/rpm/brp-compress
%{?dgroup:%define daemon_group %{dgroup}}
Summary: The merlin daemon is a multiplexing event-transport program
Name: merlin
Version: @@VERSION@@
Release: @@RELEASE@@
License: GPL
Group: op5/Monitor
URL: http://www.op5.se
Source0: %name-%version.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}
Prefix: /opt/monitor
Requires: libdbi
Requires: libaio
Requires: libdbi-dbd-mysql
Requires: ocilib >= 3.8
Requires: merlin-apps >= %version
Requires: monitor-config
BuildRequires: mysql-devel
BuildRequires: libdbi-devel
BuildRequires: ocilib-devel
BuildRequires: op5-nagios-devel >= 3.99.99.5
Obsoletes: monitor-reports-module
%description
The merlin daemon is a multiplexing event-transport program designed to
link multiple Nagios instances together. It can also inject status
data into a variety of databases, using libdbi.
%package -n monitor-merlin
Summary: A Nagios module designed to communicate with the Merlin daemon
Group: op5/Monitor
Requires: op5-nagios >= 3.99.99.4, merlin = %version-%release
Requires: monitor-config
%description -n monitor-merlin
monitor-merlin is an event broker module running inside Nagios. Its
only purpose in life is to send events from the Nagios core to the
merlin daemon, which then takes appropriate action.
%package apps
Summary: Applications used to set up and aid a merlin/ninja installation
Group: op5/Monitor
Requires: libdbi, rsync, MySQL-python
Obsoletes: monitor-distributed
%description apps
This package contains standalone applications required by Ninja and
Merlin in order to make them both fully support everything that a
fully fledged op5 Monitor install is supposed to handle.
'mon' works as a single entry point wrapper and general purpose helper
tool for those applications and a wide variety of other different
tasks, such as showing monitor's configuration files, calculating
sha1 checksums and the latest changed such file, as well as
preparing object configuration for pollers, helping with ssh key
management and allround tasks regarding administering a distributed
network monitoring setup.
%prep
%setup -q
%build
sed -i 's/^DEF_VER=.*/DEF_VER=%{version}-%{release}/' gen-version.sh
make ENABLE_OCILIB=1 ENABLE_LIBDBI=1 NAGIOS_PREFIX=/opt/monitor
make ENABLE_OCILIB=1 ENABLE_LIBDBI=1 NAGIOS_PREFIX=/opt/monitor test
%install
rm -rf %buildroot
sh install-merlin.sh --batch --root=%buildroot --bindir=%_bindir \
--libexecdir=%_libexecdir/merlin --install=files,apps,init \
--dest-dir %mod_path
chmod 777 %buildroot/%mod_path/logs
mkdir -p %buildroot/%mod_path/binlogs
mkdir -p %buildroot%_sysconfdir/logrotate.d
cp merlin.logrotate %buildroot%_sysconfdir/logrotate.d/merlin
# install plugins and create their symlinks
mkdir -p %buildroot/opt
cp -r apps/plugins %buildroot/opt
chmod 755 %buildroot/opt/plugins/*
for path in %buildroot/opt/plugins/*; do
full_f=${path##*/}
f=${full_f%.*}
ln -s $full_f %buildroot/opt/plugins/$f
done
# install crontabs
mkdir -p %buildroot%_sysconfdir/cron.d
cp apps/*.cron %buildroot%_sysconfdir/cron.d/
mkdir -p %buildroot/opt/monitor/op5/nacoma/hooks/save/
install -m 0755 op5build/nacoma_hook.py %buildroot/opt/monitor/op5/nacoma/hooks/save/merlin_hook.py
mkdir -p %buildroot%_sysconfdir/op5kad/conf.d
cp kad.conf %buildroot%_sysconfdir/op5kad/conf.d/merlin.kad
mkdir -p %buildroot%_sysconfdir/nrpe.d
cp nrpe-merlin.cfg %buildroot%_sysconfdir/nrpe.d
%post
# we must stop the merlin deamon so it doesn't interfere with any
# database upgrades, logfile imports and whatnot
/etc/init.d/merlind stop >/dev/null || :
# Verify that mysql-server is installed and running before executing sql scripts
$(mysql -Be "quit" 2>/dev/null)
if [ $? -eq 0 ]; then
%mod_path/install-merlin.sh --batch --install=db \
--nagios-cfg=%prefix/etc/nagios.cfg --dest-dir=%prefix/op5/merlin
else
echo "WARNING: mysql-server is not installed or not running."
echo "If Oracle database is to be used this is ok."
echo "If MySQL database is to be used you need to maually run:"
echo " %mod_path/install-merlin.sh --batch --install=db --nagios-cfg=%prefix/etc/nagios.cfg --dest-dir=%prefix/op5/merlin"
echo "to complete the setup of %name"
fi
# If mysql-server is running _or_ this is an upgrade
# we import logs
$(mysql -Be "quit" 2>/dev/null)
if [[ $? -eq 0 || $1 -eq 2 ]]; then
/sbin/chkconfig --add merlind
echo "Importing status events from logfiles to database"
mon log import --incremental
echo "Importing notifications from logfiles to database"
mon log import --only-notifications --incremental
fi
# restart all daemons
for daemon in merlind op5kad nrpe; do
test -f /etc/init.d/$daemon && /etc/init.d/$daemon restart || :
done
%pre -n monitor-merlin
# If we're upgrading the module while Nagios makes a call
# into it, we'll end up with a core-dump due to some weirdness
# in dlopen(). If we're installing anew, we need to update the
# config and then restart. Either way, it's safe to stop it
# unconditionally here
sh /etc/init.d/monitor stop || :
sh /etc/init.d/monitor slay || :
%preun -n monitor-merlin
if [ $1 -eq 0 ]; then
# removing the merlin module entirely
sh /etc/init.d/monitor stop || :
sh /etc/init.d/monitor slay || :
sed -i /merlin.so/d %prefix/etc/nagios.cfg
sh /etc/init.d/monitor start || :
sh /etc/init.d/merlind stop || :
fi
%post -n monitor-merlin
%mod_path/install-merlin.sh --batch --install=config \
--nagios-cfg=%nagios_cfg --dest-dir=%mod_path
sh /etc/init.d/monitor start || :
%files
%defattr(-,root,root)
%config(noreplace) %mod_path/merlin.conf
%mod_path/sql
%mod_path/merlind
%mod_path/install-merlin.sh
%mod_path/import.php
%mod_path/object_importer.inc.php
%mod_path/MerlinPDO.inc.php
%mod_path/oci8topdo.php
%mod_path/example.conf
%mod_path/init.sh
%_sysconfdir/logrotate.d/merlin
%_sysconfdir/op5kad/conf.d/merlin.kad
%_sysconfdir/nrpe.d/nrpe-merlin.cfg
/etc/init.d/merlind
%dir %mod_path/logs
%mod_path/binlogs
%files -n monitor-merlin
%defattr(-,root,root)
%mod_path/merlin.so
%files apps
%defattr(-,root,root)
%mod_path/import
%mod_path/showlog
%mod_path/ocimp
%mod_path/rename
/usr/libexec/merlin/*
/usr/bin/mon
%_sysconfdir/cron.d/*
/opt/plugins/*
/opt/monitor/op5/nacoma/hooks/save/merlin_hook.py*
%clean
rm -rf %buildroot
%changelog
* Tue Mar 17 2009 Andreas Ericsson <ae@op5.se>
- Initial specfile creation.