[mythtv-users] mythbackend still eats memory: the current status
Nick Morrott
knowledgejunkie at gmail.com
Wed May 20 23:14:15 UTC 2009
On 20/05/2009, Stephen Bridges <widget at stdin.co.uk> wrote:
> On Wednesday 20 May 2009 15:37:58 Nick Morrott wrote:
>
> > I'd suspected memory usage was growing over time (as the machine is
> > always on). Your initial posts on your increasing memory usage
> > convinced me to learn to write up some RRD scripts to monitor it over
> > time.
>
>
> I don't suppose you'd share these scripts? I've looked at trying to use
> rrdtool before but its learning curve looked too high for me.
These are the scripts I put together last year. They could probably do
with some tweaking but they seem to work for me (YMMV!):
--------------------- cut ---------------------
#!/bin/bash
#
# mythbackend-rrd-create.sh
#
# Creates an RRD database to record samples of RSS and VSZ taken every 10
# minutes.
#
# The first RRA takes a sample of 3 values and stores the last value in the DB.
# 1440 of these values are stored, providing 30 days of 30-minute figures.
#
# The second RRA takes a sample of 36 values and stores the last value in the
# DB. 720 of these values are stored, providing 180 days of 6-hour figures.
RRD_DB="/var/log/mythtv/mythbackend-mem-usage.rrd"
rrdtool create ${RRD_DB} \
--step 600 \
DS:RSS:GAUGE:1200:0:U \
DS:VSZ:GAUGE:1200:0:U \
RRA:LAST:0.5:3:1440 \
RRA:LAST:0.5:36:720
--------------------- cut ---------------------
--------------------- cut ---------------------
#!/bin/bash
#
# mythbackend-rrd-update.sh
#
# Script used to populate RRD database with data for mythbackend
# RSS/VSZ memory usage. Data also copied to log file.
#
# Script should be run every 10 minutes via cron, e.g.:
#
# 0-59/10 * * * * mythtv /usr/local/bin/mythbackend-rrd-update.sh
TIME=`/bin/date +%s`
DATA=`/bin/ps -C mythbackend -o rss=,vsz=`
LOG="/var/log/mythtv/mythbackend-mem-usage.log"
RRD="/var/log/mythtv/mythbackend-mem-usage.rrd"
RSS=`echo ${DATA} | awk -F ' ' '{print $1}'`
VSZ=`echo ${DATA} | awk -F ' ' '{print $2}'`
echo "${TIME}|${RSS}|${VSZ}" >> ${LOG}
rrdtool update ${RRD} N:${RSS}:${VSZ}
--------------------- cut ---------------------
--------------------- cut ---------------------
#!/bin/bash
#
# mythbackend-rrd-graph.sh
#
# Creates graphs showing RSS/VSZ memory usage for mythbackend based on existing
# RRD database, for previous 1 and 6 month periods.
GRAPH_FILE_1M="/var/www/html/mbe-mem-usage.png"
GRAPH_FILE_6M="/var/www/html/mbe-mem-usage-6months.png"
RRD_DB="/var/log/mythtv/mythbackend-mem-usage.rrd"
rrdtool graph ${GRAPH_FILE_1M} \
-a PNG \
--title="mythbackend RSS/VSZ memory usage (Last Month)" \
--height 400 \
--width 800 \
--vertical-label "KBytes" \
--end now \
--start end-4w \
--base 1024 \
--x-grid HOUR:6:DAY:1:DAY:7:0:%F \
DEF:RSS=${RRD_DB}:RSS:LAST \
LINE1:RSS#FF0000:RSS \
DEF:VSZ=${RRD_DB}:VSZ:LAST \
LINE1:VSZ#0000FF:VSZ \
'GPRINT:RSS:LAST:Current RSS\: %6.0lf bytes' \
'GPRINT:VSZ:LAST:Current VSZ\: %6.0lf bytes\j'
rrdtool graph ${GRAPH_FILE_6M} \
-a PNG \
--title="mythbackend RSS/VSZ memory usage (Last 6 Months)" \
--height 400 \
--width 800 \
--vertical-label "KBytes" \
--end now \
--start end-26w \
--base 1024 \
--x-grid DAY:1:WEEK:2:MONTH:1:0:%F \
DEF:RSS=${RRD_DB}:RSS:LAST:step=43200 \
LINE1:RSS#FF0000:RSS \
DEF:VSZ=${RRD_DB}:VSZ:LAST:step=43200 \
LINE1:VSZ#0000FF:VSZ \
'GPRINT:RSS:LAST:Current RSS\: %6.0lf bytes' \
'GPRINT:VSZ:LAST:Current VSZ\: %6.0lf bytes\j'
--------------------- cut ---------------------
Let me know if these work for you (or if they cause you problems) and
whether you have any suggestions to improve them.
Cheers,
Nick
--
Nick Morrott
MythTV Official wiki:
http://mythtv.org/wiki/
MythTV users list archive:
http://www.gossamer-threads.com/lists/mythtv/users
"An investment in knowledge always pays the best interest." - Benjamin Franklin
More information about the mythtv-users
mailing list