@hardik185, Open the /etc/sudoers file and add the following entries instead of just two entries that I recommended earlier.
Defaults: nrpe !requiretty
Defaults: nagios !requiretty
nagios ALL = NOPASSWD:/usr/local/nagios/etc/libexec/check_expiry.sh
nagios ALL = NOPASSWD:/usr/sbin/lchage
nagios ALL = NOPASSWD: /sbin/service,/usr/bin/systemctl,/usr/sbin/service
nrpe ALL = NOPASSWD: /sbin/service,/usr/bin/systemctl,/usr/sbin/service
Open the /usr/local/nagios/libexec/check_expiry.sh script on the line 14, and change it to look like this:
- Code: Select all
get_expiry_date=$(sudo /usr/sbin/lchage -l $1 | grep 'Password Expires' | cut -d: -f2)
I added "sudo".
Let me know if this fixes the issue.