Release Automation

Expand all | Collapse all

Get list of server from automation studio

PRASHANT Kumar

PRASHANT KumarAug 08, 2018 02:20 PM

  • 1.  Get list of server from automation studio

    Posted Aug 08, 2018 01:25 PM

    How to get server list from automation studio where CA agent is installed?



  • 2.  Re: Get list of server from automation studio

    Broadcom Employee
    Posted Aug 08, 2018 01:28 PM

    Hello,

     

    In automation studio you can go to the administration tab where you'll find an "Agents Management" view. That will show all of the agents that have reported into your execution servers.

     

    Kind regards,

    Gregg



  • 3.  Re: Get list of server from automation studio

    Posted Aug 08, 2018 01:33 PM

    Hi Gregg,

     

    Thanks for replying.

    i need all the servers in a spreadsheet or in .txt file just because CA agent is offline on more than 50 servers.



  • 4.  Re: Get list of server from automation studio

    Broadcom Employee
    Posted Aug 08, 2018 01:43 PM

    I don't see a way to get a csv or txt file of the servers from ASAP. But if you query the database then you should be able to pull what you need. The information is in the servers table.

     

    Kind regards,

    Gregg



  • 5.  Re: Get list of server from automation studio
    Best Answer

    Posted Aug 08, 2018 02:03 PM

    Thanks , Got the server list from DB.

     

    Kind regards,

    Prashant



  • 6.  Re: Get list of server from automation studio

    Broadcom Employee
    Posted Aug 08, 2018 02:06 PM

    Great! Glad I can help. Please do be sure to click the "Mark Correct" button for the post that was most helpful.

     

    Thank you,
    Gregg



  • 7.  Re: Get list of server from automation studio

    Posted Aug 08, 2018 02:11 PM

    Hi Prashant,

     

    We are using an API call to get the list. Sometimes having access to the DB can be a problem.

     

    Ajust the parameters to your liking.

     

    curl -s -u superuser:[password] -X GET --header "Accept: */*" "http://[nac_host]:8080/datamanagement/ra/administration/v5/servers

     

    I then use the json response in a python script to generate a html response and alert the sysadmin if an agent is down :

     

    #!/usr/bin/python
    # -*-coding:Latin-1 -*
    import json
    import sys
    from pprint import pprint

    jdata = sys.stdin.read()

    data = json.loads(jdata)

    print "Subject: Status des agents CA-RA en production"
    print "Mime-Version: 1.0"
    print "Content-Type: text/html"

    print "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/><title>Rapport agents CA-RA</title><style> body,h1,h2,h3,h4,h5 {font-family: Raleway, sans-serif;} TABLE, TBODY {font-family: Raleway, sans-serif; border-collapse:collapse; text-align:left; padding:0; border-spacing:0;} td{padding:5px; border:black 1px solid;} th{background: #EEEEEE; padding:5px; border:white 1px solid; text-align:left;} tr{background: white;} tr:nth-child(odd) {background: white;} tr:nth-child(even){background: #F3F4F8;}</style></head><body>"

    print "<h2>Rapport sommaire de vérification des agents CA-RA SAGIR et UGO</h2>"
    print "<h3>Serveur - Statut</h3>"

    print "<table>"
    for item in data["list"]:
    if item["reachable"] == True:
    print "<tr><td>" + item["agentId"] + " : <span style='color: #00ff00'>UP</span></td></tr>"
    else:
    print "<tr><td>" + item["agentId"] + " : <span style='color: #ff0000'>DOWN</span></td></tr>"

    print "</table></body></html>"

     

    The whole process is called like this in our NAC crontab :

     

    # Crontab entry check every morning at 7 am
    0 7 * * * /u001/CA/ReleaseAutomationServer/scripts/nolio_server_agt.sh >/dev/null 2>&1


    [appenv01@[NAC_HOST]~]$ cat /u001/CA/ReleaseAutomationServer/scripts/nolio_server_agt.sh
    #!/bin/bash
    #
    # Verification scripts for all agents
    # it's all on one line

    #
    curl -s -u superuser:[password] -X GET --header "Accept: */*" "http://[nac_hist]:[port]/datamanagement/ra/administration/v5/servers" | python /u001/CA/ReleaseAutomationServer/scripts/parse_agent_status.py | /usr/sbin/sendmail [email adress to notify]

     

    Have fun !

     

    Regards,

    GGV



  • 8.  Re: Get list of server from automation studio

    Broadcom Employee
    Posted Aug 08, 2018 02:16 PM

    That's awesome! I like this better than a db query too. Thanks for sharing guillaume.goulet-vallieres 



  • 9.  Re: Get list of server from automation studio

    Posted Aug 08, 2018 02:20 PM

    Any way to check offline agent server list?



  • 10.  Re: Get list of server from automation studio

    Posted Aug 08, 2018 02:25 PM

    Not that I know off.

     

    Unfortunatly, you need to parse the JSON response and check the "reachable" attribute :

     

    Here is an example of a response from the API :

     

    { "list": [ { "agentId": "string", "description": "string", "id": 0, "name": "string", "osType": "string", "reachable": true, "serverGroups": [ 0 ], "serverIP": "string", "serverTypeName": "string", "state": "PRE_RUN", "usageCount": 0 } ] }

     

    The way I check if an agent is reachable in python is like this :

     

    for item in data["list"]:
    if item["reachable"] == True:
    print "<tr><td>" + item["agentId"] + " : <span style='color: #00ff00'>UP</span></td></tr>"
    else:
    print "<tr><td>" + item["agentId"] + " : <span style='color: #ff0000'>DOWN</span></td></tr>"

     

    You could use any language/script the parse the json, mine is just an example.



  • 11.  Re: Get list of server from automation studio

    Broadcom Employee
    Posted Aug 08, 2018 02:39 PM

    On linux I've piped the output to jq (to parse and massage the json response data). 



  • 12.  Re: Get list of server from automation studio

    Posted Aug 08, 2018 02:46 PM

    Our sysadmin won't let us install external software.... we can't have nice things



  • 13.  Re: Get list of server from automation studio

    Broadcom Employee
    Posted Aug 09, 2018 05:50 AM

    Hello,

    I think you can extend the script of python running on agent with python installed, by default available on linux server.

     

    You can use the json object and create a dict with status of reachable=True/False as required and save this in a csv file which you can get from the agent via RA.

    converting to dict can be like below where offlineAgents is a dict

    offlineAgents[agent['agentId']]=False