Nagios web service monitoring
Install new Solaris container
Compile and install..
GD, PNG Library, Jpeg Library, zlib, Nagios core v2.0, Nagios Plugins
Lots of information about Nagios can be found at http://www.nagios.org/docs/
Configure default Solaris 10 apache (rename the template in /etc/apache to httpd.conf)
Add Alias for /nagios/ and ScriptAlias for /nagios/cgi-bin - Nagios was installed to /usr/local/nagios ($NAGIOSHOME)
/etc/apache/httpd.conf
ScriptAlias /nagios/cgi-bin/ "$NAGIOSHOME/sbin/"
Alias /nagios/ "$NAGIOSHOME/share/
AllowOverride AuthConfig order allow,deny allow from all Options ExecCGI AllowOverride AuthConfig order allow,deny allow from all Options ExecCGI
Create .htaccess files in share and sbin..
AuthName "Nagios Access"
AuthType Basic
AuthUserFile $NAGIOSHOME/etc/htpasswd.users
require valid-user
$APACHEHOME/bin/htpasswd -c $NAGIOSHOME/etc/htpasswd.users nagiosadmin
Add a group and user for Nagios
groupadd nagios
useradd -d $NAGIOSHOME -g nagios -s /bin/false -m nagios
Building Nagios
./configure --prefix=$NAGIOSHOME --with-nagios-user=nagios --with-nagios-grp=nagios --with-gd-inc=/usr/local/include --with-gd-lib=/usr/local/lib
make
make install
make install-init
Testing the Nagios configuration
$NAGIOSHOME/bin/nagios -v $NAGIOSHOME/etc/nagios.cfg
Stopping / Starting / Restarting Nagios
/etc/init.d/nagios stop | start | restart
Nagios configuration
Configuration files are located in /usr/local/nagios/etc
The only three used are nagios.cfg, cgi.cfg and minimal.cfg.
Nagios.cfg is the global configuration file. This allows splitting out configuration for hosts, services, escalations etc. To remove this complexity all includes were commented out except minimal.cfg.
Minimal.cfg holds all of the configuration for the hosts, services and notifications.
Cgi.cfg is modified to allow users access to the cgi pages.
Contact configuration
define contact{
contact_name nagios-admin
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email admin@example.com
}
Command configuration
define command {
command_name webinject
command_line /usr/local/bin/perl $USER1$/webinject.pl -c $ARG1$ $ARG2$
}
Host configuration
define host{
use generic-host
host_name www
alias www
address x.x.x.x
check_command check_http
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,r
contact_groups admins
}
Service configuration
define service{
use generic-service
host_name www
service_description Check http
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command check_http
}
define service{
use generic-service
host_name www
service_description Login
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command webinject!config.xml!1.xml
}
define service{
use generic-service
host_name www
service_description Second page
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command webinject!config.xml!2.xml
}
define service{
use generic-service
host_name www
service_description Third page
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command webinject!config.xml!3.xml
}
WebInject setup
WebInject is a perl script which uses a global config file and separate testcase files to perform html testing.
Lots more information can be found for webinject here http://www.webinject.org/manual.html
The following perl modules are needed:
LWP
HTTP::Cookies
HTTP::Request::Common
Time::HiRes
Getopt::Long;
Error
XML::Parser
XML::Simple
Crypt::SSLeay*
These can be installed via cpan (run cpan and type ‘install module’)
Global configuration
Config.xml
<testcasefile>1.xml</testcasefile>
<useragent>WebInject Application Tester</useragent>
<timeout>60</timeout>
<reporttype>nagios</reporttype>
Testcase configuration
1.xml<testcases repeat="1">
<case
id="1"
description1="Connecting to www"
method="get"
url="https://www.example.com"
logrequest="yes"
logresponse="yes"
/>
<case
id="2"
description1="Connection"
method="get"
url="https://www.example.com/login.jsp"
verifypositive="User Login"
errormessage="Unable to connect to the first login page"
logrequest="yes"
logresponse="yes"
/>
<case
id="3"
description1="Authentication"
method="post"
url="https://www.example.com/login.jsp"
postbody=”&user=test&password=test"
verifypositive="Menu"
errormessage="Unable to authenticate user test at www"
logrequest="yes"
logresponse="yes"
/>
</testcases>
