db_updater: Put parentheses back
[merlin.git] / merlin.spec
blobc9f34660dced1a26b411336dfce50dd697e17602
1 %define mod_path /opt/monitor/op5/merlin
2 %define nagios_cfg /opt/monitor/etc/nagios.cfg
4 %define install_args --batch --dest-dir=%mod_path \\\
5 --bindir=%_bindir --libexecdir=%_libdir/merlin --nagios-cfg=%nagios_cfg
7 %if 0%{?suse_version}
8 %define mysqld mysql
9 %define mysql_rpm mysql
10 %else
11 %define mysqld mysqld
12 %define mysql_rpm mysql-server
13 %endif
15 %{?dgroup:%define daemon_group %{dgroup}}
17 Summary: The merlin daemon is a multiplexing event-transport program
18 Name: merlin
19 Version: %{op5version}
20 Release: %{op5release}%{?dist}
21 License: GPLv2
22 Group: op5/Monitor
23 URL: http://www.op5.se
24 Source0: %name-%version.tar.gz
25 BuildRoot: %{_tmppath}/%{name}-%{version}
26 Prefix: /opt/monitor
27 Requires: libaio
28 Requires: merlin-apps >= %version
29 Requires: monitor-config
30 Requires: op5-mysql
31 BuildRequires: mysql-devel
32 BuildRequires: op5-nagios-devel >= 3.99.99.7
33 Obsoletes: monitor-reports-module
34 BuildRequires: check-devel
36 %if 0%{?suse_version}
37 BuildRequires: libdbi-devel
38 BuildRequires: pkg-config
39 Requires: libdbi1
40 Requires: libdbi-drivers-dbd-mysql
41 Requires(post): mysql-client
42 %else
43 BuildRequires: libdbi-devel
44 BuildRequires: pkgconfig
45 Requires: libdbi
46 Requires: libdbi-dbd-mysql
47 %endif
50 %description
51 The merlin daemon is a multiplexing event-transport program designed to
52 link multiple Nagios instances together. It can also inject status
53 data into a variety of databases, using libdbi.
56 %package -n monitor-merlin
57 Summary: A Nagios module designed to communicate with the Merlin daemon
58 Group: op5/Monitor
59 Requires: op5-nagios >= 3.99.99.7, merlin = %version-%release
60 Requires: monitor-config
61 Requires: op5-monitor-supported-database
63 %description -n monitor-merlin
64 monitor-merlin is an event broker module running inside Nagios. Its
65 only purpose in life is to send events from the Nagios core to the
66 merlin daemon, which then takes appropriate action.
69 %package apps
70 Summary: Applications used to set up and aid a merlin/ninja installation
71 Group: op5/Monitor
72 Requires: rsync
73 Requires: op5-monitor-supported-database
74 %if 0%{?suse_version}
75 Requires: libdbi1
76 Requires: python-mysql
77 %else
78 %if 0%{?rhel} <= 5
79 Requires: python26
80 Requires: python26-mysqldb
81 %else
82 Requires: MySQL-python
83 %endif
84 Requires: libdbi
85 %endif
86 Obsoletes: monitor-distributed
88 %description apps
89 This package contains standalone applications required by Ninja and
90 Merlin in order to make them both fully support everything that a
91 fully fledged op5 Monitor install is supposed to handle.
92 'mon' works as a single entry point wrapper and general purpose helper
93 tool for those applications and a wide variety of other different
94 tasks, such as showing monitor's configuration files, calculating
95 sha1 checksums and the latest changed such file, as well as
96 preparing object configuration for pollers, helping with ssh key
97 management and allround tasks regarding administering a distributed
98 network monitoring setup.
100 %package test
101 Summary: Test files for merlin
102 Group: op5/Monitor
103 Requires: monitor-livestatus
104 Requires: op5-nagios
105 Requires: merlin merlin-apps monitor-merlin
107 %description test
108 Some additional test files for merlin
110 %prep
111 %setup -q
113 %build
114 sed -i 's/^DEF_VER=.*/DEF_VER=%{version}-%{release}/' gen-version.sh
116 # If we're building for CentOS 5 we have some sed'ing to do
117 %if ( ! 0%{?suse_version} ) && ( 0%{?rhel} <= 5 )
118 # use python26 for 'mon'
119 sed -i '1s#/bin/python.*#/bin/python26#' apps/mon.py
120 %endif
123 make ENABLE_LIBDBI=1 NAGIOS_PREFIX=/opt/monitor
124 make ENABLE_LIBDBI=1 NAGIOS_PREFIX=/opt/monitor test
127 %install
128 rm -rf %buildroot
129 sh install-merlin.sh %install_args --root=%buildroot --install=files,apps,init
131 chmod 777 %buildroot/%mod_path/logs
132 mkdir -p %buildroot/%mod_path/binlogs
133 mkdir -p %buildroot%_sysconfdir/logrotate.d
134 cp merlin.logrotate %buildroot%_sysconfdir/logrotate.d/merlin
135 ln -s ../../../../usr/bin/merlind %buildroot/%mod_path/merlind
136 ln -s ../../../../%_libdir/merlin/import %buildroot/%mod_path/import
137 ln -s ../../../../%_libdir/merlin/ocimp %buildroot/%mod_path/ocimp
138 ln -s ../../../../%_libdir/merlin/showlog %buildroot/%mod_path/showlog
139 ln -s ../../../../%_libdir/merlin/merlin.so %buildroot/%mod_path/merlin.so
141 # install plugins and create their symlinks
142 mkdir -p %buildroot/opt
143 cp -r apps/plugins %buildroot/opt
144 chmod 755 %buildroot/opt/plugins/*
145 for path in %buildroot/opt/plugins/*; do
146 full_f=${path##*/}
147 f=${full_f%.*}
148 ln -s $full_f %buildroot/opt/plugins/$f
149 done
151 # install crontabs
152 mkdir -p %buildroot%_sysconfdir/cron.d
153 cp apps/*.cron %buildroot%_sysconfdir/cron.d/
155 mkdir -p %buildroot/opt/monitor/op5/nacoma/hooks/save/
156 sed -i 's#@@LIBEXECDIR@@#%_libdir/merlin#' op5build/nacoma_hook.py
157 install -m 0755 op5build/nacoma_hook.py %buildroot/opt/monitor/op5/nacoma/hooks/save/merlin_hook.py
159 mkdir -p %buildroot%_sysconfdir/op5kad/conf.d
160 cp kad.conf %buildroot%_sysconfdir/op5kad/conf.d/merlin.kad
162 mkdir -p %buildroot%_sysconfdir/nrpe.d
163 cp nrpe-merlin.cfg %buildroot%_sysconfdir/nrpe.d
166 %post
167 # we must stop the merlin deamon so it doesn't interfere with any
168 # database upgrades, logfile imports and whatnot
169 /etc/init.d/merlind stop >/dev/null || :
171 # Verify that mysql-server is installed and running before executing sql scripts
172 service %mysqld status 2&>1 >/dev/null
173 if [ $? -gt 0 ]; then
174 echo "Attempting to start %mysqld..."
175 service %mysqld start
176 if [ $? -gt 0 ]; then
177 echo "Abort: Failed to start %mysqld."
178 exit 1
182 $(mysql -Be "quit" 2>/dev/null) && MYSQL_AVAILABLE=1
183 if [ -n "$MYSQL_AVAILABLE" ]; then
184 %mod_path/install-merlin.sh %install_args --batch --install=db
185 else
186 echo "Can't login to %mysqld, probably because you have a root password set, bailing out..."
187 exit 1
190 /sbin/chkconfig --add merlind || :
192 # If mysql-server is running _or_ this is an upgrade
193 # we import logs
194 if [ $1 -eq 2 ]; then
195 echo "Importing status events from logfiles to database"
196 mon log import --incremental || :
197 echo "Importing notifications from logfiles to database"
198 mon log import --only-notifications --incremental || :
201 # restart all daemons
202 for daemon in merlind op5kad nrpe; do
203 test -f /etc/init.d/$daemon && /etc/init.d/$daemon restart || :
204 done
207 %pre -n monitor-merlin
208 # If we're upgrading the module while Nagios makes a call
209 # into it, we'll end up with a core-dump due to some weirdness
210 # in dlopen(). If we're installing anew, we need to update the
211 # config and then restart. Either way, it's safe to stop it
212 # unconditionally here
213 sh /etc/init.d/monitor stop || :
214 sh /etc/init.d/monitor slay || :
216 %preun -n monitor-merlin
217 if [ $1 -eq 0 ]; then
218 # removing the merlin module entirely
219 sh /etc/init.d/monitor stop || :
220 sh /etc/init.d/monitor slay || :
221 sed -i /merlin.so/d %prefix/etc/nagios.cfg
222 sh /etc/init.d/monitor start || :
223 sh /etc/init.d/merlind stop || :
226 %post -n monitor-merlin
227 sed -i 's#import_program = /opt/monitor/op5/merlin/import.php#import_program = /opt/monitor/op5/merlin/ocimp#g' %mod_path/merlin.conf
228 %mod_path/install-merlin.sh %install_args --install=config || :
229 sh /etc/init.d/monitor start || :
232 %files
233 %defattr(-,root,root)
234 %config(noreplace) %mod_path/merlin.conf
235 %mod_path/sample.merlin.conf
236 %mod_path/sql
237 %mod_path/merlind
238 %mod_path/install-merlin.sh
239 %_sysconfdir/logrotate.d/merlin
240 %_sysconfdir/op5kad/conf.d/merlin.kad
241 %_sysconfdir/nrpe.d/nrpe-merlin.cfg
242 /etc/init.d/merlind
243 %dir %mod_path
244 %dir %mod_path/logs
245 %mod_path/binlogs
246 /usr/bin/merlind
249 %files -n monitor-merlin
250 %defattr(-,root,root)
251 %mod_path/merlin.so
252 %_libdir/merlin/merlin.so
255 %files apps
256 %defattr(-,root,root)
257 %mod_path/import
258 %mod_path/showlog
259 %mod_path/ocimp
260 %mod_path/rename
261 %_libdir/merlin/*
262 %_bindir/mon
263 %_bindir/op5
264 %_sysconfdir/cron.d/*
265 /opt/plugins/*
266 /opt/monitor/op5/nacoma/hooks/save/merlin_hook.py*
268 %attr(700, -, -) %_libdir/merlin/mon/syscheck.db_mysql_check.sh
269 %attr(700, -, -) %_libdir/merlin/mon/syscheck.fs_ext_state.sh
270 %attr(700, -, -) %_libdir/merlin/mon/syscheck.proc_smsd.sh
272 %exclude %_libdir/merlin/mon/test.py*
273 %exclude %_libdir/merlin/mon/run-ci-test.sh
274 %exclude %_libdir/merlin/merlin.so
276 %files test
277 %_libdir/merlin/mon/test.py*
278 %_libdir/merlin/mon/run-ci-test.sh
280 %clean
281 rm -rf %buildroot
283 %changelog
284 * Tue Mar 17 2009 Andreas Ericsson <ae@op5.se>
285 - Initial specfile creation.