Using a Python script as a SAM component

Version 2

    SAM allows you to use any scripting language that you prefer to gather metrics and other information that you wish to monitor. Since Orion lives on Windows there are several scripting languages that you can use "out of the box."


    However, if you wish to use another, non-native, scripting language, all you need to do is install that program on your main Orion server (and any additional polling engines).


    This is an example of how we can use a Python script to gather information.


    1. First, we need to install Python on our Orion server. For this example, i used Python version 3.4.4 - x86 and Python 3.4 Extension for Windows x86.

    2. Once installed make sure that the Python install location is placed in the system environment path variable


    3.  In the Orion Web Console we'll need to create a SAM template and then apply it to a node.

         a. Go to Settings > SAM Settings > Create a New Template. You can call the template whatever you'd like.

         b. Click the green plus sign 'Add Component Monitors'

         c. In the pop up windows search for 'script' on the top right

         d. Select 'Windows script Monitor' and click 'Add.'


    4. In that Windows Script Monitor section replace the 'Script Engine' text field with 'python'


    5. Click the 'Edit Script' button and paste your python script in there.



    6. Since i'm running this on my main Orion server I selected it from the 'Will run against' button and defined credentials needed on that box.


    Their are 2 forms of output that can used in your script. The first is the Statistic.<value> and the Message.<value>. You can return up to 10 statistic/message pairs. The <value> can be whatever you wish to use (e.g Statistic.CPU, Statistic.variable...). You can look in the admin guide for additional formatting options. You can also pass arguments into your script by using the Script Arguments section.


    Hope this is helpful, if so, please feel free to rate this article.