View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 4 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Thu Jul 03, 2008 5:54 am 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
Hi,
I don't know if this is really the right place to put this but I find this little tweak I do quite handy.

As far as I can see the current "version" is about useless for the general world. It gives information that would only be used to for working on a problem. I work on a lot of problems, but my short term memory sort of sucks a little so I use "version" to help me along the way.

I do several things to Cecil's original ver.sh so that It will help me when I need a memory prompt.

First, I add two lines to /usr/local/bin/mythbackup

#!/bin/bash
echo -n "Last Backup was on ">/home/mythtv/lbu.txt
date >>/home/mythtv/lbu.txt

Then I add a line to /etc/X11/fluxbox/keys
echo "Mod1 v :ExecCommand ver.sh" >>/etc/X11/fluxbox/keys

Put in an entry into mythtv crontab
# Daily Drive space checkup
0 20 * * * sh /usr/bin/run-space-check.sh &>/dev/null

And add a modified (original was posted on forum somewhere) script called /usr/bin/run-space-check.sh

Code:
#!/bin/sh
# Drive space warning script
#-------------------------------------------------------------
lsmod |grep "ivtvfb "|cut -b1-6 >/tmp/tv
if [ "$(cat /tmp/tv)" = "ivtvfb" ]; then
fontsize="25"
fontcolor="lightyellow"
else
fontsize="34"
fontcolor="yellow"
fi
export DISPLAY=:0
export FONT="-adobe-helvetica-bold-*-*-*-$fontsize-*-*-*-*-*-*-*"
#----------------------------------------------------------------
email=0                    # 1 or greater to enable email
show=1                     # 1 to show osd
echo -n "" > /tmp/tts             # Nice to know when things happen
ALERT_PERCENTAGE=75        # 90% disk used, ~500mb remaining on stock install?
HOSTNAME=`hostname`
RREMAINING=`df / |awk '{print $5}' |tail -1 |sed s/%//`     # root status
MREMAINING=`df /myth |awk '{print $5}' |tail -1 |sed s/%//` # myth status

# root
echo " Root Partition has used ${RREMAINING}% of space." >>/tmp/tts
if [ $ALERT_PERCENTAGE -lt $RREMAINING ]; then
        date > /tmp/tts
        echo "WARNING, $HOSTNAME has ${RREMAINING}% root disk space used." >>/tmp/tts
        # bump flag
        email="$(($email + 1 ))"
        show="$(($show + 1 ))"
fi

ALERT_PERCENTAGE=85        # 85% myth partition used
REMAINING=`df /myth |awk '{print $5}' |tail -1 |sed s/%//`
# myth
echo " Myth Partition has used ${MREMAINING}% of space." >>/tmp/tts
if [ $ALERT_PERCENTAGE -lt $MREMAINING ]; then
        date > /tmp/tts
        echo "WARNING, $HOSTNAME has ${MREMAINING}%  disk space used for media." >>/tmp/tts
        # bump flag
        #email="$(($email + 1 ))"
        #show="$(($show + 1 ))"
fi

# show it from here if flagged
if [ $show -gt "1" ]; then
        cat /tmp/tts | osd_cat --l=8 --delay=6 --font=$FONT --shadow=3 --color=$ fontcolor  --pos=bottom --align=centre &
fi

# email it from here if flagged
if [ $email -gt "1" ]; then
#       Email me when root disk usage exceeds a specified percentage.
        date > /tmp/tts
        SENDER=mythtv@my.house
        RECIPIENT=emailme@my.work
        SMTP_SERVER=mail.my.isp
        df -h | sendEmail -f $SENDER -t $RECIPIENT -s $SMTP_SERVER -u "$HOSTNAME  has ${RREMAINING}% root disk space used."
        email=0
fi

#done


Finally, I beat up on Cecil's original /usr/local/bin/ver.sh script to make it useful to me.

