rubysecurity.org

Anecdotes from a Linux Systems Administrator. /root

Home About Books Blog Portfolio Archive

Tag Cloud


Currently Reading

MCA Microsoft Certified Associate Azure Administrator Study Guide: Exam AZ-104
MCA Microsoft Certified Associate Azure Administrator Study Guide: Exam AZ-104
308 / 435 Pages


Latest Book Reviews

Latest Posts


December 18, 2012

Setting phpMyAdmin to display a single database

by Alpha01

Edit config.inc.php

$cfg['Servers'][$i]['only_db'] = 'databasename';
Tags: [ php mysql ]
December 17, 2012

Creating a loopback file system for testing purposes

by Alpha01

Using the all mighty dd tool, 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

Tags: [ testing ]
December 11, 2012

Flush DNS cache in Mac OS X

by Alpha01

Mountain Lion and Lion

sudo killall -HUP mDNSResponder

Snow Leopard

sudo dscacheutil -flushcache
Tags: [ macos networking ]
November 1, 2012

Installing Nagios Remote Plugin Executor in CentOS and Ubuntu

by Alpha01

CentOS

yum install openssl openssl-devel gcc make autoconf xinetd

Debian/Ubuntu

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 http://www.nagios.org/download/plugins/ Configure, compile and install the Nagios plugins.

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

Download the latest NRPE plugin from http://exchange.nagios.org/directory/Addons/Monitoring-Agents/NRPE–2D-Nagios-Remote-Plugin-Executor/details. Extract, configure, compile and install the plugin with xinetd configuration.

./configure
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 = 127.0.0.1 <nagios_ip_address>

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 “192.168.0.1”, with the NRPE client’s IP.

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

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

NRPE v2.13
Tags: [ nagios centos ubuntu ]
October 31, 2012

Installing Nagios in CentOS 6

by Alpha01

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

  • Apache
  • PHP
  • GCC compiler
  • GD development libraries
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 http://www.nagios.org/download/core/ 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 http://www.nagios.org/download/plugins. Configure, compile and install the Nagios plugins.

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
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'

Reference

Tags: [ nagios centos ]