23 Feb 2019
05:38 AM
- last edited on
13 Dec 2021
02:59 AM
by
MaciejNeumann
Scenario -> I'm on deployment status page. We are done with all agents update activity. Now I want to send all these server names and respective 'restart pending' processes to a different team. Pls advise how to do it. I don't want to expand each server and manually copy-paste the processes to a text editor.
Solved! Go to Solution.
Hello.
I am mnot sure it is published out
but you have to study API docs https://www.dynatrace.com/support/help/extend-dyna...
Regards, Igor
Fresh info here:
https://answers.dynatrace.com/spaces/482/dynatrace-open-qa/questions/192233/dynatrace-managed-alert-on-hostprocess-needs-to-be.html
You need to build code to query Topology Smartscape Processes API and there you got and example answer like this https://www.dynatrace.com/support/help/extend-dyna...
"monitoringState": {
"actualMonitoringState": "ON",
"expectedMonitoringState": "ON",
"restartRequired": false
},
Then you can process restartRequired parameter and check which ones are true.
Here is a "2-liner " using curl and jq, just set the TENANT and APITOKEN environment variables:
curl -X GET "https://$TENANT/api/v1/entity/infrastructure/hosts?relativeTime=day&Api-Token=$APITOKEN" -H "accept: application/json; charset=utf-8" |jq -s '.[]| map({(.entityId): .displayName})|add' >hostsmap
curl -X GET "https://$TENANT/api/v1/entity/infrastructure/processes?relativeTime=day&Api-Token=$APITOKEN"| jq -s '.[][]|select ( .monitoringState.restartRequired==true )| .fromRelationships.isProcessOf[0]|=$hosts[.] | { "hostname" : .fromRelationships.isProcessOf[0], "processName": .displayName }' --argfile hosts hostsmap