Wednesday, February 22, 2012

Nagios Grapher - PNP Installation


Nagios Graph - PNP
Download the latest stable version from here and extract it to your favorite source path and change to this.

./configure --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata/
make all
make install

Update 2 lines in nagios.cfg, this tells nagios how to process performance data:

process_performance_data=1
service_perfdata_command=process-service-perfdata

Edit one of your command files that is listed in nagios.cfg e.g. misccommands.cfg and add following lines.

define command{
command_name process-service-perfdata
command_line /usr/local/nagios/libexec/process_perfdata.pl
}


Now you have to define the service to process the performance data with PNP. To do this look at your service definitions in services.cfg and check the following option is set in your generic service template or specific service.

process_perf_data 1


This file can be created automatically using a script in the contrib directory, ./makeserviceextinfo, this creates a configuration file in nagios/etc. (Note: Only some entries are created, this will be corrected in version 3.

Now after restarting Nagios, when viewing a Service Detail there is an icon displayed that links through to a graph (once some data has been collected).


Note: The PHP5-GD package must be installed

Install new package in perl

perl -MCPAN -e shell

then in CPAN prompt type for example:

Install Nagios::Plugins

this command installs Nagios::Plugins!

Use Twitter for SMS Notification in Nagios


First create an account on twitter to be used along with nagios. You probably also want to indicate that the account should be private via twitter settings in order for the whole internet not to see what is going on with you monitoring :). So go twitter and get an account.

Second, here is a piece of code for a script which I use as a notification handler:


#!/usr/bin/perl -w
use strict;
use Net::Twitter;
my $msg = shift;
my $twit = new Net::Twitter(username => "twitter_user",password => "twitter_pass");
if (defined($msg) && $msg !~ /^\s*$/) {
$twit->update($msg);
}

Don’t forget to replace twitter_user and twitter_pass with the details of twitter account you have created in above stage.

Now modify the nagios notification commands in the misc. commands config file (/etc/nagios/misccommands.cfg in my case) to utilize the erlier created twitter.pl script. I have the following definitions:


define command {
command_name notify-by-epager
command_line /path/to/twitter.pl "$NOTIFICATIONTYPE$ - $HOSTNAME$-$SERVICEDESC$ - $SERVICESTATE$ - $SERVICEOUTPUT$"
}

and the same for host-notify-by-epager.

Finally adjust your nagios contact definition to use the above commands for notifications and don’t forget to enable all the notifications you need

The above part will post all alerts to nagios twitter account. In order to be able to receive them via SMS or GTalk, add nagios twitter account as a friend to your personal twitter account (don’t forget to grant access to become a fried from nagios twitter account if you made it private) and follow up.
Note: in perl must install Twitter:
install Net::Twitter
or:

force install Twitter

Ubuntu Encrypted directory with EncFS

Install the ENCFS package:

apt-get install encfs fuse-utils

modprobe fuse


Make the directory where encrypted data will be stored:

mkdir /encrypted

Make a mount point:

mkdir /temp-encr

use encfs with this directories:

encfs /encrypted /temp-encr

enter your Password.

for avoid the others to access the encrypted data, just unmount the folder:

fusermount -u /encrypted /temp-encr

In encrypted folder only "Encrypted Data" could be seen.

If you want to encrypt a directory on your fileserver and have the decrypted mountpoint accessible by Linux or Windows clients via Samba, you need to modify your setup slightly to permit "other" access to the Fuse device.

First, modify the /etc/fuse.conf file so that the last line "user_allow_other" does NOT have a leading hash. Save and exit.

Next, add an option to your EncFS mount command:

encfs /encrypted /temp-encr -- -o allow_other

Convert a ssh-keygen to putty format using puttygen

First install putty-tools:

apt-get install putty-tools

then use this command to convert ssh-key:

puttygen YOUR-KEY -o OUTPUTFILE.PPK

Backup and restore debian/ubuntu package selection


If you are running Debian and have lost track of which packages you are running, it could be useful to get a backup of your currently installed packages. You can get a list by running:
dpkg --get-selections > debianlist.txt
This will put the entire list in debianlist.txt. You could then install the same packages on a different computer with:
dpkg --set-selections < debianlist.txt
You should bear in mind that you would also need to copy over configuration files from /etc when copying your system to a new computer.
To actually install the selections, use:
apt-get -u dselect-upgrade

Find out what IPs are on your subnet


Here is a quick tip on how to find out what host IPs are on your subnet using nmap. This is useful to find out what IPs are being used or just to know how many devices are connected to the subnet.

How to find out what IPs are being used on your subnet

# nmap -v -sP 192.168.1.0/24
You can replace the 192.168.1.0/24 address with whatever your IP and subnet is.
Also, for a cleaner output that removes the lines that tell you an IP is not used, try the following:

# nmap -v -sP 192.168.1.0/24 | grep -v "appears to be down"

How To Log Boot Messages in Ubuntu


Here is a quick Linux tip to log your boot messages in Ubuntu.  This is great for checking for any errors or failed startups that may be happening during boot.
Edit /etc/default/bootlogd:

# vi /etc/default/bootlogd

You’ll see the following lines:

# Run bootlogd at startup ?
BOOTLOGD_ENABLE=No
Change No to Yes:

# Run bootlogd at startup ?
BOOTLOGD_ENABLE=Yes
Now every time your computer restarts, a /var/log/boot file will be created.

tvtime

tvtime is a high quality television application for use with video capture cards on Linux systems. tvtime processes the input from a capture card and displays it on a computer monitor or projector.

http://tvtime.sourceforge.net/

7 Must Have Linux iPhone Applications


If you’re anything like me and love tech gadgets that allow you to do almost anything..then you undoubtedly own an iPhone.  For the past year of being an iPhone owner, I’ve discovered a ton of iPhone apps that help me in my every day life.  Many of them are Linux apps.  Below you will find a list I’ve put together of must have Linux iPhone apps for you to check out.
Linux Command Reference (FREE) – This iPhone app is a handy command reference for the Linux Terminal.  Perfect for situations when you need to reference a command but you’re in the server room without your computer.
LinuxTube – This app allows you to view Linux related videos as well as chat with other Linux enthusiasts.
Server Remote – Easily monitor your Linux server from your iPhone.  This iPhone application uses the standard SSH protocol to communicate with your servers, and requires no special software to beinstalled on the server end.
SSH – The best SSH client I’ve found in the iPhone app store. It works over Wi-Fi, Edge, and 3G networks.
Chmod (FREE) – Very simple and straight forward reference app for determining file and directory permissions on Mac OS X, Linux and Unix.
Vi Reference – A great reference for those of us who use Vi/Vim.
UNIX Fortune – For those old school nix users, this is the entertaining fortune cookie applicationconverted to an iPhone app.
Hopefully these Linux iPhone apps save you a little bit of time,