DX Infrastructure Management

 View Only

CA on CA Tech Tip - Using UIM API to inventory probes 

Nov 17, 2017 12:23 PM

Hi Community,

 

CA Unified Infrastructure Management offers a REST API that allows you to automate a number of tasks. We have used it for a few and we will share generic solutions that have helped us along the way. You are welcome to have the code and make modifications / improvements to it. I am sure the real programmers will take one look at what I have written and run screaming to fix it. 

 

To make this easier we have created and will continue to add to a library of Python functions. The cauimws.py library is available in GitHub for ease of sharing and modification just follow the link. In this first effort I needed to be able to get a list of all the probes in our environment and to ensure they are running. In a future share we will also extend this to show how to automatically check robots missing cdm probes and how to fix it.

 

To get a list of the probes we created this listprobestate.py Python script. Let us walk through it so you are clear on what it is doing and potentially you can extend it other purposes or use as is.

# Init logging level
logging.basicConfig(level=logging.ERROR)

# Init the dict with UIM REST API information
uim_ws = {}
uim_ws['user'] = 'uim_web_service_user'
uim_ws['password'] = 'uim_web_service_user_password'
uim_ws['url'] = 'http://ump.ca.com/rest'
uim_ws['domain'] = 'uim_domain'

In the lines above we are simply telling it how to connect to the UIM REST API. A user with Web Services in the ACL is required as well as the path to the REST API url (http or https will work). The UIM domain you can get from the top of the tree in Infrastructure Manager or Admin Console. If you need more assistance with the REST API review the documentation here

 # Setup csv file for output
with open('probesList.csv', 'wb') as probes_list:
   wout = writer(probes_list, delimiter=',')
   header = ['Hub', 'Robot', 'Probe', 'Status']
   wout.writerow(header)

In the lines above we are just setting up CSV access to a file called probesList.csv and creating the header row. Once we have that we can first get the list of hubs

    # Get the list of hubs from UIM
   hubs = get_hubs(uim_ws)
   for hub in hubs:

Now that we have the hubs we can get the robots assigned to each of the hubs

      for robot in robots:
         # Get the list of probes assigned to the robot
         probes = get_probes(uim_ws, hub['name'], robot['name'])

Now we can get the probes from each robot

          if probes:
         for probe in probes:
            # Translate the probe state
            if probe['active'].lower() == 'true':
               state = 'Active'
            else:
               state = 'Inactive'
            wout.writerow([hub['name'], robot['name'], probe['name'], state])

Finally we write our list of probes and their status. All the work is done in the library cauimws.py and that is included at the top in the statement

from cauimws import get_hubs, get_robots, get_probes

As you can see this is not so bad. Take a look at the code, share it, change it, use it and see if it helps. You can learn more about Python in this Dzone article. I will add more as time permits

 

Disclaimer: I work for CA Technologies in the IT department in the Tools and Automation Group. However, neither can I share any insight into product futures (typically I learn of product changes when you do) nor can make the product management or development team change the product. I also recommend consulting with CA support and validating all changes in test environments.

Statistics
0 Favorited
20 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

Nov 07, 2018 03:39 PM

rtirak I agree I think your best bet is to get the code from BryanKMorrow if he is willing and extend it.

 

Unfortunately, this is where my CA journey comes to an end. #lastride #lastcaoncatechtip

Nov 07, 2018 06:56 AM

Alquin

 

Yes I have used this a bunch and it has been awesome. However I have not been able to get the metrics and thresholds etc with it for anything but the CDM, ntservices, or processes probe. Most of the time I have only been able to get the CDM probe data with it. I know Bryan does a lot of work on it and I know its not easy to support it and do his normal work so I try not to bother him to much with questions. Do you have any idea how I could achieve this using his most up to date probe? Or is there somewhere, where his probe code is that I could take a look at it and build off of to try to make it compatible to achieve what I am trying to do? Or if you could let me know what I am doing wrong with it maybe if it can get me the info I am looking for?

Nov 06, 2018 04:08 PM

Hi Robert,

 

Before you go doing that which would take multiple calls take a look at the capabilities in BryanKMorrow probe of things capabilities here https://communities.ca.com/community/unified-infrastructure-management/blog/2016/07/22/probe-of-things-a-custom-probe-that-does-things

Nov 06, 2018 10:54 AM

Alquin

 

Is it also possible to get the metrics that each probe collects and/or alarms on ? Than we could have an inventory or the probes and how they are being used, the metrics they are collecting and the thresholds they are alarming on?

May 11, 2018 11:02 AM

Ok issue turned out to be in my config.ini file. You cannot have a space between the header [uim_ws] and the first value in the config.ini below are two examples first one is the bad not working second is the good and working:

 

BAD EXAMPLE - NOT WORKING

 

[uim_ws]


user = user
password = password
url = http://UMP/rest
domain = uim_domain
primary_hub = uim_primary_hub
mm_robot =main_robot_name

 

[data]


systems_list_file = systems.txt

 

 

GOOD EXAMPLE - WORKING

 

[uim_ws]
user = user
password = password
url = http://UMP/rest
domain = uim_domain
primary_hub = uim_primary_hub
mm_robot =main_robot_name

 

[data]
systems_list_file = systems.txt

May 11, 2018 09:44 AM

Alquin Gayle ,

 

I have switch to our prod Environment just to look at this since prod is still only 8.51 rather than the 9.0 beta, so the first URL returns this:

 

<version_info>
<value>
Nimsoft RESTful web services interface: version: 8.4.3, build_number: 142338
</value>
</version_info>
The second returns this:
<alarmsummary>
<clear>0</clear>
<critical>2</critical>
<information>0</information>
<major>30</major>
<minor>37</minor>
<warning>3</warning>
</alarmsummary>
So both seem to be responding as "OK"
Here is the DEBUG and Warning Result from the maintenancemode.py script
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): prdnimump01
DEBUG:urllib3.connectionpool:http://prdnimump01:80 "POST /rest/maintenance_mode/NMS/MAIN/prdnims01/add_schedule HTTP/1.1" 404 None
DEBUG:root:The status code from the create mm schedule call was 404
WARNING:root:Failed to create maintenance schedule April Microsoft Windows Patches

May 09, 2018 02:25 PM

rtirak

 

It looks like you are running the 9.0 beta. I am not sure which exact API URL you were calling from your question but I tried 2 common URL

http://ump/rest/version-info & http://ump/rest/alarms/summary and both returned OK. If you can provide the API URL you were trying to call I can validate on my 8-May beta build. We should discuss this further on validate.ca.com since it is the beta.

May 08, 2018 04:25 PM

Not sure why but when I go to the URL of the webservices api I get a 404 error after I am asked for my username and password:

 

HTTP Status 404 - Not Found


type Status report

message Not Found

description The requested resource is not available.


Apache Tomcat/7.0.81

 

 

However if I go to http://UMP_IP/rest/version-info I get a response no problem:

 

<version_info>
<value>
Nimsoft RESTful web services interface: version: 9.0.0-SNAPSHOT, build_number: 478
</value>
</version_info>

 

 

 

I have the webservices_REST probe installed on the UMP and I am using a user that is allowed WebServices REST API access. Any ideas what I am doing wrong?

Feb 22, 2018 09:58 AM

DanielBlanco

 

The output is not different however in our case because it is done in a program I can also take appropriate actions as a result. E.g. upgrade the robot if it is not at the level we desire or push packages with probes and monitoring to bring that robot up to the expected level of monitoring policy we agreed to. It also allows us to find odd things like robots bound to wrong IP addresses and have them fixed.

 

Essentially it removes our need to do the things listed above manually but drive automatic changes to improve the reliability of our monitoring.

 

Thanks for the question.

Feb 20, 2018 11:47 AM

Can you share a cleaned up example of what this script exports? Just curious what this spits out and if its different from just the Tools > Find Probes: * from w/in IM tool.

Related Entries and Links

No Related Resource entered.