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