Skip to main content

Installing Nagios Remote Plugin Executor in Solaris 11

Install gcc

pkg install pkg://sfe/runtime/gcc pkg://sfe/sfe/developer/gcc

Install system headers (not really sure if all listed were necessary):

pkg install SUNWhea SUNWbinutils SUNWarc SUNWgcc SUNWgccruntime SUNWlibsigsegv SUNWgm4 SUNWgnu-automake-110 SUNWaconf

Update your PATH:

export PATH

Manually create nagios user account, home directory, group, and assigned him a password.

mkdir -p /usr/local/nagios
useradd -d /usr/local/nagios -m nagios
groupadd nagios
usermod -G nagios nagios
passwd nagios

Download, extract, compile and install nrpe.

tar -xvf
cd /opt/nrpe-2.13
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make install
make install-daemon-config
cp src/check_nrpe /usr/local/nagios/libexec

Update permissions.

chown -R nagios:nagios /usr/local/nagios/

Add the following entry to /etc/services

nrpe 5666/tcp # NRPE

Add the following entry to /etc/inetd.conf

nrpe stream tcp nowait nagios /usr/sbin/tcpd /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -i

Convert and add the new legacy inetd entry to SMF.

inetconv -e

Awesome Applications: 


Creating large files in Solaris for testing purposes

In the Linux world, I use the dd utility to create files that need to be a certain size. Even though it works perfectly fine, its kind of annoying figuring out the output file's size of the file. This is because the size is based on the "bs" (block size) value and the total number of block size "count" together.

For example, the following dd command creates a 300 mb file called 300mb-test-fil. Each block size will be 1000 bytes, and I want of a total of 300,000 blocks.
Formula: ( (1000 x 300000) / 1000000 )

[[email protected] ~]$ dd if=/dev/zero of=300mb-test-file bs=1000 count=300000
300000+0 records in
300000+0 records out
300000000 bytes (300 MB) copied, 2.0363 s, 147 MB/s

Luckily in the Solaris world this can be easily accomplished using the mkfile utility, without doing any conversion.
I used the mkfile utility to easily create test disk files to experiment with ZFS.

[email protected]:~# mkfile 300m testdisk1
[email protected]:~# mkfile 300m testdisk2
[email protected]:~# ln -s /root/testdisk1 /dev/dsk/testdisk1
[email protected]:~# ln -s /root/testdisk2 /dev/dsk/testdisk2
[email protected]:~# zpool create tonytestpool mirror testdisk1 testdisk2
[email protected]:~# zpool status tonytestpool
pool: tonytestpool
state: ONLINE
scan: none requested

tonytestpool ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
testdisk1 ONLINE 0 0 0
testdisk2 ONLINE 0 0 0

errors: No known data errors


Awesome Applications: 


FreeBSD diskless PXE booting

After a couple of trial and error tests and lots of caffeine ingested, I finally managed to install FreeBSD 9.1 over my network completely diskless using ISC's DHCP, PXE, tftpd-hpa, and NFS.

Download iso image and copy over all files.

