Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh (storage::purestorage::flasharray::v2::restapi::plugin) : Add the flag attribute to the alert filter #5307

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Fabien-Bernard
Copy link

Community contributors

Description

Plugin : storage::purestorage::flasharray::v2::restapi::plugin
Mode : storage::purestorage::flasharray::v2::restapi::mode::alerts

At the moment, it is possible to filter alerts by : category, code, severity, opened, state, component_name, issue.

The goal of this pull request is to be able to also filter the alerts by the flag attribute.

Fixes # (issue)
Non applicable.

Type of change

  • Patch fixing an issue (non-breaking change)
  • New functionality (non-breaking change)
  • Functionality enhancement or optimization (non-breaking change)
  • Breaking change (patch or feature) that might cause side effects breaking part of the Software

How this pull request can be tested ?

For example :
To avoid alerts, of severity "warning" which have been manualy unflagged, to be catch by the service, modify the default value of the warning-status by adding the flag filter :
--warning-status='%{state} ne "closed" and %{severity} =~ /warning/i and %{flagged}'

Checklist

  • I have followed the coding style guidelines provided by Centreon
  • I have commented my code, especially hard-to-understand areas of the PR.
  • I have rebased my development branch on the base branch (develop).
  • I have provide data or shown output displaying the result of this code in the plugin area concerned.

@Fabien-Bernard Fabien-Bernard requested a review from a team as a code owner November 30, 2024 12:02
@lucie-dubrunfaut
Copy link
Contributor

Hello :)

Thank you for your contribution :) 🙏
Could you provide us with an output (anonymising the fields that require it) of the API call that allows us to test your proposed contribution (to check that it works properly and to ensure that the code is not regressed later)?

@Fabien-Bernard
Copy link
Author

Fabien-Bernard commented Dec 3, 2024

Hello,

The entire output is big, I just add an interesting snippet, you tell me if it's not enough.

A command and result example :

[centreon-engine@*** ~]$ /usr/lib/centreon/plugins/customTM/centreon_purestorage_flasharray_v2_restapi_fbe.pl --plugin=storage::purestorage::flasharray::v2::restapi::plugin --mode=alerts --hostname='***' --api-version='2.4' --api-token='***' --proto='https' --port='443' --insecure --warning-status='%{state} ne "closed" and %{severity} =~ /warning/i and %{flagged} and %{code} eq "45"' --critical-status='%{state} ne "closed" and %{severity} =~ /critical/i' --verbose --filter-category='array' --debug

WARNING: 1 problem(s) detected | 'alerts.detected.count'=1;;;0; warning: alert [component: ct0.fc3] [severity: warning] [category: array] [issue: increased invalid TX word count] 18h 29m 8s

The alert from the debug output :

{ "created":1733184307111, "description":"(hardware:ct0.fc3): increased invalid TX word count Expected: , Actual: 2", "state":"closing", "component_type":"hardware", "name":"81088063", "id":"85198c1eda7145a788a682eea667e06b", "code":45, "severity":"warning", "category":"array", "flagged":true, "updated":1733184311263, "closed":1733184318917, "notified":null, "component_name":"ct0.fc3", "expected":"", "actual":"2", "knowledge_base_url":"https://support.purestorage.com/?cid=Alert_0045", "issue":"increased invalid TX word count", "summary":"(hardware:ct0.fc3): increased invalid TX word count" }

Regards,

@omercier
Copy link
Contributor

Hi @Fabien-Bernard,
The JSON snippet you sent us does not seem complete, according to the code, the full response should contain an item entry providing an array that contains the alerts.

Could you provide us the whole --debug output to allow us deploying some automated tests?

PS: take care of sensitive data this output may contain.

@Fabien-Bernard
Copy link
Author

Fabien-Bernard commented Jan 28, 2025

Hello,

You right, here another example :

$ /usr/lib/centreon/plugins/centreon_purestorage_flasharray_v2_restapi.pl --plugin=storage::purestorage::flasharray::v2::restapi::plugin --mode=alerts --hostname='xxx' --api-version='2.4' --api-token='xxx' --proto='https' --port='xxx' --insecure --filter-category='' --warning-status='%{state} eq "open" and %{severity} =~ /warning/i' --critical-status='%{state} eq "open" and %{severity} =~ /critical/i' --verbose --debug
CRITICAL: 2 problem(s) detected | 'alerts.detected.count'=2;;;0;
== Info: Trying xxx:xxx...
== Info: Connected to xxx (xxx) port xxx (#0)
[...]
=> Recv header:
=> Recv data: 1f64

{"continuation_token":null,"items":
[
{"created":1737462338078,"state":"open","description":"(drive:ch0.nvb1): failure Expected: healthy, Actual: failed","component_type":"drive","name":"81204734","id":"55764d164ea24e6fb60bfbf44a030815","code":60,"category":"array","severity":"critical","flagged":false,"updated":1738059644723,"closed":null,"notified":null,"component_name":"ch0.nvb1","expected":"healthy","actual":"failed","knowledge_base_url":"https://support.purestorage.com/?cid=Alert_0060","summary":"(drive:ch0.nvb1): failure","issue":"failure"},
{"created":1737464651017,"state":"open","description":"(shelf:ch0): shelf drive failures(s) Expected: 0, Actual: 1","component_type":"shelf","name":"81204806","id":"f8231727fefb4496aa87cfab0e809929","code":60,"category":"array","severity":"critical","flagged":true,"updated":1738059644699,"closed":null,"notified":null,"component_name":"ch0","expected":"0","actual":"1","knowledge_base_url":"https://support.purestorage.com/?cid=Alert_0060","summary":"(shelf:ch0): shelf drive failures(s)","issue":"shelf drive failures(s)"}
],
"more_items_remaining":false,"total_item_count":null}

0

== Info: Connection #0 to host xxx left intact
critical: alert [component: ch0.nvb1] [severity: critical] [category: array] [issue: failure] 6d 21h 55m 30s
critical: alert [component: ch0] [severity: critical] [category: array] [issue: shelf drive failures(s)] 6d 21h 16m 57s

Hope it helps.

@omercier
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants