Analyzing Apache Log Files

List Client IP and Count Hits

awk -F'[ “]+’ ‘$7 == “/” { ipcount[$1]++ } END { for (i in ipcount) { printf “%15s – %d\n”, i, ipcount[i] } }’ access.log

 

List Client IP and RDNS

cat access.log | awk ‘{print $1}’ | logresolve

Installing packages in Ubuntu from cdrom (no Internet)

In many cases, the dev class vm’s do not have Internet access (annoying) so you cannot install software vi the Internet.

Mount the ISO in the VM.

On the server run the following command:

sudo mount /dev/sr0 /cdrom

ensure that only the following line is uncommented in /etc/ap[t/sources.list

deb cdrom:[Ubuntu-Server 10.04 LTS _Lucid Lynx_ – Release amd64 (20100427)]/ lucid main restricted

Run sudo apt-get update to update the repository. Then install what you need.

A wrapper for grabbing performance info from Nagios plugin

check_procs is an example for a plugin which doesn’t deliver performance data:

./check_procs -a apache2 -w 1: -c 0:
PROCS OK: 33 processes with args ‘apache2’

This can be changed with the following wrapper script:

#!/bin/bash
LINE=`/usr/local/nagios/libexec/check_procs $*`
RC=$?
COUNT=`echo $LINE | awk '{print $3}'`
echo $LINE \| procs=$COUNT
exit $RC

Now you’ll get the number together with the required label:

PROCS OK: 33 processes with args ‘apache2’| procs=33

SeleniumHQ Server on Nagios/Linux Host

These commands are tailored for a nagios installation.

Starting the selenium rc:

java -jar /usr/local/nagios/libexec/selenium/selenium-server.jar -firefoxProfileTemplate /usr/local/nagios/libexec/selenium/ff_selenium/

Sample nagios check command:

 

./check_selenium com.example.tests.someWebsiteCom http://some.website.com*firefox

Schedule:

Currently, login test is every hour.

nagios-check-webpage

This is a ruby script that can download a web page. Source here:

http://code.google.com/p/nagios-check-webpage/

Installation:

Prerequisites:

apt-get install ruby rubygems

gem update

apt-get install ruby1.8-dev

gem install hpricot

apt-get install libopenssl-ruby

 

Nagios Check Command:

define command{
        command_name    check-webpage
        command_line    $USER1$/check_webpage.rb -u $HOSTADDRESS$$ARG1$
        }