How did you test your script in bash? With root permissions or the icinga/nagios user? My guess if icinga triggers yours script it has not much permissions.
If you configured something like SELinux or AppAmor check these logs, if the system blocks the access
root@xnode002:~# su -s /bin/sh -c “/usr/lib/nagios/plugins/check_MegaRAID.py” nagios
RAID is CRITICAL
root@xnode002:~# /usr/lib/nagios/plugins/check_MegaRAID.py
All are OK
and the storcli64
root@xnode002:~# ls -l /usr/local/MegaRAID\ Storage\ Manager/StorCLI/storcli64
-rwsr-sr-x 1 nagios root 7951864 Jul 5 2019 /usr/local/MegaRAID Storage Manager/StorCLI/storcli64
root@xnode002:~# su -s /bin/sh -c “/usr/local/MegaRAID\ Storage\ Manager/StorCLI/storcli64 -AdpAllInfo -aALL” nagios
Exit Code: 0x01
root@xnode002:~# su -s /bin/sh -c "/usr/local/MegaRAID\ Storage\ Manager/StorCLI/storcli64 " nagios
Storage Command Line Tool Ver 1.23.02 Mar 28, 2017
(c)Copyright 2017, AVAGO Corporation, All Rights Reserved.
help - lists all the commands with their usage. E.g. storcli help
help - gives details about a particular command. E.g. storcli add help
List of commands:
Commands Description
add Adds/creates a new element to controller like VD,Spare…etc
delete Deletes an element like VD,Spare
show Displays information about an element
set Set a particular value to a property
get Get a particular value to a property
compare Compares particular value to a property
start Start background operation
stop Stop background operation
pause Pause background operation
resume Resume background operation
download Downloads file to given device
expand expands size of given drive
insert inserts new drive for missing
transform downgrades the controller
/cx Controller specific commands
/ex Enclosure specific commands
/sx Slot/PD specific commands
/vx Virtual drive specific commands
/dx Disk group specific commands
/fall Foreign configuration specific commands
/px Phy specific commands
/[bbu|cv] Battery Backup Unit, Cachevault commands
/jbodx JBOD drive specific commands
Other aliases : cachecade, freespace, sysinfo
Use a combination of commands to filter the output of help further.
E.g. ‘storcli cx show help’ displays all the show operations on cx.
Use verbose for detailed description E.g. ‘storcli add verbose help’
Use ‘page=’ as the last option in all the commands to set the page break.
X=lines per page. E.g. ‘storcli help page=10’
Use J as the last option to print the command output in JSON format
Command options must be entered in the same order as displayed in the help of
the respective commands.
I don’t know how to grant the permissions of MSM to nagios