Showing results for 
Search instead for 
Did you mean: 

Traffic Managers can Tweet Too

If tweeting is good enough for the Pope, then Stingray can certainly get in on the game!  If you use tools to monitor Twitter accounts, this article will explain how you can direct Stingray's event log messages to a nominated twitter account so that you can be alerted immediately a key event occurs:




You might also like to check out the companion article - TrafficScript can Tweet Too.


Creating the Twitter Application


Posting to Twitter is now a little involved.  You need to create an application with the correct access (Read + Write), and then create the appropriate oauth parameters so that clients can authenticate themselves to this application.


To start off, log on to and create an application as follows:




Follow the steps in to create the access tokens so that you can post to your application from your own twitter account.


The OAuth authentication for your application requires two public/secret key pairs that you can generate from the management website:




Configuring Stingray


Create the event action


Download and edit the following event handling script, updating the oauth tokens to match your own application and access tokens:


import sys  
import socket  
import oauth2 as oauth  
def oauth_req(url, http_method="GET", post_body=None,  
    consumer = oauth.Consumer(key="Pplp3z4ogRW4wKP3YOlAA", secret="jbWlWYOSgzC9XXXXXXXXXXXXXXXX")  
    token = oauth.Token(key="1267105740-xhMWKdsNqoKAof7wptTZ5PmNrodBJcQm1tQ5ssR", secret="p8GCJUZLXk1AeXXXXXXXXXXXX")  
    client = oauth.Client(consumer, token)  
    resp, content = client.request(  
    return content  
msg = sys.argv[-1]  
words = msg.split( '\t' )  
host = socket.gethostname().split( '.' )[0]  
update = oauth_req(  
  "status=" + words[0] + ": " + words[-1] + " (" + words[-2] + " " + words[1].split('/')[-1] + ") #" + host  


From your Stingray Admin Server, create a new External Program Action named 'Tweet', and upload the edited event handling script.


Note that the script won't work on the Stingray Virtual Appliance (because it does not have a python interpreter), and on a Linux or Solaris host, you will need to install the python oauth2 module (pip install oauth2).


Test the event out with the: 'Update and Test' button in the edit page for the Tweet action, and review the event log to confirm that there are no errors:




You should see the test tweet in your twitter feed:




Wire the action to the appropriate events


Wire up an event handler to trigger the Tweet action when the appropriate events are raised:




... and then site back and follow your twitter stream to see what's up with your Stingrays.

Version history
Revision #:
1 of 1
Last update:
‎03-15-2013 10:21:AM
Updated by:
Labels (1)