HPE OneView
1855763 Members
10731 Online
104103 Solutions
New Discussion

get appliance alert

 
SOLVED
Go to solution
bradawk1
Trusted Contributor

get appliance alert

We have an alert that says, "One or more appliance resources are below the minimum required values."  This happened from an accident one of the HPE techs did.  It has been repaired, but the alert will not go away.  I know how to remove it once I get the alrt URI and etag, but I can't seem to find it in the alerts.  I don't think I am filter correctly to retrieve it?  I tried healthCategory EQ Appliance, but that did not find it.  This is how I pull down Active allerts:

# We have multiple sites.  So, I set a site variable so that I can run the same commands
# simultaneously in multiple terminals.
SITE='<site name>'
ALERTN=alert-${SITE}
ACTV=$(python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "\"alertState EQ 'Active'\"")
curl --insecure \
     --header "X-API-Version: ${currentVersion}" \
     --header "auth: ${sessionID}" \
     --output ${ALERTN} \
     --request GET ${OneView}/rest/alerts?start=0&count=-1&filter=${ACTV}
#
# That only pulls down 25 alerts.  Pull down the rest with:
i=1
NEXT=$(jq -r '.nextPageUri' ${ALERTN} | sed -e "s|\(.*filter=\).*|\1${ACTV}|")
while [[ ${NEXT} != *"null"* ]]; do
   curl --insecure \
        --header "X-API-Version: ${currentVersion}" \
        --header "auth: ${sessionID}" \
        --output ${ALERTN}${i} \
        --request GET ${OneView}${NEXT}
   NEXT=$(jq -r '.nextPageUri' ${ALERTN}${i} | sed -e "s|\(.*filter=\).*|\1${ACTV}|")
   ((i++))
done
# Concantenate into a single file.
j=0
while [[ ${j} -t ${i} ]]; do
   echo ${j}
   if [[ ${j} -eq 0 ]]; then
      CMD="cat ${ALERTN}"
   else
      CMD="${CMD} ${ALERTN}${j}"
   fi
   ((j++))
done
$(echo ${CMD} > alert-all-raw-${SITE})
cat alert-all-raw-${SITE} | jq -r '.' > alert-${SITE}-all
ALERTS=alert-${SITE}-all
/bin/rm alert-${SITE} alert-${SITE}? alert-${SITE}[1-9]? alert-all-raw-${SITE}

I tried changing the filter to

healthCategory EQ 'Appliance'

but that did not work.  The alertTypeID is DYNAMIC.CONFIG.  The alert says:

One or more appliance resources are below the minimum required values.

Does anyone know how to get the alert URI and eTag values either through the REST API or the GUI?

2 REPLIES 2
bradawk1
Trusted Contributor
Solution

Re: get appliance alert

I figured it out:

SITE='<site name>'
ALERTN=alert-${SITE}
ACTV=$(python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "\"alertState EQ 'Locked'\"")
curl --insecure \
     --header "X-API-Version: ${currentVersion}" \
     --header "auth: ${sessionID}" \
     --output ${ALERTN} \
     --request GET ${OneView}/rest/alerts?start=0&count=-1&filter=${ACTV}
#
# That only pulls down 25 alerts at most, but it should be enough.
DESCRIP="One or more appliance resources are below the minimum required values."
#
# Can see the data we are after with:
jq -r '.members[] | select(.description=="'"${DESCRIP}"'") | { "uri": .uri, "eTag": .eTag, "description": .description }' ${ALERTN}
ALRTURI=$(jq -r '.members[] | select(.description=="'"${DESCRIP}"'") | .uri' ${ALERTN})
ETAG=jq -r '.members[] | select(.description=="'"${DESCRIP}"'") | .eTag' ${ALERTN})
USER='<your sid>'
NOTE="The resources have been fixed"
DATA='{ "alertState": "Cleared", "assignedToUser": "'${USER}'", "alertUrgency": "None", "notes": "'${NOTE}'", "eTag": "'${ETAG}'" }'
echo ${DATA} | jq -r '.'
curl --insecure --silent \
     --header "content-type: application/json" \
     --header "X-API-Version: ${currentVersion}" \
     --header "auth: ${sessionID}" \
     --data "${DATA}" \
     --request DELETE ${OneView}${ALRTURI}?force=true
Sunitha_Mod
Honored Contributor

Re: get appliance alert

Hello @bradawk1,

That's awesome! 

We are glad to know you were able to find the solution and thank you for keeping us updated.