300-435 · Question #92
Refer to the exhibit. An API request must display an alert message if change in OSPF neighbors is detected. Which code snippet must be added to complete the request?
The correct answer is A. alarm_stats = requests.post(url + "/data/service/alarms/stats", cookies=cookie_response.cookies, verify=False) if alarm_stats.status_code == 200: if json.loads(alarm_stats.text)['Correlation Engine']['ospf-neighbor-state-change'] \ ['Current State'] != '0': print('OSPF neighbor change detected!'). To detect an OSPF neighbor change, the API response must be parsed to check if the 'Current State' of the 'ospf-neighbor-state-change' alarm is not equal to '0', indicating an active or non-zero alarm.
Question
Exhibit
Options
- Aalarm_stats = requests.post(url +
"/data/service/alarms/stats",
cookies=cookie_response.cookies,
verify=False)
if alarm_stats.status_code == 200:
if json.loads(alarm_stats.text)['Correlation Engine']['ospf-neighbor-state-change']
['Current State'] != '0': print('OSPF neighbor change detected!') - Balarm_stats = requests.post(url +
"/data/service/alarms/stats",
cookies=cookie_response.cookies,
verify=False)
if alarm_stats.status_code == 200:
if json.loads(alarm_stats.text)['Correlation Engine']['ospf-neighbor-state-change']
['Total Events Counter'] != '0': print('OSPF neighbor change detected!') - Calarm_stats = requests.post(url +
"/data/service/alarms/stats",
cookies=cookie_response.cookies,
verify=False)
if alarm_stats.status_code == 200:
if json.loads(alarm_stats.text)['Correlation Engine']['ospf-neighbor-state-change']
['Current State'] == '0': print('OSPF neighbor change detected!') - Dalarm_stats = requests.post(url +
"/data/service/alarms/stats",
cookies=cookie_response.cookies,
verify=False)
if alarm_stats.status_code == 200:
if json.loads(alarm_stats.text)['Correlation Engine']['ospf-neighbor-state-change']
['Total Events Counter'] == '0': print('OSPF neighbor change detected!')
How the community answered
(32 responses)- A84% (27)
- B9% (3)
- C3% (1)
- D3% (1)
Why each option
To detect an OSPF neighbor change, the API response must be parsed to check if the 'Current State' of the 'ospf-neighbor-state-change' alarm is not equal to '0', indicating an active or non-zero alarm.
The code snippet correctly initiates an HTTP POST request to retrieve alarm statistics and, upon a successful response (status code 200), it parses the JSON content. It then specifically checks if the 'Current State' for 'ospf-neighbor-state-change' is '!= '0'', meaning that an OSPF neighbor state change event is currently active or has occurred and is not cleared, triggering the alert message.
Checking 'Total Events Counter != '0'' would indicate if any event of that type has ever occurred, not necessarily if a change is currently detected or if the state is non-zero after a change.
Checking 'Current State == '0'' would display the alert only when no OSPF neighbor change is detected (i.e., the state is normal or cleared), which is the opposite of the desired behavior.
Checking 'Total Events Counter == '0'' would display the alert only if no OSPF neighbor change events have ever occurred, which does not align with detecting a change.
Concept tested: Parsing API responses for alarm states
Topics
Community Discussion
No community discussion yet for this question.
