diff options
author | Greg Frost <gregfrost1@bigpond.com> | 2009-08-15 00:07:26 (GMT) |
---|---|---|
committer | Greg Frost <gregfrost1@bigpond.com> | 2009-08-15 00:07:26 (GMT) |
commit | c639fb92a07cea0d6aa7ebf21a67ad813f8eefcb (patch) | |
tree | a71a7a6d7a809905843101ccdcf6239565782049 /abs/core-testing/linhes-scripts/src/idle.sh | |
parent | d68de00767d3ef08d8c026f249b6dc03ad85370f (diff) | |
download | linhes_pkgbuild-c639fb92a07cea0d6aa7ebf21a67ad813f8eefcb.zip linhes_pkgbuild-c639fb92a07cea0d6aa7ebf21a67ad813f8eefcb.tar.gz linhes_pkgbuild-c639fb92a07cea0d6aa7ebf21a67ad813f8eefcb.tar.bz2 |
linhes-scripts: rename src to scripts
Diffstat (limited to 'abs/core-testing/linhes-scripts/src/idle.sh')
-rwxr-xr-x | abs/core-testing/linhes-scripts/src/idle.sh | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/abs/core-testing/linhes-scripts/src/idle.sh b/abs/core-testing/linhes-scripts/src/idle.sh deleted file mode 100755 index f95b9fa..0000000 --- a/abs/core-testing/linhes-scripts/src/idle.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/bash - -usage () { - echo "Usage: $0 [-h] [-s] [-t <minutes_needed>]" - echo - echo "-h - Print this help/usage message and quit" - echo "-s - Run silently (default is verbose)" - echo "-t - Minutes of idle time needed (default is 20)" - echo "-v - Be more verbose for debugging" - echo - echo "Silent mode is recommended for use in cron jobs or scripts." - exit $1 -} - -msg () { # A status reporting function - [ "$VERBOSE" -ne 0 ] && echo "$*" -} - -mysql_cmd () { - /usr/bin/mysql -u root mythconverg -sBe "$*" -} - -# Command line argument handling -VERBOSE=1 -TIME_BEFORE=20 -TIME_AFTER=5 # Only adjustable by editing here - -while getopts "hst:v" OPT ; do - case $OPT in - h) usage 0 ;; - s) VERBOSE=0 ;; - t) TIME_BEFORE=$OPTARG ;; - v) VERBOSE=2 ;; - *) usage 1 ;; - esac -done -# Check for extra cruft on the command line... -shift $(($OPTIND - 1)) -[ -n "$*" ] && usage 1 - -msg "Checking what MythTV is doing now or plans within $TIME_BEFORE minutes..." -msg - -/usr/bin/mythshutdown -s 1 -BUSY="$?" -msg "mythshutdown returned $BUSY" -# Ignore certain non-zero flag values -BUSY=$(($BUSY & 0x2F)) - -SCHEMALOCK=$(mysql_cmd "select count(*) from schemalock") -msg "schemalock $SCHEMALOCK" - -JOBS=$(mysql_cmd "select count(*) from jobqueue where status = 4") -msg "running jobs $JOBS" - -INUSE=$(mysql_cmd "select count(*) from inuseprograms") -msg "inuse programs $INUSE" - -POTENTIAL=$(mysql_cmd "select count(*) from recordmatch as rm, program as p - where rm.chanid = p.chanid and rm.starttime = p.starttime - and rm.starttime < now() + interval $TIME_BEFORE minute - and now() < p.endtime + interval $TIME_AFTER minute") -msg "potential recordings $POTENTIAL" -# See if any of the potential upcoming recordings are real. -# This is ugly, but only the backend knows what programs it really -# plans to record or ignore, so we can't just check the DB. :-( -if [ "$VERBOSE" -ge 2 ] ; then - mysql_cmd "select p.starttime, p.endtime, p.title, subtitle - from recordmatch as rm, program as p - where rm.chanid = p.chanid and rm.starttime = p.starttime - and rm.starttime < now() + interval $TIME_BEFORE minute - and now() < p.endtime + interval $TIME_AFTER minute - order by p.starttime, p.endtime" -fi -UPCOMING=$(/usr/bin/mythbackend --printsched 2>&1 | - /bin/awk -v potential=$POTENTIAL ' - BEGIN {item=-1;real=0} - /--- print list start ---/,/--- print list end ---/ { - if (item>0 && item<=potential && substr($0,70,1) ~ "[0-9]") real+=1; - item += 1; - } - END {print real} -') -msg "planned recordings $UPCOMING" -if [ "$VERBOSE" -ge 2 ] ; then - /usr/bin/mythbackend --printsched 2>&1 | - /bin/awk -v potential=$POTENTIAL ' - BEGIN {item=-1} - /--- print list start ---/,/--- print list end ---/ { - if (item>0 && item<=potential) print $0; - item += 1; - }' -fi -activities=$(($BUSY + $SCHEMALOCK + $JOBS + $INUSE + $UPCOMING)) -msg -if [ "$activities" -eq 0 ] ; then - msg "System is idle" - exit 0 -else - msg "System is busy" - exit 1 -fi |