#System health API
1 messages · Page 1 of 1 (latest)
You can use below through private cli Rest calls
- https://CLUSTER_IP/api/private/cli/system/health/alert?fields=subsystem,indication_time,perceived_severity,probable_cause,probable_cause_description,corrective_actions,possible_effect,acknowledge,suppress,policy,acknowledger,suppressor,additional_info,alerting_resource_name,tags
- https://CLUSTER_IP/api/private/cli/system/health/subsystem?fields=health,subsystem,outstanding_alert_count,suppressed_alert_count,node,init_state
Harvest uses the second one (not all fields) to collect subsystem details already through Rest API
https://github.com/NetApp/harvest/blob/main/conf/rest/9.12.0/subsystem.yaml
I am new to REST API. What can this API really do for me? It works for me, but can you please show me an example in what circumstances I need this?https://cluster_ip/api/private/cli/system/health/subsystem?fields=health,subsystem,outstanding_alert_count,suppressed_alert_count,node,init_state
It shows information as mentioned here https://docs.netapp.com/us-en/ontap-cli-95/system-health-subsystem-show.html#description
Exactly, my question was, Why do I need to use REST API to achieve the same ONTAP cli can do?
Rest API may come handy for automation purposes if you are making use of Rest calls.
Right, I heard the same, but how? that "https://..." seems long and not easy to remember and cannot be programmed. How can I use it for automation? Can you please show me an example for a real use case? I can use bash for automation, why would I need REST API?
Well one example is Harvest which makes use of Zapi/Rest calls to monitor ONTAP. https://github.com/NetApp/harvest
Example of this Rest End point https://github.com/NetApp/harvest/blob/main/conf/rest/9.12.0/subsystem.yaml#L3
I used bash for "automating" before and can happily say that using the API is the way to go; everything becomes much easier with structured output. Be it with python, powershell, ansible or something else.
@sick perch
Can I execute the 2nd link independently? If yes, how can I do that? Is it an Ansible code? what is the execution environment?
As you can tell, I am new to all these, I would appreciate it very much if you can help me to go through steps.
sure @outer crane We have documents for Harvest around installation and setup
https://netapp.github.io/harvest/23.02/quickstart/
https://netapp.github.io/harvest/23.02/install/overview/
Harvest is written in GO and can be installed in various ways as mentioned in above link.
So, in order to get the feeling about that example of Rest End point: https://github.com/NetApp/harvest/blob/main/conf/rest/9.12.0/subsystem.yaml#L3, I need to install Harvest.
Right?
You can always use curl to see the output of the Rest End Point.
Harvest does a lot more as mentioned here https://netapp.github.io/harvest/23.02/
Can you please show me an example on using curl to run an REST API?
sure. Just replace USER/PASSWORD and CLUSTER_IP in below
curl -k -uUSER:PASSWORD 'https://CLUSTER_IP/api/private/cli/system/health/subsystem?fields=health,subsystem,outstanding_alert_count,suppressed_alert_count,node,init_state'
sample output format will be like below
{
"records": [
{
"subsystem": "sas_connect",
"health": "ok",
"init_state": "initialized",
"outstanding_alert_count": 0,
"suppressed_alert_count": 0,
"node": [
"umeng-aff300-01",
"umeng-aff300-02"
]
},
{
"subsystem": "environment",
"health": "ok",
"init_state": "initialized",
"outstanding_alert_count": 0,
"suppressed_alert_count": 0,
"node": [
"umeng-aff300-01",
"umeng-aff300-02",
"umeng-aff300-02"
]
},
{
"subsystem": "memory",
"health": "ok",
"init_state": "initialized",
"outstanding_alert_count": 0,
"suppressed_alert_count": 0,
"node": [
"umeng-aff300-01",
"umeng-aff300-02"
]
},
}
Works with ONTAP in Data Center. Thanks for leading me through! Some other follow-ups:
- If it is true that we should always use a programming language, like python, powershell etc together with REST API to automate tasks, it alone cannot do much for us?
- I noticed some REST API has .../private/.. in it. Some doesn't. What is the diffrence?
- I am not sure of if you are familiar with REST API for FSx ONTAP, but, it doesn't work from clients located in Data Center to FSx ONTAP. It works from client in VPC. Any idea of why?
Great! Below are my responses
1: You can call Rest API's in scripts also. No fancy programming languages needed.
2: ../private/.. are a way to access ONTAP CLI through REST API. See more details here https://netapp.io/2020/11/09/private-cli-passthrough-ontap-rest-api/
3: Not sure about FSx behaviour.
A last question:
If I call "curl..." in my bash scripts, what is a good way to extract fields from JASON response body as the result?
There are few . You may try
https://github.com/stedolan/jq
https://github.com/tidwall/gjson
One more last question:
Comparing ZAPI API and REST API, do you have an estimation on what percentage of all ZAPI API's can be all achieved by REST API's?
We have found something works in ZAPI API but not in REST API, let say ONTAP 9.11.1 or 9.12.1