From 3ba0f14d951147802721a864b0e8f38990e551f6 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Thu, 9 Jul 2009 22:04:11 +0000 Subject: [PATCH] add a timeout command to the client package new boot manager sequence to bootman.py use timeout with scanapi operations --- Monitor.spec | 3 + monitor/bootman.py | 1 + monitor/scanapi.py | 8 +- timeout.pl | 275 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 283 insertions(+), 4 deletions(-) create mode 100755 timeout.pl diff --git a/Monitor.spec b/Monitor.spec index 8e237e7..f8986d9 100644 --- a/Monitor.spec +++ b/Monitor.spec @@ -130,6 +130,8 @@ rm -rf $RPM_BUILD_ROOT #################### CLIENT install -D -m 755 monitor-client.init $RPM_BUILD_ROOT/%{_initrddir}/monitor install -D -m 644 monitor.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/monitor +install -D -m 755 timeout.pl $RPM_BUILD_ROOT/usr/bin/timeout.pl + #################### SERVER install -d $RPM_BUILD_ROOT/usr/share/%{name} @@ -207,6 +209,7 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root) %{_initrddir}/monitor %{_sysconfdir}/cron.d/monitor +/usr/bin/timeout.pl %files pcucontrol %{python_sitearch}/pcucontrol diff --git a/monitor/bootman.py b/monitor/bootman.py index fdfadb2..c127611 100755 --- a/monitor/bootman.py +++ b/monitor/bootman.py @@ -448,6 +448,7 @@ class DebugInterface: "bminit-cfg-auth-getplc-update-installinit-validate-exception-bmexceptmount-exception-noinstall-update-debug-done", "bminit-cfg-auth-getplc-update-installinit-validate-bmexceptvgscan-exception-noinstall-update-debug-validate-bmexceptvgscan-done", "bminit-cfg-auth-getplc-update-installinit-validate-exception-noinstall-update-debug-validate-done", + "bminit-cfg-auth-getplc-installinit-validate-bmexceptvgscan-exception-noinstall-update-debug-validate-bmexceptvgscan-done", ]: sequences.update({n : "restart_bootmanager_rins"}) diff --git a/monitor/scanapi.py b/monitor/scanapi.py index 5928c5a..60ba41d 100644 --- a/monitor/scanapi.py +++ b/monitor/scanapi.py @@ -197,7 +197,6 @@ class ScanNodeInternal(ScanInterface): try: for port in [22, 806]: ssh = command.SSH('root', nodename, port) - #echo ' "fs_status":"'`touch /var/log/monitor 2>&1 ; if [ -d /vservers/ ] ; then touch /vservers/monitor.log 2>&1 ; fi ; grep proc /proc/mounts | grep ro,`'",' (oval, errval) = ssh.run_noexcept2(""" <<\EOF echo "{" @@ -211,11 +210,12 @@ class ScanNodeInternal(ScanInterface): ID=`grep princeton_comon /etc/passwd | awk -F : '{if ( $3 > 500 ) { print $3}}'` echo ' "princeton_comon_running":"'`ls -d /proc/virtual/$ID`'",' echo ' "princeton_comon_procs":"'`vps ax | grep $ID | grep -v grep | wc -l`'",' - echo ' "rpm_version":"'`rpm -q NodeManager`'",' - echo ' "rpm_versions":"'`rpm -q -a`'",' + echo ' "fs_status":"'`grep proc /proc/mounts | grep ro, ; if [ -x /usr/bin/timeout.pl ] ; then timeout.pl 20 touch /var/log/monitor 2>&1 ; if [ -d /vservers/ ] ; then timeout.pl 20 touch /vservers/monitor.log 2>&1 ; fi ; fi`'",' + echo ' "rpm_version":"'`if [ -x /usr/bin/timeout.pl ] ; then timeout.pl 30 rpm -q NodeManager ; fi`'",' + echo ' "rpm_versions":"'`if [ -x /usr/bin/timeout.pl ] ; then timeout.pl 45 rpm -q -a ; fi`'",' echo "}" EOF """) - + values['ssh_error'] = errval if len(oval) > 0: #print "OVAL: %s" % oval diff --git a/timeout.pl b/timeout.pl new file mode 100755 index 0000000..7ce8367 --- /dev/null +++ b/timeout.pl @@ -0,0 +1,275 @@ +#!/usr/bin/perl + +## timeout +## +## (c) 2004-2007 Piotr Roszatycki , GPL +## +## $Id: timeout.pl 4 2007-06-19 11:58:08Z piotr.roszatycki $ + +=head1 NAME + +timeout - Run command with bounded time. + +=head1 SYNOPSIS + +B S> + +B +S<[-I]> +I