XINETD/NRPE | Cannot Write to Pidfile

 Cannot write to pidfile ‘/var/run/nagios/nrpe.pid’ – check your privileges.

This error occurs when the “pidfile” cannot be rewritten. In most cases, this happens after a reboot and the file itself is read-only instead of read/write.

If that is the case, go ahead and restart the xinetd and nrpe services.

service xinetd restart
service nrpe restart

Next, check the status of xinetd and nrpe

servie xinetd status
service nrpe status

Your xinet daemon should stay active and show that it’s running. When you check NRPE, it will say failed and display the following.

 nrpe[1312]: Starting up daemon
 nrpe[1312]: Cannot write to pidfile '/var/run/nagios/nrpe.pid' - check your privileges.

To fix this, you will need to go to /var/run/xinetd.pid if you are using xinetd with nrpe.

check the permissions of the tile with ll or ls -l

-r--r----- 1 nagios nagios 6 Dec 4 10:12 xinetd.pid

In the output above, the file has only read access and cannot be written too. To fix this issue, first, change the ownership to nagios and then changed the permissions.

chown nagios:nagios /var/run/xinetd.pid

Next, change the permissions to Read, Write, No Execute

chmod 660 xinetd.pid

Once done, check the file with ll  -rw-rw—- 1 nagios nagios 6 Dec 4 10:16 xinetd.pid Restart the service

service nrpe restart

Check the status to see if the service is running.

service nrpe status

 

If the service still doesn’t work after that, you will need to locate the nrpe.cfg file and edit it.  Mine is located here /usr/local/nagios/etc/nrpe.cfg. Look for the following section and edit the section in red.

# PID FILE
# The name of the file in which the NRPE daemon should write it's process ID
# number. The file is only written if the NRPE daemon is started by the root
# user and is running in standalone mode.

pid_file=/var/run/nrpe.pid

In some cases, you will need to change it to xinetd if you have installed that. If you are just using nrpe, then you can leave that alone.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s