Mailing List Archive

1 2 3  View All
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

1 2 3  View All