glensc / nagios-plugin-check_raid

Nagios/Icinga/Sensu plugin to check current server's RAID status ⛺
144 stars 84 forks source link

"sudo: a password is required" on Ubuntu 20.0.4 #227

Closed DCL-DrewL closed 5 months ago

DCL-DrewL commented 5 months ago

As subject, getting a sudo error when running the script. The final output generated is correct, but sudo errors are kicked out by running /sbin/dmsetup.

# su nagios -c './check_raid.pl -d'
check_raid 4.0.10
Visit <https://github.com/glensc/nagios-plugin-check_raid#reporting-bugs> how to report bugs
Please include output of **ALL** commands in bugreport

DEBUG EXEC: /bin/sudo -n -A /sbin/dmsetup status --noflush at ./check_raid.pl line 506.
sudo: a password is required
DEBUG EXEC: /bin/sudo -n -A /sbin/dmsetup status at ./check_raid.pl line 506.
sudo: a password is required
DEBUG EXEC: /proc/mdstat at ./check_raid.pl line 506.
DEBUG EXEC: /bin/sudo -n -A /sbin/ssacli controller all show status at ./check_raid.pl line 506.
DEBUG EXEC: /bin/sudo -n -A /sbin/ssacli controller slot=0 logicaldrive all show at ./check_raid.pl line 506.
OK: ssacli:[HPE Smart Array P408i-a SR Gen10[OK]: Array A(OK)[LUN1:OK], Array B(OK)[LUN2:OK]]

The fix here is to update the /etc/sudoers.d/check_raid, adding the /sbin/dmsetup commands.

# diff -Nbua /etc/sudoers.d/check_raid_old /etc/sudoers.d/check_raid
--- /etc/sudoers.d/check_raid_old       2024-03-18 21:22:58.766565238 +0000
+++ /etc/sudoers.d/check_raid   2024-03-18 21:24:06.023576579 +0000
@@ -4,3 +4,5 @@
 Defaults:CHECK_RAID !requiretty
 CHECK_RAID ALL=(root) NOPASSWD: /sbin/ssacli controller all show status
 CHECK_RAID ALL=(root) NOPASSWD: /sbin/ssacli controller * logicaldrive all show
+CHECK_RAID ALL=(root) NOPASSWD: /sbin/dmsetup status
+CHECK_RAID ALL=(root) NOPASSWD: /sbin/dmsetup status --noflush

After adding the dmsetup commands.

# su nagios -c './check_raid.pl -d'
check_raid 4.0.10
Visit <https://github.com/glensc/nagios-plugin-check_raid#reporting-bugs> how to report bugs
Please include output of **ALL** commands in bugreport

DEBUG EXEC: /bin/sudo -n -A /sbin/dmsetup status --noflush at ./check_raid.pl line 506.
DEBUG EXEC: /proc/mdstat at ./check_raid.pl line 506.
DEBUG EXEC: /bin/sudo -n -A /sbin/ssacli controller all show status at ./check_raid.pl line 506.
DEBUG EXEC: /bin/sudo -n -A /sbin/ssacli controller slot=0 logicaldrive all show at ./check_raid.pl line 506.
OK: ssacli:[HPE Smart Array P408i-a SR Gen10[OK]: Array A(OK)[LUN1:OK], Array B(OK)[LUN2:OK]]

I'm running a HP SmartStorage SAS controller on Ubuntu 20.04.6 LTS. No MD RAID is configured, and arcconf is not installed.

# lspci | fgrep -i scsi
5c:00.0 Serial Attached SCSI controller: Adaptec Smart Storage PQI 12G SAS/PCIe 3 (rev 01)

# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
unused devices: <none>
glensc commented 5 months ago

You probably needed a fresh run of sudo check_raid -S.

glensc commented 5 months ago

Could it be that dmsetup was installed recently, i.e after previous check_raid -S was used?

described in the project readme, plugin will try to use all plugins it is able to, depending on tools installed. however you could force using specific plugins only with --plugin flag.

DCL-DrewL commented 5 months ago

AFAIK dmsetup has been installed since build, though the install predates me, it's an inherited system. The utility is for use with the device-mapper, which I've only used in combination with LVM and DRDB. Possibly part of the default installation, which would also explain why the md RAID utilities are installed.

Thanks for looking!

glensc commented 5 months ago

Either way, update sudo rules via -S flag, or force use only specific plugin(s). Nothing further to be done here. or I don't understand the goal of your bug report.