Title: [opsview] [9583] Improvements to reschedule_checks
- Revision
- 9583
- Author
- dferguson
- Date
- 2012-07-18 11:15:04 +0100 (Wed, 18 Jul 2012)
Log Message
Improvements to reschedule_checks
Tidy up to take better account of pipe file not being removed correctly
Log more detail about actions taken
Modified Paths
Modified: trunk/opsview-core/utils/reschedule_checks
===================================================================
--- trunk/opsview-core/utils/reschedule_checks 2012-07-18 08:03:52 UTC (rev 9582)
+++ trunk/opsview-core/utils/reschedule_checks 2012-07-18 10:15:04 UTC (rev 9583)
@@ -16,11 +16,42 @@
# along with Opsview; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# reschedule all checks on an opsview server in a balanced manner
-#
-# checks can get bunched up when running mass rechecks a lot
+# stop nagios, amend retention.dat to remove last/next check times,
+# restart nagios to reschedule everything in a balanced manner
+echo "$(date): Starting"
+echo "$(date): Shutting down Nagios"
+
/usr/local/nagios/bin/rc.opsview stop
-sleep 5
+
+pipe=/usr/local/nagios/var/rw/nagios.cmd
+
+inner_count_total=6
+inner_count=$inner_count_total
+outter_count=3
+while [ -e $pipe ]; do
+ sleep 5
+ echo "$(date): Waiting on pipe removal: inner_count=$inner_count outter_count=$outter_count"
+
+ if [ $inner_count -le 0 ]; then
+ if [ $outter_count -le 0 ]; then
+ echo "$(date): Failed to stop Nagios"
+ exit 255
+ fi
+
+ echo "$(date): Sending kill signal to Nagios processes"
+ pkill -9 -f bin/nagios
+ inner_count=$inner_count_total
+ outter_count=$((outter_count - 1))
+ fi
+ inner_count=$((inner_count - 1))
+done
+
+echo "$(date): Nagios stopped; continuing"
+
perl -n -i.bak -e 'print unless(m/(?:last|next)_check=/);' /usr/local/nagios/var/retention.dat
+
+echo "$(date): Starting Nagios"
/usr/local/nagios/bin/rc.opsview start
+
+echo "Completed at $(date)"
_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins