Mailing List Archive

Remotely monitor Backend is running
Hi Folks!


Trying to create a script to let me know when my MythTV Backend is not
running. What I have works, but apparently only if totally off-line (as
in off). This morning not quite sure what happened but the Frontend
could not find the Backend (glanced at the screen, knew it was a BE
issue). Accessing the webpage (Firefox to 192.168.4.3:6544) the “last
10” rotating display was not present, fairly certain the ‘Current Tuner
Activity” listing was present; ‘Frontend Status” was definitely present.
(Probably unnecessary information, but in case help….)


What I current have follows; cron on the computer my rump is usually in
front of has a script which inquires the Backend every 15 minutes during
the day. If no problem no notification; if there is a problem a popup
appears on my screen. Works if the MythTV is totally off, but did not
notify with the above situation. I also prefer the pop-up over an e-mail
notification.


The nitty-grity so far:


The Backend is at 192.168.4.3.


crontab on my computer:


# Test Backend 3 (BE3) is on-line every 15 minutes from 6:00 a.m. to
7:45 p.m.

# The script does not display except with a problem

*/15 07-19 * * * export DISPLAY=:0 && /bin/sh '/home/barry/MythTV
Backend Scripts/Test_BE3.sh'


==> barry@NZXT:~$ cat '/home/barry/MythTV Backend Scripts/Test_BE3.sh'

#!/bin/sh


# Test Backend 3 (BE3) 192.168.4.3

#

# Test cmd line for make appear off-line: search for " nc -z "

#

#####################################################################

# Create variables

current_date_time=$(date)


#####################################################################

# Test connection -- port 6544 is default -- use 8080 for off-line test

nc -z 192.168.4.3 6544

if [ $? -eq 0 ]

then

echo "BE3 is up."

else

echo "exit status is $?."

echo "BE3 192.168.4.3:6544 down."

Err_BE3_1="Oh-oh!! MythTV Backend 3 (BE3 - 192.168.4.3) is down! "

# XMsg_Size=" -fn '-*-*-*-r-*--0-150-0-0-p-*-iso8859-1'"

# Why this works in one script and not another -- bug

# XMsg_Size=" -fn '-*-*-*-r-*--0-200-0-0-p-*-iso8859-1'"

# echo "$current_date_time\n $Err_BE3_1\n" | xmessage $XMsg_Size -file -

echo "$current_date_time\n $Err_BE3_1\n" | xmessage -fn
'-*-*-*-r-*--0-200-0-0-p-*-iso8859-1' -file -


fi


exit



I don’t know what netcat’s -z switch does – saw it when cookbooking
another project and seemed to do what I needed. ..Something about not
sending data (which is probably good as I saw something about a lot of
pings could lock up MythTV).


Thanks!

Barry
Re: Remotely monitor Backend is running [ In reply to ]
On Fri, 8 Oct 2021 18:54:04 -0500, you wrote:

>
>Hi Folks!
>
>
>Trying to create a script to let me know when my MythTV Backend is not
>running. What I have works, but apparently only if totally off-line (as
>in off). This morning not quite sure what happened but the Frontend
>could not find the Backend (glanced at the screen, knew it was a BE
>issue). Accessing the webpage (Firefox to 192.168.4.3:6544) the ?last
>10? rotating display was not present, fairly certain the ?Current Tuner
>Activity? listing was present; ?Frontend Status? was definitely present.
>(Probably unnecessary information, but in case help?.)
>
>
>What I current have follows; cron on the computer my rump is usually in
>front of has a script which inquires the Backend every 15 minutes during
>the day. If no problem no notification; if there is a problem a popup
>appears on my screen. Works if the MythTV is totally off, but did not
>notify with the above situation. I also prefer the pop-up over an e-mail
>notification.
>
>
>The nitty-grity so far:
>
>
>The Backend is at 192.168.4.3.
>
>
>crontab on my computer:
>
>
># Test Backend 3 (BE3) is on-line every 15 minutes from 6:00 a.m. to
>7:45 p.m.
>
># The script does not display except with a problem
>
>*/15 07-19 * * * export DISPLAY=:0 && /bin/sh '/home/barry/MythTV
>Backend Scripts/Test_BE3.sh'
>
>
>==> barry@NZXT:~$ cat '/home/barry/MythTV Backend Scripts/Test_BE3.sh'
>
>#!/bin/sh
>
>
># Test Backend 3 (BE3) 192.168.4.3
>
>#
>
># Test cmd line for make appear off-line: search for " nc -z "
>
>#
>
>#####################################################################
>
># Create variables
>
>current_date_time=$(date)
>
>
>#####################################################################
>
># Test connection -- port 6544 is default -- use 8080 for off-line test
>
>nc -z 192.168.4.3 6544
>
>if [ $? -eq 0 ]
>
>then
>
>echo "BE3 is up."
>
>else
>
>echo "exit status is $?."
>
>echo "BE3 192.168.4.3:6544 down."
>
>Err_BE3_1="Oh-oh!! MythTV Backend 3 (BE3 - 192.168.4.3) is down! "
>
># XMsg_Size=" -fn '-*-*-*-r-*--0-150-0-0-p-*-iso8859-1'"
>
># Why this works in one script and not another -- bug
>
># XMsg_Size=" -fn '-*-*-*-r-*--0-200-0-0-p-*-iso8859-1'"
>
># echo "$current_date_time\n $Err_BE3_1\n" | xmessage $XMsg_Size -file -
>
>echo "$current_date_time\n $Err_BE3_1\n" | xmessage -fn
>'-*-*-*-r-*--0-200-0-0-p-*-iso8859-1' -file -
>
>
>fi
>
>
>exit
>
>
>
>I don?t know what netcat?s -z switch does ? saw it when cookbooking
>another project and seemed to do what I needed. ..Something about not
>sending data (which is probably good as I saw something about a lot of
>pings could lock up MythTV).
>
>
>Thanks!
>
>Barry

The nc -z option tells nc to do a TCP connection without sending any
data - it just disconnects again. I ran Wireshark to confirm this. So
what it does is send a SYN, gets a SYN,ACK reply, sends an ACK, sends
a FIN,ACK, gets an ACK reply. Just TCP setup and disconnect packets,
with no data in them. So what is being tested is that there is a
program that is accepting TCP connections on port 6544.

It might be better to actually use the MythTV API and, for example,
request the next recording time, as that would check that a lot more
of mythbackend is working. It is better to use Python for that, as
there is API support for Python. I have code to do that as part of my
gaps program:

http://www.jsw.gen.nz/mythtv/gaps

which is probably a reasonable example of a real life use of that API
call, so you could just take a copy of gaps and cut out all the extra
code to just leave a call to Dvr/GetUpcomingList and check the results
and then return 0 for OK or an error code from that. However, that
requires that you know at least a bit of Python. If you would like me
to do a cut down version like that, let me know.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
> On 9 Oct 2021, at 1:09 pm, Stephen Worthington <stephen_agent@jsw.gen.nz> wrote:
>
> On Fri, 8 Oct 2021 18:54:04 -0500, you wrote:
>
>>
>> Hi Folks!
>>
>>
>> Trying to create a script to let me know when my MythTV Backend is not
>> running. What I have works, but apparently only if totally off-line (as
>> in off). This morning not quite sure what happened but the Frontend
>> could not find the Backend (glanced at the screen, knew it was a BE
>> issue). Accessing the webpage (Firefox to 192.168.4.3:6544) the ?last
>> 10? rotating display was not present, fairly certain the ?Current Tuner
>> Activity? listing was present; ?Frontend Status? was definitely present.
>> (Probably unnecessary information, but in case help
> .)
>>
>>
>> What I current have follows; cron on the computer my rump is usually in
>> front of has a script which inquires the Backend every 15 minutes during
>> the day. If no problem no notification; if there is a problem a popup
>> appears on my screen. Works if the MythTV is totally off, but did not
>> notify with the above situation. I also prefer the pop-up over an e-mail
>> notification.
>>
>>
>> The nitty-grity so far:
>>
>>
>> The Backend is at 192.168.4.3.
>>
>>
>> crontab on my computer:
>>
>>
>> # Test Backend 3 (BE3) is on-line every 15 minutes from 6:00 a.m. to
>> 7:45 p.m.
>>
>> # The script does not display except with a problem
>>
>> */15 07-19 * * * export DISPLAY=:0 && /bin/sh '/home/barry/MythTV
>> Backend Scripts/Test_BE3.sh'
>>
>>
>> ==> barry@NZXT:~$ cat '/home/barry/MythTV Backend Scripts/Test_BE3.sh'
>>
>> #!/bin/sh
>>
>>
>> # Test Backend 3 (BE3) 192.168.4.3
>>
>> #
>>
>> # Test cmd line for make appear off-line: search for " nc -z "
>>
>> #
>>
>> #####################################################################
>>
>> # Create variables
>>
>> current_date_time=$(date)
>>
>>
>> #####################################################################
>>
>> # Test connection -- port 6544 is default -- use 8080 for off-line test
>>
>> nc -z 192.168.4.3 6544
>>
>> if [ $? -eq 0 ]
>>
>> then
>>
>> echo "BE3 is up."
>>
>> else
>>
>> echo "exit status is $?."
>>
>> echo "BE3 192.168.4.3:6544 down."
>>
>> Err_BE3_1="Oh-oh!! MythTV Backend 3 (BE3 - 192.168.4.3) is down! "
>>
>> # XMsg_Size=" -fn '-*-*-*-r-*--0-150-0-0-p-*-iso8859-1'"
>>
>> # Why this works in one script and not another -- bug
>>
>> # XMsg_Size=" -fn '-*-*-*-r-*--0-200-0-0-p-*-iso8859-1'"
>>
>> # echo "$current_date_time\n $Err_BE3_1\n" | xmessage $XMsg_Size -file -
>>
>> echo "$current_date_time\n $Err_BE3_1\n" | xmessage -fn
>> '-*-*-*-r-*--0-200-0-0-p-*-iso8859-1' -file -
>>
>>
>> fi
>>
>>
>> exit
>>
>>
>>
>> I don?t know what netcat?s -z switch does ? saw it when cookbooking
>> another project and seemed to do what I needed. ..Something about not
>> sending data (which is probably good as I saw something about a lot of
>> pings could lock up MythTV).
>>
>>
>> Thanks!
>>
>> Barry
>
> The nc -z option tells nc to do a TCP connection without sending any
> data - it just disconnects again. I ran Wireshark to confirm this. So
> what it does is send a SYN, gets a SYN,ACK reply, sends an ACK, sends
> a FIN,ACK, gets an ACK reply. Just TCP setup and disconnect packets,
> with no data in them. So what is being tested is that there is a
> program that is accepting TCP connections on port 6544.
>
> It might be better to actually use the MythTV API and, for example,
> request the next recording time, as that would check that a lot more
> of mythbackend is working. It is better to use Python for that, as
> there is API support for Python. I have code to do that as part of my
> gaps program:
>
> http://www.jsw.gen.nz/mythtv/gaps
>
> which is probably a reasonable example of a real life use of that API
> call, so you could just take a copy of gaps and cut out all the extra
> code to just leave a call to Dvr/GetUpcomingList and check the results
> and then return 0 for OK or an error code from that. However, that
> requires that you know at least a bit of Python. If you would like me
> to do a cut down version like that, let me know.

It is *very* easy to do this sort of stuff with systemd.

I offer 2 examples:

[Unit]
Description=MythTV backend service
After=network.target mysql.service
Requires=mysql.service
Wants=apache2.service

[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/mythbackend
User=jam
Group=video
ExecStart=/usr/local/bin/mythbackend --logpath /var/log/mythtv $MYTHBACKEND_OPTIONS

[Install]
WantedBy=multi-user.target

---------------------------------------------------
[Unit]
Description=ssh tunnel to tigger
Requires=network.service

[Service]
ExecStart=/usr/bin/ssh -p 4123 -N -R 1200:localhost:22 -R 4001:localhost:4000 me@tigger.3utilities.com
Restart=always
RestartSec=30
User=doug

[Install]
WantedBy=multi-user.target


Including time qualifications.
In all my years of using myth it has ever 'ceased working' while the myth[front][back]end process 'continues running'
Have fun!
James
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Sat, 9 Oct 2021 13:28:21 +0800, you wrote:


>In all my years of using myth it has ever 'ceased working' while the myth[front][back]end process 'continues running'

There is a current bug that seems to be in the housekeeper database
cleanup where the backend stops responding for a minute or two while
the cleanup is running. Existing recordings continue without
problems, but the start of new recordings can be delayed - I get up to
30 seconds missing at the start of recordings. If you are already
playing a recording, that keeps going, but mythfrontend is unable to
talk to mythbackend to start a new playback. This likely in only
noticeable where the database is a bit bigger than average. So if you
see mythfrontend being unresponsive, check
/var/log/mythtv/mythbackend.log for the housekeeper activity:

root@mypvr:/var/log/mythtv# grep DBCleanup
/var/log/mythtv/mythbackend.log
Oct 9 17:41:44 mypvr mythbackend: mythbackend[163593]: I CoreContext
housekeeper.cpp:754 (Run) Queueing HouseKeeperTask 'DBCleanup'.
Oct 9 17:41:44 mypvr mythbackend: mythbackend[163593]: I HouseKeeping
housekeeper.cpp:144 (Run) Running HouseKeeperTask 'DBCleanup'.
Oct 9 17:47:43 mypvr mythbackend: mythbackend[163593]: I HouseKeeping
housekeeper.cpp:164 (Run) HouseKeeperTask 'DBCleanup' Finished
Successfully.

Mythbackend is not unresponsive for the whole period that DBCleanup is
running, but in my case it is normally unresponsive for a minute or
two during that time. I have a huge database, so I see it for longer
than most. One of the devs who is doing the SAT>IP code for v32 has
had it happen to him while he was testing the new code, and I think he
was investigating, but that was a couple of months ago.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
> On 9 Oct 2021, at 2:58 pm, Stephen Worthington <stephen_agent@jsw.gen.nz> wrote:
>
> On Sat, 9 Oct 2021 13:28:21 +0800, you wrote:
>
>
>> In all my years of using myth it has ever 'ceased working' while the myth[front][back]end process 'continues running'
>
> There is a current bug that seems to be in the housekeeper database
> cleanup where the backend stops responding for a minute or two while
> the cleanup is running. Existing recordings continue without
> problems, but the start of new recordings can be delayed - I get up to
> 30 seconds missing at the start of recordings. If you are already
> playing a recording, that keeps going, but mythfrontend is unable to
> talk to mythbackend to start a new playback. This likely in only
> noticeable where the database is a bit bigger than average. So if you
> see mythfrontend being unresponsive, check
> /var/log/mythtv/mythbackend.log for the housekeeper activity:
>
> root@mypvr:/var/log/mythtv# grep DBCleanup
> /var/log/mythtv/mythbackend.log
> Oct 9 17:41:44 mypvr mythbackend: mythbackend[163593]: I CoreContext
> housekeeper.cpp:754 (Run) Queueing HouseKeeperTask 'DBCleanup'.
> Oct 9 17:41:44 mypvr mythbackend: mythbackend[163593]: I HouseKeeping
> housekeeper.cpp:144 (Run) Running HouseKeeperTask 'DBCleanup'.
> Oct 9 17:47:43 mypvr mythbackend: mythbackend[163593]: I HouseKeeping
> housekeeper.cpp:164 (Run) HouseKeeperTask 'DBCleanup' Finished
> Successfully.
>
> Mythbackend is not unresponsive for the whole period that DBCleanup is
> running, but in my case it is normally unresponsive for a minute or
> two during that time. I have a huge database, so I see it for longer
> than most. One of the devs who is doing the SAT>IP code for v32 has
> had it happen to him while he was testing the new code, and I think he
> was investigating, but that was a couple of months ago.


Steven
I really do not have an axe to grind, was mearly saying "this works well"

But say you've stumbled over the 'unresponsive' bug, for me, shutdown of mythbackend takes 1 or 2 minutes then startup takes another 20 secs.
Also if the unresponsive delay is DB then maybe API calls behave normally.

Since the objective is 'have fun' so no worries, but methinks the solutions talked about here are aimed at the wrong problem.

ciao
James
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Sat, 9 Oct 2021 15:16:05 +0800, you wrote:

>
>
>> On 9 Oct 2021, at 2:58 pm, Stephen Worthington <stephen_agent@jsw.gen.nz> wrote:
>>
>> On Sat, 9 Oct 2021 13:28:21 +0800, you wrote:
>>
>>
>>> In all my years of using myth it has ever 'ceased working' while the myth[front][back]end process 'continues running'
>>
>> There is a current bug that seems to be in the housekeeper database
>> cleanup where the backend stops responding for a minute or two while
>> the cleanup is running. Existing recordings continue without
>> problems, but the start of new recordings can be delayed - I get up to
>> 30 seconds missing at the start of recordings. If you are already
>> playing a recording, that keeps going, but mythfrontend is unable to
>> talk to mythbackend to start a new playback. This likely in only
>> noticeable where the database is a bit bigger than average. So if you
>> see mythfrontend being unresponsive, check
>> /var/log/mythtv/mythbackend.log for the housekeeper activity:
>>
>> root@mypvr:/var/log/mythtv# grep DBCleanup
>> /var/log/mythtv/mythbackend.log
>> Oct 9 17:41:44 mypvr mythbackend: mythbackend[163593]: I CoreContext
>> housekeeper.cpp:754 (Run) Queueing HouseKeeperTask 'DBCleanup'.
>> Oct 9 17:41:44 mypvr mythbackend: mythbackend[163593]: I HouseKeeping
>> housekeeper.cpp:144 (Run) Running HouseKeeperTask 'DBCleanup'.
>> Oct 9 17:47:43 mypvr mythbackend: mythbackend[163593]: I HouseKeeping
>> housekeeper.cpp:164 (Run) HouseKeeperTask 'DBCleanup' Finished
>> Successfully.
>>
>> Mythbackend is not unresponsive for the whole period that DBCleanup is
>> running, but in my case it is normally unresponsive for a minute or
>> two during that time. I have a huge database, so I see it for longer
>> than most. One of the devs who is doing the SAT>IP code for v32 has
>> had it happen to him while he was testing the new code, and I think he
>> was investigating, but that was a couple of months ago.
>
>
>Steven
>I really do not have an axe to grind, was mearly saying "this works well"

Mostly, for most people. But there are some who have ongoing
problems.

>But say you've stumbled over the 'unresponsive' bug, for me, shutdown of mythbackend takes 1 or 2 minutes then startup takes another 20 secs.

Shutdown taking a long time is likely a very old bug in all the MythTV
software - when a MythTV program is asked to shut down from the
outside (kill or kill -15), it mostly shuts down but there is one last
thread left running, doing nothing. If you ask it to shut down a
second time, that last thread will shut down and shutdown completes
normally. This happens with mythfrontend and mythbackend and likely
any other MythTV software that uses the same core routines to handle
its multitasking. See here for my fix for this in mythbackend:

https://lists.archive.carbon60.com/mythtv/users/627999

With this fix, shutdown is immediate. Startup still takes a while,
mostly spent testing all the tuners.

And see here for my fix for killing mythfrontend:

https://lists.archive.carbon60.com/mythtv/users/637565?page=last

>Also if the unresponsive delay is DB then maybe API calls behave normally.

No, API calls are also non-responsive - my gaps program using the API
to get the recording schedule times out with no response from
mythbackend.

>
>Since the objective is 'have fun' so no worries, but methinks the solutions talked about here are aimed at the wrong problem.
>
>ciao
>James
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!
> It might be better to actually use the MythTV API and, for example,
> request the next recording time, as that would check that a lot more
> of mythbackend is working. It is better to use Python for that, as
> there is API support for Python. I have code to do that as part of my
> gaps program:
>
> http://www.jsw.gen.nz/mythtv/gaps
>
> which is probably a reasonable example of a real life use of that API
> call, so you could just take a copy of gaps and cut out all the extra
> code to just leave a call to Dvr/GetUpcomingList and check the results
> and then return 0 for OK or an error code from that. However, that
> requires that you know at least a bit of Python. If you would like me
> to do a cut down version like that, let me know.


“Yes, please!” to your offer of a cut-down version. As I mentioned in my
original post I piece and patch things together – not elegant but as
long as it works! Will download your ‘Gaps’ for a learning experience –
see what do understand.


I’m assuming the utility would be on my (local) computer and send
inquires to the (remote) Backend. To me makes more sense in this usage
to have Local send inquires to the Remote system: my script sends the
“You there?” (SYN) and if doesn’t get an “Yup!” (ACK) puts up an error
message window. (If the remote Backend is down/having problems it might
not be able to send out a ‘help!’ message.)


Also if posted here could be used by others – seems like it would be a
good utility to have just to monitor everything running properly rather
sitting down at night to watch a show and being greeted with the “can’t
find the Backend” screen.


Thanks!

Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!


I’m already unsure!! Looking at your ‘gaps’:


# import Utilities as api
#except:
# print('Please install the MythTV Utilities.py file - suggested location: /usr/local/bin.')
# print('The Utilities.py file is available as text from here:')
# print(' https://www.mythtv.org/wiki/Python_API_Examples')
# print('Please ensure that it is saved in UTF-8 format.')
# exit(2)
## BJM
## See “Python API Examples.odt”
## Section ==> “Install in a dist-packages directory (hardest/preferred)”

So I go to the wiki page; according to “Install in a dist-packages
directory (hardest/preferred)” section the wiki page seems to indicate
Utilities.py (etc.) to be a subdir of MythTV, which is on the Backend.
OTOH the suggested location is /usr/local/bin, which I do have on this
(‘local’) computer. ...I think I answered my own question but want to be
sure.


Barry
Re: Remotely monitor Backend is running [ In reply to ]
On Sat, 9 Oct 2021 09:04:35 -0500, you wrote:

>
>Hi Stephen!
>
>
>I?m already unsure!! Looking at your ?gaps?:
>
>
># import Utilities as api
>#except:
># print('Please install the MythTV Utilities.py file - suggested location: /usr/local/bin.')
># print('The Utilities.py file is available as text from here:')
># print(' https://www.mythtv.org/wiki/Python_API_Examples')
># print('Please ensure that it is saved in UTF-8 format.')
># exit(2)
>## BJM
>## See ?Python API Examples.odt?
>## Section ==> ?Install in a dist-packages directory (hardest/preferred)?
>
>So I go to the wiki page; according to ?Install in a dist-packages
>directory (hardest/preferred)? section the wiki page seems to indicate
>Utilities.py (etc.) to be a subdir of MythTV, which is on the Backend.
>OTOH the suggested location is /usr/local/bin, which I do have on this
>(?local?) computer. ...I think I answered my own question but want to be
>sure.
>
>
>Barry

What version of MythTV are you using? The Utilities.py package is
only necessary for quite old versions. Which is why those lines are
commented out in the latest version of gaps. It should just run
against the MythTV Python bindings without any intermediary package
such as Utilities.py with MythTV v31.

If you just run gaps, it should tell you to install a couple of
packages if they are not present already. All the standard Python
packages will be already installed as part of Python itself, and I
think that includes enum34 in Python 3, so probably just dateutil will
be needed. In Ubuntu, the package name for that is python3-dateutil.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Sat, 9 Oct 2021 08:07:36 -0500, you wrote:

>
>Hi Stephen!
>> It might be better to actually use the MythTV API and, for example,
>> request the next recording time, as that would check that a lot more
>> of mythbackend is working. It is better to use Python for that, as
>> there is API support for Python. I have code to do that as part of my
>> gaps program:
>>
>> http://www.jsw.gen.nz/mythtv/gaps
>>
>> which is probably a reasonable example of a real life use of that API
>> call, so you could just take a copy of gaps and cut out all the extra
>> code to just leave a call to Dvr/GetUpcomingList and check the results
>> and then return 0 for OK or an error code from that. However, that
>> requires that you know at least a bit of Python. If you would like me
>> to do a cut down version like that, let me know.
>
>
>?Yes, please!? to your offer of a cut-down version. As I mentioned in my
>original post I piece and patch things together ? not elegant but as
>long as it works! Will download your ?Gaps? for a learning experience ?
>see what do understand.
>
>
>I?m assuming the utility would be on my (local) computer and send
>inquires to the (remote) Backend. To me makes more sense in this usage
>to have Local send inquires to the Remote system: my script sends the
>?You there?? (SYN) and if doesn?t get an ?Yup!? (ACK) puts up an error
>message window. (If the remote Backend is down/having problems it might
>not be able to send out a ?help!? message.)
>
>
>Also if posted here could be used by others ? seems like it would be a
>good utility to have just to monitor everything running properly rather
>sitting down at night to watch a show and being greeted with the ?can?t
>find the Backend? screen.
>
>
>Thanks!
>
>Barry

Here is the cut down version of gaps:

http://www.jsw.gen.nz/mythtv/test-mythbackend.py

It will return 0 if it connects to mythbackend and gets back a valid
response. A non-zero exit code means there is something wrong - see
the exit() calls in the code for the meaning of each. I am not sure
that exit(4) should be there - that means that it was able to connect
to mythbackend and got a valid response, but that there were no
scheduled recordings. That can be valid, but is much more likely to
indicate that no tuners were found, or there is no EPG data, so
mythbackend was unable to schedule any recordings.

And if any has a better name for this little program, please let me
know.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!

Thanks for the ‘condensed gaps’ – I’ll download and test later today. As
for a better name, I’m not the one to ask! <chuckling> My most inventive
computer name is “BrokenTab” because it had a broken tab holding the
heat sink on (since replaced). Scripts generally get named for what they
do and put in a subdir titled something about the function. Guess our
creative abilities lie elsewhere!


> What version of MythTV are you using? The Utilities.py package is
> only necessary for quite old versions.

Umm, was commented, wasn’t it? I’m using version 30 on the current
Backend; creating a new computer which will use v31 or whatever is current.


Will play with test-mythbackend.py and see if come up with any quirks:
I’ve got some monitoring scripts that work on one system but need a
slightly different command on another system and the two systems are cloned!


Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!

Thanks for the ‘condensed gaps’ – I’ll download and test later today. As
for a better name, I’m not the one to ask! <chuckling> My most inventive
computer name is “BrokenTab” because it had a broken tab holding the
heat sink on (since replaced). Scripts generally get named for what they
do and put in a subdir titled something about the function. Guess our
creative abilities lie elsewhere!


> What version of MythTV are you using? The Utilities.py package is
> only necessary for quite old versions.

Umm, was commented, wasn’t it? I’m using version 30 on the current
Backend; creating a new computer which will use v31 or whatever is current.


Will play with test-mythbackend.py and see if come up with any quirks:
I’ve got some monitoring scripts that work on one system but need a
slightly different command on another system and the two systems are cloned!


Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!

> Here is the cut down version of gaps:
>
> http://www.jsw.gen.nz/mythtv/test-mythbackend.py



Something not quite working right for me with “/test-mythbackend.py
<http://www.jsw.gen.nz/mythtv/test-mythbackend.py>”. Here doing from
Terminal: python3 '/home/barry/MythTV Backend
Scripts/Test_Mythbackend.py' (don’t fiddle with the original until know
it’s right!) and I’m on my computer (not the Backend).


Error is:

Traceback (most recent call last):

File "/home/barry/MythTV Backend Scripts/Test_Mythbackend.py", line 13,
in <module>

from MythTV.services_api import send as api

ModuleNotFoundError: No module named 'MythTV'



Thought maybe because (line 33) HOST = 'localhost' so changed to HOST =
'192.168.4.3' (my Backend’s IP). Still not finding the API services thingie.



Also, I don’t have a “ MythTV.services_api”, or at least that I could
find. sudo service --status-all does list ‘mythtv-backend‘ but nothing
with ‘api’ listed.



Only ones that seemed close to what the script wants:

/home/barry/git/mythtv/mythtv/bindings/python/MythTV/services_api

        (The two mythtv’s in a row is correct)

/usr/lib/python2.7/dist-packages/MythTV/services_api


(used: find / -type d -iname *api* 2>/dev/null | grep -i myth)



The ‘line 13 error’ … Line 13 is from MythTV.services_api import send as api

– no idea what is being looked for so can’t guess. Plus still has to be
looking at the other computer (the Backend).


Hope this makes sense!


Thanks!

Barry
Re: Remotely monitor Backend is running [ In reply to ]
On 10/10/21 11:24 AM, Barry Martin wrote:
>
> Hi Stephen!
>
>> Here is the cut down version of gaps:
>>
>> http://www.jsw.gen.nz/mythtv/test-mythbackend.py
>
>
>
> Something not quite working right for me with “/test-mythbackend.py <http://www.jsw.gen.nz/mythtv/test-mythbackend.py>”. Here doing from
> Terminal: python3 '/home/barry/MythTV Backend Scripts/Test_Mythbackend.py' (don’t fiddle with the original until know it’s right!) and I’m on my
> computer (not the Backend).
>
>
> Error is:
>
> Traceback (most recent call last):
>
> File "/home/barry/MythTV Backend Scripts/Test_Mythbackend.py", line 13, in <module>
>
> from MythTV.services_api import send as api
>
> ModuleNotFoundError: No module named 'MythTV'
>
>
>
> Thought maybe because (line 33) HOST = 'localhost' so changed to HOST = '192.168.4.3' (my Backend’s IP). Still not finding the API services thingie.
>
>
>
> Also, I don’t have a “ MythTV.services_api”, or at least that I could find. sudo service --status-all does list ‘mythtv-backend‘ but nothing
> with ‘api’ listed.
>
>
>
> Only ones that seemed close to what the script wants:
>
>     /home/barry/git/mythtv/mythtv/bindings/python/MythTV/services_api
>
>         (The two mythtv’s in a row is correct)
>
>     /usr/lib/python2.7/dist-packages/MythTV/services_api
>
>
> (used: find / -type d -iname *api* 2>/dev/null | grep -i myth)
>
>
>
> The ‘line 13 error’ … Line 13 is from MythTV.services_api import send as api
>
> – no idea what is being looked for so can’t guess. Plus still has to be looking at the other computer (the Backend).

Does the computer you're running the above on have MythTV installed? E.g. is it
a remote frontend?

Or, just run this: locate -b '\services_api' . If installed, you'll see something
*similar* to this:

/usr/local/lib/python3.8/dist-packages/MythTV/services_api

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Sun, 10 Oct 2021 11:24:28 -0500, you wrote:

>
>Hi Stephen!
>
>> Here is the cut down version of gaps:
>>
>> http://www.jsw.gen.nz/mythtv/test-mythbackend.py
>
>
>
>Something not quite working right for me with ?/test-mythbackend.py
><http://www.jsw.gen.nz/mythtv/test-mythbackend.py>?. Here doing from
>Terminal: python3 '/home/barry/MythTV Backend
>Scripts/Test_Mythbackend.py' (don?t fiddle with the original until know
>it?s right!) and I?m on my computer (not the Backend).
>
>
>Error is:
>
>Traceback (most recent call last):
>
>File "/home/barry/MythTV Backend Scripts/Test_Mythbackend.py", line 13,
>in <module>
>
>from MythTV.services_api import send as api
>
>ModuleNotFoundError: No module named 'MythTV'
>
>
>
>Thought maybe because (line 33) HOST = 'localhost' so changed to HOST =
>'192.168.4.3' (my Backend?s IP). Still not finding the API services thingie.
>
>
>
>Also, I don?t have a ? MythTV.services_api?, or at least that I could
>find. sudo service --status-all does list ?mythtv-backend? but nothing
>with ?api? listed.
>
>
>
>Only ones that seemed close to what the script wants:
>
>/home/barry/git/mythtv/mythtv/bindings/python/MythTV/services_api
>
> ??? ??? (The two mythtv?s in a row is correct)
>
>/usr/lib/python2.7/dist-packages/MythTV/services_api
>
>
>(used: find / -type d -iname *api* 2>/dev/null | grep -i myth)
>
>
>
>The ?line 13 error? ? Line 13 is from MythTV.services_api import send as api
>
>? no idea what is being looked for so can?t guess. Plus still has to be
>looking at the other computer (the Backend).
>
>
>Hope this makes sense!
>
>
>Thanks!
>
>Barry

Since you are running MythTV v30, which uses Python 2, you will need a
Python 2 version of test-mythbackend.py (and gaps and any other Python
software that interfaces with MythTV). I will do a Python 2 version,
but it may take a few iterations to get it working properly as I do
not have any Python 2 versions of MythTV to test it with.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
>Since you are running MythTV v30, which uses Python 2, you will need a
>Python 2 version of test-mythbackend.py (and gaps and any other Python
>software that interfaces with MythTV). I will do a Python 2 version,
>but it may take a few iterations to get it working properly as I do
>not have any Python 2 versions of MythTV to test it with.

I have put the Python 2 and Python 3 compatible version on my web
server:

http://www.jsw.gen.nz/mythtv/test-mythbackend.py

This is the Python 3 version, since most people will be using that
now. Change the top line to use it with Python 2.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!

> I have put the Python 2 and Python 3 compatible version on my web
> server:
>
> http://www.jsw.gen.nz/mythtv/test-mythbackend.py
>
> This is the Python 3 version, since most people will be using that
> now. Change the top line to use it with Python 2.


You’re good!! I’ll download in a little while and report back.

Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Bill!

> Does the computer you're running the above on have MythTV installed? E.g. is it
> a remote frontend?
>
> Or, just run this: locate -b '\services_api' . If installed, you'll see something
> *similar* to this:
>
> /usr/local/lib/python3.8/dist-packages/MythTV/services_api


That seems to be the issue: this/my computer does not have any Myth on
it (other than notes, etc., and that isn’t what we’re looking for). So
the (python) script should be looking at the Backend for services.api.


Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!

> I have put the Python 2 and Python 3 compatible version on my web
> server:
>
> http://www.jsw.gen.nz/mythtv/test-mythbackend.py
>
> This is the Python 3 version, since most people will be using that
> now. Change the top line to use it with Python 2.

Minor problems to report. Changed the top line to *#!/usr/bin/env python2*


I added a comment:

*# Top line is "#!/usr/bin/env python3" or "#!/usr/bin/env python2"*

*# depending on which version of MythTV: v30 and less uses Python 2*


...I’m thinking should ‘confuse’ anything but just to let you know.




Ran and got this:

*barry@NZXT:~$ python '/home/barry/MythTV Backend Scripts/Test-BE.py' *

**

*Traceback (most recent call last):*

**

*File "/home/barry/MythTV Backend Scripts/Test-BE.py", line 23, in <module>*

**

*from enum import IntEnum*

**

*ImportError: No module named enum*

**

*
*

**

*barry@NZXT:~$ python *

**

*Python 2.7.17 (default, Feb 27 2021, 15:10:58) *

**

*[GCC 7.5.0] on linux2*

**

*Type "help", "copyright", "credits" or "license" for more information.*

**

*>>> exit()*



Noted in the script there is a statement to “print … install the
...enum34 package” however this didn’t show up in Terminal. Will do in a
little while.


Barry
Re: Remotely monitor Backend is running [ In reply to ]
On 11/10/2021 16:49, Barry Martin wrote:
>
> Hi Bill!
>
>> Does the computer you're running the above on have MythTV installed? E.g. is it
>> a remote frontend?
>>
>> Or, just run this: locate -b '\services_api' . If installed, you'll see something
>> *similar*  to this:
>>
>>    /usr/local/lib/python3.8/dist-packages/MythTV/services_api
>
>
> That seems to be the issue: this/my computer does not have any Myth on it (other than notes, etc.,
> and that isn’t what we’re looking for). So the (python) script should be looking at the Backend for
> services.api.
>
I think you're a little confused here (or maybe I am).

You need to have a python module on the host that is making the request in order to format it into
something that the api on the backend understands.

Normally, you'd get that automatically when you install a frontend on that host.

I though the whole point of this was that the /frontend/ needed to know if the backend was up? If
so, that's where this code should be running. Why are you running it on a non-mythtv host at all?

--

Mike Perkins

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
Hi Mike!

> > /That seems to be the issue: this/my computer does not have any Myth
> on it (other than notes, etc., /
> > /and that isn’t what we’re looking for). So the (python) script should
> be looking at the Backend for /
> > /services.api./
> >
> I think you're a little confused here (or maybe I am).
>
> You need to have a python module on the host that is making the request in order to format it into
> something that the api on the backend understands.
>
> Normally, you'd get that automatically when you install a frontend on that host.
>
> I though the whole point of this was that the /frontend/ needed to know if the backend was up? If
> so, that's where this code should be running. Why are you running it on a non-mythtv host at all?

Hi Mike!


