View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 23 posts ] 
Go to page 1, 2  Next

Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Thu Jan 18, 2007 5:34 pm 
Offline
Joined: Fri Nov 18, 2005 9:22 am
Posts: 777
Location: spencerport, ny (USA)
Link: http://www.thornsoft.com/Misc/babysit_commflag.sh
Description: Utility to watch over mythcommflag and prevent it from hogging the CPU. This improves playback while commflag is running, so you don't have to restrict commflag to the wee hours of the morning.

Problem Solved: mythcommflag defaults to "nice" value 17. But that's not good enough. It needs to be 19 (lowest priority).

If you can't use commflagging without having to manually renice the priority to 19, this is for you.

Installation:
From a directory such as /tmp, as root:
Code:
wget http://www.thornsoft.com/Misc/babysit_commflag.sh
cp babysit_commflag.sh /usr/local/bin
chmod +x /usr/local/bin/babysit_commflag.sh


Test run: babysit_commflag.sh
It should exit with no messages, if mythcommflag isn't found, or IS found, but already is at 19. Otherwise, it'll renice to 19 and output a message saying that it did so.

Suggested usage - add this line to crontab:
Code:
* * * * * /usr/local/bin/babysit_commflag.sh >>/var/log/mythtv/babysit_commflag.log 2>&1


This runs the job every minute. You may have brief episodes of choppy playback when one job ends and another starts, but the babysitter will catch it within a minute, and calm it down.

Please leave feedback, suggestions, fixes here.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 23, 2007 7:32 pm 
Offline
Joined: Mon Nov 07, 2005 10:09 am
Posts: 153
commflag was always messing up my recordings so i enabled it to only occur in the middle of the night when no one would be watching. That fixed the problem, but with the obvious disadvantage of having to watch shows a day late to auto skip commercials.

I suspect i can let commflag run at anytime now.

My only remaining concern is if the bandwidth between master and slave backends becomes a bottleneck, rather than cpu cylces, will this help?

