centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
310 stars 273 forks source link

Problem with os::linux::local::plugin Regex --exclude-mountpoint doesn't works #4424

Closed dailyline closed 1 year ago

dailyline commented 1 year ago

Hello,

We use centreon plugin to check datstorage space on remote linux. I want to exlude more than one folder. We use 'os::linux::local::plugin' mode 'storage'. A single exclusion works I have problem with the regexp of "--exclude-mountpoint 'Exclude filesystem mount point (regexp can be used)" I try lots of things --exclude-mountpoint '(/boot|/dev)' --exclude-mountpoint '((/boot|/dev)$$)' "--exclude-mountpoint '(/boot|/dev)"

error is syntax error near unexpected token `(' or Receive header underflow - only 0 bytes received (4 expected). _

full syntax /usr/lib64/nagios/plugins/check_centreon_nrpe3 -u -H tatayoyo -p 5666 --cipher-list ADH --ssl-version=TLSv1.2 -t 120 -c check_centreon_plugins -a 'os::linux::local::plugin' 'storage --units 'B' --free --warning-usage 1400MB: --critical-usage 900MB: --exclude-mountpoint '^(?!(/boot|/dev)) '

garnier-quentin commented 1 year ago

It works for me:

perl centreon_plugins.pl --plugin=os/linux/local/plugin.pm --mode=storage --exclude-mountpoint='' --verbose
OK: All storages are ok | 'used_/'=93249998848B;;;0;250375106560 'used_/boot/efi'=38895616B;;;0;535805952 'used_/dev/shm'=0B;;;0;4110893056 'used_/run'=2023424B;;;0;822181888 'used_/run/lock'=4096B;;;0;5242880 'used_/run/user/1000'=118784B;;;0;822177792
Storage '/' Usage Total: 233.18 GB Used: 86.85 GB (39.25%) Free: 134.42 GB (60.75%)
Storage '/boot/efi' Usage Total: 510.98 MB Used: 37.09 MB (7.26%) Free: 473.89 MB (92.74%)
Storage '/dev/shm' Usage Total: 3.83 GB Used: 0.00 B (0.00%) Free: 3.83 GB (100.00%)
Storage '/run' Usage Total: 784.09 MB Used: 1.93 MB (0.25%) Free: 782.16 MB (99.75%)
Storage '/run/lock' Usage Total: 5.00 MB Used: 4.00 KB (0.08%) Free: 5.00 MB (99.92%)
Storage '/run/user/1000' Usage Total: 784.09 MB Used: 116.00 KB (0.01%) Free: 783.98 MB (99.99%)
$ perl centreon_plugins.pl --plugin=os/linux/local/plugin.pm --mode=storage --exclude-mountpoint='(/run|/boot/efi)' --verbose
OK: All storages are ok | 'used_/'=93249929216B;;;0;250375106560 'used_/dev/shm'=0B;;;0;4110893056
Storage '/' Usage Total: 233.18 GB Used: 86.85 GB (39.25%) Free: 134.42 GB (60.75%)
Storage '/dev/shm' Usage Total: 3.83 GB Used: 0.00 B (0.00%) Free: 3.83 GB (100.00%)

Be careful in NRPE. You cannot use the character !. So you cannot do negative regexp and that's why i have added the option --exclude-mounpoint.

dailyline commented 1 year ago

Hello, Thanks for your answer. I just tested like you did and it actually works. I ran a test with my args with your command line and the result is ok ./centreon_plugins.pl --plugin=os/linux/local/plugin.pm --mode=storage --exclude-mountpoint='(/var|/boot/efi)' --units=B --free --warning-usage=1400MB: --critical-usage=900MB: --verbose It's not works when I exclude / exemple (/[boot/efi) It's return "UNKNOWN: No storage found (filters or command issue)"

My initial problem seems to come to my syntax when I use check_centreon_nrpe3, I will investigate. Thanks again for you assistance.

garnier-quentin commented 1 year ago

thanks for your feedback. i close it. Your regexp (/[boot/efi) cannot match (--> [)