I can see your viewpoint. Here if the Frontend doesn’t find the Backend
it (the FE) displays a screen indicating it is having problems and is
asking for a button to be clicked to rescan, do manually, etc. By that
time the Backend has sometimes been off for hours, missing recordings.


What I would like to do is have a warning message pop up on my computer,
which does not have MythTV on it, if something is wrong with the
Backend. Something like xmessage as it puts a window up; e-mail is a
so-so option as I’m not always on e-mail.


The ‘nc -z 192.168.4.3 6544’ command in my initial post works but only
if the Backend is completely off-line. Had an issue where MythTV
partially hung: I was getting part of the webpage. It was not recording
nor communicating with the Frontends. Big annoyance was I was literally
sitting with my back to the Backend much of the day, just I didn’t know
there was a problem because no one was watching recorded TV until that
night.


Hope that clarifies things.


Barry
Re: Remotely monitor Backend is running [ In reply to ]
On Mon, 11 Oct 2021 11:58:22 -0500, you wrote:

>
>Hi Stephen!
>
>> I have put the Python 2 and Python 3 compatible version on my web
>> server:
>>
>> http://www.jsw.gen.nz/mythtv/test-mythbackend.py
>>
>> This is the Python 3 version, since most people will be using that
>> now. Change the top line to use it with Python 2.
>
>Minor problems to report. Changed the top line to *#!/usr/bin/env python2*
>
>I added a comment:
>
>*# Top line is "#!/usr/bin/env python3" or "#!/usr/bin/env python2"*
>*# depending on which version of MythTV: v30 and less uses Python 2*
>
>...I?m thinking should ?confuse? anything but just to let you know.

If you look at the title comment just a few lines down, I have already
put that information in it.

>
>Ran and got this:
>
>*barry@NZXT:~$ python '/home/barry/MythTV Backend Scripts/Test-BE.py'
>*Traceback (most recent call last):
>*File "/home/barry/MythTV Backend Scripts/Test-BE.py", line 23, in <module>
>*from enum import IntEnum
>*ImportError: No module named enum
>*
>*barry@NZXT:~$ python
>**
>*Python 2.7.17 (default, Feb 27 2021, 15:10:58)
>*
>*[GCC 7.5.0] on linux2
>*
>*Type "help", "copyright", "credits" or "license" for more information.*
>*
>*>>> exit()*
>
>Noted in the script there is a statement to ?print ? install the
>...enum34 package? however this didn?t show up in Terminal. Will do in a
>little while.

Yes, I forgot to move the original import line down into the
conditional, so it was still there ahead of the intended code. Fixed
in v1.2.

I have also added code to check for services_api and prompt you to
install that if it is not present. That is a bit problematic. It is
in the libmyth-python package, but depending on the system you are
running test-mythbackend.py from, the correct version of
libmyth-python to match the v30 on your backend box may or may not be
available. And installing libmyth-python will drag in a number of
other packages, including bits of MythTV. I am not sure just how much
would need to be installed to satisfy the dependencies of
libmyth-python, but it could extend up to a complete MythTV backend
system with database, and that is not really what you would want on
that PC. It might be necessary to see if you could just copy bits of
the correct libmyth-python package across from your backend box,
rather than install the full libmyth-python package. If that is even
possible.

So I think I need to create a virtual PC running a similar setup to
the PC you want to run this on and try it out and see what happens. So
what is that PC running? And your current backend box is running
MythTV v30, but what version of Ubuntu is it running?
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
I have also added code to check for services_api and prompt you to
install that if it is not present. That is a bit problematic. It is
in the libmyth-python package, but depending on the system you are
running test-mythbackend.py<http://test-mythbackend.py> from, the correct version of
libmyth-python to match the v30 on your backend box may or may not be
available. And installing libmyth-python will drag in a number of
other packages, including bits of MythTV. I am not sure just how much
would need to be installed to satisfy the dependencies of
libmyth-python, but it could extend up to a complete MythTV backend
system with database, and that is not really what you would want on
that PC. It might be necessary to see if you could just copy bits of
the correct libmyth-python package across from your backend box,
rather than install the full libmyth-python package. If that is even
possible.

So I think I need to create a virtual PC running a similar setup to
the PC you want to run this on and try it out and see what happens. So
what is that PC running? And your current backend box is running
MythTV v30, but what version of Ubuntu is it running?
_______________________________________________
Wondering if there is a different way of going about this (brainstorming?):
- use System Event / Client Disconnected on the BE to run a script that throws a message to wherever when nominated FE disconnects?
- use the Frontend Services API / GetStatus maybe state field has something useful?
- use the Frontend Services API / SendKey to trigger script on FE from desktop that then throws message to wherever?
Re: Remotely monitor Backend is running [ In reply to ]
On 11/10/2021 23:51, Barry Martin wrote:
>
> Hi Mike!
>
>> > /That seems to be the issue: this/my computer does not have any Myth on it (other than notes,
>> etc., /
>> > /and that isn’t what we’re looking for). So the (python) script should be looking at the Backend
>> for /
>> > /services.api./
>> > I think you're a little confused here (or maybe I am).
>>
>> You need to have a python module on the host that is making the request in order to format it into
>> something that the api on the backend understands.
>>
>> Normally, you'd get that automatically when you install a frontend on that host.
>>
>> I though the whole point of this was that the /frontend/ needed to know if the backend was up? If
>> so, that's where this code should be running. Why are you running it on a non-mythtv host at all?
>
> Hi Mike!
>
>
> I can see your viewpoint. Here if the Frontend doesn’t find the Backend it (the FE) displays a
> screen indicating it is having problems and is asking for a button to be clicked to rescan, do
> manually, etc. By that time the Backend has sometimes been off for hours, missing recordings.
>
>
> What I would like to do is have a warning message pop up on my computer, which does not have MythTV
> on it, if something is wrong with the Backend. Something like xmessage as it puts a window up;
> e-mail is a so-so option as I’m not always on e-mail.
>
>
> The ‘nc -z 192.168.4.3 6544’ command in my initial post works but only if the Backend is completely
> off-line. Had an issue where MythTV partially hung: I was getting part of the webpage. It was not
> recording nor communicating with the Frontends. Big annoyance was I was literally sitting with my
> back to the Backend much of the day, just I didn’t know there was a problem because no one was
> watching recorded TV until that night.
>
> Hope that clarifies things.
>
It does and thank you.

I thought that many of these reliability problems had been ironed out many versions ago. I, too,
spend chunks of my day with my back to my mythv server (amongst others!) and it runs 24/7. I cannot
think of the last time I logged on in the morning and it wasn't there.

Of course, everyone's setup is different, which is one reason why we have this mailing list after
all. I wish you luck finding a solution.

In my view the best place to put a watchdog is on the backend, which is where all the software
libraries are guaranteed to be. I know a number of folks already do this and the backend gets
restarted should it 'unexpectedly' fail. (Tuners can also disappear and can be checked and rebooted
in the same fashion.) Since I have never had the need I can't point to solutions but there have been
several on this mailing list in the past.

--

Mike Perkins

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Tue, 12 Oct 2021 04:34:20 +0000, you wrote:

>I have also added code to check for services_api and prompt you to
>install that if it is not present. That is a bit problematic. It is
>in the libmyth-python package, but depending on the system you are
>running test-mythbackend.py from, the correct version of
>libmyth-python to match the v30 on your backend box may or may not be
>available. And installing libmyth-python will drag in a number of
>other packages, including bits of MythTV. I am not sure just how much
>would need to be installed to satisfy the dependencies of
>libmyth-python, but it could extend up to a complete MythTV backend
>system with database, and that is not really what you would want on
>that PC. It might be necessary to see if you could just copy bits of
>the correct libmyth-python package across from your backend box,
>rather than install the full libmyth-python package. If that is even
>possible.
>
>So I think I need to create a virtual PC running a similar setup to
>the PC you want to run this on and try it out and see what happens. So
>what is that PC running? And your current backend box is running
>MythTV v30, but what version of Ubuntu is it running?
>_______________________________________________
>Wondering if there is a different way of going about this (brainstorming?):
>- use System Event / Client Disconnected on the BE to run a script that throws a message to wherever when nominated FE disconnects?

If the backend is not functioning, does the FE disconnect event
happen? It is a backend event, IIRC. So if the backend has crashed
or locked up, the event may not happen.

>- use the Frontend Services API / GetStatus maybe state field has something useful?

I have never used the Frontend Services GetStatus API, but I took a
quick look and there is nothing there that reports the status of its
backend connection. There may be ways to infer a disconnection but it
would require experimentation to find out. And there is still the
potential problem of having to install libmyth-python's dependencies
on a non-MythTV box.

>- use the Frontend Services API / SendKey to trigger script on FE from desktop that then throws message to wherever?

Yes, that would be a way of putting a message on screen in a frontend
box. But we want to be able to do this from a non-MythTV box.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Tue, 12 Oct 2021 16:25:44 +1300, you wrote:


>So I think I need to create a virtual PC running a similar setup to
>the PC you want to run this on and try it out and see what happens. So
>what is that PC running? And your current backend box is running
>MythTV v30, but what version of Ubuntu is it running?

I have installed Ubuntu 18.04.6 in a virtual machine and can now test
the test-mythbackend.py program there. It looks like installing
libmyth-python on a non-MythTV box works - there are quite a few other
packages that need to be installed, but it does not pull in any more
of MythTV. But test-mythbackend.py is not getting the services_api
correctly, so I will have to work out what the problem is. Which
looks like it will have to wait until tomorrow.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
Hi Mark!

You write this to Stephen on my issue:

> Wondering if there is a different way of going about this (brainstorming?):
> - use System Event / Client Disconnected on the BE to run a script that throws a message to wherever when nominated FE disconnects?
> - use the Frontend Services API / GetStatus maybe state field has something useful?
> - use the Frontend Services API / SendKey to trigger script on FE from desktop that then throws message to wherever?

This seems more on track with the monitoring I had mind: basically a
non-Myth computer asking the Backend “are you there, and more
importantly are you working?” Any computer can go to the Backends’s
webpage (might be the wrong term – the thing one gets when type the
Backend’s address + port: 192.168.4.3:6544).   (The IP is that of my
Backend.)

As I recall when the BE didn’t work (locked up?/failed?/whatever term)
the scrolling “Last Ten Recordings” was not present (no pictures, was
condensed to a bar), I don’t recall how “Current Tuner Activity” was
displayed but seems some may have been there (I have two quad tuners, so
eight encoders are displaying – don’t recall if all eight were present).
Frontend Status had a listing. I'm not sure if something as simple as
the local machine inquiring something in
http://192.168.4.3:6544/misc/overview.qsp
<http://192.168.4.3:6544/misc/overview.qsp> (which is the full page:
Last Ten Recordings, Current Tuner Activity, Frontend Status) is closer
to what I am requesting. Don't need the visual, just something to
trigger an alarm (xmsessage pop-up) when it's not working (I got the
address from the 'inspect' function of Firefox - so seems like a good
place to start.) Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!
> Yes, I forgot to move the original import line down into the
> conditional, so it was still there ahead of the intended code. Fixed
> in v1.2.