mount -o loop FreeBSD-9.0-RELEASE-amd64-disc1.iso /mnt
mkdir -p /srv/tftp/freebsd/amd64
cp -a /mnt/* /srv/tftp/freebsd/amd64
cp -a /mnt/.cshrc /srv/tftp/freebsd/amd64
cp -a /mnt/.profile /srv/tftp/freebsd/amd64
cp -a /mnt/.rr_moved /srv/tftp/freebsd/amd64

Create the following directories:

mkdir /srv/tftp/freebsd/amd64/jails
mkdir -p /srv/tftp/freebsd/amd64/conf/base/jails
mkdir /srv/tftp/freebsd/amd64/conf/default
chmod -R 777 /srv/tftp/freebsd/amd64/conf
chmod -R 777 /srv/tftp/freebsd/amd64/jails

Edit /srv/tftp/freebsd/amd64/etc/fstab, comment out the entry in the file:

#/dev/iso9660/FREEBSD_INSTALL / cd9660 ro 0 0

Add the following entry to /srv/tftp/freebsd/amd64/etc/rc.conf:


NFS configuration:


dhcpd configuration (of course, IP may differ depending on your environment): will be the IP that wil be assigned to the new FreeBSD system. is the IP of the NFS server where the installation files are stored in.
The filename path is relative to what path you configured with tftpd-hpa.

host freebsdboot {
  hardware ethernet 08:00:27:2b:f9:f8;
  filename "freebsd/amd64/boot/pxeboot";
  option root-path "";

FreeBSD Diskless PXE


Awesome Applications: 


PHP memory_limit stress testing

I wrote this code a couple of years ago that I found it was very useful when I was troubleshooting PHP memory limit settings. The script essentially creates one huge array until it runs out of memory.

ini_set('display_errors', true);
while (1) {
        echo 'Hello' . nl2br("\n");
        $array = array(1,2);
        while(1) {
                $tmp = $array;
                $array = array_merge($array, $tmp);
                echo memory_get_usage() . nl2br("\n");


Awesome Applications: 

Finding the number of files inside a subdirectory

for i in `ls .`; do echo $i; ls -laR $i| grep -v ^[.dlt] | grep -v ^$ | wc -l; echo "--------------------" ; done


Setting phpMyAdmin to display a single database


$cfg['Servers'][$i]['only_db'] = 'databasename';



Awesome Applications: 

Creating a loopback file system for testing purposes

(This example the block size is 1024 bytes and a total of 5000 blocks)

dd if=/dev/zero of=/tmp/temploopbackimage.img bs=1024 count=5000

Associate the image file to the loopback device

losetup /dev/loop3 /tmp/temploopbackimage.img

Now you should be able to format /dev/loop3

Awesome Applications: 

Flush DNS cache in Mac OS X

Mountain Lion and Lion

sudo killall -HUP mDNSResponder

Snow Leopard

sudo dscacheutil -flushcache


Installing Nagios Remote Plugin Executor


yum install openssl openssl-devel gcc make autoconf xinetd


apt-get install openssl build-essential libssl-dev gcc make autoconf xinetd

Create nagios user and give it a password.

/usr/sbin/useradd -m nagios
passwd nagios

Download and extract the latest stable Nagios Plugins from
Configure, compile and install the Nagios plugins.

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make install

Download the latest NRPE plugin from
Extract, configure, compile and install the plugin with xinetd configuration.

make all
make install-daemon
make install-xinetd

Edit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the only_from directive.

only_from = 

Add the following entry for the NRPE daemon to the /etc/services file.

nrpe 5666/tcp # NRPE

Restart the xinetd service.

/etc/init.d/xinetd restart

Copy over sample config file.

mkdir /usr/local/nagios/etc/
cp sample-config/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg

Copy over check_nrpe binary to /usr/local/nagios/libexec

cp src/check_nrpe /usr/local/nagios/libexec/

Update permissions.

chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

Update firewall.

iptables -A INPUT -p tcp -m tcp --dport 5666 -j ACCEPT

Testing Communication
Issue the following command to test communication on the Nagios monitoring server. Replace IP "", with the NRPE client's IP.

/usr/local/nagios/libexec/check_nrpe -H

You should get a string back that tells you what version of NRPE is installed on the remote host, like this:

NRPE v2.13

Awesome Applications: 

Installing Nagios in CentOS 6

Make sure you've installed the following packages on your CentOS installation before continuing.

GCC compiler
GD development libraries

Performed on

yum install httpd php gcc glibc glibc-common gd gd-devel make autoconf

Create nagios user and give it a password.

/usr/sbin/useradd -m nagios
passwd nagios

Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache

Download and extract the latest stable Nagios Core from
Run the Nagios configure script, passing the name of the group you created earlier:

./configure --with-command-group=nagcmd

Compile Nagios

make all

Install Nagios

make install

Update the email address associated with the nagiosadmin contact definition in /usr/local/nagios/etc/objects/contacts.cfg .

Install the Nagios web config file in the Apache conf.d directory.

make install-webconf

Install Nagios init config

make install-init

Create htaccess user to access the Nagios web interface.

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache to make the new settings take effect.

service httpd restart

Add Nagios to the list of system services and have it automatically start when the system boots.

chkconfig --add nagios
chkconfig nagios on

Download and extract the latest stable Nagios Plugins from
Configure, compile and install the Nagios plugins.

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make install

Update permissions

chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

Verify the sample Nagios configuration files.

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, start Nagios.

service nagios start

Post Installation
To make things easier to myself, the ncheck and nrestart aliases were created in /root/.bashrc to check the nagios configuration and restart the service respectively.

alias ncheck='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg'
alias nrestart='service nagios restart'



Awesome Applications: 


Premium Drupal Themes by Adaptivethemes