Code:
#!/bin/bash
killall osd_cat
lsmod |grep "ivtvfb "|cut -b1-6 >/tmp/tv
if [ "$(cat /tmp/tv)" = "ivtvfb" ]; then
fontsize="25"
fontcolor="lightyellow"
else
fontsize="34"
fontcolor="yellow"
fi
export FONT="-adobe-helvetica-bold-*-*-*-$fontsize-*-*-*-*-*-*-*"
export DISPLAY=:0
cat /etc/KnoppMyth-version > /tmp/ver
date >> /tmp/ver
echo "....." >> /tmp/ver
/sbin/ifconfig |grep eth |cut -b1-4 >/tmp/net
/sbin/ifconfig "$(cat /tmp/net)" | sed -n -e '/inet addr:\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/s//\1/p' | cut -c11-26 >/tmp/ip
echo -n  "IP $(cat /tmp/ip) _._ MythTV  - " >> /tmp/ver
cat /etc/hostname >> /tmp/ver
echo "....." >> /tmp/ver
cat /etc/mythtv/version >> /tmp/ver
echo "....." >> /tmp/ver
/usr/bin/run-space-check.sh
cat /tmp/tts >> /tmp/ver
cat /home/mythtv/lbu.txt >> /tmp/ver
cat /tmp/ver | osd_cat --l=14 --delay=18 --font=$FONT --shadow=2 --color=$fontcolor --pos=middle --align=centre&


Now when I press alt v or select version on the menu, I get some meat & potatoes. Those with a 350 card will see if the ivtvfb is loaded as the font changes color and size to work with a tv out display.

One cavet, ip will be blank if you have two nics, you will have to manually select one or the other. ( l left room for improvments Smile ) Caution if doing copy and paste, watch for line wrapped lines!

Many thanks to tjc & Human who made it possible for me to offer this.small token Smile
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 03, 2008 8:29 am 
Offline
Joined: Sat Mar 11, 2006 4:01 pm
Posts: 61
Location: Tobaccoville, NC, USA
quick though. what format do you want the ip's listed as?

if you replace the following:
Code:
/sbin/ifconfig |grep eth |cut -b1-4 >/tmp/net
/sbin/ifconfig "$(cat /tmp/net)" | sed -n -e '/inet addr:\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/s//\1/p' | cut -c11-26 >/tmp/ip
echo -n  "IP $(cat /tmp/ip) _._ MythTV  - " >> /tmp/ver


with:
Code:
echo -n "IP(s) for Mythtv - " >> /tmp/ver
echo "" >> /tmp/ver
echo -n "$(/sbin/ifconfig |sed -n -e '/inet addr:\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/s//\1/p' |cut -c11-26)" >> /tmp/ver
echo "" >> /tmp/ver

you should wind up with something like this:

Code:
IP(s) for Mythtv -
172.16.2.63
1.2.3.4
127.0.0.1


Also, you dont have to create temp files for ip and net.

by the way, the this also handles multiple network cards. IF I run the original script on my box, instead of only getting the ip for eth0, I get nothing due to the script bombing out trying to ifconfig "eth0 eth1" or something similar.

_________________
"If the facts don't fit the theory, change the facts"
--Albert Einstein


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 03, 2008 8:32 am 
Offline
Joined: Sat Mar 11, 2006 4:01 pm
Posts: 61
Location: Tobaccoville, NC, USA
PS: good work though, and I love the idea of having more information available onscreen.

_________________
"If the facts don't fit the theory, change the facts"
--Albert Einstein


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 09, 2008 9:18 pm 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
Hi,

Thanks for the tips :) Not quite what I am after yet but does give me something to play with later on. Don't have the need for the lo ip to be displayed.

For those boy scouts, the _._ MythTV should have a meaning.

I did notice that I left out some other tid-bits that make for the rest of the information.
In the /usr/local/bin/mythbackup script, I add :
#!/bin/bash
echo -n "Last Backup run "> /home/mythtv/lbu.txt
date >> /home/mythtv/lbu.txt

#----------------------------------------------------------------------------

That is for the those like myself that don't remember when the last backup was started :)

And to compensate for the extra information, increase the line count to be ~ 18 in stead of 14
cat /tmp/ver | osd_cat --l=18 --delay=18 --font=$FONT --shadow=2 --color=$fontcolor --pos=middle --align=centre&

If and when I find the original space script I will also post the link so there is proper credits :)

It may not be pretty, but does work well enough for my needs.
Thanks
Mike


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 4 guests


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:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu