top

Omonitor - Installation

Updated 2009-05-03 by Oles Hnatkevych

Installing server (on Unix)

If you have a small network, then using xinetd service will be enough. Comparing to old inetd new xinetd can provide ip-address of remote host, and has more flexible configuration.

That is how I do this.

Preparation

Make sure you have xinetd, apache, mysql or sqlite3, fping, php (pcre, pdo_mysql or pdo_sqlite, sockets, posix, pcntl, date; list of loaded modules you can find running 'php -m')

Unpacking

Add a new user account to run omonitor and unpack archive:
adduser -m omonitor 	# linux
# or
pw useradd omonitor -m	# freebsd

su - omonitor
tar xvzf /path/to/omonitor.tar.gz
cd omonitor/etc/

Preparing database

MySQL is preffered as I experienced problems with Sqlite3 handling simultaneous updates for some reason.

mysql:

mysql> CREATE DATABASE omonitor DEFAULT CHARACTER SET utf8;
mysql> GRANT all ON omonitor.* to omonitor@localhost IDENTIFIED BY 'somepassword';
sqlite:
cd ~omonitor
mkdir data/
chmod g+w data/ # make this folder writable by httpd or apache user! use chgrp or whatever

Configure server

Create etc/server.inc.php
<?
$WEBURL="http://www.yourhost.com/omonitor/";

// path to mysql socket depends on your OS/distribution
$PDO_DSN="mysql:unix_socket=/tmp/mysql.sock;dbname=omonitor";
$PDO_USER='omonitor';
$PDO_PASSWORD='somepassword';

/*
// if you use sqlite then use these lines
$DATABASE="/home/omonitor/data/data-sqlite";
$PDO_DSN="sqlite:$DATABASE";
$PDO_USER='';
$PDO_PASSWORD='';
*/
?>

Create database

This script will create all tables also check that all needed php modules are available.
cd /path/to/bin/
php setup.php init

Configure agent

Create etc/localhost
SERVERS="localhost"
PHP="/usr/bin/php"
# or
PHP="/usr/local/bin/php" # for freebsd users

Configure server basic checks

Create etc/clients
[/.*/]
UP      1h
LOAD    5.0 10.0
DISK    * 90 95

Configure server pinger

Create hosts with list of hostnames you want to ping for connectivity test
first.host.name
second.host.name
# ...

Configure cron for server

Add to crontab:
*/5 * * * * omonitor /bin/sh /path/to/bin/server urlchecker pinger cleaner

Configure server to accept client connections

You have two choices: xinetd service or a standalone daemon. Daemon has to be restarted when you change php configuration, xined service does not. Daemon has to be started when your system comes up, xined service does it by itself. Daemon should handle lot of connections better.

Configure server as a standalone daemon

FreeBSD:
cp /path/to/etc/freebsd-omonitor.sh /usr/local/etc/rc.d/omonitor.sh
chmod +x /usr/local/etc/rc.d/omonitor.sh
vi /usr/local/etc/rc.d/omonitor.sh # fix user and path
/usr/local/etc/rc.d/omonitor.sh start
... or

Configure server as a xinetd service

Create xinted service (put to /etc/xinetd.d/omonitor):
service omonitor
{
	type            = UNLISTED
	socket_type     = stream
	port            = 1975
	protocol        = tcp
	wait            = no
	user            = somebody
	server          = /usr/bin/php
	server_args     = /path/to/bin/acceptor.php
	disable         = no
	instances       = 100
	cps             = 1000 1
}
Then make xinetd reload config
killall -1 xinetd

Configure apache

Add to Apache config:
Alias /omonitor /path/to/omonitor/www
<Directory /path/to/omonitor/www>
	Allow from all
	Allow override all
	DirectoryIndex index.php
</Directory>
Then restart Apache.

Test it out

Go to http://www.yourhost.com/omonitor/. Look for logs/server.log for the problems.

Configure it further

Customize etc/clients, etc/alerts to your needs.



Installing agent on Unix

Unpacking

If you have not unpacked it when configure server, then to it as described in server installation.

Configuring

Create (or add to) localhost
SERVERS="server.host.name"
#SERVERS="localhost"

Configuring cron to run agent

Add to crontab
*/5 * * * * omonitor /bin/sh /path/to/bin/client proc disk cpu dmsg


Installing agent on Windows

Unpacking

Put somewhere the win/ subfolder from omonitor archive to windows box that is running 24x7 and is domain member

Install and configure PHP

Get latest php and pecl installation for windows; at the time of writing they are
php-5.2.8-Win32.zip and pecl-5.2.6-Win32.zip. Unpack php zip to c:\php\ and pecl zip (php_win32service.dll is enough) to c:\php\ext\. Add path c:\php to PATH environment (my computer-properties-additional-environment variables)

Copy c:\php\php.ini-recommended to c:\php\php.ini and make sure it has

short_open_tag = On
error_reporting  =  E_ALL & ~E_NOTICE
register_globals = Off
register_argc_argv = On
extension=php_sockets.dll
extension=php_win32service.dll
com.allow_dcom = true

Configure omonitor windows agent

Create omon.config.php in the folder you unpacked:
<?
//$DOMAIN = "domain.name";// if you have Active Directory
$DNSDOMAIN = "domain.name"; // if your DNS is not Active Directory
$SERVER = "server.host.name";
//$DEBUG=false;
?>
Create file stations with list of hosts and tests for them:
some-pc-host proc disk
# another-host.domain.name proc disk

Test it

Test it out running php run-all-tests.php

Register as a service

Run php omon-service.php register then run services.msc and setup service account that may query domain members for WMI data. Start the service.