![如何使用 Conky 监控我的 mythtv 后端?](https://linux22.com/image/959067/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20Conky%20%E7%9B%91%E6%8E%A7%E6%88%91%E7%9A%84%20mythtv%20%E5%90%8E%E7%AB%AF%EF%BC%9F.png)
我想使用 Conky 来监控 mythtv 后端,我该如何设置?
答案1
只是对 mythtv-status 选项做一个快速评论,您可以设置主机选项,在/etc/default/mythtv-status
这种情况下,如果 mythtv-status 升级或重新安装,它会被记住。
您还可以设置其他选项,例如打开彩色输出并向输出添加其他信息。
答案2
来自论坛帖子(内容和语法已编辑):
我最近发现了这一点,因为我需要其他东西,但我认为检查远程和本地前端的状态可能会很好。
我编写了一个脚本,用于在 conky 中显示本地和远程前端的状态,我想与你分享。我刚刚开始学习编写脚本,这是我第一次尝试使用变量,我主要只是将一些可以从 shell 中输入的内容放入其中,而无需变量或错误更正,因此我为此学习了一些准备工作。
有关如何使用的说明位于文件的注释中,并且此链接应该让您了解 mythtv telnet 以及如何启用它。
第二张屏幕截图显示了我如何将它与 DemonBobs 想法和 conky mythtv 录制状态结合使用,请在此处找到
#!/bin/bash
#Made By Kemble Wagner
#To use this Script you need to Enable Network Remote Control Interface on Mythfrontend
#Thanks to wagnerrp from mythtv-users on freenode for his contributions and tips
#the output files are meant to be used with conky
#e.g .conkyrc
#${color #8844ee}Local Frontend Status:
#${color #8844ee} ${execi 30 mythnc.sh > /dev/null && cat /var/tmp/local.myth}
#${color #8844ee}Remote Frontend Status:
#${color #8844ee} ${execi 30 mythnc.sh > /dev/null && cat /var/tmp/remote.myth}
#Version 0.2 14/04/09
#Version 0.3 " " fixed sed to make it parse long file names and unusual characters with spaces and no spaces when outputting Video Playback
#Version 0.4 " " added more events to output in human friendly terms changes it so only one instance of nc is used to prevent hammering of ports
#Version 0.5 17/04/09 add some fixes to playback status and added a check status in the even the frontend not running but the host is up
#change the host names to suit add more if needed
LOCALHOST=box
#path to text file leave as default is ok
OUTPUTFILE1=/var/tmp/local.myth
OUTPUTFILETMP1=/var/tmp/local.myth.tmp
FETEST1=/var/tmp/local.fetest
FILENAME1=`cat $OUTPUTFILETMP1 | grep 'Playback Video' |sed -e 's/[[ \t]]*/_/g' | sed 's/\(.*\)\..*/\1/' | sed 's/ *//g' | sed -e 's/^.*\///;s/ .*$//'`
RECFILE1=`cat $OUTPUTFILETMP1 | grep 'Playback Recorded' |sed -e 's/[[ \t]]*/_/g' | sed 's/\(.*\)\..*/\1/' | sed 's/ *//g' | sed -e 's/^.*\///;s/ .*$//'`
#remote host variables
#the stuff below is an attempt to convert telnet status info into human friendly readable info
#below are localhost checks
nc -c exit $LOCALHOST 6546 && echo opened > $FETEST1|| echo closed > $FETEST1
#Checking if MythFrontend is running
if (cat $FETEST1 | grep closed ); then
echo "$LOCALHOST is up but MythFrontend doesn't seem to be running" > $OUTPUTFILE1
else
echo -e "query location\nexit" | nc $LOCALHOST 6546 > $OUTPUTFILETMP1
fi
#Checking for TV recording Menu
if (cat $OUTPUTFILETMP1 | grep PlaybackBox ); then
echo "$LOCALHOST is Idle in TV Recordings Menu" > $OUTPUTFILE1
else
#Checking for Program Guide
if (cat $OUTPUTFILETMP1 | grep GuideGrid ); then
echo " $LOCALHOST is in TV Guide" > $OUTPUTFILE1
else
#Checking for MythVideo Gallery
if (cat $OUTPUTFILETMP1 | grep videogallery ); then
echo "MythVideo Menu On $LOCALHOST is Idle" > $OUTPUTFILE1
else
#Checking for MythVideo Listings
if (cat $OUTPUTFILETMP1 | grep videolistings); then
echo "MythVideo Menu On $LOCALHOST is Idle" > $OUTPUTFILE1
else
#Checking for MythVideo Browser
if (cat $OUTPUTFILETMP1 | grep videobrowser); then
echo "MythVideo Menu On $LOCALHOST is Idle" > $OUTPUTFILE1
else
#Checking for MythMusics
if (cat $OUTPUTFILETMP1 | grep playmusic ); then
echo "Playing Music Cant you Hear?" > $OUTPUTFILE1
else
#Checking for MainMenu
if (cat $OUTPUTFILETMP1 | grep MainMenu ); then
echo "$LOCALHOST is in The Main Menu" > $OUTPUTFILE1
else
#Checking for Live TV
if (cat $OUTPUTFILETMP1 | grep "Playback LiveTV" ); then
echo "$LOCALHOST is Watching Live TV" > $OUTPUTFILE1
else
#Checking for MythVideo Playback
if (cat $OUTPUTFILETMP1 | grep "Playback Video" ); then
echo "MythVideo is playing $FILENAME1" > $OUTPUTFILE1
else
if (cat $OUTPUTFILETMP1 | grep "Playback Recorded" ); then
echo "MythTV is playing recording $RECFILE1" > $OUTPUTFILE1
else
#if none of the above simply display then query status output
if (cat $OUTPUTFILETMP1 | grep "#"); then
cat $OUTPUTFILETMP1 | grep "#" > $OUTPUTFILE1
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
#setting remote host variables you can reproduce this for as many hosts as you want
REMOTE=frontend
OUTPUTFILE2=/var/tmp/remote.myth
OUTPUTFILETMP2=/var/tmp/remote.myth.tmp
# script gets slow if the host is not up when continueing to set remote host variables so check its up first
#checking remote frontend is up first
if ! `/bin/ping -W1 -c1 $REMOTE >/dev/null 2>&1` ; then
echo "$REMOTE Seems Offline" > $OUTPUTFILE2 && exit 0
else
#contine setting remote host variables
FILENAME2=`cat $OUTPUTFILETMP2 | grep 'Playback Video' |sed -e 's/[[ \t]]*/_/g' | sed 's/\(.*\)\..*/\1/' | sed 's/ *//g' | sed -e 's/^.*\///;s/ .*$//'`
RECFILE2=`cat $OUTPUTFILETMP2 | grep 'Playback Recorded' | sed -e 's/^.*\///;s/ .*$//' | sed 's/\(.*\)\..*/\1/'`
FETEST2=/var/tmp/remote.fetest
#below are remote host checks
nc -c exit $REMOTE 6546 && echo opened > $FETEST2|| echo closed > $FETEST2
#Checking if MythFrontend is running
if (cat $FETEST2 | grep closed ); then
echo "$REMOTE is up but MythFrontend doesn't seem to be running" > $OUTPUTFILE2
else
echo -e "query location\nexit" | nc $REMOTE 6546 > $OUTPUTFILETMP2
fi
#Checking for TV recording Menu
if (cat $OUTPUTFILETMP2 | grep PlaybackBox ); then
echo "$REMOTE is Idle in TV Recordings Menu" > $OUTPUTFILE2
else
#Checking for Program Guide
if (cat $OUTPUTFILETMP2 | grep GuideGrid ); then
echo "$REMOTE is in TV Guide" > $OUTPUTFILE2
else
#Checking for MythVideo Gallery
if (cat $OUTPUTFILETMP2 | grep videogallery ); then
echo "MythVideo Menu On $REMOTE is Idle" > $OUTPUTFILE2
else
#Checking for MythVideo Listings
if (cat $OUTPUTFILETMP2 | grep videolistings); then
echo "MythVideo Menu On $REMOTE is Idle" > $OUTPUTFILE2
else
#Checking for MythVideo Browser
if (cat $OUTPUTFILETMP2 | grep videobrowser); then
echo "MythVideo Menu On $REMOTE is Idle" > $OUTPUTFILE2
else
#Checking for MythMusics
if (cat $OUTPUTFILETMP2 | grep playmusic ); then
echo "Playing Music Cant you Hear?" > $OUTPUTFILE2
else
#Checking for MainMenu
if (cat $OUTPUTFILETMP2 | grep MainMenu ); then
echo "$REMOTE is in The Main Menu" > $OUTPUTFILE2
else
#Checking for Live TV
if (cat $OUTPUTFILETMP2 | grep "Playback LiveTV" ); then
echo "$REMOTE is Watching Live TV" > $OUTPUTFILE2
else
#Checking for MythVideo Playback
if (cat $OUTPUTFILETMP2 | grep "Playback Video" ); then
echo "MythVideo On $REMOTE is playing $FILENAME2" > $OUTPUTFILE2
else
if (cat $OUTPUTFILETMP2 | grep "Playback Recorded" ); then
echo "MythTV On $REMOTE is playing recording $RECFILE2" > $OUTPUTFILE2
else
#if none of the above simply display then query status output
if (cat $OUTPUTFILETMP2 | grep "#"); then
cat $OUTPUTFILETMP2 | grep "#" > $OUTPUTFILE2
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
考虑到为了在 conky 中启用几行代码而不得不编写的大量代码,我认为这非常微妙。无论如何,这对我来说很有趣,我希望人们尝试一下,并告诉我它进展如何,如果您需要任何帮助,我很乐意帮助您设置它。
参考
- 原始论坛帖子作者: oobe-feisty
答案3
这是关于在任何 ubuntu 机器上使用 conky 查看后端录制信息的操作方法。这可以通过在使用 conky 的 ubuntu 机器上安装 mythtv-status 来实现。我对 mythtv-status 做了一些修改。
/home/username/.mythtv/config.xml
将你的 mythbuntu 盒子复制到你的本地 ubuntu 桌面/home/username/.mythtv/config.xml
编辑 config.xml 文件以反映后端的 IP 地址
gedit ~/.mythtv/config.xml
编辑此行。将 localhost 更改为后端的 IP 地址。在我的例子中
<DBHostName>localhost</DBHostName>
变成:
<DBHostName>192.168.15.3</DBHostName>
将 config.xml 链接到
/root/.mythtv/config.xml
sudo mkdir /root/.mythtv sudo ln -s ~/.mythtv/config.xml /root/.mythtv/config.xml
这是为了修复 mythtv 状态中的 perl api 警告。
安装 mythtv-status
sudo apt-get 更新 sudo apt-get 安装 mythtv-status
编辑 mythtv-status 来反映我的更改。
sudo gedit /usr/bin/mythtv-status
大约 21 行。将 localhost 更改为后端的 ip 地址
my $host = "localhost";
在我的例子中,它变为。
my $host = "192.168.15.3";
编辑.conkyrc 文件以添加输出。
gedit ~.conkyrc
在顶部附近添加:
text_buffer_size 1024
在底部添加
${color #0077ff} ${execi 300 perl /usr/bin/mythtv-status KISP}
更改颜色以对应您当前的 .conkyrc 配置。
运行conky进行测试。
参考
- 原始论坛帖子作者:DemonBob