Jump to content

Alert on too many ffmpeg process


MSattler

Recommended Posts

MSattler

I wanted a script to alert me if too many ffmpeg processes were running on my server.  Mainly because sometimes rogue ffmpeg processes are running.

 

I came up with this:

 

function numInstances([string]$process)

    {

         @(get-process -ea silentlycontinue $process).count

    }

 

$result = numinstances ffmpeg

echo $result

$cred = Import-CliXml c:\users\administrator\cred.clixml

     if ($result -gt 4) {

          Send-MailMessage -SmtpServer “smtp.gmail.com” -UseSsl -Port 587 -From “someemailaddress@email.com” -To “someemailaddress@email.com” `

          -Body (“Too Many ffmpeg proccesses (" + $result + ") running on EmbySat 1”) -Subject “EmbySat1” -Credential $cred

 

      }

 

 

Now the credentials are saved in cred.clixml.  The way to save your creds is in powershell:

 

$cred=get-credential | Export-CliXML c:\somedirectory\

 

Now you can use those credentials in your script without them being in clear text.

 

Change the $result -gt 4 to whatever number you want to alert for.  I use Boxcar on my iphone, which provides an email address to send alerts to.  This then gives me popup alerts on my iPhone.

 

 

 

 

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...