6 Replies Latest reply on Sep 5, 2017 1:15 AM by Rajat Jain

    Usage of REST API for Integrating with other tools

    Rajat Jain
      Share This:

      Hello Everyone,


      I have read the documentation regarding REST API and still not able to understand that what is the actual usage of REST API.


      Is it used as a dashboard creator which is generally used by customer who do not prefer to use Discovery UI for day to day task. By using this you can build your own UI and
      from there, you can perform multiple task.

      Or, it is used to feed data to other tools etc, similar to CSV and XML API without downloading and then uploading the data.


      Also, I understand that we need to write some small script (a very simple one), but not getting where to implement that.


      Please guide me in this.



      Rajat Jain

        • 1. Re: Usage of REST API for Integrating with other tools
          Ilan Sviry

          Hi Rajat


          One of my usage of the Rest API is for data mining, where I wrote a short external Python program that get information from the BMC Discovery directly using Rest API and then analyse the report information.


          This way I can analyse and compare many objects simultaneously without using the Discovery compare functionality that can compare only two objects at the same time.


          one of the reports I use is to compare all the DiscoveryAccess (usually the history of the last 30 days) of the same endpoint, in order to find discrepancies and changes happen to the packages and services related to this endpoint, during this period.


          Best regards,


          2 of 2 people found this helpful
          • 2. Re: Usage of REST API for Integrating with other tools
            Rajat Jain

            Hello Ilan,


            Request you to please share one of your python script and also let me know if it needs to be uploaded in a different way than uploading TKU/Custom scripts.



            Rajat Jain

            • 3. Re: Usage of REST API for Integrating with other tools
              Kerryn Wood

              Hi RAJAT JAIN,


              I think you misunderstand, that's not the way it works. You run scripts on your system to request information from the Discovery Appliance made available by the REST API. Ilan Sviry did mention an "extranal Python program".


              In the spirit of a community ... I suggest you have a go at formulating scripts (using Discovery's documentation or there are many [many, many, many] references online) and then use the community to help with a specific problem rather than just requesting Ilan's hard work. That said, if Ilan is willing to share that's great too

              1 of 1 people found this helpful
              • 4. Re: Usage of REST API for Integrating with other tools
                Ravian Nugraha

                Well, I'm pretty sure you are aware the concept of REST API.

                It give us a whole new perspective when we are trying to integrate ADDM with another application.

                For me personally, I will use REST API as a method to allow an automation from BMC Remedy ITSM (Change Management especially).

                It will allows our customer to bypass a ton of procedure where the stakeholder have to talk one another just to get those record to CMDB.

                And I believe there will be many other cases that can be optimize using this REST API (even though it still limited in some scenario).



                Ravian Nugraha

                1 of 1 people found this helpful
                • 5. Re: Usage of REST API for Integrating with other tools
                  Ilan Sviry

                  Hi Rajat

                  Hope it can help, following is an example regarding how to use BMC Discovery big data with external Python code and REST API

                  As part of Incident Management, when you try to investigate an incident it is very important to know what was the last changes. For example if there is some problem with a server functionality, usually you will check it services, to see if there were any changes.

                  But since there is a large number of services and large number of discovery points (DiscoveryAccess) you may go to Excel, use a discovery report, export it to a csv, load it and manipulate it in the Excel.

                  Instead you can run this python code to find the changes in online manner.

                  The following Python code can receive an IP (scan via endpoint) and analyse all the available DiscoveryAccess for this Host. The output is which service was changed, either if it was installed or removed (add/delete) or one of the service attributes like Username or Start Mode or State (modify) was changed during this period

                  following is a situation where the “McAfee Audit Manager Service” was discovered only 4 times out of the 6 scanning of this host:

         : McAfee Audit Manager Service  was discovered only  4  out of  6  discovery scans

                  following is a situation where the service state of “Virtual Disk” service was changed from RUNNING to STOPPED

         : Virtual Disk  -  {'LocalSystem:Manual:Manual:STOPPED', 'LocalSystem:Manual:Manual:RUNNING'}


                  Following is the Python code I have used:



                  import requests

                  import IPython


                  IP_Input = input(["Please enter host IP:"])


                  url = 'http://<BMC Discovery url>/api/v1.0/data/search'


                  headers = {

                      'accept': 'application/json',

                      'authorization': 'Bearer <API user token>'



                  params = {

                      'query': "search DiscoveryAccess where end_state = 'GoodAccess' and endpoint = '" + IP_Input + "' order by discovery_starttime show endpoint, discovery_starttime, explode #DiscoveryAccess:DiscoveryAccessResult:DiscoveryResult:ServiceList.#List:List:Member:DiscoveredService.display_name as 'Display Name', join([#DiscoveryAccess:DiscoveryAccessResult:DiscoveryResult:ServiceList.#List:List:Member:DiscoveredService.username,  #DiscoveryAccess:DiscoveryAccessResult:DiscoveryResult:ServiceList.#List:List:Member:DiscoveredService.start_mode, #DiscoveryAccess:DiscoveryAccessResult:DiscoveryResult:ServiceList.#List:List:Member:DiscoveredService.state], ':')",

                      'limit': 10000



                  r = requests.get(url=url, params=params, headers=headers)


                  json = r.json()

                  x = json[0]['results']

                  dictA = {}

                  dictCount = {}


                  # Report column

                  IP_key = 0

                  discovery_starttime_key = 1

                  display_name_key = 2

                  service_attribute_key = 4


                  for i in range(len(x)):

                  # The dictionary index (dictIndex) is a combination of the IP and service display name

                  dictIndex = x[i][0]+ ' : ' + x[i][2]

                      if not dictIndex in dictA:

                          dictA[dictIndex] = {x[i][3]}


                          dictA[dictIndex] = {x[i][3]} | dictA[dictIndex]

                            if not dictIndex in dictCount:

                                dictCount[dictIndex] = 1


                                dictCount[dictIndex] = 1 + dictCount[dictIndex]


                  # Print the changes

                  for dictIndex in dictA:


                  # Check for service attribute change

                  if len(dictA[dictIndex]) > 1:

                  print(dictIndex, ' - ',dictA[dictIndex])


                  # Check for service changes (install/uninstall)

                  if dictCount[dictIndex] < max(dictCount.values()):

                  print(dictIndex, ' was discovered only ',dictCount[dictIndex], ' out of ', max(dictCount.values()), ' discovery scans')

                  3 of 3 people found this helpful
                  • 6. Re: Usage of REST API for Integrating with other tools
                    Rajat Jain

                    Thanks a lot for all your help Ilan. The concept of REST API is quite clear to me now.