Quantcast
Channel: THWACK: Popular Discussions - Orion SDK
Viewing all articles
Browse latest Browse all 3719

Alert creation with Python.

$
0
0

Hello.

I  try to trigger new alert with help of Python.

I found an old discussion here on thwack with example in PowerShell  Insert directly to AlertLog or Events Log , and tried to use it as template, so I received next code:

 

def main():

    npm_server = 'localhost'

    username = 'admin'

    password = ''

 

 

    swis = SwisClient(npm_server, username, password)

    print("Add an alert:")

 

        # set up property bag for the new node

 

 

    props = {

        'AlertDefID':'9a05848a-f441-4a5d-8b2c-e74e3a61b42d', ##Replace here with the Guid of the alert definition you are using. Random GUIDs won't work 

        'ActiveObject': 8,

        'ObjectType':'Node',

        'State': 2,

        'WorkingState':0, 

        'ObjectName':'uMPLS-PE1_7k-1.main.velcom.by', 

        'AlertMessage':'was triggered. IT IS  SUCCESS!!!!', 

        'Acknowledged':0

    }

 

 

 

    print("Adding alert {}... ".format(props['AlertDefID']), end="")   

    results = swis.create('Orion.AlertStatus', **props)

    print("DONE!")

 

 

   

requests.packages.urllib3.disable_warnings()

 

if __name__ == '__main__':

    main()

 

It does not show any script errors and runs OK, but alert instance doesnt appear in DB and Manage Alerts view.

As I understand active alert instance is defined by 3 entries in DB : Orion.AlertStatus, Orion.AlertObjects, Orion.AlertActive.

And Orion.AlertStatus seems to be the main one, because it have fields related to other ones.

 

 

So can someone help me in this question or guide to the right direction. maybe I have to pass additional parameters to Orion.AlertStatus entry, or maybe have to create other entries in DB.

Thanks in advance for your replies.


Viewing all articles
Browse latest Browse all 3719

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>