Checking if Oscam is using a currently decoding a channel by command line or Webif

There are 12 replies in this Thread which was already clicked 2,582 times. The last Post () by s3n0.

  • Hi,

    I'd like to know if it's possible to check, running a bash script, if the oscam is currently decoding any channel either by a reader or by a client.

    I'd like to do this check in order to safely schedule a periodic oscam's restart it without corrupting a recording or interrupting a viewing.

    So either a command line variable or a wget one would be really useful.

  • Hi.


    For example, you can test the activity of readers or a single reader via Oscam-Webif. You can read the idle status of the readers. Based on that, you then do what you need. Alternatively, you can check the Standby status for the Enigma power state (the set-top-box power state). Both principles are used in my script.

  • First of all I apologize for my late reply, but I couldn't examine and study your script before.

    Then, I really want to thank you for the effort you specifically did for me, editing your script, I really apreeciated it.


    I actually needed much less, because I have a script which perform a series of operation.

    So, I only needed to read if any of the readers is engaged and assign this to a variable.

    Depending on it I'll then have various commands.


    I saw that this command:

    cat /tmp/test-oscam-api.xml | sed -rn '/name="'$READER_LABEL'"/,/times/p'


    creates a file which would be useful, indeed, ecm.info which contains, above all, the reader used at the moment.

    And I thought I could use it by the sed command.

    But, the problem is that it deletes the file when no readers is used (that means Oscam is not actually used, at moment, by a channel or a recording going on).

    My knowledge of sed command is limited and I tried different options but I did not manage to avoid the deleting of ecm.info.

    Is that possible. Or is simply possible to have a way for a sort of yes/no answer to the question: is Oscam decrypting any channels at the moment?

  • OK, so try the following script to find out the queried satellite channels (Serv-ID).

    If the sum of all surveyed satellite channels is zero, then Oscam is asleep.


    In my opinion, however, the test method using the is_standby function from my previous script is sufficient. This is_standby function tests whether the set-top box is in standby mode (when no one is watching any TV channels).

  • I'll check your script or examine it as soon as possible.

    I understand your point but in my case it wouldn't do what I need because there's a script running every some hours that needs to know, as its last operation, if it can also restart oscam and, at the moment, it does based on the simple fact that there is no recordings going on, regardless of the fact the recording is only from a FTA channel or not.

    If I could know if oscam is actually and actively decoding, the script would restart oscam in case of FTA, whilst now it just does not restart not to risk to ruin the recordings.

    If I simply checked if the box were in standby, I simply did not have the oscam restart even if possible.

    Here is not the oscam the main actor of the problem, but the possible ruining of a recording ;)

    I'm looking forward to get into your script ;)

  • Open the Oscam API in a web browser ... simply open the following website (XML document):

    http://192.168.x.x:8888/oscamapi.html?part=status

    Then find the data you need and use it.


    Sitting on the example script above can also be simplified. However, I deliberately wrote it as before, if you wanted to use REGEX expressions on a block of certain data found between two words (strings) from the part of the "sed" command in front. Theoretically, it should be sufficient to use only the back of the above "sed" command:

    .............. | sed -rn 's/.*srvid="([0-9]*)".*/\1/p'


    Or you can search for all "idle time" data idle="0" in the "connected client" blocks client type="c", and if they are all greater than cca 10 seconds (depending on the type of card encoding, as some encodings do not require a repeated request from the decoder card !) then Oscam is asleep:

    .............. | sed -rn '/type="c"/,/client>/ {s/.*idle="([0-9]*)".*/\1/p}'

  • Here is a second example ... maybe it will be a better script for your needs.


    The function in the script returns "0" if at least one number is less than 20, otherwise the function returns "1".


    Thus, if at least one client accesses Oscam within 20 seconds, the function returns the value "0", otherwise the function returns "1".


  • I was enlightened by your line

    http://192.168.x.x:8888/oscamapi.html?part=status

    (obviously with my box IP and oscam port)


    and I actually think there is a much simpler way. Using this line in my browser, it showed this output when oscam did not decode any channel


    OK OK CARDOK CARDOK CARDOK CONNECTED ERROR CONNECTED ERROR CONNECTED CONNECTED OFF ERROR ERROR CONNECTED ERROR UNKNOWN ERROR CONNECTED CONNECTED CONNECTED ERROR ERROR CONNECTED CONNECTED CONNECTED CONNECTED UNKNOWN OFF


    but this other output when oscam if it was decoding a channel


    OK OK CARDOK unknown CARDOK CARDOK CONNECTED ERROR unknown CONNECTED ERROR unknown CONNECTED CONNECTED OFF ERROR ERROR CONNECTED OFF UNKNOWN OFF unknown CONNECTED CONNECTED CONNECTED ERROR ERROR CONNECTED unknown CONNECTED unknown CONNECTED CONNECTED UNKNOWN OFF unknown OK


    where the only difference is the presence of the string "unknown OK" only in this second case.

    So I thought I could use a wget or a grep command to copy this output into a file in order to check for this string.

    But clearly my linux commands knowledge is too limited at the moment and I didn't manage to do that.


    For instance, among many other tries, I did an attempt by this command:


    Output=$(wget -q -O - "http://MY_USERNAME:MY_PASSWORD@x.y.w.z:MY_PORT" | sed -n '1,/unknown OK/ p')


    but it gets into an error. How may I get this http output into a string or a file?

  • That's nonsense. You should see the XML-encoded "status" from Oscam-Webif. Try it in Shell as well, with the help of wget, with std-out (argument -O -). You must use user:password details also. If you are not logged in to your Oscam-Webif, it will not work (status is denied if you are not logged in).

    Code
    USR="your_login_name"
    PAS="your_login_password"
    wget -q -O - --no-check-certificate --no-cache --no-cookies "http://${USR}:${PAS}@127.0.0.1:8888/oscamapi.html?part=status"
  • This script produced only the file

    ecm.info

    in /var/volatile/tmp


    but no output. And, as I said before, the file is created only if this wget command is launched while oscam is decoding and is deleted if oscam is not decoding.

    So, as an alternative to the "output method" I talked about in my previous post, I used the command TEST to simply check if this file exists or not.

    And it works ;)


    So, many many many thanks: your help was decisive, although in a different way in respect to your initial idea.

    But here, what matters is the solution!

  • What is your Enigma distribution and build (the Enigma2 core version) ?


    Some Linux systems in some Enigmas do not include the full-featured "wget" tool and you need to modify it or use other arguments and switches for this tool.

    I can also check the functionality of wget remotely - if you believe me, write me on Skype and then give me a TeamViewer ID + password and I can look at your Shell.


    Or write this to Shell, to find out its version:

    wget --help

    It is quite possible that your wget comes from truncated Linux (maybe it's just part of the BusyBox set, as basic tools and commands for small versions of Linux). For example in OpenATV 6.4 enigma is used GNU Wget 1.20.3 (full Linux version, not as a BusyBox component).

  • I use OBH 4.3 and this is the wget output.

    GNU Wget 1.19.5, a non-interactive network retriever.


    I decided to base my check only on the existence of ecm.info, which I (wrongly) believed it was created by the wget command you showed me. Instead, it is created by the decoding itself.

    So, by this two simple lines


    FILE=/var/volatile/tmp/ecm.info

    if test -f "$FILE"

    .....


    I got to my target.

    And, also, is not based on the box IP or its username and password. This way I can pass it on some friends without having to edit anything.


    Actually, the perfect and ultimate solution would be to know if the Oscam is running only because I'm watching or streaming a channel that needs it, or because there is a recording active and which is using Oscam.

    At the moment I can only know if a recording is active (by a wget command based on active timers) and, now, if oscam is decoding.

    But it might be that the recording is on on a FTA channel and the oscam is decoding because I'm watching a channel...


    All of this is to prevent an oscam restart while I'm recording a that needs Oscam to be running (without interruption

  • I do not understand you. So does the script work for you or does it not work? Will it write an error or not? Or what exactly ... I don't understand absolutely anything now.


    The purpose of testing Oscam activity is clear to me (you share ... so it is not possible to test just Enigma2 power state via OpenWebif before updating Oscam).


    🤔

OSCam-EMU Support Forum

Configs, discussion, downloads and guides for OSCam-EMU Softcam.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!