OK -- will download the update  and update you on the new download. 
(Sorry: couldn't resist!)



> So I think I need to create a virtual PC running a similar setup to
> the PC you want to run this on and try it out and see what happens. So
> what is that PC running? And your current backend box is running
> MythTV v30, but what version of Ubuntu is it running?

Ubuntu 18.04.6


Thanks!



_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On 12/10/2021 05:34, Mark Perkins wrote:
>
>
> I have also added code to check for services_api and prompt you to
> install that if it is not present.  That is a bit problematic.  It is
> in the libmyth-python package, but depending on the system you are
> running test-mythbackend.py <http://test-mythbackend.py> from, the
> correct version of
> libmyth-python to match the v30 on your backend box may or may not be
> available.  And installing libmyth-python will drag in a number of
> other packages, including bits of MythTV.  I am not sure just how much
> would need to be installed to satisfy the dependencies of
> libmyth-python, but it could extend up to a complete MythTV backend
> system with database, and that is not really what you would want on
> that PC.  It might be necessary to see if you could just copy bits of
> the correct libmyth-python package across from your backend box,
> rather than install the full libmyth-python package.  If that is even
> possible.
>
> So I think I need to create a virtual PC running a similar setup to
> the PC you want to run this on and try it out and see what happens. So
> what is that PC running?  And your current backend box is running
> MythTV v30, but what version of Ubuntu is it running?
> _______________________________________________
>
> Wondering if there is a different way of going about this (brainstorming?):
> - use System Event / Client Disconnected on the BE to run a script that
> throws a message to wherever when nominated FE disconnects?
> - use the Frontend Services API / GetStatus maybe state field has
> something useful?
> - use the Frontend Services API / SendKey to trigger script on FE from
> desktop that then throws message to wherever?
>

It could be as simple as querying the backend API.

$ curl http://<backend_ip>:6544/Status/GetStatus

Returns data *only* in XML, of the backend status
(we are working on a proper endpoint that can return
the data in the format you request)

There is also

$ curl http://<backend_ip>:6544/Status/GetStatusHTML

This returns *only* html and is used by both mythweb
and the "webfrontend"


Regards
Stuart

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On 12/10/2021 14:52, Barry Martin wrote:
>
> Hi Mark!
>
> You write this to Stephen on my issue:
>
>> Wondering if there is a different way of going about this (brainstorming?):
>> - use System Event / Client Disconnected on the BE to run a script that throws a message to wherever when nominated FE disconnects?
>> - use the Frontend Services API / GetStatus maybe state field has something useful?
>> - use the Frontend Services API / SendKey to trigger script on FE from desktop that then throws message to wherever?
>
> This seems more on track with the monitoring I had mind: basically a
> non-Myth computer asking the Backend “are you there, and more
> importantly are you working?” Any computer can go to the Backends’s
> webpage (might be the wrong term – the thing one gets when type the
> Backend’s address + port: 192.168.4.3:6544).   (The IP is that of my
> Backend.)
>
> As I recall when the BE didn’t work (locked up?/failed?/whatever term)
> the scrolling “Last Ten Recordings” was not present (no pictures, was
> condensed to a bar), I don’t recall how “Current Tuner Activity” was
> displayed but seems some may have been there (I have two quad tuners, so
> eight encoders are displaying – don’t recall if all eight were present).
> Frontend Status had a listing. I'm not sure if something as simple as
> the local machine inquiring something in
> http://192.168.4.3:6544/misc/overview.qsp
> <http://192.168.4.3:6544/misc/overview.qsp> (which is the full page:
> Last Ten Recordings, Current Tuner Activity, Frontend Status) is closer
> to what I am requesting. Don't need the visual, just something to
> trigger an alarm (xmsessage pop-up) when it's not working (I got the
> address from the 'inspect' function of Firefox - so seems like a good
> place to start.) Barry
>

Please use the /Status API endpoint as per my other message, as the qsp
scripts will be going away.


