4 Replies Latest reply on Feb 15, 2016 12:12 PM by Steven Klassen

    Request For Comment: Python wrapper around common Orion operations

    SimonMorris

      Hello,

      I've been looking at writing a Python library to interact with the Orion database to read, and after a lot of testing, write.

      I'd use this to create middleware between CMDB's, web services and so on to get useful data out of Orion using applications or scripts.

      No code exists yet but it would look something like this

      # Some examples of how pyorion might work, this code doesn't exist yet

      #


      >>> config = { 'db_server': '127.0.0.1', 'db_user': 'user',

              'db_passwd': '123', 'db_database': 'orion',

              'verbose': True

      }


      >>> a = PyOrion(**config)

      >>> host = a.getHostByName('lon1dc01')

      <__main__.PyOrionHost instance at 0xb775584c>


      >>> host.getAvailability(period='today')

      99.9


      >>> host.getAvailability(period='thisyear')

      99.5


      >>> host.getAvailability(from=time.strptime("Thu Sep 2 16:24:10 2010"), to=time.strptime("Thu Sep 23 16:24:10 2010"))

      99.999


      >>> host.getCurrentCPU()

      80


      >>> host.getHistoricalCPU(period='today')

      79.994


      >>> host.getHistoricalCPU(period='thisyear')

      79.887


      >>> new_host = {'node_name': 'SERVER02', 'ip_address': '10.0.0.1', 'node_type': 'ICMP'}

      >>> a.addHost(new_host)

       


      Would you use this Python library? What would you use it for? Is this a bad idea?

      Please contribute some thoughts here, and also read my blog for more information about how I get on

      http://beerandspeech.org/blog/2010/9/23/interacting-with-solarwinds-in-a-pythonic-way-pyorion.html

      Thanks

       

      ~sm