According to the Nagios Documentation, Nagios is still init-based, so to allow any user to start and stop the Nagios service, we're going to:
- create an operator Command alias
- create an operator group
- allow anyone in the operator group to start/stop the Nagios Service:
- As an example, add the user "ahmed" to the operator group (as per your question)
first change the sudoers file:
sudo visudo
in the section # Cmnd alias specification add:
Cmnd_Alias CMD_OPERATOR=/etc/rc.d/init.d/nagios
in the ### User privilege specification section ### add:
# Allow the group "operator" to use certain applications
%operator ALL=CMD_OPERATOR
Now create the group operator:
sudo groupadd operator
and add ahmed to the operator group:
sudo usermod --append --groups operator ahmed
That's it! Now ahmed can perform all these commands:
sudo /etc/rc.d/init.d/nagios start
sudo /etc/rc.d/init.d/nagios reload
sudo /etc/rc.d/init.d/nagios stop
by providing his own password.
Why?
Well, now you have an operator group, you can:
- easily add other programs these kind of users need to perform
- easily revoke their operator rights if needed