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