In this article we will look into all the possible scenarios which can cause "nrpe.service: main process exited, code=exited, status=2/INVALIDARGUMENT" error and the solution to fix this error. You might have seen this error in a Server where you have installed nrpe client package. Basically Nagios connects the Servers through nrpe client package to gather the System stats.
So if the nrpe services does not work properly then Nagios will start showing "Socket timeout" error and when you come back and check the Server where you are running the nrpe service then you might encounter "nrpe.service: main process exited, code=exited, status=2/INVALIDARGUMENT" error there. We will see all the possible scenario where this error can occur and will also look at the solution to solve this issue.
nrpe.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Also Read: Best Steps to Install Perl on RHEL/CentOS 8
You might have observed "main process exited, code=exited, status=1/INVALIDARGUMENT" error while trying to start or restart the nrpe service in your Linux based systems. When you run systemctl status nrpe command to check the status, then output will show something like below.
[root@localhost ~]# systemctl status nrpe.service ● nrpe.service - Nagios Remote Program Executor Loaded: loaded (/usr/lib/systemd/system/nrpe.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2020-09-21 21:48:04 UTC; 8s ago Docs: http://www.nagios.org/documentation Process: 516 ExecStopPost=/bin/rm -f /var/run/nrpe/nrpe.pid (code=exited, status=0/SUCCESS) Process: 514 ExecStart=/usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f $NRPE_SSL_OPT (code=exited, status=2) Main PID: 514 (code=exited, status=2) Sep 21 21:48:04 localhost systemd[1]: Started Nagios Remote Program Executor. Sep 21 21:48:04 localhost systemd[1]: Starting Nagios Remote Program Executor... Sep 21 21:48:04 localhost systemd[1]: nrpe.service: main process exited, code=exited, status=2/INVALIDARGUMENT Sep 21 21:48:04 localhost systemd[1]: Unit nrpe.service entered failed state. Sep 21 21:48:04 localhost systemd[1]: nrpe.service failed.
NOTE:
root
user to run all the below commands. You can use any user with sudo
access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo
access to the User.You can check additional systemctl status messages if any by using systemctl status nrpe -l
command as shown below. Usually if there will be any configuration issue then it will that error in the below output and then you can go and check nrpe.cfg file for any possible mistakes. If it shows any permission issue then you can verify that error by checking the nrpe.pid
permission by using ls -lrt /etc/nagios/nrpe.pid
. This path will be set on pid_file parameter in nrpe.cfg
file.
If there is any issue in the creation of nrpe.pid
file then you can change the path of the file to a different directory where nrpe will have the access to create nrpe.pid
file.
[root@localhost ~]# systemctl status nrpe -l ● nrpe.service - Nagios Remote Program Executor Loaded: loaded (/usr/lib/systemd/system/nrpe.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2020-09-21 21:48:04 UTC; 3h 29min ago Docs: http://www.nagios.org/documentation Process: 516 ExecStopPost=/bin/rm -f /var/run/nrpe/nrpe.pid (code=exited, status=0/SUCCESS) Process: 514 ExecStart=/usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f $NRPE_SSL_OPT (code=exited, status=2) Main PID: 514 (code=exited, status=2) Sep 21 21:48:04 localhost systemd[1]: Started Nagios Remote Program Executor. Sep 21 21:48:04 localhost systemd[1]: Starting Nagios Remote Program Executor... Sep 21 21:48:04 localhost systemd[1]: nrpe.service: main process exited, code=exited, status=2/INVALIDARGUMENT Sep 21 21:48:04 localhost systemd[1]: Unit nrpe.service entered failed state. Sep 21 21:48:04 localhost systemd[1]: nrpe.service failed.
In the next steps, If you see this error then first you need to check the nrpe process if it is running or not using ps command as shown below.
[root@localhost ~]# ps -ef | grep -i nrpe root 769 2383 0 00:41 pts/0 00:00:00 grep --color=auto -i nrpe
As you can see above, nrpe process is not running. So the next steps would be to check the Systemd Logs as this service is controller by SystemD. You can check the SystemD logs by using journaltctl -xfeu nrpe command as shown below. You can check journalctl command Man Page to Know more about all the available options.
[root@localhost ~]# journalctl -xfeu nrpe -- Logs begin at Fri 2020-03-13 04:24:07 UTC. -- Sep 21 21:20:48 localhost systemd[1]: Started Nagios Remote Program Executor. -- Subject: Unit nrpe.service has finished start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit nrpe.service has finished starting up. -- -- The start-up result is done. Sep 21 21:20:48 localhost systemd[1]: Starting Nagios Remote Program Executor... -- Subject: Unit nrpe.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit nrpe.service has begun starting up. Sep 21 21:20:48 localhost systemd[1]: nrpe.service: main process exited, code=exited, status=2/INVALIDARGUMENT Sep 21 21:20:48 localhost systemd[1]: Unit nrpe.service entered failed state. Sep 21 21:20:48 localhost systemd[1]: nrpe.service failed. Sep 21 21:25:27 localhost systemd[1]: Started Nagios Remote Program Executor. -- Subject: Unit nrpe.service has finished start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit nrpe.service has finished starting up. -- -- The start-up result is done.
As you can see from above error it is trying to start the nrpe service but it is going to failed state. Above output is not giving much clue about the error. You can also check systemd-analyze
output to confirm if there is any error showing here.
[root@localhost ~]# systemd-analyze blame | grep -i nrpe
If you don't see any error here as well then you can tail the /var/log/messages
output to find out any error as shown below.
[root@localhost ~]# tail /var/log/messages
Usually checking above logs will provide enough information about the error but you can try some more troubleshooting steps. You can try to disable the nrpe service and then enable it again.
[root@localhost ~]# systemctl disable nrpe [root@localhost ~]# systemctl enable nrpe
In case above steps does not work then you can try rebooting your Server once by using init 6
or reboot
command as shown below.
[root@localhost ~]# reboot [root@localhost ~]# init 6
After rebooting the Server if the nrpe service gets started then you can either check the nrpe service using systemctl status nrpe
command or check the nrpe process using ps command, it will show the output like below.
[root@localhost ~]# ps -ef | grep -i nrpe nrpe 141496 1 0 Sep10 ? 00:00:21 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f
Recommended Posts:-
6 Easy Steps to Install dig and nslookup command on RHEL/CentOS 8 | dig command not found
How to Install Let's Encrypt(Certbot) on RHEL/CentOS 8 Using 10 Easy Steps
8 Easy Ways to check Ubuntu Version using Bash Command Line
5 Easy Steps to Install Openssh-Server on Ubuntu 20.04 to Enable SSH
Unix/Linux Find Files and Directories Owned By a Particular User(5 Useful Examples)
15 Practical Bash For Loop Examples in Linux/Unix for Professionals
6 Popular Methods to List All Running Services Under Systemd in Linux
33 Practical Examples of ulimit command in Linux/Unix for Professionals