Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Need a custom monitor code/script (paid work)
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Need a custom monitor code/script (paid work)

Hi, am trying to monitor m3u8 http url, and here is what i need. A script that can monitor this.

  1. get the http response from m3u8 url, the response generally contains a parameter bandwidth=some digit within that response in plain text.
  2. script needs to read this digit, and should trigger a second set of script if the above digit is less than a number say 500000
  3. second set of script, should be able to ssh to a external box, get the PID using a particular grep command, issue a kill on the pid.
  4. send a email as work is done.
  5. that should be it.

script should run on centos. any takers. basically i need to do this for like 10 urls, every 5min.

thank you very much.

Comments

  • check pm.

  • Easy enough - I hope you didn't offer any serious money for this :)

    Have a freebie:

    #!/bin/bash
    
    url="http://url/playlist.m3u8"
    minbw="500000"
    sshserver="user@hostname"
    procname="ffserver"
    
    bandwidth=$(curl --connect-timeout 5 -s "$url" | grep -Po '(?<=BANDWIDTH=)[0-9]*')
    if [ "$bandwidth" == "" ]; then
      echo "Error: Could not get bandwidth from $url"
      exit 0
    fi
    
    killproc(){
      local killresult
      killresult=$(ssh $sshserver "pkill $procname")
      case "$?" in
      0)
        echo "Success: process $procname at $sshserver was killed"
        # use smtp-cli to send an email here
        ;;
      1)
        echo "Failed: process $procname at $sshserver was not killed"
        # optional smtp-cli here
        ;;
      esac
    }
    
    if [ "$bandwidth" -lt "$minbw" ]; then
      killproc
    fi
    

    This script assumes a couple of things - you've setup ssh keys/etc, you have a single running $procname process (although this could be changed into a grep/pgrep to get a certain PID), and you know how to setup smtp-cli (or an alternate email-from-cmdline method).

    Happy new year!

  • Segment, i think this is what i need, same kind of script. so far have not offered anyone anything yet, but do you have spare time to get this script / write script for me , i cannot write code, so, however i can understand code. and how much to be paid.

  • sure - pm me and I'll sort it out for you

  • Thank you very much everybody, Segment has solved the problem and sent me code which exactly works the way it needs to be, Thank you so much Segment.

Sign In or Register to comment.