Révision 17f78427
Whitespace cleanup
- remove trailing whitespace
- remove empty lines at the end of files
| plugins/mythtv/mythtv_status_ | ||
|---|---|---|
| 2 | 2 |
# |
| 3 | 3 |
# Munin plugin for MythTV |
| 4 | 4 |
# This plugin can graph:- Encoder Status, Days Remaining in Schedule, Job schedule, Recording Schedule, Recorded Programes, Recorded hours |
| 5 |
#
|
|
| 5 |
# |
|
| 6 | 6 |
# Create a symbolic link to mythtv_status_{GraphType}
|
| 7 | 7 |
# Where {GraphType} can be encoder, epg, job, schedule, recorded
|
| 8 | 8 |
# for example mythtv_status_encoder |
| 9 | 9 |
# |
| 10 |
# NOTE: This plugin needs to run as root so add the following to your munin-node config file
|
|
| 10 |
# NOTE: This plugin needs to run as root so add the following to your munin-node config file |
|
| 11 | 11 |
# [mythtv_status*] |
| 12 | 12 |
# user=root |
| 13 | 13 |
# The http/xml status page must be enabled in the mythtv backend. |
| 14 | 14 |
# |
| 15 | 15 |
# $Log$ |
| 16 | 16 |
# Revision 0.1 2008/03/27 idobson |
| 17 |
# Code for all options except recorded implemented
|
|
| 17 |
# Code for all options except recorded implemented |
|
| 18 | 18 |
# |
| 19 | 19 |
# Revision 0.2 2008/03/28 idobson |
| 20 | 20 |
# Tidied up the code abit/removed dead functions |
| ... | ... | |
| 35 | 35 |
# Revision 0.7 2008/04/3 idobson |
| 36 | 36 |
# Now using SQL to read the number of days in the EPG |
| 37 | 37 |
# Changed recordings symlink to schedule, makes more sense |
| 38 |
#
|
|
| 38 |
# |
|
| 39 | 39 |
# Revision 0.8 2008/04/6 idobson |
| 40 | 40 |
# Tidied up the SQL code abit, moved it into a function. |
| 41 | 41 |
# |
| ... | ... | |
| 43 | 43 |
# Added a check that we got the XML data before trying to parse it. |
| 44 | 44 |
# |
| 45 | 45 |
# Revision 1.0 2008/04/15 idobson |
| 46 |
# Fixed undef returned from SQL query, it now returns 0,
|
|
| 46 |
# Fixed undef returned from SQL query, it now returns 0, |
|
| 47 | 47 |
# added error handler to SQL sub. It just dies with an error text. |
| 48 | 48 |
# |
| 49 | 49 |
# Revision 1.1 2008/05/03 idobson |
| ... | ... | |
| 94 | 94 |
my $result=""; |
| 95 | 95 |
my $gata=""; |
| 96 | 96 |
my $VideoInput=1; |
| 97 |
$GraphOption=`basename $0 | sed 's/^mythtv_status_//g' | tr '_' '-'` ;
|
|
| 97 |
$GraphOption=`basename $0 | sed 's/^mythtv_status_//g' | tr '_' '-'` ; |
|
| 98 | 98 |
chomp $GraphOption; |
| 99 | 99 |
|
| 100 | 100 |
PrepSQLRead(); |
| ... | ... | |
| 103 | 103 |
if ($ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
| 104 | 104 |
print "yes\n"; |
| 105 | 105 |
exit 0; |
| 106 |
}
|
|
| 106 |
} |
|
| 107 | 107 |
|
| 108 | 108 |
#Config Options |
| 109 | 109 |
##Configuration for encoder, no config data needs to read from anywhere |
| ... | ... | |
| 135 | 135 |
print "FreeEncoders.colour 00FF00\n"; |
| 136 | 136 |
print "HungEncoders.colour 000000\n"; |
| 137 | 137 |
print "HungEncoders.draw LINE1\n"; |
| 138 |
print "HungEncoders.label Encoders that have hung (no DB update)\n";
|
|
| 138 |
print "HungEncoders.label Encoders that have hung (no DB update)\n"; |
|
| 139 | 139 |
print "HungEncoders.warning 0:0\n"; |
| 140 | 140 |
} |
| 141 | 141 |
|
| ... | ... | |
| 147 | 147 |
print "graph_title MythTV EPG days/Programs\n"; |
| 148 | 148 |
print "graph_category tv\n"; |
| 149 | 149 |
print "graph_vlabel Days\/Programs\n"; |
| 150 |
|
|
| 150 |
|
|
| 151 | 151 |
@result=SQLQuery("SELECT DISTINCT `sourceid` FROM `cardinput`");
|
| 152 | 152 |
$VideoInput = 1; |
| 153 | 153 |
foreach $gata (@result) {
|
| ... | ... | |
| 259 | 259 |
@result=SQLQuery("SELECT count(*) FROM `capturecard` ");
|
| 260 | 260 |
my $FreeRecorders=$result[0]; |
| 261 | 261 |
my $ActiveTuners=0; |
| 262 |
@result=SQLQuery("SELECT videosource.name, count( inuseprograms.recusage )
|
|
| 262 |
@result=SQLQuery("SELECT videosource.name, count( inuseprograms.recusage )
|
|
| 263 | 263 |
FROM inuseprograms, channel, videosource |
| 264 | 264 |
WHERE inuseprograms.recusage = 'recorder' |
| 265 | 265 |
AND inuseprograms.chanid = channel.chanid |
| ... | ... | |
| 283 | 283 |
} |
| 284 | 284 |
print "FreeEncoders.value $FreeRecorders\n"; |
| 285 | 285 |
@result=SQLQuery("SELECT count(inuseprograms.recusage)
|
| 286 |
from inuseprograms
|
|
| 287 |
where inuseprograms.recusage = 'recorder'
|
|
| 286 |
from inuseprograms |
|
| 287 |
where inuseprograms.recusage = 'recorder' |
|
| 288 | 288 |
and (UNIX_TIMESTAMP( NOW( )) - UNIX_TIMESTAMP(inuseprograms.lastupdatetime)) / 60 > 20"); |
| 289 | 289 |
print "HungEncoders.value $result[0]\n"; |
| 290 | 290 |
} |
| ... | ... | |
| 296 | 296 |
foreach $gata (@result) {
|
| 297 | 297 |
print "EPGDays$VideoInput.value $gata\n"; |
| 298 | 298 |
$VideoInput++; |
| 299 |
}
|
|
| 299 |
} |
|
| 300 | 300 |
|
| 301 | 301 |
#Get number of programs in EPG per video source |
| 302 | 302 |
$VideoInput = 1; |
| ... | ... | |
| 324 | 324 |
@result=SQLQuery("SELECT COUNT(*) FROM `record`");
|
| 325 | 325 |
print "RecordingSchedules.value $result[0]\n"; |
| 326 | 326 |
|
| 327 |
#Connect to mythtv using the MythTV object
|
|
| 327 |
#Connect to mythtv using the MythTV object |
|
| 328 | 328 |
my $Repeats=0; |
| 329 | 329 |
my $Recordings=0; |
| 330 | 330 |
my $Conflicts=0; |
| ... | ... | |
| 374 | 374 |
sub PrepSQLRead {
|
| 375 | 375 |
my $hostname = `hostname`; |
| 376 | 376 |
chomp($hostname); |
| 377 |
|
|
| 377 |
|
|
| 378 | 378 |
# Read the mysql.txt file in use by MythTV. Could be in a couple places, so try the usual suspects |
| 379 | 379 |
my $found = 0; |
| 380 | 380 |
my @mysql = ('/usr/local/share/mythtv/mysql.txt',
|
| ... | ... | |
| 423 | 423 |
my ($QUERY) = @_; |
| 424 | 424 |
my @data; |
| 425 | 425 |
my $ref; |
| 426 |
my $dbh = DBI->connect_cached("DBI:mysql:$SQLDBName:$SQLServer", $SQLUser, $SQLPassword)
|
|
| 426 |
my $dbh = DBI->connect_cached("DBI:mysql:$SQLDBName:$SQLServer", $SQLUser, $SQLPassword)
|
|
| 427 | 427 |
or die "Couldn't connect to database: " . DBI->errstr; |
| 428 | 428 |
my $table_data = $dbh->prepare($QUERY) or die "Couldn't prepare statement: " . $dbh->errstr; |
| 429 | 429 |
$table_data->execute or die "Couldn't execute statement: " . $table_data->errstr; |
| ... | ... | |
| 435 | 435 |
return @data; |
| 436 | 436 |
} else {
|
| 437 | 437 |
return 0; |
| 438 |
}
|
|
| 438 |
} |
|
| 439 | 439 |
} |
| 440 | 440 |
|
| 441 | 441 |
# Returns true if the show is scheduled to record |
Formats disponibles : Unified diff