ensure that runlevelagent starts when a new package is installed.
[monitor.git] / Monitor.spec
1 #
2 # $Id$
3
4
5 %define url $URL: svn+ssh://svn.planet-lab.org/svn/monitor/trunk/monitor.spec $
6
7 %define name monitor
8 %define version 3.0
9 %define taglevel 17
10
11 %define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
12 %global python_sitearch %( python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)" )
13
14 Name: %{name}
15 Version: %{version}
16 Release: %{release}
17 Source0: %{name}-%{version}.tar.bz2
18 License: GPL
19 Group: Applications/System
20 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
21
22 Vendor: PlanetLab
23 Packager: PlanetLab Central <support@planet-lab.org>
24 Distribution: PlanetLab %{plrelease}
25 URL: %(echo %{url} | cut -d ' ' -f 2)
26
27 Summary: Monitor account initialization for the root image.
28 Group: Applications/System
29
30 %description
31 Monitor is a collection of secondary scripts for configuring the node polling
32 system, syncing the PLC db with the monitoring database, notifying users,
33 interacting with PCU hardware, applying penalties to sites that violate
34 acceptable use.
35
36 ######################################## CLIENT
37
38 %package client
39 Summary: Monitor hooks for a PLC node
40 Group: Applications/System
41 Requires: curl
42 Requires: coreutils
43
44 %description client
45 The client scripts handle account creation inside of a node.  This will
46 include configuration setup for the monitoring agent running on the node.  It
47 will also include any cron or init scripts needed to perform this kind of
48 maintenance.
49 ######################################## Server Deps
50 %package server-deps
51 Summary: Monitor hooks for the PLC server.
52 Group: Applications/System
53
54 Requires: python
55 Requires: python-setuptools-devel
56 Requires: python-peak-util-extremes
57 Requires: TurboGears
58
59 Requires: compat-libstdc++-296
60 Requires: openssh-clients
61 Requires: perl-libwww-perl
62 Requires: perl-IO-Socket-SSL 
63 Requires: MySQL-python
64 Requires: nmap
65 Requires: rt3
66
67 Requires: plewww-plekit
68
69 #Requires: zabbix-client
70 #Requires: zabbix-gui
71 #Requires: zabbix-server
72
73 %description server-deps
74 The server side include all python modules and scripts needed to fully
75
76 ######################################## Server
77 %package server
78 Summary: Monitor hooks for the PLC server.
79 Group: Applications/System
80
81 Requires: python
82
83 Requires: monitor-server-deps
84 Requires: monitor-pcucontrol
85 Requires: PLCWWW >= 4.2
86 Requires: bootcd-%{pldistro}-%{_arch} >= 4.2
87
88 %description server
89 The server side include all python modules and scripts needed to fully
90 operation, track, and interact with any third-party monitoring software, such
91 as Zabbix DB.
92
93 ######################################## RT setup
94
95 %package rt
96 summary: Dependencies and default configuration for RT3
97 group: applications/system
98 Requires: monitor-server
99 Requires: rt3
100 Requires: rt3-mailgate
101
102 %description rt
103 RT3 is a ticket tracking system.  This RPM integrates RT into the MyOps
104 framework, and MyPLC in general.
105
106 ######################################## PCU Control
107
108 %package pcucontrol
109 summary: pcu controls for monitor and plcapi
110 group: applications/system
111 requires: python
112
113 %description pcucontrol
114 both monitor and the plcapi use a set of common commands to reboot machines
115 using their external or internal pcus.  this package is a library of several
116 supported models.
117
118 ####################################### RunlevelAgent
119 %package runlevelagent
120 summary: the RunlevelAgent that reports node runlevels
121 group: applications/system
122 requires: python
123
124 %description runlevelagent
125 The RunlevelAgent starts as early as possible during boot-up and production
126 mode to actively report the observed runlevel to PLC and update the
127 'last_contact' field.
128
129 %prep
130 %setup -q
131
132 %build
133 # NOTE: the build uses g++ cmdamt/
134 # NOTE: TMPDIR is needed here b/c the tmpfs of the build vserver is too small.
135 cd pcucontrol/models/intelamt
136 export TMPDIR=$PWD/tmp
137 make
138 cd ..
139
140 %install
141 rm -rf $RPM_BUILD_ROOT
142 #################### CLIENT 
143 install -D -m 755 monitor-client.init $RPM_BUILD_ROOT/%{_initrddir}/monitor
144 install -D -m 644 monitor.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/monitor
145
146 #################### SERVER
147 install -d $RPM_BUILD_ROOT/usr/share/%{name}
148 install -d $RPM_BUILD_ROOT/data/var/lib/%{name}
149 install -d $RPM_BUILD_ROOT/data/var/lib/%{name}/archive-pdb
150 install -d $RPM_BUILD_ROOT/var/lib/%{name}
151 install -d $RPM_BUILD_ROOT/var/lib/%{name}/archive-pdb
152 install -d $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/
153 install -d $RPM_BUILD_ROOT/var/www/html/monitorlog/
154
155 install -D -m 644 monitor.functions $RPM_BUILD_ROOT/%{_sysconfdir}/plc.d/monitor.functions
156 install -D -m 755 monitor-server.init $RPM_BUILD_ROOT/%{_sysconfdir}/plc.d/monitor
157 install -D -m 755 zabbix/monitor-zabbix.init $RPM_BUILD_ROOT/%{_sysconfdir}/plc.d/zabbix
158 install -D -m 755 rt3/monitor-rt3.init $RPM_BUILD_ROOT/%{_sysconfdir}/plc.d/rt3
159
160 echo " * Installing core scripts"
161 rsync -a --exclude www --exclude archive-pdb --exclude .svn --exclude CVS \
162           ./ $RPM_BUILD_ROOT/usr/share/%{name}/
163
164 echo " * Installing web pages"
165 rsync -a www/ $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/
166 rsync -a log/ $RPM_BUILD_ROOT/var/www/html/monitorlog/
167
168 echo " * Installing cron job for automated polling"
169 install -D -m 644 monitor-server.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/monitor-server.cron
170 echo " * TODO: Setting up Monitor account in local MyPLC"
171 # TODO: 
172
173 install -d $RPM_BUILD_ROOT/%{python_sitearch}/monitor
174 install -d -D -m 755 monitor $RPM_BUILD_ROOT/%{python_sitearch}/monitor
175 # TODO: need a much better way to do this.
176 rsync -a monitor/ $RPM_BUILD_ROOT/%{python_sitearch}/monitor/
177 #for file in __init__.py database.py config.py ; do 
178 #       install -D -m 644 monitor/$file $RPM_BUILD_ROOT/%{python_sitearch}/monitor/$file
179 #done
180 rsync -a pcucontrol/ $RPM_BUILD_ROOT/%{python_sitearch}/pcucontrol/
181 install -D -m 755 threadpool.py $RPM_BUILD_ROOT/%{python_sitearch}/threadpool.py
182
183 touch $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/monitorconfig.php
184 chmod 777 $RPM_BUILD_ROOT/var/www/cgi-bin/monitor/monitorconfig.php
185
186 install -D -m 644 rt3/rt.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/rt.cron
187 chmod 755 $RPM_BUILD_ROOT/usr/share/%{name}/rt3/adduserstort.pl
188 chmod 755 $RPM_BUILD_ROOT/usr/share/%{name}/rt3/rtcron.d/*.sh
189 #install -D -m 755 monitor-default.conf $RPM_BUILD_ROOT/etc/monitor.conf
190 #cp $RPM_BUILD_ROOT/usr/share/%{name}/monitorconfig-default.py $RPM_BUILD_ROOT/usr/share/%{name}/monitorconfig.py
191
192 #################### RunlevelAgent
193 install -D -m 755 RunlevelAgent.py $RPM_BUILD_ROOT/usr/bin/RunlevelAgent.py
194 install -D -m 755 monitor-runlevelagent.init $RPM_BUILD_ROOT/%{_initrddir}/monitor-runlevelagent
195
196 mkdir -p $RPM_BUILD_ROOT/var/log
197 touch $RPM_BUILD_ROOT/var/log/server-deps.log
198
199
200 %clean
201 rm -rf $RPM_BUILD_ROOT
202
203 %files server-deps
204 /var/log/server-deps.log
205
206 %files server
207 %defattr(-,root,root)
208 #%config /usr/share/%{name}/monitorconfig.py
209 #%config /etc/monitor.conf
210 /usr/share/%{name}
211 /var/lib/%{name}
212 /var/www/cgi-bin/monitor
213 %{_sysconfdir}/cron.d/monitor-server.cron
214 %{python_sitearch}/threadpool.py
215 %{python_sitearch}/threadpool.pyc
216 %{python_sitearch}/threadpool.pyo
217 %{python_sitearch}/monitor
218 %{_sysconfdir}/plc.d/monitor
219 %{_sysconfdir}/plc.d/monitor.functions
220 %{_sysconfdir}/plc.d/zabbix
221
222 %files client
223 %defattr(-,root,root)
224 %{_initrddir}/monitor
225 %{_sysconfdir}/cron.d/monitor
226
227 %files rt 
228 %defattr(-,root,root)
229 /usr/share/%{name}/rt3
230 %{_sysconfdir}/plc.d/rt3
231 %{_sysconfdir}/cron.d/rt.cron
232
233 %files pcucontrol
234 %{python_sitearch}/pcucontrol
235
236 %files runlevelagent
237 /usr/bin/RunlevelAgent.py
238 /usr/bin/RunlevelAgent.pyo
239 /usr/bin/RunlevelAgent.pyc
240 /%{_initrddir}/monitor-runlevelagent
241
242 %post server-deps
243 #easy_install --build-directory /var/tmp -UZ ElementTree
244 ##easy_install --build-directory /var/tmp -UZ http://pypi.python.org/packages/2.5/E/Extremes/Extremes-1.1-py2.5.egg
245
246
247 ## TODO: something is bad wrong with this approach.
248 easy_install --build-directory /var/tmp -UZ http://files.turbogears.org/eggs/TurboGears-1.0.7-py2.5.egg
249 easy_install --build-directory /var/tmp -UZ http://pypi.python.org/packages/source/S/SQLAlchemy/SQLAlchemy-0.5.3.tar.gz
250 easy_install --build-directory /var/tmp -UZ Elixir
251
252 # crazy openssl libs for racadm binary
253 ln -s /lib/libssl.so.0.9.8b /usr/lib/libssl.so.2
254 mkdir /usr/share/monitor/.ssh
255 chmod 700 /usr/share/monitor/.ssh
256
257 if grep 'pam_loginuid.so' /etc/pam.d/crond ; then
258     sed -i -e 's/^session    required   pam_loginuid.so/#session    required   pam_loginuid.so/g' /etc/pam.d/crond
259 fi
260 # NOTE: add the default xml stuff if it's not already in the default xml config.
261 if ! grep '<category id="plc_monitor">' /etc/planetlab/default_config.xml ; then 
262     sed -i 's|<category id="plc_net">| <category id="plc_monitor">\n <name>Monitor Service Configuration</name>\n <description>Monitor</description>\n <variablelist>\n <variable id="enabled" type="boolean">\n <name>Enabled</name>\n <value>true</value>\n <description>Enable on this machine.</description>\n </variable>\n <variable id="email">\n <value></value>\n </variable>\n <variable id="dbpassword">\n <value></value>\n </variable>\n <variable id="host" type="hostname">\n <name>Hostname</name>\n <value>pl-virtual-06.cs.princeton.edu</value>\n <description>The fully qualified hostname.</description>\n </variable>\n <variable id="ip" type="ip">\n <name>IP Address</name>\n <value/>\n <description>The IP address of the monitor server.</description>\n </variable>\n </variablelist>\n </category>\n <category id="plc_net">|' /etc/planetlab/default_config.xml
263 fi
264 if ! grep '<category id="plc_rt">' /etc/planetlab/default_config.xml ; then 
265     sed -i 's|<category id="plc_net">| <category id="plc_rt">\n <name>RT Configuration</name>\n <description>RT</description>\n <variablelist>\n <variable id="enabled" type="boolean">\n <name>Enabled</name>\n <value>false</value>\n <description>Enable on this machine.</description>\n </variable>\n <variable id="host" type="hostname">\n <name>Hostname</name>\n <value>localhost.localdomain</value>\n <description>The fully qualified hostname.</description>\n </variable>\n <variable id="ip" type="ip">\n <name>IP Address</name>\n <value/>\n <description>The IP address of the RT server.</description>\n </variable>\n </variablelist>\n </category>\n <category id="plc_net">|' /etc/planetlab/default_config.xml
266 fi
267 if ! grep '<category id="plc_zabbix">' /etc/planetlab/default_config.xml ; then 
268     sed -i 's|<category id="plc_net">| <category id="plc_zabbix">\n <name>Zabbix Configuration</name>\n <description>Zabbix</description>\n <variablelist>\n <variable id="enabled" type="boolean">\n <name>Enabled</name>\n <value>false</value>\n <description>Enable on this machine.</description>\n </variable>\n <variable id="host" type="hostname">\n <name>Hostname</name>\n <value>localhost.localdomain</value>\n <description>The fully qualified hostname.</description>\n </variable>\n <variable id="ip" type="ip">\n <name>IP Address</name>\n <value/>\n <description>The IP address of the Zabbix server.</description>\n </variable>\n </variablelist>\n </category>\n <category id="plc_net">|' /etc/planetlab/default_config.xml
269 fi
270
271 # NOTE: enable monitor by default, since we're installing it.
272 plc-config --save /etc/planetlab/default_config.xml \
273                         --category plc_monitor --variable enabled --value true
274
275 %post rt
276 plc-config --save /etc/planetlab/default_config.xml \
277                         --category plc_rt --variable enabled --value true
278
279 %post server
280 # TODO: this will be nice when we have a web-based service running., such as
281 #               an API server or so on.
282 # TODO: create real monitorconfig.py from monitorconfig-default.py
283 # TODO: create monitorconfig.php using phpconfig.py 
284 # TODO: create symlink in /var/lib/monitor for chroot environments
285 # TODO: update the content of automate_pl03.sh 
286 # TODO: Use the installed version of bootcd to create custom boot images. ( or, use the api now).
287
288 # NOTE: generate the python defines from zabbix include files.
289 #php /usr/share/%{name}/zabbix/getdefines.php > %{python_sitearch}/monitor/database/zabbixapi/defines.py
290
291 # apply patches to zabbix
292 #patch -d /var/www/html/zabbix/ -p0 < /usr/share/%{name}/zabbix/zabbix-auto-login.diff
293
294 #chkconfig --add monitor-server
295 #chkconfig monitor-server on
296
297 %post client
298 chkconfig --add monitor
299 chkconfig monitor on
300
301 %post runlevelagent
302 chkconfig --add monitor-runlevelagent
303 chkconfig monitor-runlevelagent on
304 if [ "$PL_BOOTCD" != "1" ] ; then
305         service monitor-runlevelagent restart
306 fi
307
308
309 %changelog
310 * Thu Jun 18 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-17
311 - added bootmanager log links
312 - addressed root cause of IntegrityErrors ; big deal
313 - adjusted templates to accomodate fix for IntegrityErrors
314 - added session.flush() to bootman.py to write out ActionsRecords
315 - fixed policy to either pause penalties or apply them ; not both.
316
317 -* Wed Jun 17 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-16
318 -- Added Rpyc from 1.0 branch.
319 -- add pcuhistory
320 -- add setup-agent for password protected keys.
321 -- other minor improvements.
322
323 * Wed Jun 17 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-15
324 - automate install
325 - auto-close tickets
326
327 * Fri Jun 12 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-14
328 - update web
329 - update policy
330 - added statistics dir
331
332 * Mon Jun 08 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-13
333 - remove plccache from controllers, all lookups from db.
334 - reformat emailTxt messags
335 - updated bootstates in bootman.py
336
337 * Tue Jun 02 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-12
338 - tag of latest changes.
339 - need to test end to end.
340
341 * Sat May 30 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - Monitor-3.0-11
342 - big merge from the 2.0 branch
343
344 * Tue May 26 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - Monitor-3.0-10
345 - minor improvements in rendering with sortable tables
346
347 * Tue May 19 2009 Baris Metin <Talip-Baris.Metin@sophia.inria.fr> - Monitor-3.0-9
348
349 * Fri May 15 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - Monitor-3.0-8
350 - first draft with sortable tables + checkpoint
351
352 * Fri May 15 2009 Baris Metin <tmetin@sophia.inria.fr>
353 - use plekit tables from plewww.
354 - depend on plewww-plekit
355
356 * Tue May 12 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-7
357 - make docs a noop
358 - fix for package name dependency
359 - correct docs
360
361 * Mon May 04 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-6
362 - add improved docs to the latest build and tag.
363
364 * Mon May 04 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-5
365 - add documentation hooks for adding in-line docs like NM and PLCAPI
366
367 * Fri May 01 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-4
368 - Rough pass over monitor-3.0 to allow it to work with 4.3 API.
369 - replaced GetNodeNetworks, nodeinterface_ids and using new bootstates
370 - 'safeboot', 'failboot', 'reinstall', etc.
371
372 * Tue Apr 28 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-3
373 - same as 2.0-12 tag.
374
375 * Mon Apr 27 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-2
376 - merge from 2.0, remove more zabbix code, simplify install, etc.
377
378 * Thu Apr 16 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-1
379 - major merge from 2.0 branch.
380 - ready to be updated with 4.3 and web changes.
381
382 * Fri Feb 27 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-2.0-1
383 - preparing to make a 2.0 branch for monitor.
384
385 * Mon Jan 05 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-2.0-0
386 - new changes are significantly different, that I'm upping the number for clarity.
387
388 * Wed Sep 24 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-1.0-8
389 - These are all changes in the latest Monitor code.  I will branch this version
390 - next, before making additional large changes.
391
392 * Mon Sep 01 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - Monitor-1.0-7
393 - Checkpointing current version for 4.2-rc21 - many many changes
394
395 * Mon Aug 11 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-1.0-6
396 - This is a major tag of every thing.  probably needs a very different release
397 - number.
398
399 * Fri Jul 18 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-1.0-5
400 - Incremental improvements
401
402 * Mon May 19 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-1.0-4
403 - tagging everything for OneLab tech-transfer.
404
405
406 * Fri May 09 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-1.0-3
407
408
409 * Mon May 05 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-1.0-2
410
411
412 * Wed Apr 23 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-1.0-1
413 - This should be ready for 4.2rc2
414
415
416 * Mon Apr 07 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - monitor-1.0-0
417 - initial addition.
418
419 %define module_current_branch 2.0