usolved / check_usolved_vsphere_alarms

Nagios Plugin for getting alarms from VMWare vSphere
7 stars 3 forks source link

Fix exclude filters not working without include filters #5

Closed araujorm closed 3 years ago

araujorm commented 3 years ago

Currently to be able to use exclude filters, one has to have an include filter. A requirement that prevents the check being used for simple excludes like the following:

./check_usolved_vsphere_alarms.pl -H 172.0.1.1 -U username -P password -C 'e:name=*Virtual machine CPU usage*'

which is useful if one wants to be alerted about everything except virtual machine cpu usage alerts (and as this example, more aren't hard to imagine).

Worse, this always yields OK, even if there are other alerts that don't contain the aforementioned substring, which I think isn't the expected behaviour.

This commit should fix the above issues.

Side note about something this pull request doesn't address, but should be considered to the future: the wildcard syntax currently implemented is very limited, as it only supports *string* patterns and not other variants like string* or st*ring. I would suggest replace (or if backwards compatibility is a concern, complement e.g. i=datastore:bastion,e~name=^Virtual.*CPU) with perl regular expressions on the filters, as that is given for free with perl, would be more complete and (in case of replacing) should quite simplify and reduce the code.

araujorm commented 3 years ago

First proposal was not quite correct, now it should be OK.

usolved commented 3 years ago

Thanks a lot for your time and effort to fix the bug and enhance the plugin :). Just tested your commit and it seems to be working great and I merged your pull request.

Good point with the regular expressions for the filter to give it more flexibility.