Ubuntu Server 10.04.3 LTS (64-bit) and Nagios Core 3.3.1
Ubuntu Server 10.04.3 LTS (64-bit) and Nagios Core 3.3.1
Greetings and salutations.
I'm new to Nagios and after playing around with it today, I decided to try and get it going for my network. However, I'm not a Linux guru but I do know enough to be dangerous. My preferred platform is Ubuntu Server 10.04.3 LTS because it is the latest version of Ubuntu Server that allows a support contract if needed.
My 1st attempt was simply to install Nagios using the single command-line install (aptitude -y install nagios3), but it installed version 3.2.3 and not the current 3.3.1. I was also at a loss trying to find out where it expected the configuration files and could not find any of the samples that much of the documentation talks about. So I wiped out the system and started over...this time trying to install from the source by following the Ubuntu Quickstart Guide. It was fairly close but still needed some changes just to make it work right in the newer version of Ubuntu.
Since I seem to be treading on territory that is partial undocumented, I will document the steps that I took to get 3.3.1 working on Ubuntu Server 10.04.3. Hopefully I won't goof up too bad and if I do, please let me know. Also, I plan to make many revisions to each of these posts as I work out the kinks.
I will document this over several posts in this thread...mainly because a single post will likely not hold everything.
Post #1 - Introduction / Overview
Post #2 - Analysis and Design
Post #3 - Installation and Configuration of Ubuntu Server
Post #4 - Installation of Nagios
Post #5 - Configuration of Nagios
I'm new to Nagios and after playing around with it today, I decided to try and get it going for my network. However, I'm not a Linux guru but I do know enough to be dangerous. My preferred platform is Ubuntu Server 10.04.3 LTS because it is the latest version of Ubuntu Server that allows a support contract if needed.
My 1st attempt was simply to install Nagios using the single command-line install (aptitude -y install nagios3), but it installed version 3.2.3 and not the current 3.3.1. I was also at a loss trying to find out where it expected the configuration files and could not find any of the samples that much of the documentation talks about. So I wiped out the system and started over...this time trying to install from the source by following the Ubuntu Quickstart Guide. It was fairly close but still needed some changes just to make it work right in the newer version of Ubuntu.
Since I seem to be treading on territory that is partial undocumented, I will document the steps that I took to get 3.3.1 working on Ubuntu Server 10.04.3. Hopefully I won't goof up too bad and if I do, please let me know. Also, I plan to make many revisions to each of these posts as I work out the kinks.
I will document this over several posts in this thread...mainly because a single post will likely not hold everything.
Post #1 - Introduction / Overview
Post #2 - Analysis and Design
Post #3 - Installation and Configuration of Ubuntu Server
Post #4 - Installation of Nagios
Post #5 - Configuration of Nagios
Last edited by LHammonds on Tue Jan 03, 2012 2:11 pm, edited 2 times in total.
Re: Ubuntu Server 10.04.3 LTS (64-bit) and Nagios Core 3.3.1
Tools utilized in this process
The list below are sources of information that helped me configure this system as well as some places that might be helpful to me later on as this process continues.
SORRY - This site limits max number of links to 5. Yep, that's all they allow...so no more working links for you.
Assumptions
This documentation will need to make use of some very-specific information that will most-likely be different for each person / location. And as such, I will note some of these in this section. They will be highlighted in red throughout the document as a reminder that you should plug-in your own value rather than actually using my "place-holder" value.
Under no circumstance should you use that actual values I list below. They are place-holders for the real thing. This is just a checklist template you need to have answered before you start the install process.
Wherever you see RED in this document, you need to substitute it for what your company uses. Use the list below as a template you need to have answered before you continue.
Analysis and Design
My company has the following equipment on the network:
Since it seems this server will not be growing in size over time, space partitioning is not much of a concern as long as a sufficient amount of room is available. The only thing that needs to be backed up for this server is the configuration files. So once this server is setup and stable, a single backup of the configuration is all that is necessary. I see no reason to maintain an OS or application backup since this is not a high-priority server and will not even require a secondary offsite server. If the server becomes unusable and needs to be replaced, a simple re-install of the OS and application onto a new VM will be sufficient. With that said, I will only be using a default 8 GB partition and will let the OS consume the entire space with a single LVM (Logical Volume Manager).
Virtual Machine Settings
You could install this bare-metal onto a physical box or even run it inside a VM on your desktop using Oracle's VirtualBox but since I have a VMware infrastructure, I will be using VMware as noted below (which shouldn't affect much in the documentation)
Virtual Manager: VMware vSphere Client 4.1
Virtual Host: VMware ESXi Server 4.1
The 1st time I installed Ubuntu, I used the console for everything but it was painfully slow to view man (manual) pages and navigating in VI (text editor). However, I found out that PuTTY is a far better solution for your Ubuntu console because it handles the screen draws much faster and allows for scrolling and copying text.
Download the portable edition and run the install...except it doesn't really "install" like a normal program, it simply extracts to a specified folder and will run from that folder even if you put it on a USB stick and carry over to a new computer (requires no install to run and thus leaves a very small footprint on your system)
- VMware vSphere 4.1.0
- Ubuntu Server 10.04 LTS, 64-bit
- Portable PuTTY 0.61
- Nagios Core 3.3.1
- Nagios Plugins 1.4.15
The list below are sources of information that helped me configure this system as well as some places that might be helpful to me later on as this process continues.
SORRY - This site limits max number of links to 5. Yep, that's all they allow...so no more working links for you.
Assumptions
This documentation will need to make use of some very-specific information that will most-likely be different for each person / location. And as such, I will note some of these in this section. They will be highlighted in red throughout the document as a reminder that you should plug-in your own value rather than actually using my "place-holder" value.
Under no circumstance should you use that actual values I list below. They are place-holders for the real thing. This is just a checklist template you need to have answered before you start the install process.
Wherever you see RED in this document, you need to substitute it for what your company uses. Use the list below as a template you need to have answered before you continue.
- Ubuntu Server name: srv-nagios
- Internet domain: mydomain.com
- Server domain alias (Windows): work
- Server fully-qualified domain: work.mydomain.com
- Mail Server IP address: 192.168.107.14
- Ubuntu Server IP address: 192.168.107.21
- Ubuntu Server IP subnet mask: 255.255.255.0
- Ubuntu Server IP gateway: 192.168.107.1
- Internal DNS Server 1: 192.168.107.23
- Internal DNS Server 2: 192.168.107.212
- External ISP DNS Server 1: 200.100.10.1
- External ISP DNS Server 2: 200.100.10.2
- External IP to Domain: 198.100.100.100
- Ubuntu Admin ID: administrator
- Ubuntu Admin Password: myadminpass
- Ubuntu Root Password: myrootpass
- Nagios Admin Password: mynagiospass
- Nagios Service Password: myservicepass
Analysis and Design
My company has the following equipment on the network:
- 4 ESXi 4.1 VMware Linux Servers, 64-bit
- 3 Ubuntu Server 10.04.3 LTS, 64-bit
- 3 Windows 2008 Server, 64-bit
- 2 Windows 2008 Server, 32-bit
- 20 Windows 7 PC, 64-bit
- 17 Windows 2003 Server, 32-bit
- 200 Windows XP PC, 32-bit
- 2 Windows 2000 Server, 32-bit
- 40 HP LaserJet Printers
- 30 Extreme Networks' Edge Switches
Since it seems this server will not be growing in size over time, space partitioning is not much of a concern as long as a sufficient amount of room is available. The only thing that needs to be backed up for this server is the configuration files. So once this server is setup and stable, a single backup of the configuration is all that is necessary. I see no reason to maintain an OS or application backup since this is not a high-priority server and will not even require a secondary offsite server. If the server becomes unusable and needs to be replaced, a simple re-install of the OS and application onto a new VM will be sufficient. With that said, I will only be using a default 8 GB partition and will let the OS consume the entire space with a single LVM (Logical Volume Manager).
Virtual Machine Settings
You could install this bare-metal onto a physical box or even run it inside a VM on your desktop using Oracle's VirtualBox but since I have a VMware infrastructure, I will be using VMware as noted below (which shouldn't affect much in the documentation)
Virtual Manager: VMware vSphere Client 4.1
Virtual Host: VMware ESXi Server 4.1
- Configuration: Custom
- Name: srv-nagios
- Datastore: MainOffice-LUN0
- Virtual Machine Version: 7
- Guest Operating System: Linux, Version: Ubuntu Linux (64-bit)
- Number of virtual processors: 1
- Memory Size: 1024 MB
- Number of NICs: 1
- NIC 1: VM Network
- Adapter: E1000, Connect at Power On: Checked
- SCSI controller: LSI Logic Parallel
- Select a Disk: Create a new virtual disk
- Create a Disk: 8 GB, No thin provisioning, No cluster features, Store with the virtual machine
- Advanced Options: Virtual Device Node = SCSI (0:0)
- Remove Floppy Drive
- Mount CD/DVD Drive to Ubuntu ISO (ubuntu-10.04.3-server-amd64.iso). Make sure CD/DVD is set to Connect at power on
- Set boot options to Force BIOS Setup so you can set CDROM to boot before the Hard Disk
The 1st time I installed Ubuntu, I used the console for everything but it was painfully slow to view man (manual) pages and navigating in VI (text editor). However, I found out that PuTTY is a far better solution for your Ubuntu console because it handles the screen draws much faster and allows for scrolling and copying text.
Download the portable edition and run the install...except it doesn't really "install" like a normal program, it simply extracts to a specified folder and will run from that folder even if you put it on a USB stick and carry over to a new computer (requires no install to run and thus leaves a very small footprint on your system)
- Start PuTTY
- Type the following and click the Save button:
Host Name: srv-nagios (or the IP such as 192.168.107.21)
Port: 22
Connection type: SSH
Saved Sessions: srv-nagios - Now all you have to do is double-click on the session name and it will connect to your server (when online).
Last edited by LHammonds on Wed Jan 04, 2012 12:44 pm, edited 1 time in total.
Re: Ubuntu Server 10.04.3 LTS (64-bit) and Nagios Core 3.3.1
Install Ubuntu Server
NOTE: During the setup process, we are going to use the root account to make things easier. Later on, it will be best to use the "sudo" command to only temporarily grant root access rather than logging in with root access.
You will want to be notified via email, pager or text messaging so it is crucial that you add the ability to send mail. Since this is not going to be a mail server, we do not want to complicate matters by trying to install a full mail server like postfix or anything like that. We simply want the ability to send out mail to be processed by an external mail server such as GMail or your own internal mail server such as Zimbra or Microsoft Exchange.
To add a simple mail sending program, typing the following:
If you plan to use GMail as your mail server which requires TLS support, you will need to type the following as well:
You can then test your ability to send email by trying to send yourself some test messages. Here are some samples you can use but be sure to change the values to suit your needs.
For GMail:
This file sharing section is optional but can be handy if you need to swap files between the Linux server and a Windows machine.
This documentation will utilize this share for passing pre-configured files (configs, scripts, etc.) to make it faster/easier during installation.
NOTE: During the setup process, we are going to use the root account to make things easier. Later on, it will be best to use the "sudo" command to only temporarily grant root access rather than logging in with root access.
- Power on the Virtual Machine (VM)
- Press {ENTER} to accept English
- Select Install Ubuntu Server {ENTER}
- Press {ENTER} to accept English
- Press {ENTER} to accept United States
- Select No to not detect keyboard layout
- Press {ENTER} to accept USA
- Press {ENTER} to accept USA
- Type srv-nagios {ENTER} (this is your hostname)
- Press {ENTER} to accept detected time zone (America/Chicago)
- Select Guided - Use entire disk and set up LVM {ENTER}
- Select SCSI3 (0,0,0) (sda) - 8.6 GB VMware Virtual disk {ENTER}
- Select Yes to write changes to disk, {ENTER}
- Press {ENTER} to accept default of 8.3 GB
- Select Yes to write changes to disk, {ENTER}
- Type Administrator, {ENTER} for the full name (NOTE: Do not use "zimbra" as a choice here)
- Press {ENTER} to accept the default of the lowercase name of administrator
- Type myadminpass, {ENTER}, myadminpass, {ENTER}
- Select No, {ENTER} to not encrypt your home directory
- Press {ENTER} to accept a blank line for the HTTP proxy
- Select Install security updates automatically, {ENTER}
- Highlight only OpenSSH server and press {SPACEBAR} to enable, {ENTER} to continue. NOTE: This allows us to use PuTTY after installation to connect to the server.
- Select Yes, {ENTER} to install GRUB boot loader to the master boot record
- Installation Complete - from the VM menu, select VM --> Edit Settings and select CD/DVD Drive 1 and change to "Client Device" which will effectively remove the ISO. Now press {ENTER} to reboot.
- At the console login prompt, login with your administrator account (administrator / myadminpass)
- At the $ prompt, type sudo passwd root {ENTER}, type your administrator password (myadminpass), it will ask for a new password, type myrootpass and verify. NOTE: This enables the root account.
- At the $ prompt, change to the super user root account by typing su {ENTER} and then provide the new root password you just configured.
- Type vi /etc/network/interfaces {ENTER} and change the following: (We need to change the network interface card (NIC) from using DHCP to a static IP) From: [quote]iface eth0 inet dhcp[/quote] To: [quote]iface eth0 inet [b]static address [color=#ff0000]192.168.107.21[/color] netmask [color=#ff0000]255.255.255.0[/color] gateway [color=#ff0000]192.168.107.1[/color] network [color=#ff0000]192.168.107[/color].0 broadcast [color=#ff0000]192.168.107[/color].255[/b][/quote] NOTE #1: You may need to manually remove the DHCP record (lease) associated to this Ubuntu server from your DHCP server so the correct IP can be found by other machines on the network. This can be avoided by temporarily configuring the VM Network Adapter connection to be "Host Only Network" instead of "VM Network" so the server is isolated during setup...at least until you reach the testing of the static IP below. NOTE #2: You might also need to manually add a HOST(A) record to your Windows DNS server (for [color=#ff0000]srv-nagios.mydomain.com[/color] and [color=#ff0000]srv-nagios.work.mydomain.com[/color]) [list]
- Restart the network by typing /etc/init.d/networking restart
- Sanity check! Type ifconfig and make sure the settings are correct. Then type ping google.com or similar and see if ping works.
- Shutdown and power off the server by typing shutdown -P now {ENTER}
- At this point forward, you can use PuTTY to access the console rather than the console itself for better performance, ability to scroll, etc.
- In VM menu, select VM --> Snapshot --> Take Snapshot. Give it a name like STEP 1 and description of Ubuntu Server 10.04.3 LTS, clean install, Static IP: 192.168.107.21 and click OK
- Start the Ubuntu server and connect using PuTTY.
- At the login prompt, login with your administrator account (administrator / myadminpass) and then type su and the root password (myrootpass)
- At the $ prompt, type aptitude -y install vim-nox for use instead of the built-in VI editor. more info
- Type dpkg-reconfigure dash and answer No
- Remove AppArmor to avoid problems by typing the following:
Code: Select all
/etc/init.d/apparmor stop update-rc.d -f apparmor remove aptitude remove apparmor apparmor-utils - Update the repository by typing aptitude update
- Upgrade the server software by typing aptitude -y safe-upgrade
- Reboot the server by typing reboot
You will want to be notified via email, pager or text messaging so it is crucial that you add the ability to send mail. Since this is not going to be a mail server, we do not want to complicate matters by trying to install a full mail server like postfix or anything like that. We simply want the ability to send out mail to be processed by an external mail server such as GMail or your own internal mail server such as Zimbra or Microsoft Exchange.
To add a simple mail sending program, typing the following:
Code: Select all
aptitude -y install sendemailCode: Select all
aptitude -y install libio-socket-ssl-perl libnet-ssleay-perlFor GMail:
For your internal mail server (192.168.107.14):sendemail -f John.Doe@gmail.com -t John.Doe@gmail.com -u "Test Subject" -m "This is only a test." -s smtp.gmail.com -o tls=yes -xu John.Doe -xp MyGMailPassword
Configure Ubuntu for File Sharingsendemail -f "[email protected]" -t "[email protected]" -s 192.168.107.14:25 -u "Test Subject" -m "This is only a test"
sendemail -f "admin <[email protected]>" -t "John Doe <[email protected]>" "Jane Boss <[email protected]>" "Joe Dirt <[email protected]>" -s 192.168.107.14:25 -u "Test Subject" -m "This is only a test"
sendemail -f "admin <[email protected]>" -t "John Doe <[email protected]>" -cc "Jane Boss <[email protected]>" -bcc "Joe Dirt <[email protected]>" -s 192.168.107.14:25 -u "Test Subject" -m "This is only a test"
This file sharing section is optional but can be handy if you need to swap files between the Linux server and a Windows machine.
This documentation will utilize this share for passing pre-configured files (configs, scripts, etc.) to make it faster/easier during installation.
- Start the Ubuntu server and connect using PuTTY.
- At the login prompt, login with your administrator account (administrator / myadminpass) and then type su and the root password (myrootpass)
- Install Samba by typing aptitude -y install samba smbfs (NOTE: To share a folder with Windows, you just need the samba package, to connect to a Windows share, you need both samba and smbfs)
- Type the following commands:
Code: Select all
cp /etc/samba/smb.conf /etc/samba/smb.conf.bak mkdir -p /srv/samba/share chown nobody:nogroup /srv/samba/share/ - Edit the configuration file by typing vi /etc/samba/smb.conf
- Change workgroup = WORKGROUP to workgroup = work (you are using the domain alias)
- Change:
to:
Code: Select all
# security = userCode: Select all
security = user - Add the following section to the end of the file:
Code: Select all
[share] comment = Ubuntu File Server Share path = /srv/samba/share browsable = yes guest ok = yes read only = no create mask = 0755 - Save and exit the file.
- Restart the samba services to utilize the new configuration by typing:
Code: Select all
restart smbd restart nmbd - You should now be able to click Start --> Run and type \\srv-nagios or \\192.168.107.21 {ENTER} and see an explorer window with a Share folder. Drag-n-drop a file into the Share folder. If it worked, it will not display an error message and you should be able to view it from the server by typing ls -l /srv/samba/share/
- Shutdown and power off the server by typing shutdown -P now {ENTER}
- In VM menu, select VM --> Snapshot --> Take Snapshot. Give it a name like STEP 2 and description of Ubuntu Server 10.04.3 LTS, File share configured, Static IP: 192.168.107.21. The Snapshot Manager should now have a nice hierarchy of snapshots (STEP 1 --> STEP 2 --> You are here)
Re: Ubuntu Server 10.04.3 LTS (64-bit) and Nagios Core 3.3.1
Prerequisites
Whenever you make changes, you will need to stop and restart Nagios. Here are the various control commands you will use frequently:
Verify your configuration files:
Manipulate the Nagios service:
Viewing the log file
Viewing the main configuration file
Object configuration files:
- Install the required programs:
Code: Select all
aptitude -y install build-essential php5-gd wget wibgd2-xpm libgd2-xpm-dev - Create users and groups:
Code: Select all
adduser --system --no-create-home --disabled-login --group nagios groupadd nagcmd usermod -G nagcmd nagios usermod -a -G nagcmd www-data
- Download Nagios software (NOTE: You can use newer links once new versions become available):
Code: Select all
cd /opt wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.3.1.tar.gz wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz - Build and install Nagios Core:
Code: Select all
tar -xzvf /opt/nagios-3.3.1.tar.gz cd /opt/nagios ./configure --with-command-group=nagcmd make all make install make install-init make install-config make install-commandmode - Edit the contacts by typing vi /usr/local/nagios/etc/objects/contacts.cfg and change the following:
Code: Select all
define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias John Doe ; Full name of user email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } - Save and close the above file and type the following:
Code: Select all
cd /opt/nagios make install-webconf - Set the nagiosadmin password to mynagiospassword by typing the following:
Code: Select all
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin /etc/init.d/apache2 reload - Build and install the Nagios plugins by typing the following:
Code: Select all
cd /opt tar xzf /opt/nagios-plugins-1.4.15.tar.gz cd /opt/nagios-plugins-1.4.15 ./configure --with-nagios-user=nagios --with-nagios-group=nagios make make install - Ensure Nagios can execute by typing chmod +x /etc/init.d/nagios (NOTE: On this version of Ubuntu and Nagios, it is already set correctly)
- Type the following to avoid startup problems: (NOTE: This is not documented anywhere, it is just my trial, error and observation)
Code: Select all
mkdir -p /usr/local/nagios/var/spool/checkresults chown nagios:nagios /usr/local/nagios/var/spool/checkresults chown nagios:nagios /usr/local/nagios/var/spool chown nagios:nagios /usr/local/nagios/var - Ensure Nagios is started whenever the system boots up:
Code: Select all
/usr/sbin/update-rc.d -f nagios defaults ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios - Check your Nagios configuration file for errors. Look for errors in red.
Code: Select all
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg - NOTE TO SELF: I need to generate (and document) an SSL certificate to enable SSL to protect the password during authentication. Self-Signed Certs
- Type vi /usr/local/nagios/etc/objects/commands.cfg to change both /bin/mail references to match the correct sendemail binary and syntax:
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/sendemail -s 192.168.107.14:25 -f "admin <[email protected]>" -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"
}
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/sendemail -s 192.168.107.14:25 -f "admin <[email protected]>" -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **"
} - Start Nagios for the 1st time.
Code: Select all
/etc/init.d/nagios start - Access the web-based administration utility at http://192.168.107.21/nagios/ (use nagiosadmin for the ID and mynagiospassword for the password)
Whenever you make changes, you will need to stop and restart Nagios. Here are the various control commands you will use frequently:
Verify your configuration files:
Code: Select all
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Code: Select all
/etc/init.d/nagios stop
/etc/init.d/nagios start
/etc/init.d/nagios restart
Code: Select all
vi /usr/local/nagios/var/nagios.logCode: Select all
/usr/local/nagios/etc/nagios.cfgCode: Select all
/usr/local/nagios/etc/objects/commands.cfg
/usr/local/nagios/etc/objects/contacts.cfg
/usr/local/nagios/etc/objects/localhost.cfg
/usr/local/nagios/etc/objects/printer.cfg
/usr/local/nagios/etc/objects/switch.cfg
/usr/local/nagios/etc/objects/templates.cfg
/usr/local/nagios/etc/objects/timeperiods.cfg
/usr/local/nagios/etc/objects/windows.cfg
Last edited by LHammonds on Tue Jan 03, 2012 6:51 pm, edited 1 time in total.
Re: Ubuntu Server 10.04.3 LTS (64-bit) and Nagios Core 3.3.1
Now comes the fun part...tailoring Nagios to your environment!
Configuring the Windows Clients
Before we start configuring Nagios to look at our servers, we need to prep the servers by installing a client service on them to help collect data.
Look at SourceForge.net for the latest Win32 zip file. The version I have and that this documentation is referring to is 0.3.9. This will be much easier to rollout than the MSI file...trust me.
I also do not want the Nagios clients installed on the servers to communicate to anything but the Nagios server and must also use a password for additional security and utilize a non-default port number (anything but 12489)
Now extract the zip file to a folder called "NSClient" (or extract it and then rename the folder). Preferable location would be on your file server where you keep your other software to distribute and is accessible by all servers.
Edit the nsc.ini file.
In the "modules" section, uncomment the 1st block of DLL files by removing the semicolon which should look like this when done:
In the "Settings" section, you need to uncomment "allowed_hosts" and set it equal to your Nagios server's IP address. Also uncomment "password" and set it to myservicepass. It should look something like this:
I am not a fan of default settings so we are going to change the default communication port number from 12489 to 12500. In the "NSClient" section, uncomment "port" and change the value to 12500. Even if you do not change it from the default, you should still uncomment it to ensure it uses that exact port. It should look something like this:
That concludes the changes to the nsc.ini file. Save and close it.
Now create a new text file in the same folder called "service-install.txt" and copy the following into it:
Now create another text file called "service-uninstall.txt" and copy the following into it:
If you cannot see the .txt extension of known files, you might have to change windows to allow you to view the file extensions. This is important because you now need to rename both of those files from .txt to .bat. If you don't know how, then open a command prompt, change to the drive and folder where the files are located and type "ren service-install.txt service-install.bat"
All you have to do now is copy this "NSClient" folder to your server's C: drive (or wherever) and double-click on the "service-install.bat" file to install the service and start it up. No reboot required! If you want to uninstall it from the server, simply double-click the "service-uninstall.bat" which will stop the service and then remove it. You are then free to delete the folder. No reboot required!
The Win32 NSClient folder will work for your 64-bit servers as well. The only problem is if you need to check for the existence of running processes such as Explorer.exe or Notepad.exe which are 64-bit. The Win32 client cannot properly detect 64-bit programs. If this specific case is required, you can instead install the 64-bit MSI installer and manually configure it. NOTE: The 0.3.9 version does not have a 64-bit client, you will need to go back one revision to 0.3.8 to find one.
Nagios Configuration Files
As noted once already, I have several Windows and Linux servers that I will want to monitor. Each will have some common items and many will have unique items to monitor or some degree of variation.
I've opted to organize the structure where each server will have its own configuration file. To make things a bit easier, I will configure Nagios to simply look in a server folder to find all the configuration files rather than listing each one in the main configuration file.
The 1st server I configure will contain the most common aspects to all servers...basically being the most complex. Once configured, I then copy that file to a new server file and change the parts specific to the new server and remove any bits that do not apply.
...WILL COME BACK LATER...
Researching Linux server clients
Configuring the Windows Clients
Before we start configuring Nagios to look at our servers, we need to prep the servers by installing a client service on them to help collect data.
Look at SourceForge.net for the latest Win32 zip file. The version I have and that this documentation is referring to is 0.3.9. This will be much easier to rollout than the MSI file...trust me.
I also do not want the Nagios clients installed on the servers to communicate to anything but the Nagios server and must also use a password for additional security and utilize a non-default port number (anything but 12489)
Now extract the zip file to a folder called "NSClient" (or extract it and then rename the folder). Preferable location would be on your file server where you keep your other software to distribute and is accessible by all servers.
Edit the nsc.ini file.
In the "modules" section, uncomment the 1st block of DLL files by removing the semicolon which should look like this when done:
Code: Select all
[modules]
;# NSCLIENT++ MODULES
;# A list with DLLs to load at startup.
; You will need to enable some of these for NSClient++ to work.
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
; * *
; * N O T I C E ! ! ! - Y O U H A V E T O E D I T T H I S *
; * *
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
CheckWMI.dll
CheckNSCP.dll
;
; Script to check external scripts and/or internal aliases.
;CheckExternalScripts.dll
;
; NSCA Agent if you enable this NSClient++ will talk to NSCA hosts repeatedly (so dont enable unless you want to use NSCA)
;NSCAAgent.dll
;
; LUA script module used to write your own "check deamon".
;LUAScript.dll
;
; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!
;RemoteConfiguration.dll
; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)
;NRPEClient.dll
; Extreamly early beta of a task-schedule checker
;CheckTaskSched.dll
Code: Select all
[Settings]
;# OBFUSCATED PASSWORD
; This is the same as the password option but here you can store the password in an obfuscated manner.
; *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the
; password. Its just a bit harder to do it at first glance.
;obfuscated_password=Jw0KAUUdXlAAUwASDAAB
;
;# PASSWORD
; This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly.
password=myservicepass
;
;# ALLOWED HOST ADDRESSES
; This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons.
; If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password).
; The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access
allowed_hosts=192.168.107.21
;
;# USE THIS FILE
; Use the INI file as opposed to the registry if this is 0 and the use_reg in the registry is set to 1
; the registry will be used instead.
use_file=1
;
; # USE SHARED MEMORY CHANNELS
; This is the "new" way for using the system tray based on an IPC framework on top shared memmory channels and events.
; It is brand new and (probably has bugs) so dont enable this unless for testing!
; If set to 1 shared channels will be created and system tray icons created and such and such...
;shared_session=0
Code: Select all
[NSClient]
;# ALLOWED HOST ADDRESSES
; This is a comma-delimited list of IP address of hosts that are allowed to talk to NSClient deamon.
; If you leave this blank the global version will be used instead.
;allowed_hosts=
;
;# NSCLIENT PORT NUMBER
; This is the port the NSClientListener.dll will listen to.
port=12500
;
;# BIND TO ADDRESS
; Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname.
; Leaving this blank will bind to all avalible IP adresses.
;bind_to_address=
;
;# SOCKET TIMEOUT
; Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out.
;socket_timeout=30
Now create a new text file in the same folder called "service-install.txt" and copy the following into it:
Code: Select all
@ECHO OFF
NSClient++.exe -install
START NET START NSClientpp /WAIT
PAUSE
Code: Select all
@ECHO OFF
START NET STOP NSClientpp /WAIT
NSClient++.exe -uninstall
PAUSE
All you have to do now is copy this "NSClient" folder to your server's C: drive (or wherever) and double-click on the "service-install.bat" file to install the service and start it up. No reboot required! If you want to uninstall it from the server, simply double-click the "service-uninstall.bat" which will stop the service and then remove it. You are then free to delete the folder. No reboot required!
The Win32 NSClient folder will work for your 64-bit servers as well. The only problem is if you need to check for the existence of running processes such as Explorer.exe or Notepad.exe which are 64-bit. The Win32 client cannot properly detect 64-bit programs. If this specific case is required, you can instead install the 64-bit MSI installer and manually configure it. NOTE: The 0.3.9 version does not have a 64-bit client, you will need to go back one revision to 0.3.8 to find one.
Nagios Configuration Files
As noted once already, I have several Windows and Linux servers that I will want to monitor. Each will have some common items and many will have unique items to monitor or some degree of variation.
I've opted to organize the structure where each server will have its own configuration file. To make things a bit easier, I will configure Nagios to simply look in a server folder to find all the configuration files rather than listing each one in the main configuration file.
The 1st server I configure will contain the most common aspects to all servers...basically being the most complex. Once configured, I then copy that file to a new server file and change the parts specific to the new server and remove any bits that do not apply.
...WILL COME BACK LATER...
Researching Linux server clients
Last edited by LHammonds on Wed Jan 04, 2012 6:16 pm, edited 4 times in total.
Re: Ubuntu Server 10.04.3 LTS (64-bit) and Nagios Core 3.3.1
Custom Functions
This post will cover the extra functionality that I added for my shop.
check_https
On one of my Linux servers, I have a web mail service that I wanted to keep an eye on. However, the check_http did not work because the server only uses SSL (HTTPS) on port 443. I did not see a check_https command so I tried my hand at making one and it works like a champ.
Here is how I made and implemented custom HTTPS checking function.
The first thing was to create a script that would communicate to the server. We already have WGET installed as one of the prerequisite programs so I used that program. Here is what the script looks like:
/usr/local/nagios/libexec/check_https
After creating the file, you need to set the correct ownership and permissions as follows:
To test it out, run the command against a server running HTTPS and then against a server not running HTTPS. Example:
Next, we add this script to the commands file. Type vi /etc/local/nagios/etc/objects/commands.cfg
Find the existing "check_http" command and you basically just copy the definition and add "s" to the end of http and remove the "-I" option. Example:
Now we can add a service to monitor HTTPS by adding the following to the server configuration file:
check_mysql
I did not find a MySQL function but a simple TCP test to the MySQL port will work. If your server does not use the default of 3306, be sure to change that in the command.
vi /usr/local/nagios/etc/objects/commands.cfg
Edit your server config file
This post will cover the extra functionality that I added for my shop.
check_https
On one of my Linux servers, I have a web mail service that I wanted to keep an eye on. However, the check_http did not work because the server only uses SSL (HTTPS) on port 443. I did not see a check_https command so I tried my hand at making one and it works like a champ.
Here is how I made and implemented custom HTTPS checking function.
The first thing was to create a script that would communicate to the server. We already have WGET installed as one of the prerequisite programs so I used that program. Here is what the script looks like:
/usr/local/nagios/libexec/check_https
Code: Select all
#!/bin/bash
###########################################
## Name : check_https
## Version : 1.0
## Date : 2012-01-03
## Author : LHammonds
## Purpose : Check for response from HTTPS server
## Requirements : WGET
## Parameters :
## 1 = Server IP Address (Required)
## 2 = Port Number (Optional)
## Exit Codes :
## 0 = Success
## 1 = Failure
## 2 = Error, missing required parameter
###########################################
OUTFILE="/tmp/check_https_out.$$"
ERRFILE="/tmp/check_https_err.$$"
WGETCMD="$(which wget)"
## Do basic check on arguments passed to the script.
if [ "$1" = "" ]; then
echo "Missing required parameter"
exit 2
fi
if [ "$2" = "" ]; then
## Assume default port.
SSLPORT="443"
else
SSLPORT=$2
fi
${WGETCMD} --no-check-certificate --output-document=${OUTFILE} -S https://$1:${SSLPORT} 2> ${ERRFILE}
RETURNVALUE=$?
if [ ${RETURNVALUE} -eq 0 ]; then
echo "HTTPS OK"
EXITCODE=0
else
echo "Connection refused. Code=${RETURNVALUE}"
EXITCODE=1
fi
if [ -f ${OUTFILE} ]; then
rm ${OUTFILE}
fi
if [ -f ${ERRFILE} ]; then
rm ${ERRFILE}
fi
exit ${EXITCODE}
Code: Select all
chown nagios:nagios /usr/local/nagios/libexec/check_https
chmod 0755 /usr/local/nagios/libexec/check_https
Code: Select all
/usr/local/nagios/libexec/check_https 192.168.107.14 443
/usr/local/nagios/libexec/check_https 192.168.107.15 443
Find the existing "check_http" command and you basically just copy the definition and add "s" to the end of http and remove the "-I" option. Example:
Code: Select all
define command{
command_name check_http
command_line $USER1$/check_http -I $HOSTADDRESS $ARG1$
}
define command{
command_name check_https
command_line $USER1$/check_https $HOSTADDRESS 443
}
Code: Select all
define service{
use generic-service
host_name srv-webserver
service_description web mail server
check_command check_https
notifications_enabled 0
}
I did not find a MySQL function but a simple TCP test to the MySQL port will work. If your server does not use the default of 3306, be sure to change that in the command.
vi /usr/local/nagios/etc/objects/commands.cfg
Code: Select all
define command{
command_name check_mysql
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 3306
}
Code: Select all
define service{
use local-service
host_name srv-mysql
service_description MySQL
check_command check_mysql
notifications_enabled 1
}