How to "Oscam check script"

There are 42 replies in this Thread which was already clicked 33,958 times. The last Post () by kiko2004.


  • Very new to linux so this might be a silly question.


    when i try see if oscam is running I get this (using this in terminal)
    ps ax | grep cam



    1918 ? Ssl 0:03 /usr/local/bin/CCcam.x86
    4188 ? S< 0:00 /usr/local/bin/oscam.x86
    4189 ? S< 0:00 /usr/local/bin/oscam.x86
    4190 ? S< 0:00 /usr/local/bin/oscam.x86
    4191 ? S<l 0:15 /usr/local/bin/oscam.x86
    4192 ? S<l 0:15 /usr/local/bin/oscam.x86
    4196 ? S< 0:00 /usr/local/bin/oscam.x86
    4197 ? S< 0:00 /usr/local/bin/oscam.x86
    4198 ? S< 0:00 /usr/local/bin/oscam.x86
    4199 ? S< 0:00 /usr/local/bin/oscam.x86
    4200 ? S< 0:00 /usr/local/bin/oscam.x86


    Does this mean there is more then one oscam running?

  • This script has the 2 methods of check:


    #!/bin/bash
    if ! ps x |grep -v grep |grep -c /emu/oscam/oscam.x86 >/dev/null
    then
    oscript start
    echo `date "+%d/%m/%y %R process was not working"` >> /var/log/oscam_restart_log
    # This part above will check if there is NO oscam process running.
    # And if this condition it truth, it will start it and write to log.
    # Log entry will contain time stamp and reason of execution (process not working)
    # If first condition in not truth (oscam was running), go further to next condition.
    elif
    tail -8 /var/log/oscam.log |grep -v grep |grep -c ins40 >/dev/null
    then
    oscript restart
    echo `date "+%d/%m/%y %R ins40 error detected"` >> /var/log/oscam_restart_log
    elif
    tail -8 /var/log/oscam.log |grep -v grep |grep -c deadlock >/dev/null
    then
    oscript restart
    echo `date "+%d/%m/%y %R deadlock error detected"` >> /var/log/oscam_restart_log
    # Those 2 conditions will look for 2 common errors in Oscam: "ins40" and "deadlock"
    # If last 8 lines of your oscam.log contain any of those errors, it will restart oscam.
    # Log entries will include the exact reason of restart.
    # ins40 error is random error that will keep oscam running but no CWs returned.
    # deadlock is older error that appear if you use CCcam protocol in oscam.server
    else
    echo "ok"
    # If oscam passes all conditions and all is OK, it will simply echo "ok"
    fi

  • Oscam check script for ultimo
    1. Make a script like this and ftp to /usr/script where other scripts are for ex oscam_check
    2. Make a cronjob for ex emu restart at a certain time
    3. Go to /etc/bhcron and open files bh.cron and root
    4. Add in both files below the lines a 5 min cron as you do in debian to check cccam or oscam and save files.
    5. Do a hard reset and you will see in oscam.log that script works every 5 min and write log


    #!/bin/sh
    remove_tmp () {
    rm -rf /tmp/*.info* /tmp/*.tmp*
    }
    oscam_rs () {
    killall -9 oscam 2>/dev/null
    sleep 3
    remove_tmp
    /usr/bin/oscam -b
    }


    if ! ps x |grep -v grep |grep -c /usr/bin/oscam >/dev/null
    then
    oscam_rs
    echo `date "+%d/%m/%y %R process was not working"` >> /var/log/oscam_restart_log
    elif
    tail -8 /var/log/oscam.log |grep -v grep |grep -c ins40 >/dev/null
    then
    oscam_rs
    echo `date "+%d/%m/%y %R ins40 error detected"` >> /var/log/oscam_restart_log
    elif
    tail -8 /var/log/oscam.log |grep -v grep |grep -c deadlock >/dev/null
    then
    oscam_rs
    echo `date "+%d/%m/%y %R deadlock error detected"` >> /var/log/oscam_restart_log
    else
    echo "ok"
    fi

    • Official Post

    Thanks arber for the script, i have made ipk file for BlackHole image, to restart EMU at 8am and run oscamcheck script every 10 minutes.


    FTP to /tmp > Green button > Yellow button > Manual Install IPK Packages


    Do a hard reset and you will see in oscam.log that script works every 5 min and write log.


    You can test the script is working by telnet command, killall -9 oscam wait a few minutes and check var/log/oscam_restart_log.


    You should get process was not working, which means the script is working and oscam was restarted.


    Enjoy..

  • Hey, that's what I', but I have an error, it's not responding.


    #!/bin/sh
    remove_tmp () {
    rm -rf /tmp/*.info* /tmp/*.tmp*
    }
    oscam_rs () {
    killall -9 oscam-stable 2>/dev/null
    sleep 3
    remove_tmp
    /usr/bin/oscam-stable -b
    }


    if ! ps x |grep -v grep |grep -c /usr/bin/oscam-stable >/dev/null
    then
    oscam_rs
    echo `date "+%d/%m/%y %R process was not working"` >> /media/usb/tmp/oscam_restart_log
    elif
    tail -8 /media/usb/tmp/oscam.log |grep -v grep |grep -c ins40 >/dev/null
    then
    oscam_rs
    echo `date "+%d/%m/%y %R ins40 error detected"` >> /media/usb/tmp/oscam_restart_log
    elif
    tail -8 /media/usb/tmp/oscam.log |grep -v grep |grep -c deadlock >/dev/null
    then
    oscam_rs
    echo `date "+%d/%m/%y %R deadlock error detected"` >> /media/usb/tmp/oscam_restart_log
    else
    echo "ok"
    fi


    oscam ist rename oscam-stable.


    This I put to a file oscamcheck.sh und upload /etc/init.d/ i have PLI 2.1.


    In the cron I entered */5 * * * * /etc/init.d/oscamcheck.sh But it doesn't work. I really I don't know how to go on, it Will someone please?

  • As of ubuntu 10.04 don't use the name oscam in the script or the logfile.
    Name it ServerOK.sh or Ubuntu will always find an instance of "oscam"!

  • I tryed this script on my raspberry and set cron for 1 minute, but instead of checking the oscam and restarting if it's stoped it will restart it every minute.


    Can someone adapt it for raspberry ? Thanks.


  • Funny to see my old script has reached this board in altered state :P


    --


    I noticed that Oscam is started with command 'oscam -b'.
    This should be 'oscam -b -r 2' , without you are not able to restart oscam through the web interface.


    Also, please note..


    - Removing the .tmp files is a bit destructive for other .tmp files, and not nescesary to clean for oscam-restart.
    - Restart on ins40 or deadlock errors are outdated. This wont happen anymore in current oscam versions.
    - The killall command looks a bit strange: killall -9 oscam-stable 2 >/dev/null (where does the 2 stands for?)
    - This script was made for Ubuntu/Debian. Note that ps x command is not available in tuxbox, should be ps w .


    Hope this solves a few errors!

  • I tryed this script on my raspberry and set cron for 1 minute, but instead of checking the oscam and restarting if it's stoped it will restart it every minute.


    Can someone adapt it for raspberry ? Thanks.


    Hi GeorgeXL,


    did you get this set up on your PI & if you did any chance of a walk through please?


    Thanks
    Calisto

  • Have just got this from a good friend to help with restarting oscam if it stops:


    ssh into your pi now
    with putty


    type
    ps ax
    press enter
    should give u a big long list of crap


    in that list will be oscam running
    just look for the word oscma


    on the left of them they will be given a number ID
    ie... 15532
    or something
    could be anything


    sudo kill -9 ***


    so now type
    cd /usr/local/bin or wherever your oscam is
    then type
    sudo ./oscam -b -r 2


  • Just a little hint..


    if you have a long output from a command, like ps ax, you can filter the output with grep.. like:


    ps x a | grep "osc"


    This will output only lines with "osc" in it..

  • Oscam.log folder -- history


    2013/02/23 11:43:39 2E5034B0 c card (09CD&000000/106E/B7:5AE8): found (101 ms) by ***it (of 1 avail 1)
    2013/02/23 11:43:49 2E5034B0 c card (09CD&000000/106E/B7:25ED): found (100 ms) by ***it (of 1 avail 1)
    2013/02/23 11:43:59 2E5034B0 c card (09CD&000000/106E/B7:673E): found (100 ms) by ***it (of 1 avail 1)
    2013/02/23 14:26:32 2C6334B0 r client timeout=5000 ms, fallback timeout=2500 ms, cache delay=120 ms
    2013/02/23 14:26:32 2C6334B0 r [videoguard2-reader] classD0 ins40: (-2) status not ok f8 ef
    2013/02/23 14:27:16 2C6334B0 r [videoguard2-reader] classD0 ins40: (-2) status not ok f8 ef
    2013/02/23 14:27:16 2E7FF4B0 c card (09CD&000000/1FAC/B7:9D4F): not found (2535 ms) by ***it (of 1 avail 1)
    2013/02/23 14:27:18 2C6334B0 r [videoguard2-reader] classD0 ins40: (-2) status not ok f8 ef
    2013/02/23 14:27:39 2C6334B0 r [videoguard2-reader] classD0 ins40: (-2) status not ok f8 ef
    2013/02/23 14:27:39 2E7FF4B0 c card (09CD&000000/0FC7/B7:8497): not found (2535 ms) by ***it (of 1 avail 1)
    2013/02/23 14:27:41 2C6334B0 r [videoguard2-reader] classD0 ins40: (-2) status not ok f8 ef
    2013/02/23 14:28:03 2C6334B0 r [videoguard2-reader] classD0 ins40: (-2) status not ok f8 ef
    2013/02/23 14:28:03 2E7FF4B0 c card (09CD&000000/3C03/B7:4C64): not found (2535 ms) by ***it (of 1 avail 1)
    2013/02/23 14:28:06 2C6334B0 r [videoguard2-reader] classD0 ins40: (-2) status not ok f8 ef
    2013/02/23 14:28:45 2C6334B0 r [videoguard2-reader] classD0 ins40: (-2) status not ok f8 ef



    this script follow the word from oscam.log
    is perfect functional, with cronjob at 1 or 2 minutes
    Oscam1.10_SNV_r5893


    ################################
    monitor restart for Oscam_r5893


    is working correct, after you start the cronJob
    tested Ok !!!
    feedback from oscam.log-- following this tree words "ins40","classD0",and "timeout"


    if one of this 3 words , will appear (pup up) 10 times in oscam.log, restart of oscam will follow,....


    super ok !!! is put in usr/script and atr 755 or 777
    #################################################
    #oscamcheck.sh or oscammonitor.sh
    ##################################################



    #!/bin/bash


    founds=`tail -10 /var/log/oscam.log | grep "ins40" | wc -l`
    founds2=`tail -10 /var/log/oscam.log | grep "classD0" | wc -l`
    founds3=`tail -20 /var/log/oscam.log | grep "timeout" | wc -l`


    if [ $founds -gt 3 ] || [ $founds2 -ge 1 ] || [ $founds3 -ge 1 ]
    then
    echo "Error found, restart...";
    echo "Error found, restart..." >> /var/log/oscam.check
    /usr/bin/killall -9 oscam_r5893
    /usr/bin/oscam_r5893 &
    else
    echo "oscam still ok 2";
    echo "oscam is still ok 2!" >> /var/log/oscam.check
    fi


    ##########
    the end
    and have fun
    #######################
    cronjob etc/cron/crontab/root


    ++++++++++++++
    in root --atr 755-- I put:
    */1 * * * * /usr/script/CCcamCheck.sh start /dev/null
    or
    1 * * * * /usr/script/CCcamCheck.sh start /dev/null


    I don 't know which is correct for ver 2.2 gutamine CRON
    =============


    oscam.check folder from var/log/
    will show this


    oscam is still ok 2!
    oscam is still ok 2!
    oscam is still ok 2!
    oscam is still ok 2!
    oscam is still ok 2!
    oscam is still ok 2!
    Error found, restart...
    oscam is still ok 2!
    oscam is still ok 2!
    oscam is still ok 2!
    oscam is still ok 2!


    also when you will run manual the script -- you will get same message on screen of TV
    ==========
    don't forget to start from cronmanager /START ON--- the crontabs !!!!!
    or run with DCC
    crontab -e
    ================
    and set also Crontab START at BOOT-- to be active !!!!
    ================
    restart , and have fun, will work like a clock ,...
    bye


    I tested on DM800HD , image nemesis2.3_ svn_095r6 _SSL84 by ramiMAHER


    Nemesis2-3-dm800HD-SVN(095r6)-10-23-2011-ramiMAHER #ssl84

  • ###########################################################################
    #!/bin/bash
    ###########################################################################


    process=`ps auxwww | grep oscam | grep -v grep | awk '{print $1}'`


    if [ -z '$process' ];


    then


    echo "Couldn't find oscam running. Restarting server-binary"
    echo "Couldn't find oscam running. Restarting server-binary" >> /var/log/oscam.check
    nohup /usr/bin/oscam_r5893 >> /var/log/oscam.log &


    else


    echo "oscam is still OK 1 !" ############################## #this will be on TV screen only
    echo "oscam is still OK 1!" >> /var/log/oscam.check ############# this will be in file oscam.check



    fi


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


    founds=`tail -10 /var/log/oscam.log | grep "ins40" | wc -l`
    founds2=`tail -10 /var/log/oscam.log | grep "classD0" | wc -l`
    founds3=`tail -20 /var/log/oscam.log | grep "timeout" | wc -l`


    if [ $founds -gt 3 ] || [ $founds2 -ge 1 ] || [ $founds3 -ge 1 ]


    then


    echo "Error found, restart...";
    echo "Error found, restart..." >> /var/log/oscam.check
    /usr/bin/killall -9 oscam_r5893
    /usr/bin/oscam_r5893 &


    else


    echo "oscam still ok 2";
    echo "oscam is still ok 2!" >> /var/log/oscam.check


    fi



    ###########################################################################
    # end of script
    ###########################################################################


    oscam.check folder from var/log/
    will show this


    oscam is still OK 1!
    oscam is still ok 2!
    oscam is still OK1!
    oscam is still ok 2!
    oscam is still OK 1!
    oscam is still ok 2!
    Couldn't find oscam running. Restarting server-binary
    Error found, restart...
    oscam is still OK 1!
    oscam is still ok 2!
    oscam is still OK1!
    oscam is still ok 2!
    Couldn't find oscam running. Restarting server-binary
    oscam is still ok 2!
    oscam is still OK1!
    oscam is still ok 2!
    oscam is still OK1!
    Error found, restart...
    oscam is still OK 1!
    oscam is still ok 2!
    oscam is still OK1!
    oscam is still ok 2!
    oscam is still OK 1!
    oscam is still ok 2!


    PS: oscam is check from 2 directions,... according with oscam.log file

  • small modifications to first script ,....


    process=`ps auxwww | grep oscam | grep -v grep | awk '{print $1}'`


    if [ -z '$process' ];


    then


    echo "Couldn't find oscam running. Restarting server-binary"
    echo "Couldn't find oscam running. Restarting server-binary" >> /var/log/oscam.check
    #nohup /usr/bin/oscam_r5893 >> /var/log/oscam.log &


    /usr/bin/killall -9 oscam_r5893
    /usr/bin/oscam_r5893 &



    else
    echo " oscam is still OK 1!" >> /var/log/oscam.check
    echo "oscam is still OK 1!" #aceasta linie o afiseaza doar pe Ecran, prima are calea spre folder oscam.check


    fi



    with this correction, both scripts will work separate , like a clock,...
    bye



    oscam is still OK 1!
    oscam is still ok 2!
    oscam is still OK 1!
    oscam is still ok 2!
    oscam is still OK 1!
    Error found, restart Oscam
    oscam is still OK 1!
    oscam is still ok 2!
    oscam is still OK 1!
    oscam is still ok 2!
    oscam is still OK 1!

  • #!/bin/bash


    #if ! ps x |grep -v grep |grep -c /emu/oscam/oscam.x86 >/dev/null


    if ! ps x |grep -v grep |grep -c /usr/bin/oscam >/dev/null


    then


    # oscam start


    /usr/bin/oscam_5893 &


    #/usr/bin/oscam_versiunexxxx
    #also the path to Oscam binary


    echo


    `date "+%d/%m/%y %R process working OK"` >> /var/log/oscam.check



    # This part above will check if there is NO oscam process running.
    # And if this condition it truth, it will start it and write to log.
    # Log entry will contain time stamp and reason of execution (process not working)
    # If first condition in not truth (oscam was running), go further to next condition.


    elif


    tail -8 /var/log/oscam.log |grep -v grep |grep -c ins40 >/dev/null


    then


    #oscam restart
    /usr/bin/killall -9 oscam_r5893
    /usr/bin/oscam_r5893 &


    #/usr/bin/oscam_versiunexxxx


    echo


    `date "+%d/%m/%y %R ins40 error detected"` >> /var/log/oscam.check


    elif


    tail -8 /var/log/oscam.log |grep -v grep |grep -c deadlock >/dev/null


    then


    #oscam restart
    /usr/bin/killall -9 oscam_5893
    /usr/bin/oscam_5893 &
    #/usr/bin/oscam_versiunexxxx


    echo


    `date "+%d/%m/%y %R deadlock error detected"` >> /var/log/oscam.check



    # Those 2 conditions will look for 2 common errors in Oscam: "ins40" and "deadlock"
    # If last 8 lines of your oscam.log contain any of those errors, it will restart oscam.
    # Log entries will include the exact reason of restart.
    # ins40 error is random error that will keep oscam running but no CWs returned.
    # deadlock is older error that appear if you use CCcam protocol in oscam.server


    else


    echo " still OK 2 " # you can select your option , with date or without date
    echo " still OK 2!" >> /var/log/oscam.check
    echo


    `date "+%d/%m/%y %R Oscam still Ok 2"` >> /var/log/oscam.check



    # If oscam passes all conditions and all is OK, it will simply echo "Oscam still Ok 2" or you can select the version with date + hour


    fi


    #######################
    Script was tested and works,....
    see here



    still OK 2!
    22/06/13 15:24 Oscam ok 2
    still OK 2!
    22/06/13 15:25 Oscam ok 2
    still OK 2!
    22/06/13 15:26 Oscam ok 2
    still OK 2!
    22/06/13 15:27 Oscam ok 2
    still OK 2!
    22/06/13 15:28 Oscam ok 2
    still OK 2!
    22/06/13 15:29 Oscam ok 2
    still OK 2!
    22/06/13 15:30 Oscam ok 2
    still OK 2!
    22/06/13 15:31 Oscam ok 2
    still OK 2!
    22/06/13 15:32 Oscam ok 2
    still OK 2!
    22/06/13 15:33 Oscam ok 2
    still OK 2!
    22/06/13 15:34 Oscam ok 2

  • final version here, {because I made some error, of editing }
    ####################################################
    ##################################################################################
    #!/bin/sh
    ###############################################################################


    if ! ps x |grep -v grep |grep -c /usr/bin/oscam_r5893 >/dev/null


    # example { if ! ps x |grep -v grep |grep -c /emu/oscam/oscam.x86 >/dev/null }
    #/usr/bin/oscam_versionexxxx
    #also take attention to the path to Oscam binary !!!!!!!


    then


    # oscam start or restart


    /usr/bin/killall -9 oscam_r5893
    /usr/bin/oscam_r5893 &


    #/usr/bin/oscam_versiunexxxx
    #also take attention to the path to Oscam binary !!!!!!!



    echo `date "+%d/%m/%y %R Oscam NOT working , restarting...."` >> /var/log/oscam.check



    # This part above will check if there is NO oscam process running.
    # And if this condition it truth, it will start it and write to log.
    # Log entry will contain time stamp and reason of execution (process not working)
    # If first condition in not truth (oscam was running), go further to next condition.


    elif


    tail -8 /var/log/oscam.log |grep -v grep |grep -c ins40 >/dev/null


    then


    #oscam restart
    /usr/bin/killall -9 oscam_r5893
    /usr/bin/oscam_r5893 &


    #/usr/bin/oscam_versiunexxxx


    echo `date "+%d/%m/%y %R ins40 error detected"` >> /var/log/oscam.check


    elif


    tail -8 /var/log/oscam.log |grep -v grep |grep -c deadlock >/dev/null


    then


    #oscam restart
    /usr/bin/killall -9 oscam_r5893
    /usr/bin/oscam_r5893 &


    #/usr/bin/oscam_versiunexxxx


    echo `date "+%d/%m/%y %R deadlock error detected"` >> /var/log/oscam.check



    # Those 2 conditions will look for 2 common errors in Oscam: "ins40" and "deadlock"
    # If last 8 lines of your oscam.log contain any of those errors, it will restart oscam.
    # Log entries will include the exact reason of restart.
    # ins40 error is random error that will keep oscam running but no CWs returned.
    # deadlock is older error that appear if you use CCcam protocol in oscam.server


    else


    echo " Oscam still ok 2 "
    #echo " Oscam still ok 2!" >> /var/log/oscam.check
    echo `date "+%d/%m/%y %R Oscam still ok 2!"` >> /var/log/oscam.check



    # If oscam passes all conditions and all is OK, it will simply echo "Oscam still OK 2 !"


    fi



    ##################################################################################
    #!/bin/sh
    ###############################################################################


    if ps x |grep -v grep |grep -c usr/bin/CCcam_2.1.3 >/dev/null
    #if ps x |grep -v grep |grep -c CCcam_2.1.3 >/dev/null


    then


    echo "CCcam OK 3"
    #echo "CCcam OK 3" >> /var/log/CCcam.check
    echo `date "+%d/%m/%y %R CCcam OK 3"` >> /var/log/CCcam.check


    else


    echo "CCcam restarting"
    #echo "CCcam restarting" >> /var/log/CCcam.check
    echo `date "+%d/%m/%y %R CCcam restarting... "` >> /var/log/CCcam.check


    /usr/bin/killall -9 CCcam_2.1.3
    /usr/bin/CCcam_2.1.3 &


    fi


    ######################
    ####End of script ####
    ######################




    ####################################################
    Tested, and Works well
    22/06/13 21:34 Oscam still ok 2!
    22/06/13 21:35 Oscam still ok 2!
    22/06/13 21:36 Oscam NOT working OK
    22/06/13 21:37 Oscam still ok 2!
    22/06/13 21:38 Oscam still ok 2!
    ................
    22/06/13 22:23 Oscam still ok 2!
    22/06/13 22:24 Oscam still ok 2!
    22/06/13 22:25 Oscam still ok 2!
    22/06/13 22:26 Oscam still ok 2!
    22/06/13 22:27 Oscam still ok 2!
    22/06/13 22:28 Oscam still ok 2!
    22/06/13 22:29 Oscam still ok 2!
    22/06/13 22:30 Oscam still ok 2!
    22/06/13 22:31 ins40 error detected
    22/06/13 22:32 Oscam still ok 2!
    22/06/13 22:33 Oscam still ok 2!


    ...............

OSCam Support Forum

Configs, discussion, downloads and guides for OSCam Softcam.

Participate now!

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