:::: MENU ::::

Posts Categorized / Linux

  • Dec 07 / 2016
  • 0

Nagios plugin – Error “No such file or directory”

When trying to execute a nagios plugin, you’re getting this error:

# /usr/lib/nagios/plugins/check_procs 
bash: /usr/lib/nagios/plugins/check_procs: No such file or directory

But when checking further, the file does exist:

# ls -l /usr/lib/nagios/plugins/check_procs 
-rwxr-xr-x 1 root root 124929 Jan 19  2016 /usr/lib/nagios/plugins/check_procs

This can be due to some 32 bit libc libraries missing. To fix that, you will have to install the 32-bit shared libraries for AMD64 by installing this package:


And now, you can try again, error should have gone away!

# /usr/lib/nagios/plugins/check_procs 
PROCS OK: 152 processes|procs=152;-1;-1;0
  • Nov 24 / 2016
  • 0

NRPE – Enable command args (Jessie, …)

With recent versions of NRPE server, the possibility to enable command args has been disabled.

For example, on a Debian Jessie, you can get this kind of error on console:

CHECK_NRPE: Received 0 bytes from daemon

and in logs:

Error: Request contained command arguments! 

!WARNING! This change can lead to security issue, this is why it has been disabled by default. You have to double check your servers can’t be reached from anywhere with NRPE commands (to avoid execution of unwanted or malicious code).

Once you’re sure there’s no security breach in your infra, you can go on with the installation of source:

cd /tmp
apt-get update
apt-get install -y build-essential devscripts debhelper libssl-dev dpatch libwrap0-dev autotools-dev
ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/libssl.so
apt-get source nagios-nrpe-server

Then, you’ll have to change the rules defined in the rules file:

cd nagios-nrpe-2.15/
vi debian/rules

You must add this line –enable-command-args after –libdir=/usr/lib/nagios.
You should so get something like


Finally, you can compile your new configuration and install it:

make all
cd ..
dpkg -i nagios-nrpe-server_2.15-1.1_amd64.deb

Ensure you set the value for dont_blame_nrpe in /etc/nagios/nrpe.cfg (this is the default path, it can be different depending on your installation).


And here you go, you can now restart your NRPE server and send any nrpe commands.

  • Nov 21 / 2016
  • 0

Apache – mod_auth compatibility for 2.2 and 2.4

Since Apache 2.4, mod_auth changed and some directive like

Order allow,deny
Allow from all

that have been replaced with

Require all granted

If you want to automatically handle same configuration for multiple servers where different versions of Apache are installed, you can use this trick:

<IfModule mod_version.c>
  <IfVersion < 2.4>
    Order allow,deny
    Allow from all
  <IfVersion >= 2.4>
    Require all granted
<IfModule !mod_version.c>
  Order allow,deny
  Allow from all

Thanks to that change, your configuration will be working whatever version of Apache you’re using.

  • Oct 28 / 2016
  • 0

Add a confirmation dialog with bash

If you have a bash script doing some critical actions, it can be useful to add a confirmation dialog to double check with the user that he really wants to perform the action.

Here is a very simple script allowing this kind of checking:

echo "Welcome to your favourite script!"
read -r -p "Are you sure you want to execute it? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
  echo "Execution in progress..."
  # Write your action here
  echo "Action canceled."
echo "End of script."

Output will look like:

  • Case ‘yes’:
    $ bash script_yesno.sh 
    Welcome to your favourite script!
    Are you sure you want to execute it? [y/N] y
    Execution in progress...
    End of script.
  • Case ‘no’:
    $ bash script_yesno.sh 
    Welcome to your favourite script!
    Are you sure you want to execute it? [y/N] N
    Action canceled.

It’s up to you customizing it depending on your needs and your feelings!

  • Oct 19 / 2016
  • 0

Apache Tomcat – Get logs directly cleaned with rotation

Tomcat allows you to rotate easily your log files with AccessLogValve but it can be more difficult to get cleaning in logs directories automatically.

For that, you can easily use some smart find commands combined with actions:

  1. Get logs older than 3 days compressed so they can be smaller but still accessible
    find /var/log/tomcat/ -mtime +3 -regex ".*\.\(log\|txt\)$" -exec gzip "{}" \;
  2. Get logs older than 60 days deleted permanently
    find /var/log/tomcat/ -mtime +60 -name "*.gz" -exec rm "{}" \;

You will probably have to adjust the logs path depending on your needs, and you can also modify the retention time for each action.
Once the command looks correct with what you’re expecting, you can set them up as cron so it can be executed automatically every day.

  • Oct 14 / 2016
  • 0

Generate a random file with specific size

It’s possible to easily generate a random file with specific size filled differently depending on the needs:

  • Fill a 200MB file with zeroes
    dd if=/dev/zero of=/tmp/file.out bs=1024KB count=200
  • Fill a 200MB file with random values (longer than zeroes – depending on processor)
    dd if=/dev/random of=/tmp/file2.out bs=1024KB count=200

Question ? Contact