Révision 17f78427
Whitespace cleanup
- remove trailing whitespace
- remove empty lines at the end of files
| plugins/mythtv/mythtv_programs | ||
|---|---|---|
| 2 | 2 |
# |
| 3 | 3 |
# Munin plugin for MythTV |
| 4 | 4 |
# This plugin can graph:- EPG programs per channel |
| 5 |
#
|
|
| 6 |
# NOTE: This plugin needs to run as root so add the following to your munin-node config file
|
|
| 5 |
# |
|
| 6 |
# NOTE: This plugin needs to run as root so add the following to your munin-node config file |
|
| 7 | 7 |
# [mythtv_status*] |
| 8 | 8 |
# user=root |
| 9 | 9 |
# |
| ... | ... | |
| 48 | 48 |
print "cannot find MythTV configuration file my.txt\n"; |
| 49 | 49 |
exit 1; |
| 50 | 50 |
} |
| 51 |
}
|
|
| 52 |
|
|
| 51 |
} |
|
| 52 |
|
|
| 53 | 53 |
#Config Options |
| 54 | 54 |
##Configuration for encoder, no config data needs to read from anywhere |
| 55 | 55 |
if ($ARGV[0] and $ARGV[0] eq "config"){
|
| ... | ... | |
| 71 | 71 |
print "Channel" . $Channel . "EPG.label EPG days for channel $gata\n"; |
| 72 | 72 |
$Ptr=0; |
| 73 | 73 |
} |
| 74 |
}
|
|
| 74 |
} |
|
| 75 | 75 |
exit 0; |
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 | 78 |
#Actually dump data to Munin |
| 79 |
@result=SQLQuery("SELECT o.chanid, (UNIX_TIMESTAMP(MAX(c.endtime))
|
|
| 80 |
- UNIX_TIMESTAMP(NOW()))/86400
|
|
| 81 |
FROM channel o, program c
|
|
| 79 |
@result=SQLQuery("SELECT o.chanid, (UNIX_TIMESTAMP(MAX(c.endtime))
|
|
| 80 |
- UNIX_TIMESTAMP(NOW()))/86400 |
|
| 81 |
FROM channel o, program c |
|
| 82 | 82 |
WHERE o.chanid = c.chanid |
| 83 |
AND o.visible = '1'
|
|
| 83 |
AND o.visible = '1' |
|
| 84 | 84 |
GROUP BY o.chanid"); |
| 85 | 85 |
my $Ptr=0; |
| 86 | 86 |
foreach $gata (@result) {
|
| ... | ... | |
| 89 | 89 |
$Ptr=1; |
| 90 | 90 |
} else {
|
| 91 | 91 |
if ( $gata > 12 ) {
|
| 92 |
print "Channel" . $Channel . "EPG.value 12.0\n";
|
|
| 93 |
} else {
|
|
| 92 |
print "Channel" . $Channel . "EPG.value 12.0\n"; |
|
| 93 |
} else {
|
|
| 94 | 94 |
print "Channel" . $Channel . "EPG.value $gata\n"; |
| 95 |
}
|
|
| 95 |
} |
|
| 96 | 96 |
$Ptr=0; |
| 97 | 97 |
} |
| 98 | 98 |
} |
| ... | ... | |
| 104 | 104 |
sub PrepSQLRead {
|
| 105 | 105 |
my $hostname = `hostname`; |
| 106 | 106 |
chomp($hostname); |
| 107 |
|
|
| 107 |
|
|
| 108 | 108 |
# Read the mysql.txt file in use by MythTV. Could be in a couple places, so try the usual suspects |
| 109 | 109 |
my $found = 0; |
| 110 | 110 |
my @mysql = ('/usr/local/share/mythtv/mysql.txt',
|
| ... | ... | |
| 153 | 153 |
my ($QUERY) = @_; |
| 154 | 154 |
my @data; |
| 155 | 155 |
my $ref; |
| 156 |
my $dbh = DBI->connect("DBI:mysql:$SQLDBName:$SQLServer", $SQLUser, $SQLPassword)
|
|
| 156 |
my $dbh = DBI->connect("DBI:mysql:$SQLDBName:$SQLServer", $SQLUser, $SQLPassword)
|
|
| 157 | 157 |
or die "Couldn't connect to database: " . DBI->errstr; |
| 158 | 158 |
my $table_data = $dbh->prepare($QUERY) or die "Couldn't prepare statement: " . $dbh->errstr; |
| 159 | 159 |
$table_data->execute or die "Couldn't execute statement: " . $table_data->errstr; |
| ... | ... | |
| 165 | 165 |
return @data; |
| 166 | 166 |
} else {
|
| 167 | 167 |
return 0; |
| 168 |
}
|
|
| 168 |
} |
|
| 169 | 169 |
} |
Formats disponibles : Unified diff