Copy head to branch. ALso bump spec.
[mom.git] / pl_mom.spec
1 %define name pl_mom
2 %define version 2.2
3 %define release 01%{?pldistro:.%{pldistro}}%{?date:.%{date}}
4  
5 Summary: PlanetLab node monitoring tools
6 Name: %{name}
7 Version: %{version}
8 Release: %{release}
9 License: GPL
10 Group: System Environment/Kernel
11 Source: %{name}-%{version}.tgz
12 Vendor: PlanetLab
13 Packager: PlanetLab Central <support@planet-lab.org>
14 Distribution: PlanetLab 3.0
15 URL: http://cvs.planet-lab.org/cvs/pl_mom
16 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
17 Requires: expect
18 # swapmon requires vps and bwlimit.py
19 Requires: util-vserver, util-vserver-python
20 # bwmon requires tc
21 Requires: iproute
22  
23 %description
24 pl_mom is a suite of PlanetLab node monitoring tools.
25
26 swapmon is a swap monitoring daemon. Every 30 seconds, it checks
27 process memory usage. At 90% utilization, resets the slice that is
28 consuming the most physical memory. At 95% utilization, it reboots the
29 machine to avoid a crash.
30
31 pl_mop is a cron job that "fixes" various common problems with nodes
32 (dead services, ext3 corruption, zombie SSH sessions, etc.).
33
34 %prep
35 %setup -q
36
37 %build
38
39 %install
40 rm -rf $RPM_BUILD_ROOT
41
42 # Utility functions
43 install -D -m 644 pl_mom.py $RPM_BUILD_ROOT/%{_datadir}/%{name}/pl_mom.py
44
45 # Bandwidth monitor (bwmon), run periodically
46 #install -D -m 755 bwmon.py $RPM_BUILD_ROOT/%{_datadir}/%{name}/bwmon.py
47
48 # Swap monitoring daemon (swapmon)
49 install -D -m 755 swapmon.py $RPM_BUILD_ROOT/%{_datadir}/%{name}/swapmon.py
50 install -D -m 755 swapmon.init $RPM_BUILD_ROOT/%{_initrddir}/swapmon
51
52 # Cleanup script
53 install -D -m 755 pl_mop.sh $RPM_BUILD_ROOT/usr/bin/pl_mop.sh
54
55 # Runs pl_mop and bwmon periodically
56 install -D -m 644 pl_mom.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/pl_mom
57
58 %clean
59 rm -rf $RPM_BUILD_ROOT
60
61 %pre
62 if [ "$PL_BOOTCD" != "1" ] ; then
63     service pl_mom stop
64 fi
65
66 exit 0
67
68 %post 
69 chkconfig --add swapmon
70 chkconfig swapmon on
71 if [ "$PL_BOOTCD" != "1" ] ; then
72     service swapmon restart
73 fi
74
75 # Randomize pl_mop run time
76 M=$((60 * $RANDOM / 32768))
77 H=$((24 * $RANDOM / 32768))
78 sed -i -e "s/@M@/$M/" -e "s/@H@/$H/" %{_sysconfdir}/cron.d/pl_mom
79
80 exit 0
81
82 %preun
83 # 0 = erase, 1 = upgrade
84 if [ "$1" -eq 0 ]; then
85     if [ "$PL_BOOTCD" != "1" ] ; then
86         service swapmon stop
87     fi
88     chkconfig swapmon off
89     chkconfig --del swapmon
90 fi
91
92 exit 0
93
94 %files
95 %defattr(-, root, root, -)
96 %{_datadir}/%{name}/pl_mom.py*
97 %{_datadir}/%{name}/swapmon.py*
98 %{_initrddir}/swapmon
99 /usr/bin/pl_mop.sh
100 %{_sysconfdir}/cron.d/pl_mom
101
102 %changelog
103 * Wed Jul 19 2006 Faiyaz Ahmed <faiyaza@cs.princeton.edu> 0.4-7.planetlab
104 - swapmon: Added state info so same reset email does not keep getting
105   sent. If slice is already being killed, will wait for a timeout
106   before trying to kill again.
107
108 * Mon Jul 17 2006 Faiyaz Ahmed <faiyaza@cs.princeton.edu> 0.4-6.planetlab
109 - swapmon: Added state information per slice.  Slices are now killed
110   after consuming more memory than the threshold more than twice.
111   Also fixed the slice restart issue where slices would be restarted
112   and repeated restart emails would be sent.
113
114 * Mon Jul 10 2006 Faiyaz Ahmed <faiyaza@cs.princeton.edu> 0.4-5.planetlab
115 - bwmon: Initialize default limits
116
117 * Mon Jul 10 2006 Faiyaz Ahmed <faiyaza@cs.princeton.edu> 0.4-4.planetlab
118 - bwmon: Use cached values if NM stops responding