cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Webhook handling/Custom python script

Here to help

Webhook handling/Custom python script

Hi Everyone, I have a question about using the Webhook feature in Meraki. I'm currently doing research on this topic and I'm not sure how to handle the webhook for my use case. What do you think? The situation: I'd like to use a webhook to monitor a port on an MX. If I did implement this, I realize there is a 5 minute delay, but aside from that, what service would be best to catch the hook and then make another call back to the Dashboard API based on conditional logic regarding the information contained in the output of the webook? I want the logic to flow something like: If line status changes from 'connected' to 'disconnected' on a specific port, then send a webhook to a service which can execute a call back to the API. I also feel as though I could write a custom python script and put it on a server somewhere that would then poll the API at a X interval, process the output looking for that change in line status, and then take an action. I'm leaning more toward the custom python script, but it would essentially need to run 24/7/365. Any thoughts?
5 REPLIES 5
Highlighted
Getting noticed

Re: Webhook handling/Custom python script

Hi Tory,

 

If you're not hesitant to go cloud, you might want to look at the serverless framework:  https://serverless.com/

 

You can write your code, deploy it, and it'll wait for any incoming triggers to execute the logic you program into it.

 

Hope this helps

Sidney Burks
Captive Portal and Meraki API Automation
Founder and CTO, Boundless Digital
sidney@boundless.fr
https://www.boundless.fr
Highlighted
Here to help

Re: Webhook handling/Custom python script

@boundless-digit This looks very promising, thank you! I'm still looking for other suggestions. I also just noticed that there doesn't appear to be an API call that can return the status of an MX port whether it is 'connected' or not. Unfortunately the call that exists appears to only return whether it is enabled or disabled. I'm still digging though.
Highlighted
Kind of a big deal

Re: Webhook handling/Custom python script

I've use the Flask framework for Python to do this kind of stuff in the past. Not sure if that's really what you're looking for here, but it'll get the job done.

 

I would also suggest looking at Node-RED. I haven't used it myself, but it should be able to do this too. 

Highlighted
Kind of a big deal

Re: Webhook handling/Custom python script

First warning; to use a webhook it is compulsory to use a public SSL certificate.  You can not use a self signed certificate or plain http.

 

So if you use something like Flask you will also need to setup a DNS name pointing to the server and get an SSL certificate from something like LetsEncrypt (doing this in Linux is much easier).

 

ngrok is also popular.  They have an option to provide an SSL certificate and a tunnel agent enabling you to use something like Flask on one of your own machines without the complications above.  Never tried it on Windows, but this config would probably be easier on a Windows machine (Windows is like a tax when trying to do things like this).

https://ngrok.com/ 

 

Next up is the severless options (like what @boundless-digit  mentions).  I personally use Amazon AWS lambda for my stuff.  They provide the SSL certificate, load balancers, and everything for you.  I tend to use node.js for stuff like this, by Python is also workable.  This has a bit of a learning curve.

https://aws.amazon.com/lambda/ 

 

Next their are GUI style providers like Zapier.  They provide a tonne of integrations for linking things together, but I don't think they support customisations, but you should take a look at this option just in case.

https://zapier.com/ 

Highlighted
Kind of a big deal

Re: Webhook handling/Custom python script


@PhilipDAth wrote:

First warning; to use a webhook it is compulsory to use a public SSL certificate.  You can not use a self signed certificate or plain http.

 

So if you use something like Flask you will also need to setup a DNS name pointing to the server and get an SSL certificate from something like LetsEncrypt (doing this in Linux is much easier).

 

 


You can use just the IP as long as your cert is set up correctly, but this is a really good point and one I totally forgot about. I'm using Let's Encrypt for my scripts, but I can understand why others might not want to go this route. Good catch!

Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.