/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/when_idle/etc/init.d/when_idle
ViewVC logotype

Contents of /trunk/nl.nikhef.ndpf.tools/when_idle/etc/init.d/when_idle

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2343 - (show annotations) (download)
Tue Jul 19 09:55:39 2011 UTC (10 years, 6 months ago) by ronalds
File size: 1292 byte(s)
added delay before putting node back online after final reboot
1 #!/bin/sh
2
3 # put the node back online
4
5 PBS_MOM=pbs_mom
6 PBSNODES=/usr/bin/pbsnodes
7 WHEN_IDLE_FLAG=${WHEN_IDLE_FLAG:-"when_idle"}
8 VERBOSE=${VERBOSE:-0}
9 CLEAR_DELAY=${CLEAR_DELAY:-600}
10
11 # health check
12 if [ ! -x $PBSNODES ]; then
13 echo "Cannot execute $PBSNODES: $!" >&2
14 exit 1
15 fi
16
17 mom_pid=$(pgrep -u root "$PBS_MOM")
18 if [ -z "$mom_pid" ]; then
19 echo "Could not find a running pbs_mom process, will not put node back online" >&2
20 exit 2
21 fi
22
23 # Here we know that pbs_mom is running
24 # Check that the node is offline AND has the idle flag set
25 host=`hostname -f`
26 node_info=`$PBSNODES -a $host`
27
28 # Is the node currently offline?
29 echo $node_info | grep -q -e "state =.*offline"
30 if [ $? -eq 0 ]; then
31 [ $VERBOSE -gt 0 ] && echo "Node is offline"
32 else
33 [ $VERBOSE -gt 0 ] && echo "Node is not offline"
34 exit 2
35 fi
36
37 # Is the node offline with the "when_idle" flag?
38 echo $node_info | grep -q -e "note =.*$WHEN_IDLE_FLAG"
39 if [ $? -eq 0 ]; then
40 [ $VERBOSE -gt 0 ] && echo "Node has flag set"
41 else
42 [ $VERBOSE -gt 0 ] && echo "Node does not have flag set"
43 exit 2
44 fi
45
46 # sleep in background until reconfiguration etc have finished
47 # and only then put the node back online
48 ( sleep $CLEAR_DELAY ;
49 logger -p user.notice "Putting node $host back online" ;
50 $PBSNODES -c $host -N "" ) &
51
52 exit 0

Properties

Name Value
svn:executable *
svn:keywords id

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28