[120] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | # Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 4 | # contributor license agreements. See the NOTICE file distributed with |
---|
| 5 | # this work for additional information regarding copyright ownership. |
---|
| 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 7 | # (the "License"); you may not use this file except in compliance with |
---|
| 8 | # the License. You may obtain a copy of the License at |
---|
| 9 | # |
---|
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 11 | # |
---|
| 12 | # Unless required by applicable law or agreed to in writing, software |
---|
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 15 | # See the License for the specific language governing permissions and |
---|
| 16 | # limitations under the License. |
---|
| 17 | |
---|
| 18 | COMMANDS=( "qstat" "qalter" "checkjob" ) |
---|
| 19 | ERROR=0 |
---|
| 20 | for (( i=0; i<${#COMMANDS[@]}; i++ )) |
---|
| 21 | do |
---|
| 22 | cmd=${COMMANDS[$i]} |
---|
| 23 | CMD_PATH=`which $cmd 2>/dev/null` |
---|
| 24 | if [ $? -ne 0 ] |
---|
| 25 | then |
---|
| 26 | echo Could not find $cmd in PATH |
---|
| 27 | ERROR=1 |
---|
| 28 | fi |
---|
| 29 | done |
---|
| 30 | if [ $ERROR -ne 0 ] |
---|
| 31 | then |
---|
| 32 | exit 1 |
---|
| 33 | fi |
---|
| 34 | |
---|
| 35 | jobs=`qstat -i |grep -o -e '^[0-9]*'` |
---|
| 36 | for job in $jobs |
---|
| 37 | do |
---|
| 38 | echo -en "$job\t" |
---|
| 39 | PATTERN="job [^ ]* violates active HARD MAXPROC limit of \([0-9]*\) for user [^ ]*[ ]*(R: \([0-9]*\), U: \([0-9]*\))" |
---|
| 40 | OUT=`checkjob $job 2>&1|grep -o -e "$PATTERN"` |
---|
| 41 | if [ $? -eq 0 ] |
---|
| 42 | then |
---|
| 43 | echo -en "| Exceeds resource limits\t" |
---|
| 44 | COMMENT_FIELD=`echo $OUT|sed -e "s/$PATTERN/User-limits exceeded. Requested:\2 Used:\3 MaxLimit:\1/"` |
---|
| 45 | qstat -f $job|grep '^[ \t]*comment = .*$' >/dev/null |
---|
| 46 | if [ $? -ne 0 ] |
---|
| 47 | then |
---|
| 48 | echo -en "| Comment field updated\t" |
---|
| 49 | qalter $job -W comment="$COMMENT_FIELD" >/dev/null |
---|
| 50 | else |
---|
| 51 | echo -en "| Comment field already set\t" |
---|
| 52 | fi |
---|
| 53 | else |
---|
| 54 | echo -en "| Doesn't exceed limits.\t" |
---|
| 55 | fi |
---|
| 56 | echo |
---|
| 57 | done |
---|