Possible solution to intranet bandwidth issues is using a quality of service setup with dd-wrt (prioritizing packets with specific datatype) I could maybe prioritize packets leaving the master "/myth/tv" store (to the remote frontends), over packets entering the master "/myth/tv" store (from the remote backends). So that frontends get the data they need on time with out hiccups. (i don't have gigE)

Other possibility would be a bandwidth_babysit script that ramps down something if bandwidth is an issue. It might be good discussion for a new thread. However, I will drop the idea for now until i verify that bandwidth and not disk i/o or cpu is really the issue while watching multiple streams of hd. (at 10/100 speeds)

Anyway, thanks for your scripts. Seems like a very useful and clever way to improve everyday use of knoppmyth.


Last edited by randomhtpcguy on Wed Jan 24, 2007 8:45 am, edited 2 times in total.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 23, 2007 10:55 pm 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
Nice. Added to next release.

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 8:56 am 
Offline
Joined: Fri Oct 20, 2006 12:04 pm
Posts: 905
Location: LA, CA
This works great!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 9:26 am 
Offline
Joined: Fri Nov 18, 2005 9:22 am
Posts: 777
Location: spencerport, ny (USA)
cesman wrote:
Nice. Added to next release.

I'm Honored! Thanks.


Top
 Profile  
 
PostPosted: Fri Feb 02, 2007 12:12 am 
Offline
Joined: Wed Apr 28, 2004 10:42 pm
Posts: 405
Location: Bendigo, Victoria, Australia
thornsoft wrote:
Suggested usage - add this line to crontab:
Code:
* * * * * /usr/local/bin/babysit_commflag.sh >>/var/log/mythtv/babysit_commflag.log 2>&1



NOTE: If you're putting it into the system crontab you need to include the user name in field six.
Code:
 * * * * * root /usr/local/bin/babysit_commflag.sh >>/var/log/mythtv/babysit_commflag.log 2>&1

[/quote]

_________________
Paul Turpie
-------------
<--Is your location in your profile? Why not?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 03, 2007 3:05 pm 
Offline
Joined: Wed Dec 21, 2005 1:14 pm
Posts: 145
Location: Charlotte NC USA
Just wanted to let you know, I added this to my backend over a week ago and seems to be working fine.

Thanks for the script


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 03, 2007 5:35 pm 
Offline
Joined: Sat Feb 04, 2006 7:58 pm
Posts: 21
Great work.

For safety's sake you should ensure that you rotate the logfile as well.

Add the following to /etc/logrotate.d/babysit_commflag (assuming you use the log file/path in the crontab entry):

Code:
/var/log/mythtv/babysit_commflag.log {
        daily
        rotate 7
        notifempty
        copytruncate
        compress
}

_________________
Perth, Western Australia.

R5F1
P4 3.2Ghz (Northwood)
AsRock P4i65G
Nvidia FX5200 (Fanless)
512Mb PC 3200
2 x WDC WD1200JB-00FUA0 120Gb PATA
Atheros AR5212 802.11abg NIC
DVD-RW ASUS DRW-1608P2S
2 x DVICO DVB-T Lite


Top
 Profile  
 
PostPosted: Sun Mar 04, 2007 5:45 am 
Offline
Joined: Thu Oct 20, 2005 5:43 pm
Posts: 134
thornsoft wrote:
Link: [url]

Problem Solved: mythcommflag defaults to "nice" value 17. But that's not good enough. It needs to be 19 (lowest priority).

If you can't use commflagging without having to manually renice the priority to 19, this is for you.


Thanks for the solution. I just wanted to mention that it can be worse than "nice" 17 when it starts. I started a comm flag job manually from the recorded pprograms menu and found this in the log later
Code:
Sun Mar  4 20:38:02 EST 2007 : commflag pid [6461] at ni [0], renicing to 19.

[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 04, 2007 10:21 am 
Offline
Joined: Sun Sep 25, 2005 3:50 pm
Posts: 1013
Location: Los Angeles
This script worked very well for me, too except... I have a non-standard installation and my root partition is not really big (3 GB), but I've never had a problem with it filling up until a few days ago. It seems that an entry is written to my syslog everytime this script runs because it is envoked by cron. I had the script running every minute from mythtv's crontab. I deleted my old, large log files as well as stopped the script from running in cron. That cleared up my partiton. I was looking at webmin trying to figure out if there was a way to exclude just this script from logging in my syslog, but nothing jumped out at me. Anyone have any ideas?

_________________
Mike
My Hardware Profile


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 04, 2007 10:39 am 
Offline
Joined: Fri Nov 18, 2005 9:22 am
Posts: 777
Location: spencerport, ny (USA)
mihanson wrote:
trying to figure out if there was a way to exclude just this script from logging in my syslog, but nothing jumped out at me. Anyone have any ideas?

Dang! I never knew that crap showed up there. Mine seems to be rotating off though. Still, my syslogs are fill of it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 08, 2007 11:03 am 
Offline
Joined: Sun Sep 25, 2005 3:50 pm
Posts: 1013
Location: Los Angeles
To help with my issue of log size, I adjusted my crontab to run every 3 minutes instead of every minute. I also found and deleted a bunch of mysql .bin files that I did not need. My root partition is at about 75% full now and things seem much better.

_________________
Mike
My Hardware Profile


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 16, 2007 10:02 pm 
Offline
Joined: Wed Sep 13, 2006 2:14 pm
Posts: 20
I noticed that the script only worked for a single commflag process. I wanted to allow for multiple commflaging processes to run simultaneously, so I modified the script...

Code:
#!/bin/bash
# babysit_commflag.sh   v0.14 by Chris Thornton - chris@thornsoft.com
# Utility to renice commflag if it is running at higher than "nice" level 19.
# Home: http://www.thornsoft.com/Misc/babysit_commflag.sh
# Copyright 2007 Chris Thornton
# Free for any use.
# Installation:
#  cp babysit_commflag.sh /usr/local/bin
#  chmod +x /usr/local/bin/babysit_commflag.sh
# Usage: Add to crontab (crontab -e):
# * * * * * /usr/local/bin/babysit_commflag.sh >>/var/log/mythtv/babysit_commflag.log 2>&1

NOWDATE=$(date)
PROCCOMMFLAG=`ps -eo pid,ni,comm |grep "mythcommflag" | grep -v "<defunct>" \
    |grep -v grep | awk ' { print $1 } '`
#if commflag IS running, and NIce value <19...
for ARG in $PROCCOMMFLAG
do
    NICOMMFLAG=`ps -eo pid,ni,comm | grep "mythcommflag" | grep $ARG | \
        grep -v "<defunct>" | grep -v grep | awk ' { print $2 } '`
    if [ "${NICOMMFLAG}"  -ne "19" ]
    then
        renice 19 -p "${ARG}"
        echo "$NOWDATE : commflag pid [$ARG] at ni [$NICOMMFLAG], renicing to 19."
    fi
done


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 20, 2007 5:01 pm 
Offline
Joined: Sun Jan 22, 2006 12:37 am
Posts: 30
Location: Cleveland, OH
cesman wrote:
Nice. Added to next release.


This babysitting script is great, thank you. I think it might have been overlooked in R5F1. I wonder if it can be added in next time, especially any and all changes regarding crontab, logrotate, multiple commflag jobs.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 4:32 am 
Offline
Joined: Thu Feb 02, 2006 3:57 am
Posts: 31
I just stumbled across this thread and I was curious since I have been doing something similar. In my opinion, the script is overkill because the same thing can be accomplished without using a script at all. Just add this line to /etc/crontab:
Code:
* * * * * root renice 19 $(pidof mythcommflag)

Except for the logfile (which I don't even want), I think this does exactly what the script does and it works with multiple processes.

For those that don't want syslog filling up with this stuff, I believe the only option is to redirect all cron logging to /dev/null. To do this, edit /etc/syslog.conf. Add "cron," after the semicolon on the *.* line to exclude it from this catch-all rule. Then uncomment the cron.* line and change the logfile to /dev/null. The 2 lines should look like this when you're done:
Code:
*.*;cron,auth,authpriv.none     -/var/log/syslog
cron.*                          /dev/null

After saving the changes, restart syslogd:
Code:
/etc/init.d/sysklogd restart


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ] 
Go to page 1, 2  Next



All times are UTC - 6 hours




Who is online

Users browsing this forum: Baidu [Spider] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu