- bump release for initialization bugfix
[mom.git] / pl_mom.spec
1 %define name pl_mom
2 %define version 0.4
3 %define release 5%{?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 bwmon is a cron job that monitors the average bandwidth usage of each
32 slice and enforces a daily byte limit for each slice.
33
34 pl_mop is a cron job that "fixes" various common problems with nodes
35 (dead services, ext3 corruption, zombie SSH sessions, etc.).
36
37 %prep
38 %setup -q
39
40 %build
41
42 %install
43 rm -rf $RPM_BUILD_ROOT
44
45 # Utility functions
46 install -D -m 644 pl_mom.py $RPM_BUILD_ROOT/%{_datadir}/%{name}/pl_mom.py
47
48 # Bandwidth monitor (bwmon), run periodically
49 install -D -m 755 bwmon.py $RPM_BUILD_ROOT/%{_datadir}/%{name}/bwmon.py
50
51 # Swap monitoring daemon (swapmon)
52 install -D -m 755 swapmon.py $RPM_BUILD_ROOT/%{_datadir}/%{name}/swapmon.py
53 install -D -m 755 swapmon.init $RPM_BUILD_ROOT/%{_initrddir}/swapmon
54
55 # Cleanup script
56 install -D -m 755 pl_mop.sh $RPM_BUILD_ROOT/usr/local/planetlab/bin/pl_mop.sh
57
58 # Runs pl_mop and bwmon periodically
59 install -D -m 644 pl_mom.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/pl_mom
60
61 %clean
62 rm -rf $RPM_BUILD_ROOT
63
64 %pre
65 if [ "$PL_BOOTCD" != "1" ] ; then
66     service pl_mom stop
67 fi
68
69 exit 0
70
71 %post 
72 chkconfig --add swapmon
73 chkconfig swapmon on
74 if [ "$PL_BOOTCD" != "1" ] ; then
75     service swapmon restart
76 fi
77
78 # Randomize pl_mop run time
79 M=$((60 * $RANDOM / 32768))
80 H=$((24 * $RANDOM / 32768))
81 sed -i -e "s/@M@/$M/" -e "s/@H@/$H/" %{_sysconfdir}/cron.d/pl_mom
82
83 exit 0
84
85 %preun
86 # 0 = erase, 1 = upgrade
87 if [ "$1" -eq 0 ]; then
88     if [ "$PL_BOOTCD" != "1" ] ; then
89         service swapmon stop
90     fi
91     chkconfig swapmon off
92     chkconfig --del swapmon
93 fi
94
95 exit 0
96
97 %files
98 %defattr(-, root, root, -)
99 %{_datadir}/%{name}/pl_mom.py
100 %{_datadir}/%{name}/bwmon.py
101 %{_datadir}/%{name}/swapmon.py
102 %{_initrddir}/swapmon
103 /usr/local/planetlab/bin/pl_mop.sh
104 %{_sysconfdir}/cron.d/pl_mom
105
106 %changelog
107 * Mon Jul 10 2006 Faiyaz Ahmed <faiyaza@cs.princeton.edu> 0.4-5.planetlab
108 - bwlimit: Initialize default limits
109
110 * Mon Jul 10 2006 Faiyaz Ahmed <faiyaza@cs.princeton.edu> 0.4-4.planetlab
111 - bwlimit: Use cached values if NM stops responding