Configure Nagios on Ubuntu Server

I’m assuming that you’ve already read the post on installing nagios AND have successfully installed nagios on your LAMP server. I have recently wiped out the 9.04-upgraded-to-10.04.1 server in favor of a fresh install of 10.04.2LTS. I followed my own guide and nagios is installed and running on production equipment.

I needed to add a new user to be able to access all the same admin functionality of the nagios website.
Create the login for apache:

htpasswd /usr/local/nagios/etc/htpasswd.users USERNAME
PASSWORD
PASSWORD

Add the user to the contacts list:

nano /usr/local/nagios/etc/objects/contacts.cfg
define contact{
contact_name USERNAME
use generic-contact
alias FULL NAME
email EMAIL@DOMAIN.TLD
}
Add the USERNAME after “nagiosadmin” under the define contactgroup{ area
Note, you will need to add a “, ” after nagiosadmin

Restart Nagios to re-read the configuration:

/etc/init.d/nagios restart

I would like to make a parent of an object (switch parent of server, or server hosting virtual machines etc)

define host{
use windows-server
host_name HOSTNAME
alias LONGNAME
address IPADDRESS
parents SERVER_OR_SWITCH_NAME – this must have a valid .cfg file already created
hostgroups SERVERGROUP1, SERVERGROUP3, ETC

Add Icons to Nagios Network Map
Upload your png file to /usr/local/nagios/share/images/logos/
Install the PNG to GD2 application:
apt-get install libgd-tools
Convert your PNG to a GD2:
pngtogd2 PNGFILE.png PNGFILE.gd2 cs 1

Create the host image config file:
nano /usr/local/nagios/etc/objects/hostimages.cfg

define hostextinfo{
host_name HOSTNAME, HOSTNAME2, ETC
# notes_url http://sitefornoteshere
icon_image FILENAME.png
icon_image_alt 0 ALTNAMEOFDEVICE
vrml_image FILENAME.png
statusmap_image FILENAME.gd2
}

Restart Nagios:
/etc/init.d/nagios restart

Reset MySQL Password

I setup a LAMP server for a developer a while back and he changed the passwords for root and the root mysql user to something besides my defaults. So when he asked me to give him the password for the database, I could not really help him out. Or could I?

Stop the mysql services:
/etc/init.d/mysql stop

Start mysql without the passwords:
mysqld_safe --skip-grant-tables &

Connect to the safe mysql:
mysql -u root

Set a new root password:
use mysql;
update user set password=PASSWORD("your_New_Password_here") where User='root';
flush privileges;
quit

Stop the safe mysql database:
/etc/init.d/mysql stop

Start mysql and test:
/etc/init.d/mysql start
mysql -u root -pYOURNEWPASSWORDHERE

*note – there is no space between -p and your password.

AND, in case you’re just wanting to change the password of a known user:
mysqladmin -u root -pOLDPASSWORD password NEWPASSWORD

Mount NFS on Ubuntu

Basic LAMP Ubuntu 10.04.2 LTS trying to mount NFS share from a FreeNAS 0.7.2 system. I was running the following command:

mount -t nfs 10.10.0.99:/mnt/hotswap/NFS/ /mnt/freenas/

and receiving the following error

mount: wrong fs type, bad option, bad superblock on 10.10.0.99:/mnt/hotswap/NFS/,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)
In some cases useful info is found in syslog – try
dmesg | tail or so

Awesome. So I tried with the -o ‘vers=3’ command just in case. Same issues persist.

It looks like the common NFS files are missing in the vanilla ubuntu server installation:
apt-get install nfs-common
Rerun the mount command is successful

And, since I like to create NFS on ubuntu as well:
apt-get install nfs-kernel-server
nano /etc/exports
Add:
/path/to/share Hostname(rw,sync,no_root_squash)
or in my case
/NFS *(rw,sync,no_root_squash)
Then restart nfs
/etc/init.d/nfs-kernel-server restart

iFolder

I was tasked with removing access to dropbox, but also with creating an internally-hosted dropbox-like solution. This is about as creative as I could get as most of the users were on Windows, with another handful of developers using their Macs:
iFolder 3.8.x

Installed Ubuntu 10.04.2 LTS x32
LAMP, MySQL, Mail Server

Change the password for the root user
sudo passwd root

Log in as root
su

Add the PPA repositories to your system
nano /etc/apt/sources.list
Add the following lines at the bottom of the file:

deb http://ppa.launchpad.net/marceloshima/ifolder/ubuntu lucid main
deb-src http://ppa.launchpad.net/marceloshima/ifolder/ubuntu lucid main

Save and Close
Add the signing of the packages
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ED649F97DE6BFD99
Test configuration
apt-get update

Install ifolder3-enterprise
apache2ctl stop
apt-get install ifolder3-enterprise

Create the self-signed cert/Allow Apache features
make-ssl-cert generate-default-snakeoil
a2enmod ssl
a2enmod rewrite

Link the conf files
ln -sf /etc/ifolder-server/apache/ifolder_apache.conf /etc/apache2/conf.d/
a2ensite default-ssl

Install .net files
apt-get install liblog4net1.2-cil
apache2ctl restart

Test by navigating to http://IPADDRESS/admin
You must create a user before you can use http://IPADDRESS/ifolder or the locally installed applications.

To change any configuration, just run either of these commands:
ifolder-admin-setup
ifolder-web-setup

Molly-Guard

After having someone reboot the wrong linux machine (again), we decided to take some action:

apt-get install molly-guard

This works on Debian/Ubuntu systems. After install, try running reboot or shutdown commands – the molly-guard will force you to type in the name of the system you’re trying to reboot/power off before it will actually allow the command to continue.