We are going to install Nagios monitoring tool and Nagat for configuring the nagios sctuff. If you search Sourceforge you will see a few different nagat tools that users have written to do different stuff. I am also going to include the nrpe_nt executable, the wincheck_counter (this does command line perfmons on windows) and a vb script that does services up or down state. The great thing about Nagios is you can make your own Plugins for it etc...
This how-to requires apache and php to be installed and configured correctly!
Get nagios and decompress it.
[quote]tar -zxvf nagios-1.2.tar.gz[/quote]
Make a directory to install Nagios in
[quote]mkdir /usr/local/nagios[/quote]
You need to add the user and group for nagios.
[quote]groupadd nagios
useradd -g nagios nagios
[/quote]
Now lets configure the application for installation.
[quote]./configure --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios/ --with-nagios-user=nagios --with-nagios-grp=nagios[/quote]
You should see this output:
[quote]*** Configuration summary for nagios 1.2 02-02-2004 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Embedded Perl: no
Install ${prefix}: /usr/local/nagios
Lock file: ${prefix}/var/nagios.lock
Init directory: /etc/rc.d/init.d
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios//
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute
External Data Routines:
------------------------
Status data: Default (text file)
Object data: Template-based (text file)
Comment data: Default (text file)
Downtime data: Default (text file)
Retention data: Default (text file)
Peformance data: Default (external commands)
Extended info data: Template-based (text file)
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
continue installation:
make all
make install
You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install-init
- This installs the init script in /etc/rc.d/init.d
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
[/quote]
Next you have to do the following as it states from the output above.
[quote]make all
make install
make install-init
make install-commandmode
make install-config[/quote]
The command "make install-config" installs sample config scripts in [quote]/usr/local/nagios/etc[/quote]
You need to make the directory read write so you can edit the files with the Nagat configuratoin tool.
[quote]cd /usr/local/nagios
chmod 777 etc -R (this is so nagat can write the config files)
[/quote]
Now you need to edit Apache.
[quote]vi /usr/local/apache/conf/httpd.conf[/quote]
Now insert the following under ScriptAlias.
[quote]#for nagios
ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/
<Directory "/usr/local/nagios/sbin/">
AllowOverride AuthConfig
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
Alias /nagios/ /usr/local/nagios/share/
<Directory "/usr/local/nagios/share">
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
Alias /nagiosadmin/ /usr/local/apache/htdocs/nagat/
<Directory "/usr/local/apache/htdocs/nagat/">
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
[/quote]
Now you can check the nagios config from the terminal. I like using the tool in Nagat that does the same thing so you can see it in a webpage.
[quote]/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg[/quote]
You can put security on each section of the reporting tool to limit access to it. This is stored in CFG.CGI file.
[quote]htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin[/quote]
Enter the password when asked. now lets put the .htaccess files in the directories for security.
[quote]vi /usr/local/nagios/share/.htaccess
vi /usr/local/nagios/sbin/.htaccess
[/quote]
Enter in this in the .htaccess file.
[quote]AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user
[/quote]
Now it is time to install the nagios plugin so you can actually monitor stuff. These are some of the generic default monitoring scripts for like Oracle or cpu etc..
The app is "nagios-plugins-1.4.0alpha1.tar"
[quote]tar -zxvf nagios-plugins-1.4.0alpha1.tar[/quote]
Now lets compile the plugin.
[quote]./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-cgiurl=/nagios/cgi-bin[/quote]
OK you know the drill with make and make install.
[quote]make
make install
[/quote]
Now if you use Nagat you have to do chmod 777 on the directory with the executable.
[quote]chmod 777 /usr/local/nagios/var/rw/ -R[/quote]
You need to do the same thing for hte nagios execuable too.
[quote]chmod 777 /usr/local/nagios/bin/ -R[/quote]
Now lets install NRPE 2.0 so you can execute remote commands on another machine. nrpe-2.0.tar.gz
[quote]tar –zxvf nrpe-2.0.tar.gz[/quote]
Now lets configure the app.
[quote]./configure
make all
[/quote]
Ok we have to copy it to the directory so Nagios can execute it.
[quote]cp /src/check_nrpe /usr/local/nagios/libexec/ [/quote]
You will see other plugins in the directory above and you can test them from shell.
Copy wincheck_counter.exe and *.dll to widows box and edit the nrpe.cfg file and change these lines: You have to change the local ip or the nagios service will not start on the windows box.
[quote]server_address=<localhost ip>
allowed_hosts=<nagios server ip>
dont_blame_nrpe= to 1
debug= to 0 unless you want the eventlog to go crazy
[/quote]
Here are some samples of monitoring stuff you can do with the counter.
[quote]# General Health
command[check_gen_sut]=C:\winnt\wincheck\wincheck_counter -C "System" -P "System Up Time" -f "System Up Time is %f Seconds"
command[check_gen_prq]=C:\winnt\wincheck\wincheck_counter -C "System" -P "% Registry Quota in use" -w 75 -c 85 -f "Registry Quota in use is %f%%"
# Processor Health
command[check_proc_tpt]=C:\winnt\wincheck\wincheck_counter -C "Processor" -I "_Total" -P "% Processor Time" -w 70 -c 85 -f "Processor Time is %f%%"
command[check_proc_pql]=C:\winnt\wincheck\wincheck_counter -C "System" -P "Processor Queue Length" -w 80 -c 90 -f "Processor Queue Length is %f"
command[check_proc_ppt]=C:\winnt\wincheck\wincheck_counter -C "Processor" -I "_Total" -P "% Privileged Time" -w 20 -c 25 -f "Processor Privileged Time is %f%%"
command[check_proc_dpt]=C:\winnt\wincheck\wincheck_counter -C "Processor" -I "_Total" -P "% DPC Time" -w 40 -c 50 -f "Deferred Procedure calls is %f%%"
# Memory Health
command[check_mem_pps]=C:\winnt\wincheck\wincheck_counter -C "Memory" -P "Pages/sec" -c 50 -w 25 -f "Pages per second is %f"
command[check_mem_fps]=C:\winnt\wincheck\wincheck_counter -C "Memory" -P "Page Faults/sec" -w 50 -c 100 -f "Page Faults per second is %f"
command[check_mem_pfu]=C:\winnt\wincheck\wincheck_counter -C "Paging File" -I "_Total" -P "% Usage" -w 65 -c 71 -f "Paging File Usage is %f%%"
# Disk Health
command[check_disk_c]=C:\winnt\wincheck\wincheck_counter -C "LogicalDisk" -I "C:" -P "% Free Space" -w 20 -c 10 -f "Disk C is %f%% free."
command[check_disk_pdt]=C:\winnt\wincheck\wincheck_counter -C "PhysicalDisk" -I "_Total" -P "% Disk Time" -w 40 -c 50 -f "%% Disk Time is %f"
command[check_disk_rql]=C:\winnt\wincheck\wincheck_counter -C "PhysicalDisk" -I "_Total" -P "Avg. Disk Read Queue Length" -w 1 -c 2 -f "Avg. Read Queue Length is %f"
command[check_disk_wql]=C:\winnt\wincheck\wincheck_counter -C "PhysicalDisk" -I "_Total" -P "Avg. Disk Write Queue Length" -w 1 -c 2 -f "Avg. Write Queue Length is %f"
# Exchange 5.5
command[msexchangeimc_que_out]=C:\winnt\wincheck\wincheck_counter -C "MSExchangeIMC" -P "Queued Outbound" -w 200 -c 250 -f "Queued Outbound is %f Emails Waiting for Delivery"
[/quote]
Now to get nrpe to work you have to do these to manually. In /usr/local/nagios/etc/ edit these two files for check_nrpe to work with windows perfmons.
[quote]Checkcommands.cfg
define command {
command_name check_nrpe
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
Services.cfg (examples)
define service {
host_name exchange
service_description check_disk_c
check_command check_nrpe!check_disk_c
use generic-service
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
check_period 24x7
notification_interval 0
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
}
[/quote]
I will try to attach the applications and the custom tools plus my config files so you do not have to reinvent the wheel on you're hosts, services, etc.. files. The file is 2.6 megs.
Strabo