Regards
Stuart


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On 10/12/21 9:04 AM, Barry Martin wrote:
>
> Hi Stephen!
>> Yes, I forgot to move the original import line down into the
>> conditional, so it was still there ahead of the intended code.  Fixed
>> in v1.2.
>
> OK -- will download the update  and update you on the new download.  (Sorry: couldn't resist!)
>
>
>
>> So I think I need to create a virtual PC running a similar setup to
>> the PC you want to run this on and try it out and see what happens. So
>> what is that PC running?  And your current backend box is running
>> MythTV v30, but what version of Ubuntu is it running?
>
> Ubuntu 18.04.6
>
>
> Thanks!

The MythTV.services_api directory can be copied from any host running
a backend/frontend. if you want to use it. You may need to load other
Python packages in order to use it, but that's OK. The Wiki you cited
has instructions for setting PYTHONPATH to point to where you put it.

Here's a command line version that does the last test in Stephen's
script that just sees if there's at lease one upcoming recording:

$ curl --header Accept:application/JSON --silent yourBE:6544/Dvr/GetUpcomingList?Count=1 | json_pp - | grep '"Count"'

Which returns: "Count" : "1", if there's at least one upcoming recording.
That may be easier to do.

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Tue, 12 Oct 2021 09:04:28 -0500, you wrote:

>
>Hi Stephen!
>> Yes, I forgot to move the original import line down into the
>> conditional, so it was still there ahead of the intended code. Fixed
>> in v1.2.
>
>OK -- will download the update? and update you on the new download.?
>(Sorry: couldn't resist!)
>
>
>
>> So I think I need to create a virtual PC running a similar setup to
>> the PC you want to run this on and try it out and see what happens. So
>> what is that PC running? And your current backend box is running
>> MythTV v30, but what version of Ubuntu is it running?
>
>Ubuntu 18.04.6

I guessed right then, that is what I installed on a virtual machine to
test with. V1.3 is now available, which does work with Python 2 on a
non-MythTV Ubuntu 18.04.6 VM talking to an Xubuntu 18.04.6 MythTV v30
backend on another VM. You will need to install some Python 2
packages it will tell you about. I was testing with the PPA v30+fixes
packages, so I recommend installing the Mythbuntu PPA v30 repository
on the non-MythTV box and installing (or updating to) the
libmyth-python package from there. Use the -n option to tell it the
IP address or DNS name of the backend to talk to. It works with IPv4
and IPv6.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
I run .31 in a Ubuntu VM on ESX server using one of the original HDHomeRun 2-tuner boxes. For some reason, sometimes the list of upcoming recordings disappears. The rules are still there, so I think it has something to do with communicating with the tuner device. I have not spent much time in trying to figure it out because I spent 10 minutes on a workaround that’s “good enough for me”. In case it helps, I created a cron job to run a curl command to check if there were recordings scheduled. If not, it restarts the backend.

Crontab
29,59 * * * * /home/username/resetMyth.sh

Script
#!/bin/bash

SHOWS=$(curl -H "Accept: application/json" http://mythtv:6544/Dvr/GetUpcomingList 2> /dev/null | jq .ProgramList.Count | cut -d '"' -f 2)
if [ $SHOWS -eq 0 ]; then
echo "Restarting Myth Backend"
sudo systemctl restart mythtv-backend
fi

Regards,
Charles
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!

> http://www.jsw.gen.nz/mythtv/test-mythbackend.py


Downloaded version 1.3, changed the initial line to run Python 2. Did
not add any lines this time! Results:


barry@NZXT:~$ *python2 '/home/barry/MythTV Backend
Scripts/Test-v1_3-work.py' *

Please install the MythTV services_api version compatible with your
MythTV backend.

In Ubuntu, to get the current version of the MythTV services_api, do
"sudo apt install libmyth-python".

If you still get this message after installing libmyth-python, do "sudo
apt install python-future python-requests".

Traceback (most recent call last):

File "/home/barry/MythTV Backend Scripts/Test-v1_3-work.py", line 35, in
<module>

from MythTV.services_api import send as api

ImportError: No module named MythTV.services_api



So *sudo apt install libmyth-python* – installs a bunch of stuff .



barry@NZXT:~$ *python2 '/home/barry/MythTV Backend
Scripts/Test-v1_3-work.py' *

Please install the MythTV services_api version compatible with your
MythTV backend.

In Ubuntu, to get the current version of the MythTV services_api, do
"sudo apt install libmyth-python".

If you still get this message after installing libmyth-python, do "sudo
apt install python-future python-requests".

Traceback (most recent call last):

File "/home/barry/MythTV Backend Scripts/Test-v1_3-work.py", line 35, in
<module>

from MythTV.services_api import send as api

File "/usr/lib/python2.7/dist-packages/MythTV/__init__.py", line 36, in
<module>

from .utility import *

File "/usr/lib/python2.7/dist-packages/MythTV/utility/__init__.py", line
2, in <module>

from .enum import EnumValue, Enum, BitwiseEnum

File "/usr/lib/python2.7/dist-packages/MythTV/utility/enum.py", line 9,
in <module>

from builtins import int

ImportError: No module named builtins



OK, so we got the same error message again, but this time with others.
Will run "sudo apt install python-future python-requests". Seems like I
had to run that installation for another programme on another computer
around here, so not unusual. … Installs a bunch more.



barry@NZXT:~$ *python2 '/home/barry/MythTV Backend
Scripts/Test-v1_3-work.py' *

Please install the MythTV services_api version compatible with your
MythTV backend.

In Ubuntu, to get the current version of the MythTV services_api, do
"sudo apt install libmyth-python".

If you still get this message after installing libmyth-python, do "sudo
apt install python-future python-requests".

Traceback (most recent call last):

File "/home/barry/MythTV Backend Scripts/Test-v1_3-work.py", line 35, in
<module>

from MythTV.services_api import send as api

ImportError: No module named services_api



Hmmm! Still seeing the error message.


As for the ‘services_api’ I’ll try changing localhost to the Backend’s IP

HOST = 'localhost' ==> HOST = ‘192.168.4.3’

(Not doing anything to change line numbers.)



barry@NZXT:~$ *python2 '/home/barry/MythTV Backend
Scripts/Test-v1_3-work.py' *

Please install the MythTV services_api version compatible with your
MythTV backend.

In Ubuntu, to get the current version of the MythTV services_api, do
"sudo apt install libmyth-python".

If you still get this message after installing libmyth-python, do "sudo
apt install python-future python-requests".

Traceback (most recent call last):

File "/home/barry/MythTV Backend Scripts/Test-v1_3-work.py", line 35, in
<module>

from MythTV.services_api import send as api

ImportError: No module named services_api



Changed back to localhost, though seems like it should be looking to the
Backend.


Barry
Re: Remotely monitor Backend is running [ In reply to ]
On 10/12/21 5:44 PM, Barry Martin wrote:
>
> Hi Stephen!
>
>> http://www.jsw.gen.nz/mythtv/test-mythbackend.py
>
>
> Downloaded version 1.3, changed the initial line to run Python 2. Did not add any lines this time! Results:
>
>
> barry@NZXT:~$ *python2 '/home/barry/MythTV Backend Scripts/Test-v1_3-work.py' *
>
> Please install the MythTV services_api version compatible with your MythTV backend.
>
> In Ubuntu, to get the current version of the MythTV services_api, do "sudo apt install libmyth-python".
>
> If you still get this message after installing libmyth-python, do "sudo apt install python-future python-requests".
>
> Traceback (most recent call last):
>
> File "/home/barry/MythTV Backend Scripts/Test-v1_3-work.py", line 35, in <module>
>
> from MythTV.services_api import send as api
>
> ImportError: No module named MythTV.services_api
>
>
>
> So *sudo apt install libmyth-python* – installs a bunch of stuff .

........

What does this return?:

sudo updatedb ; locate -b '\services_api'

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Tue, 12 Oct 2021 17:44:58 -0500, you wrote:

>
>Hi Stephen!
>
>> http://www.jsw.gen.nz/mythtv/test-mythbackend.py
>
>
>Downloaded version 1.3, changed the initial line to run Python 2. Did
>not add any lines this time! Results:
>
>
>barry@NZXT:~$ *python2 '/home/barry/MythTV Backend
>Scripts/Test-v1_3-work.py' *
>
>Please install the MythTV services_api version compatible with your
>MythTV backend.
>
>In Ubuntu, to get the current version of the MythTV services_api, do
>"sudo apt install libmyth-python".
>
>If you still get this message after installing libmyth-python, do "sudo
>apt install python-future python-requests".
>
>Traceback (most recent call last):
>
>File "/home/barry/MythTV Backend Scripts/Test-v1_3-work.py", line 35, in
><module>
>
>from MythTV.services_api import send as api
>
>ImportError: No module named MythTV.services_api
>
>
>
>So *sudo apt install libmyth-python* ? installs a bunch of stuff .
>
>
>
>barry@NZXT:~$ *python2 '/home/barry/MythTV Backend
>Scripts/Test-v1_3-work.py' *
>
>Please install the MythTV services_api version compatible with your
>MythTV backend.
>
>In Ubuntu, to get the current version of the MythTV services_api, do
>"sudo apt install libmyth-python".
>
>If you still get this message after installing libmyth-python, do "sudo
>apt install python-future python-requests".
>
>Traceback (most recent call last):
>
>File "/home/barry/MythTV Backend Scripts/Test-v1_3-work.py", line 35, in
><module>
>
>from MythTV.services_api import send as api
>
>File "/usr/lib/python2.7/dist-packages/MythTV/__init__.py", line 36, in
><module>
>
>from .utility import *
>
>File "/usr/lib/python2.7/dist-packages/MythTV/utility/__init__.py", line
>2, in <module>
>
>from .enum import EnumValue, Enum, BitwiseEnum
>
>File "/usr/lib/python2.7/dist-packages/MythTV/utility/enum.py", line 9,
>in <module>
>
>from builtins import int
>
>ImportError: No module named builtins
>
>
>
>OK, so we got the same error message again, but this time with others.
>Will run "sudo apt install python-future python-requests". Seems like I
>had to run that installation for another programme on another computer
>around here, so not unusual. ? Installs a bunch more.
>
>
>
>barry@NZXT:~$ *python2 '/home/barry/MythTV Backend
>Scripts/Test-v1_3-work.py' *
>
>Please install the MythTV services_api version compatible with your
>MythTV backend.
>
>In Ubuntu, to get the current version of the MythTV services_api, do
>"sudo apt install libmyth-python".
>
>If you still get this message after installing libmyth-python, do "sudo
>apt install python-future python-requests".
>
>Traceback (most recent call last):
>
>File "/home/barry/MythTV Backend Scripts/Test-v1_3-work.py", line 35, in
><module>
>
>from MythTV.services_api import send as api
>
>ImportError: No module named services_api
>
>
>
>Hmmm! Still seeing the error message.
>
>
>As for the ?services_api? I?ll try changing localhost to the Backend?s IP
>
>HOST = 'localhost' ==> HOST = ?192.168.4.3?
>
>(Not doing anything to change line numbers.)
>
>
>
>barry@NZXT:~$ *python2 '/home/barry/MythTV Backend
>Scripts/Test-v1_3-work.py' *
>
>Please install the MythTV services_api version compatible with your
>MythTV backend.
>
>In Ubuntu, to get the current version of the MythTV services_api, do
>"sudo apt install libmyth-python".
>
>If you still get this message after installing libmyth-python, do "sudo
>apt install python-future python-requests".
>
>Traceback (most recent call last):
>
>File "/home/barry/MythTV Backend Scripts/Test-v1_3-work.py", line 35, in
><module>
>
>from MythTV.services_api import send as api
>
>ImportError: No module named services_api
>
>
>
>Changed back to localhost, though seems like it should be looking to the
>Backend.
>
>
>Barry

It is looking like there are still some missing Python modules. The
easiest way to tell exactly what is going on is just to manually run
the "from" command. So run "python2", then from the Python command
prompt, run:

from MythTV.services_api import send as api

There should be a detailed traceback which will tell you what the
missing Python module is called. To exit Python, use Ctrl-D (which
closes the input file from the keyboard, causing Python to exit).
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stuart!
> It could be as simple as querying the backend API.
>
> $ curl http://<backend_ip>:6544/Status/GetStatus
>
> Returns data*only* in XML, of the backend status
> (we are working on a proper endpoint that can return
> the data in the format you request)
>
> There is also
>
> $ curl http://<backend_ip>:6544/Status/GetStatusHTML
>
> This returns*only* html and is used by both mythweb
> and the "webfrontend"


Hi Stuart!

Both options show potential for my monitoring project. Probably need a
‘grep’ or three but that’s part of the fun! And thanks for telling me
‘qsp’ is going away. No idea what it is but I won’t be creating
something that only lasts a few more versions.

Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Bill!

> Here's a command line version that does the last test in Stephen's
> script that just sees if there's at lease one upcoming recording:
>
> $ curl --header Accept:application/JSON --silent yourBE:6544/Dvr/GetUpcomingList?Count=1 | json_pp - | grep '"Count"'
>
> Which returns: "Count" : "1", if there's at least one upcoming recording.
> That may be easier to do.


YESSS!!! This is certainly simpler, at least for what I’m wishing to do.
I’m guessing any result but ‘ *"Count" : "1",* ‘ means there’s a
problem. As a quick experiment changed the command’s
GetUpcomingList?Count=1 to 0 (zero) and received ‘254’. Tested with 9
and 99 and received those numbers back – 9^th and 99^th upcoming
programmes maybe? Probably easier to stick with the expected result and
anything else is considered an error.

Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!


> I guessed right then, that is what I installed on a virtual machine to
> test with. V1.3 is now available, which does work with Python 2 on a
> non-MythTV Ubuntu 18.04.6 VM talking to an Xubuntu 18.04.6 MythTV v30
> backend on another VM. You will need to install some Python 2
> packages it will tell you about. I was testing with the PPA v30+fixes
> packages, so I recommend installing the Mythbuntu PPA v30 repository
> on the non-MythTV box and installing (or updating to) the
> libmyth-python package from there. Use the -n option to tell it the
> IP address or DNS name of the backend to talk to. It works with IPv4
> and IPv6.

You are good! I will experiment with this monitoring option also. As for
the installation of the packages, I didn’t want to go too far and end up
creating a MythTV device out of this computer. Wouldn’t be all that bad,
just not really necessary.

Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Charles!
> Crontab
> 29,59 * * * * /home/username/resetMyth.sh
>
> Script
> #!/bin/bash
>
> SHOWS=$(curl -H "Accept: application/json"http://mythtv:6544/Dvr/GetUpcomingList 2> /dev/null | jq .ProgramList.Count | cut -d '"' -f 2)
> if [ $SHOWS -eq 0 ]; then
> echo "Restarting Myth Backend"
> sudo systemctl restart mythtv-backend
> fi


And a thank you to you too! The half-hour check by the cron job to so an
automatic reset will be handy – I’m not always at the computer! (Is that
blasphemous?! <g>)

Your curl command (at least when I isolate it and test at Terminal)
results in just a number, which for a cookbook scripter like me will
probably be a lot easier to use.


Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Bill!

> What does this return?:
>
> sudo updatedb ; locate -b '\services_api'


Nothing (which isn’t a good sign but does explain some other error
messages).

Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!


> It is looking like there are still some missing Python modules. The
> easiest way to tell exactly what is going on is just to manually run
> the "from" command. So run "python2", then from the Python command
> prompt, run:
>
> from MythTV.services_api import send as api
>
> There should be a detailed traceback which will tell you what the
> missing Python module is called. To exit Python, use Ctrl-D (which
> closes the input file from the keyboard, causing Python to exit).


From Terminal:


barry@NZXT:~$ python2
Python 2.7.17 (default, Feb 27 2021, 15:10:58)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from MythTV.services_api import send as api
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named services_api
>>> exit()
barry@NZXT:~$


Which verifies what Bill had asked (I received his message prior to yours).

Barry
Re: Remotely monitor Backend is running [ In reply to ]
On Wed, 13 Oct 2021 11:26:16 -0500, you wrote:

>
>Hi Stephen!
>
>
>> It is looking like there are still some missing Python modules. The
>> easiest way to tell exactly what is going on is just to manually run
>> the "from" command. So run "python2", then from the Python command
>> prompt, run:
>>
>> from MythTV.services_api import send as api
>>
>> There should be a detailed traceback which will tell you what the
>> missing Python module is called. To exit Python, use Ctrl-D (which
>> closes the input file from the keyboard, causing Python to exit).
>
>
> From Terminal:
>
>
>barry@NZXT:~$ python2
>Python 2.7.17 (default, Feb 27 2021, 15:10:58)
>[GCC 7.5.0] on linux2
>Type "help", "copyright", "credits" or "license" for more information.
> >>> from MythTV.services_api import send as api
>Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
>ImportError: No module named services_api
> >>> exit()
>barry@NZXT:~$
>
>
>Which verifies what Bill had asked (I received his message prior to yours).
>
>Barry

So the libmyth-python package from MythTV v30 is not installed.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On 10/13/21 11:21 AM, Barry Martin wrote:
>
> Hi Bill!
>
>> Here's a command line version that does the last test in Stephen's
>> script that just sees if there's at lease one upcoming recording:
>>
>> $ curl --header Accept:application/JSON --silent yourBE:6544/Dvr/GetUpcomingList?Count=1 | json_pp - | grep '"Count"'
>>
>> Which returns: "Count" : "1", if there's at least one upcoming recording.
>> That may be easier to do.
>
>
> YESSS!!! This is certainly simpler, at least for what I’m wishing to do. I’m guessing any result but ‘ *"Count" : "1",* ‘ means there’s a problem. As a quick experiment changed the command’s GetUpcomingList?Count=1 to 0 (zero) and received ‘254’. Tested with 9 and 99 and received those numbers back – 9^th and 99^th upcoming programmes maybe? Probably easier to stick with the expected result and anything else is considered an error.

The Count parameter just tells the GetUpcomingList endpoint how many upcoming
recordings to return. I selected 1 because I assume you really care that at
least one recording will be made in the future.

Count=0 returns ALL upcoming recordings. That's OK, but probably more than
you need.

If "Count" : "0", is returned , there are no upcoming recordings.

If there curl fails, it's unable to communicate with the backend
or at least with the Services API thread.

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!

> So the libmyth-python package from MythTV v30 is not installed.


Sorry about the delay in responding: took my friend to urgent care
facility this morning. Nothing overly serious a prescription for
antibiotics shouldn’t cure in a week. (In U.S. ‘urgent care facility’ is
a walk-in medical site for symptoms less than requiring Emergency Room
treatment.)


OK, back to business. Downloaded the current test-mythbackend.py
<http://www.jsw.gen.nz/mythtv/test-mythbackend.py> – looks to be v.1.3
of October 12^th still. Modified initial line to use python2.


barry@NZXT:~$ python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py'

Please install the MythTV services_api version compatible with your
MythTV backend.

In Ubuntu, to get the current version of the MythTV services_api, do
"sudo apt install libmyth-python".

If you still get this message after installing libmyth-python, do "sudo
apt install python-future python-requests".

Traceback (most recent call last):

File "/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py", line 35, in <module>

from MythTV.services_api import send as api

ImportError: No module named services_api



OK, expected.


barry@NZXT:~$ sudo apt install libmyth-python

[sudo] password for barry:

Reading package lists... Done

Building dependency tree

Reading state information... Done

libmyth-python is already the newest version
(2:29.1+fixes.20180414.329c235-0ubuntu3).

The following package was automatically installed and is no longer required:

libpdf-api2-perl

Use 'sudo apt autoremove' to remove it.

0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.



Pretty much expected. Re-ran test-mythbackend_v1_3-101421.py' – same
error. Expected.



barry@NZXT:~$ sudo apt install python-future python-requests

Reading package lists... Done

Building dependency tree

Reading state information... Done

python-future is already the newest version (0.15.2-4ubuntu2).

python-requests is already the newest version (2.18.4-2ubuntu0.1).

The following package was automatically installed and is no longer required:

libpdf-api2-perl

Use 'sudo apt autoremove' to remove it.

0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.



Still “ImportError: No module named services_api “ – obviously I’m doing
something not quite right. Seems like I need to tell it which version
(30) to download.


Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Bill!
> The Count parameter just tells the GetUpcomingList endpoint how many upcoming
> recordings to return. I selected 1 because I assume you really care that at
> least one recording will be made in the future.
>
> Count=0 returns ALL upcoming recordings. That's OK, but probably more than
> you need.
>
> If "Count" : "0", is returned , there are no upcoming recordings.
>
> If there curl fails, it's unable to communicate with the backend
> or at least with the Services API thread.


Thanks for the explanation – that helps so I can figure how to create a
“if see ‘0’ then display the error message” routine. ...I can’t find it
right now but the other day there was a post to me which did a reboot of
the Backend when it saw a problem. Seems like it needed to be told to
reboot the remote machine (Backend) as as it was seemed like it would
reboot the local machine.


Barry
Re: Remotely monitor Backend is running [ In reply to ]
On 10/14/21 5:30 PM, Barry Martin wrote:
>
> Hi Stephen!
>
>> So the libmyth-python package from MythTV v30 is not installed.
>
>
> Sorry about the delay in responding: took my friend to urgent care facility this morning. Nothing overly serious a prescription for antibiotics
> shouldn’t cure in a week. (In U.S. ‘urgent care facility’ is a walk-in medical site for symptoms less than requiring Emergency Room treatment.)
>
>
> OK, back to business. Downloaded the current test-mythbackend.py <http://www.jsw.gen.nz/mythtv/test-mythbackend.py> – looks to be v.1.3 of
> October 12^th still. Modified initial line to use python2.
>
>
> barry@NZXT:~$ python '/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py'
>
> Please install the MythTV services_api version compatible with your MythTV backend.
>
> In Ubuntu, to get the current version of the MythTV services_api, do "sudo apt install libmyth-python".
>
> If you still get this message after installing libmyth-python, do "sudo apt install python-future python-requests".
>
> Traceback (most recent call last):
>
> File "/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py", line 35, in <module>
>
> from MythTV.services_api import send as api
>
> ImportError: No module named services_api
>
>
>
> OK, expected.
>
>
> barry@NZXT:~$ sudo apt install libmyth-python
>
> [sudo] password for barry:
>
> Reading package lists... Done
>
> Building dependency tree
>
> Reading state information... Done
>
> libmyth-python is already the newest version (2:29.1+fixes.20180414.329c235-0ubuntu3).
>
> The following package was automatically installed and is no longer required:
>
> libpdf-api2-perl
>
> Use 'sudo apt autoremove' to remove it.
>
> 0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.
>
>
>
> Pretty much expected. Re-ran test-mythbackend_v1_3-101421.py' – same error. Expected.
>
>
>
> barry@NZXT:~$ sudo apt install python-future python-requests
>
> Reading package lists... Done
>
> Building dependency tree
>
> Reading state information... Done
>
> python-future is already the newest version (0.15.2-4ubuntu2).
>
> python-requests is already the newest version (2.18.4-2ubuntu0.1).
>
> The following package was automatically installed and is no longer required:
>
> libpdf-api2-perl
>
> Use 'sudo apt autoremove' to remove it.
>
> 0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.
>
>
>
> Still “ImportError: No module named services_api “ – obviously I’m doing something not quite right. Seems like I need to tell it which version
> (30) to download.

The list of files in the libmyth-python package is here and it looks OK. Assuming you're on Bionic

https://packages.ubuntu.com/bionic/all/libmyth-python/filelist

I can't explain why they're not being loaded.

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On 10/14/21 5:52 PM, Bill Meek wrote:
> The list of files in the libmyth-python package is here and it looks OK. Assuming you're on Bionic
>
> https://packages.ubuntu.com/bionic/all/libmyth-python/filelist

Oops, no, the services_api is NOT in the above.

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Thu, 14 Oct 2021 17:30:40 -0500, you wrote:

>
>Hi Stephen!
>
>> So the libmyth-python package from MythTV v30 is not installed.
>
>
>Sorry about the delay in responding: took my friend to urgent care
>facility this morning. Nothing overly serious a prescription for
>antibiotics shouldn?t cure in a week. (In U.S. ?urgent care facility? is
>a walk-in medical site for symptoms less than requiring Emergency Room
>treatment.)
>
>
>OK, back to business. Downloaded the current test-mythbackend.py
><http://www.jsw.gen.nz/mythtv/test-mythbackend.py> ? looks to be v.1.3
>of October 12^th still. Modified initial line to use python2.
>
>
>barry@NZXT:~$ python '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py'
>
>Please install the MythTV services_api version compatible with your
>MythTV backend.
>
>In Ubuntu, to get the current version of the MythTV services_api, do
>"sudo apt install libmyth-python".
>
>If you still get this message after installing libmyth-python, do "sudo
>apt install python-future python-requests".
>
>Traceback (most recent call last):
>
>File "/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py", line 35, in <module>
>
>from MythTV.services_api import send as api
>
>ImportError: No module named services_api
>
>
>
>OK, expected.
>
>
>barry@NZXT:~$ sudo apt install libmyth-python
>
>[sudo] password for barry:
>
>Reading package lists... Done
>
>Building dependency tree
>
>Reading state information... Done
>
>libmyth-python is already the newest version
>(2:29.1+fixes.20180414.329c235-0ubuntu3).

This will be the problem, I think. It is libmyth-python 0.29.1, not
v30. So you will need to install the MythTV v30 repository and
update:

sudo add-apt-repository ppa:mythbuntu/30
sudo apt update
sudo apt full-upgrade
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Thu, 14 Oct 2021 17:41:09 -0500, you wrote:

>
>Hi Bill!
>> The Count parameter just tells the GetUpcomingList endpoint how many upcoming
>> recordings to return. I selected 1 because I assume you really care that at
>> least one recording will be made in the future.
>>
>> Count=0 returns ALL upcoming recordings. That's OK, but probably more than
>> you need.
>>
>> If "Count" : "0", is returned , there are no upcoming recordings.
>>
>> If there curl fails, it's unable to communicate with the backend
>> or at least with the Services API thread.
>
>
>Thanks for the explanation ? that helps so I can figure how to create a
>?if see ?0? then display the error message? routine. ...I can?t find it
>right now but the other day there was a post to me which did a reboot of
>the Backend when it saw a problem. Seems like it needed to be told to
>reboot the remote machine (Backend) as as it was seemed like it would
>reboot the local machine.
>
>
>Barry

It is possible to control a remote machine via ssh. First make sure
sshd is installed on the remote machine and enable root login:

sudo apt install sshd
cd /etc/ssh

Then edit sshd_config to enable root logins. Add a line:

PermitRootLogin yes

That normally goes in the "Authentication" section. Restart sshd to
enable the new setting:

sudo systemctl restart sshd

If the remote PC does not have a root password, install one:

sudo passwd

Then from the local machine login to root on the remote machine:

ssh root@<remote PC>

It will challenge you about the key being new if you have never used
that login before - answer yes. Then give the root password for the
remote PC, and after it logs in, exit again.

Generate a key pair:

ssh-keygen

Copy the public key of the key pair to the remote PC:

ssh-copy-id -i root@<remote PC>

Use the exact same root@<remote PC> form that you are going to use to
login with on an ssh command. If you use a host name, you will always
need to use the same format of host name (with or without the domain).
If you use an IPv4 address, you will always need to use that IP
address. If you use an IPv6 address, you will always need to use that
IPv6 address. You will be asked for the remote PC's password before it
will copy the key.

Now try logging in to the remote PC again:

ssh root@<remote PC>

That should work without the password. At this point, you need to
decide whether you want to have the remote PC root account accessible
from anywhere on your network just using an ssh password login. If
you do not want that, go to (or ssh to) the remote PC again and edit
/etc/sshd_config again. Change the "PermitRootLogin" option from
"yes" to "prohibit-password" and restart sshd again, and run this
command:

sudo passwd -dl root

to delete the root password and lock the root account (password login
not permitted). Now root logins will only be allowed using a key pair
(or via sudo, as usual). An ssh key pair connection is very secure,
but having a key pair set up does mean that the remote PC is now only
as secure as the local user on this PC.

So now in a script on the local PC running as your normal user, you
can do things like:

ssh root@<remote PC> <script-name>

to run a script on the remote PC as root. The remote script could do:

systemctl restart mythtv-backend

for example, to restart mythbackend. Or:

reboot

to reboot the remote PC.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
Hi Bill!

> The list of files in the libmyth-python package is here and it looks OK. Assuming you're on Bionic
>
> https://packages.ubuntu.com/bionic/all/libmyth-python/filelist
>
> I can't explain why they're not being loaded.

And now with Stephen pointing out in my output error it is using version
0.29 my eyes bullseyed-focused on the listing “/usr/lib/python2.7/dist-packages/MythTV-0.28._1.egg-info“ – the third file listed but “first one” when comes to visual (by line
length). “Even worse” is the package list is 0.28!

Will do the repository update and report back. ...(See my message to
Stephen – getting closer!)

Barry
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!

>> libmyth-python is already the newest version
>> (2:29.1+fixes.20180414.329c235-0ubuntu3).
> This will be the problem, I think. It is libmyth-python 0.29.1, not
> v30. So you will need to install the MythTV v30 repository and
> update:
>
> sudo add-apt-repository ppa:mythbuntu/30
> sudo apt update
> sudo apt full-upgrade


“Funny” how that version 0.29 got overlooked! ..OK, did the correction,
rerun python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py' …. Well, seems better:

barry@NZXT:~$ python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py'
Unable to get BackendStatusPort settings from MythTV database, using
defaults
barry@NZXT:~$

Try changing HOST= ‘localhost’ to using the IP address of the Backend….
same error.

And thanks for the detailed instructions on ssh (your next message).
Have some familiarity, mainly with Raspberry Pi’s, but your details with
copying the keys and restarting just modules is something I’ve bumbled
around with. Will do that later today.

Barry
Re: Remotely monitor Backend is running [ In reply to ]
On Fri, 15 Oct 2021 10:13:30 -0500, you wrote:

>Hi Stephen!
>
>>> libmyth-python is already the newest version
>>> (2:29.1+fixes.20180414.329c235-0ubuntu3).
>> This will be the problem, I think. It is libmyth-python 0.29.1, not
>> v30. So you will need to install the MythTV v30 repository and
>> update:
>>
>> sudo add-apt-repository ppa:mythbuntu/30
>> sudo apt update
>> sudo apt full-upgrade
>
>
>?Funny? how that version 0.29 got overlooked! ..OK, did the correction,
>rerun python '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py' ?. Well, seems better:
>
>barry@NZXT:~$ python '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py'
>Unable to get BackendStatusPort settings from MythTV database, using
>defaults
>barry@NZXT:~$

That message means that you did not use the -n option to tell it which
PC to talk to, so it tried to find a database on the local PC to get
the address and port number from. As there is no local database, it
was unable to connect to it and gives you that message. Getting that
message means that you have all the required Python modules, so that
is good news.

>Try changing HOST= ?localhost? to using the IP address of the Backend?.
>same error.

I am not sure what you did there - what you need to do is use -n <IP
address> on the command line.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
Hi Stephen!

> That message means that you did not use the -n option to tell it which
> PC to talk to, so it tried to find a database on the local PC to get
> the address and port number from. As there is no local database, it
> was unable to connect to it and gives you that message. Getting that
> message means that you have all the required Python modules, so that
> is good news.
>
>> Try changing HOST= ?localhost? to using the IP address of the Backend?.
>> same error.
> I am not sure what you did there - what you need to do is use -n <IP
> address> on the command line.


Last part first: within the python script I had changed


HOST = 'localhost'

PORT = 6544


to


HOST = ‘192.168.4.3’

PORT = 6544


The IP address being that of the Backend.



Back to the first section, adding the -n switch…


From your Python script:

parser.add_argument('-n', '--host', action='store', help='MythTV backend
hostname or IP address (default: '+host+')')


Well, that’s where the -n comes from (my ‘cookbook’ learning and
patching together isn’t the best way!)


python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py' -n 192.168.4.3

Unable to get BackendStatusPort settings from MythTV database, using
defaults



python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py -n 192.168.4.3'

python: can't open file '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py -n 192.168.4.3': [Errno 2] No
such file or directory



python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py' -n --host 192.168.4.3

Unable to get BackendStatusPort settings from MythTV database, using
defaults

usage: test-mythbackend_v1_3-101421.py [-h] [-V] [-n HOST] [-p PORT]

test-mythbackend_v1_3-101421.py: error: argument -n/--host: expected one
argument



python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py' -n --host '192.168.4.3'

Unable to get BackendStatusPort settings from MythTV database, using
defaults

usage: test-mythbackend_v1_3-101421.py [-h] [-V] [-n HOST] [-p PORT]

test-mythbackend_v1_3-101421.py: error: argument -n/--host: expected one
argument



python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py' -n 192.168.4.3

Unable to get BackendStatusPort settings from MythTV database, using
defaults


- - -


python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py' -h

Unable to get BackendStatusPort settings from MythTV database, using
defaults

usage: test-mythbackend_v1_3-101421.py [-h] [-V] [-n HOST] [-p PORT]


Test that mythbackend is running and responding to API calls (Version: 1.3)


optional arguments:

-h, --help show this help message and exit

-V, --version

display the version number and exit

-n HOST, --host HOST

MythTV backend hostname or IP address (default: localhost)

-p PORT, --port PORT

MythTV backend API port number (default: 6544)



python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py' -V

Unable to get BackendStatusPort settings from MythTV database, using
defaults

Version 1.3



It seems like from Terminal I’m not passing the host’s IP address on to
the Python script.


For ‘fun’ cd’d to the subdirectory so I’m working where the Python
script is – same error.


OK, now you get to tell me what simple little thing I’m overlooking! And
just for more fun checked:


barry@NZXT:~/MythTV Backend Scripts$ ping -c2 192.168.4.3

PING 192.168.4.3 (192.168.4.3) 56(84) bytes of data.

64 bytes from 192.168.4.3: icmp_seq=1 ttl=64 time=0.206 ms

64 bytes from 192.168.4.3: icmp_seq=2 ttl=64 time=0.150 ms


--- 192.168.4.3 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1005ms

rtt min/avg/max/mdev = 0.150/0.178/0.206/0.028 ms

barry@NZXT:~/MythTV Backend Scripts$ ping -c2 192.168.4.3 -p 6544

PATTERN: 0x6544

PING 192.168.4.3 (192.168.4.3) 56(84) bytes of data.

64 bytes from 192.168.4.3: icmp_seq=1 ttl=64 time=0.184 ms

64 bytes from 192.168.4.3: icmp_seq=2 ttl=64 time=0.193 ms


--- 192.168.4.3 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1007ms

rtt min/avg/max/mdev = 0.184/0.188/0.193/0.014 ms


Thanks!

Barry
Re: Remotely monitor Backend is running [ In reply to ]
On 10/16/21 10:13 AM, Barry Martin wrote:
>
> Hi Stephen!
>
>> That message means that you did not use the -n option to tell it which
>> PC to talk to, so it tried to find a database on the local PC to get
>> the address and port number from. As there is no local database, it
>> was unable to connect to it and gives you that message. Getting that
>> message means that you have all the required Python modules, so that
>> is good news.
>>
>>> Try changing HOST= ?localhost? to using the IP address of the Backend?.
>>> same error.
>> I am not sure what you did there - what you need to do is use -n <IP
>> address> on the command line.
>
>
> Last part first: within the python script I had changed
>
>
> HOST = 'localhost'
>
> PORT = 6544
>
>
> to
>
>
> HOST = ‘192.168.4.3’
>
> PORT = 6544
>
>
> The IP address being that of the Backend.
>
>
>
> Back to the first section, adding the -n switch…
>
>
> From your Python script:
>
> parser.add_argument('-n', '--host', action='store', help='MythTV backend hostname or IP address (default: '+host+')')
>
>
> Well, that’s where the -n comes from (my ‘cookbook’ learning and patching together isn’t the best way!)
>
>
> python '/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py' -n 192.168.4.3
>
> Unable to get BackendStatusPort settings from MythTV database, using defaults
>
>
>
> python '/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py -n 192.168.4.3'
>
> python: can't open file '/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py -n 192.168.4.3': [Errno 2] No such file or directory
>
>
>
> python '/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py' -n --host 192.168.4.3
>
> Unable to get BackendStatusPort settings from MythTV database, using defaults
>
> usage: test-mythbackend_v1_3-101421.py [-h] [-V] [-n HOST] [-p PORT]
>
> test-mythbackend_v1_3-101421.py: error: argument -n/--host: expected one argument
>
>
>
> python '/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py' -n --host '192.168.4.3'
>
> Unable to get BackendStatusPort settings from MythTV database, using defaults
>
> usage: test-mythbackend_v1_3-101421.py [-h] [-V] [-n HOST] [-p PORT]
>
> test-mythbackend_v1_3-101421.py: error: argument -n/--host: expected one argument
>
>
>
> python '/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py' -n 192.168.4.3
>
> Unable to get BackendStatusPort settings from MythTV database, using defaults
>
>
> - - -
>
>
> python '/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py' -h
>
> Unable to get BackendStatusPort settings from MythTV database, using defaults
>
> usage: test-mythbackend_v1_3-101421.py [-h] [-V] [-n HOST] [-p PORT]
>
>
> Test that mythbackend is running and responding to API calls (Version: 1.3)
>
>
> optional arguments:
>
> -h, --help show this help message and exit
>
> -V, --version
>
> display the version number and exit
>
> -n HOST, --host HOST
>
> MythTV backend hostname or IP address (default: localhost)
>
> -p PORT, --port PORT
>
> MythTV backend API port number (default: 6544)
>
>
>
> python '/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py' -V
>
> Unable to get BackendStatusPort settings from MythTV database, using defaults
>
> Version 1.3
>
>
>
> It seems like from Terminal I’m not passing the host’s IP address on to the Python script.
>
>
> For ‘fun’ cd’d to the subdirectory so I’m working where the Python script is – same error.
>
>
> OK, now you get to tell me what simple little thing I’m overlooking! And just for more fun checked:
>
>
> barry@NZXT:~/MythTV Backend Scripts$ ping -c2 192.168.4.3
>
> PING 192.168.4.3 (192.168.4.3) 56(84) bytes of data.
>
> 64 bytes from 192.168.4.3: icmp_seq=1 ttl=64 time=0.206 ms
>
> 64 bytes from 192.168.4.3: icmp_seq=2 ttl=64 time=0.150 ms
>
>
> --- 192.168.4.3 ping statistics ---
>
> 2 packets transmitted, 2 received, 0% packet loss, time 1005ms
>
> rtt min/avg/max/mdev = 0.150/0.178/0.206/0.028 ms
>
> barry@NZXT:~/MythTV Backend Scripts$ ping -c2 192.168.4.3 -p 6544
>
> PATTERN: 0x6544
>
> PING 192.168.4.3 (192.168.4.3) 56(84) bytes of data.
>
> 64 bytes from 192.168.4.3: icmp_seq=1 ttl=64 time=0.184 ms
>
> 64 bytes from 192.168.4.3: icmp_seq=2 ttl=64 time=0.193 ms
>
>
> --- 192.168.4.3 ping statistics ---
>
> 2 packets transmitted, 2 received, 0% packet loss, time 1007ms
>
> rtt min/avg/max/mdev = 0.184/0.188/0.193/0.014 ms
>

Make sure there's a ~/.mythtv/config.xml file on this host. Python
bindings need this too. The contents look like any other remote
mythfrontend's would.

Even better than ping: nmap -p 3306,6544 --reason 192.168.4.3

Expect to see:

PORT STATE SERVICE REASON
3306/tcp open mysql syn-ack
6544/tcp open mythtv syn-ack

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
On Sat, 16 Oct 2021 10:13:04 -0500, you wrote:

>
>Hi Stephen!
>
>> That message means that you did not use the -n option to tell it which
>> PC to talk to, so it tried to find a database on the local PC to get
>> the address and port number from. As there is no local database, it
>> was unable to connect to it and gives you that message. Getting that
>> message means that you have all the required Python modules, so that
>> is good news.
>>
>>> Try changing HOST= ?localhost? to using the IP address of the Backend?.
>>> same error.
>> I am not sure what you did there - what you need to do is use -n <IP
>> address> on the command line.
>
>
>Last part first: within the python script I had changed
>
>
>HOST = 'localhost'
>
>PORT = 6544
>
>
>to
>
>
>HOST = ?192.168.4.3?
>
>PORT = 6544
>
>
>The IP address being that of the Backend.
>
>
>
>Back to the first section, adding the -n switch?
>
>
> From your Python script:
>
>parser.add_argument('-n', '--host', action='store', help='MythTV backend
>hostname or IP address (default: '+host+')')
>
>
>Well, that?s where the -n comes from (my ?cookbook? learning and
>patching together isn?t the best way!)
>
>
>python '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py' -n 192.168.4.3
>
>Unable to get BackendStatusPort settings from MythTV database, using
>defaults
>
>
>
>python '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py -n 192.168.4.3'
>
>python: can't open file '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py -n 192.168.4.3': [Errno 2] No
>such file or directory
>
>
>
>python '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py' -n --host 192.168.4.3
>
>Unable to get BackendStatusPort settings from MythTV database, using
>defaults
>
>usage: test-mythbackend_v1_3-101421.py [-h] [-V] [-n HOST] [-p PORT]
>
>test-mythbackend_v1_3-101421.py: error: argument -n/--host: expected one
>argument
>
>
>
>python '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py' -n --host '192.168.4.3'
>
>Unable to get BackendStatusPort settings from MythTV database, using
>defaults
>
>usage: test-mythbackend_v1_3-101421.py [-h] [-V] [-n HOST] [-p PORT]
>
>test-mythbackend_v1_3-101421.py: error: argument -n/--host: expected one
>argument
>
>
>
>python '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py' -n 192.168.4.3
>
>Unable to get BackendStatusPort settings from MythTV database, using
>defaults
>
>
>- - -
>
>
>python '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py' -h
>
>Unable to get BackendStatusPort settings from MythTV database, using
>defaults
>
>usage: test-mythbackend_v1_3-101421.py [-h] [-V] [-n HOST] [-p PORT]
>
>
>Test that mythbackend is running and responding to API calls (Version: 1.3)
>
>
>optional arguments:
>
>-h, --help show this help message and exit
>
>-V, --version
>
>display the version number and exit
>
>-n HOST, --host HOST
>
>MythTV backend hostname or IP address (default: localhost)
>
>-p PORT, --port PORT
>
>MythTV backend API port number (default: 6544)
>
>
>
>python '/home/barry/MythTV Backend
>Scripts/test-mythbackend_v1_3-101421.py' -V
>
>Unable to get BackendStatusPort settings from MythTV database, using
>defaults
>
>Version 1.3
>
>
>
>It seems like from Terminal I?m not passing the host?s IP address on to
>the Python script.
>
>
>For ?fun? cd?d to the subdirectory so I?m working where the Python
>script is ? same error.
>
>
>OK, now you get to tell me what simple little thing I?m overlooking! And
>just for more fun checked:
>
>
>barry@NZXT:~/MythTV Backend Scripts$ ping -c2 192.168.4.3
>
>PING 192.168.4.3 (192.168.4.3) 56(84) bytes of data.
>
>64 bytes from 192.168.4.3: icmp_seq=1 ttl=64 time=0.206 ms
>
>64 bytes from 192.168.4.3: icmp_seq=2 ttl=64 time=0.150 ms
>
>
>--- 192.168.4.3 ping statistics ---
>
>2 packets transmitted, 2 received, 0% packet loss, time 1005ms
>
>rtt min/avg/max/mdev = 0.150/0.178/0.206/0.028 ms
>
>barry@NZXT:~/MythTV Backend Scripts$ ping -c2 192.168.4.3 -p 6544
>
>PATTERN: 0x6544
>
>PING 192.168.4.3 (192.168.4.3) 56(84) bytes of data.
>
>64 bytes from 192.168.4.3: icmp_seq=1 ttl=64 time=0.184 ms
>
>64 bytes from 192.168.4.3: icmp_seq=2 ttl=64 time=0.193 ms
>
>
>--- 192.168.4.3 ping statistics ---
>
>2 packets transmitted, 2 received, 0% packet loss, time 1007ms
>
>rtt min/avg/max/mdev = 0.184/0.188/0.193/0.014 ms
>
>
>Thanks!
>
>Barry

It look like the problems you are having are due to the way you are
running test-mythbackend.py. The easy way to run it is to execute it
directly as a command:

test-mythbackend.py <options>

This does require that test-mythbackend.py has been given the
executable option when you downloaded it:

chmod a+x test-mythbackend.py

If you run it as an argument from a python command, then you need to
use different syntax in order to pass options to test-mythbackend.py
instead of to python. The -c option of the python command tells
python that it is to stop looking for any further options on its
command line and instead run the command directly after the -c option
and pass the rest of the python command line options to the program it
is running via -c. So instead of:

python '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py' -n 192.168.4.3

it should be:

python -c '/home/barry/MythTV Backend
Scripts/test-mythbackend_v1_3-101421.py' -n 192.168.4.3

or preferably:

/home/barry/MythTV\ Backend\ Scripts/test-mythbackend_v1_3-101421.py
-n 192.168.4.3

or

"/home/barry/MythTV Backend Scripts/test-mythbackend_v1_3-101421.py"
-n 192.168.4.3

I have also put v1.4 on my web server. This makes it only try to
access the database if neither -n or -p is used on the command line.
So it will not waste time trying to access a non-existent local
database when you are using -n to tell it to talk to a different PC.
And I have also eliminated the use of text message output except for
install problems - it will now just return a result code without any
warning text messages.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remotely monitor Backend is running [ In reply to ]
Barry a friendly word :) Are you using digest mode to get your emails or
individual emails?


You're probably not aware but for some reason each time you reply to an
email it is creating a new thread in many email browsers like
Thunderbird so for this discussion there are something like 8 or more
threads all started by you all with the title "Re: [mythtv-users]
Remotely monitor Backend is running".


One or two replies to digest emails is fine but for big discussions it's
best to turn individual emails on and make sure you reply to the correct
email so you don't break the threading.


Thanks

Paul H.

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org