Monday, July 26, 2010

Install Monitor Plugins for CACTI

Plugins Monitor for Cacti
Requirement :
- Cacti is running
- Download plugin monitor
http://cactiusers.org/downloads/monitor.tar.gz
- Download Plugin Architecture
http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7d-PA-v2.4.zip


Install Plugin Architecture
---------------------------
# mkdir /var/www/cacti/plugins

mode 1:

# cd /tmp/
# ftp -a http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7g-PA-v2.8.tar.gz
# tar -zxvf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
# cd cacti-plugin-arch
# cp cacti-plugin-0.8.7g-PA-v2.8.diff /var/www/cacti/
# cd /var/www/cacti/
# patch -p1 -N < cacti-plugin-0.8.7g-PA-v2.8.diff 

Mode 2: 

# cd /tmp/ 

# ftp -a http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7g-PA-v2.8.tar.gz 

# tar -zxvf cacti-plugin-0.8.7g-PA-v2.8.tar.gz 

# cd cacti-plugin-arch

# cd files-0.8.7g 

# cp -R include/ /var/www/cacti/include

# cp -R lib/ /var/www/cacti/lib 

# cp -R plugins/ /var/www/cacti/plugins

# cp *.php /var/www/cacti/


Import pa database

#mysql -u root -p cacti < /tmp/cacti-plugin-0.8.7g-PA-v2.8/files-0.8.7g/pa.sql



Install Plugin Monitor
----------------------

# cd /tmp/
# ftp -a http://cactiusers.org/downloads/monitor.tar.gz
# tar -zvxf monitor.tar.gz
# mkdir /var/www/cacti/plugins
# mv monitor /var/www/cacti/plugins/
# vi /var/www/cacti/include/configl.php

edit + add as below, adjust with your cacti :

/* Default database settings*/
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactipassword";
$database_port = "3306";

$plugins = array();
$plugins[] = 'monitor';

$config['url_path'] = '/cacti/';


Import database plugin monitor

# mysql -u root -p cacti < /var/www/cacti/plugins/monitor/monitor.sql finish and the screenshoot should like this:



Change poller interval from per 5 minutes to 1 minute - Cacti

Data sourcers -> RRAs -> add "Hourly (1 Minute Average)"
select "average" and "max"
x-files: 0.5
Steps: 1
Rows: 500
Timespan: 14400

It just works
don't forget to add "hourly" to "Associated RRA's" for each data source (templates) and delete the old .rrd files.
In Data sources (templates): Step must be 60 and Heartbeat should be 120.

edit crontab
/etc/crontab
*/5***** to */1******

edit
console>setting>poller
change cron interval to "every minute"

Instal Cacti on OpenBSD


This is the step for installing cacti on openbsd.
I`m use OpenBSD 4.7 on VMWare Workstation 7 in Windows Desktop.


1. instal the package
Set the package PATH
#export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.7/packages/i386/


   Package needed for OpenBSD :


  • rrdtool
  • apache-httpd
  • net-snmp
  • mysql-server
  • php5-core
  • php5-mysql
  • php5-snmp
Instal following package (ports) needed for OpenBSD
#pkg_add rrdtool net-snmp php5-core php5-snmp apache-httpd

Instal MYSQL-SERVER
# pkg_add mysql-server

Create the Default Database
# /usr/local/bin/mysql_install_db
Start the database server
# /usr/local/bin/mysqld_safe >/dev/null 2>&1 &
Set the passwords
#/usr/local/bin/mysqladmin -u root password 'new-password'
You should replace "new-password" with an actual one.

Instal PHP
# pkg_add php5-mysql

This will automatically backtrack and install PHP5 itself.

Then ...

# ln -s /var/www/conf/modules.sample/php5.conf /var/www/conf/modules

# ln -fs /var/www/conf/php5.sample/mysql.ini /var/www/conf/php5/mysql.ini

Then you have to modify /var/www/htdocs/httpd.conf
to include php files as usable index files Apache.
In /var/www/conf/httpd.conf, enter, find where it says:

DirectoryIndex index.html

And change it to

DirectoryIndex index.html index.php

and uncomment the following line:

AddType application/x-httpd-php .php

Instal PHPMYADMIN
# pkg_add -v phpMyAdmin

The the soft links-
# ln -fs /var/www/conf/php5.sample/gd.ini /var/www/conf/php5/gd.ini

# ln -fs /var/www/conf/php5.sample/mbstring.ini /var/www/conf/php5/mbstring.ini

# ln -fs /var/www/conf/php5.sample/mcrypt.ini /var/www/conf/php5/mcrypt.ini

# ln -fs /var/www/conf/php5.sample/mysql.ini /var/www/conf/php5/mysql.ini

# ln -s /var/www/phpMyAdmin/ /var/www/htdocs/phpmyadmin

Edit the /var/www/phpMyAdmin/config.inc.php file
so that the blowfish secret is set to whatever you want,
and the username and password for the server are set
to whatever you configured for access in the MySQL installation.
This will also act as the authentication into phpMyAdmin as well.
Then restart Apache.

2. Starting the apache

# apachectl start

if you want to verify that php is actually working after getting apache running:

Open http://yourserver ip/ in your favorite web browser.

3. Install cacti
download cacti from http://cactiusers.org/downloads/

# cd /var/www
# ftp -a http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
# tar -xzvf cacti-0.8.7g.tar.gz

Add a couple useful links for the inevitable, if infrequent, update:

# cd /var/www
# ln -s cacti-0.8.7g cacti
# cd /var/www/htdocs
# ln -s ../cacti cacti

4. Database Setup
Create the database and setup MySQL authentication.

# cd cacti-0.8.7g
# mysql -u root -p 
mysql>create database cacti;
mysql>exit
# mysql -u root -p cacti < cacti.sql
# mysql -u root -p cacti
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
mysql> flush privileges;

if failed to load cacti.sql to cacti database,
open http://yourserver-ip/phpmyadmin/

create database named "cacti" , then
back to OpenBSD root command

# mysql -u root -p cacti < cacti.sql
# mysql -u root -p cacti
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
mysql> flush privileges;

Edit include/config.php and specify the database type, name, host, user and password
for your Cacti configuration.

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "somepassword";

5. System User
Create a system user to run the cron jobs and own the rra and log files,
then set the appropriate permissions on cacti's directories for graph/log generation.

# useradd -u900 -g=uid -c "Cacti user" -d /var/empty -s /sbin/nologin _cacti
# chown -R _cacti rra/ log/

Add a line to your /etc/crontab file similar to:

*/5 * * * * _cacti /usr/local/bin/php /var/www/cacti/poller.php > /dev/null 2>&1

add following line in /etc/rc.conf.local
httpd_flags="-u"


6. Jump into cacti

Point your web browser to: http://yourserver-ip/cacti/. Follow the prompts from there.