deployingcactiandphpweathermap_11dec2012
TRANSCRIPT
-
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
1/11
CareNet 2012, Deploying Cacti and PHP Weathermap | Victor Tsarinenko, [email protected] 1 of 11
Deploying Cacti and PHP Weathermap
Project owners:
Kristina Groth
Sven Jonsson
Peter Sjdin
Coaches:
Siraj Rathore
Voravit Tanyingyong
Experts:
Ola Gran
Robert Olsson
Bjrn Pehrson
Bernt Sundstrm
Team members:
Axel Fant Eldh [email protected]
Ruslan Mukhammadov [email protected]
Victor Tsarinenko [email protected]
Nikolaos Roumpoutsos [email protected]
Denys Knertser [email protected]
Ioannis Sapountzis [email protected]
Razvan Popescu [email protected]
-
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
2/11
CareNet 2012, Deploying Cacti and PHP Weathermap | Victor Tsarinenko, [email protected] 2 of 11
ContentsContact .............................................................................................................................................................................. 3
Purpose of this document ..................................................................................................................................... 3
Revision history........................................................................................................................................................... 3
Intro .................................................................................................................................................................................... 4
Installing Cacti .............................................................................................................................................................. 4
Installing Cacti plugin architecture ............................................................................................................ 5
Installing the Weathermap plugin............................................................................................................... 6
Making it all work together ............................................................................................................................. 6
Adding devices, graphs, maps............................................................................................................................. 9
Summary....................................................................................................................................................................... 10
References ................................................................................................................................................................... 11
-
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
3/11
CareNet 2012, Deploying Cacti and PHP Weathermap | Victor Tsarinenko, [email protected] 3 of 11
Contact
Name: Victor Tsarinenko
Email: [email protected]
Purpose of this document
This document describes the installation procedure of Cacti - network graphing system,
and steps required to configure and run it together with PHP Weathermap plugin which
helps with network visualization.
Revision history
Version 1.0 December 8, 2012
Original document
-
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
4/11
CareNet 2012, Deploying Cacti and PHP Weathermap | Victor Tsarinenko, [email protected] 4 of 11
Intro
Cacti provides means of collecting network statistics and representing this data on
graphs. [1] Cacti is based on the RRDTool [2] for collecting and storing the data. Within
CareNet project Cacti is used mainly to collect and store statistics of the router
interfaces and the average load on the routers. Power monitoring solution forResidential Gateways [3] is also based on Cacti. The Weathermap plugin is used to
create visual map of the core CareNet network. [4]
Installing Cacti
Installation of Cacti under Ubuntu server 12.04 x64 is pretty straightforward; however,
in order for the Weathermap plugin to work one will need to install Cacti plugin
architecture. Plugin architecture enables support for various plugins developed for
Cacti. If you dont like the idea of installing Plugin architectures manually you can follow
the Easy install how-to from Cacti forums, which describes how to add the specific
repositories containing the package. [5] This report will describe manual installation of
Cacti plugin architecture.
To install cacti run:
# apt-get update
# apt-get install cacti
This will install Cacti v.0.8.7h (the version available at the time of writing thisdocument) together with the required packages, including MySQL, PHP, Apache (or
another web server), and several libraries. The install will require some space on the
hard drive so make sure to run your installation on a host with enough space.
During the installation you will be asked to set the root password for MySQL, make sure
to use strong passwords. A warning message regarding the incorrect path for the adodb
php library may pop up; we will correct the path later manually. If you already run
Apache on your host then the choice for the web server is obvious, however, if you want
to use another web server you can do so, for our install we use Apache. Use dbconfig toconfigure the database unless you really know what you are doing. At the final step of
the installation you will have to create a database for cacti: type the root password you
created in earlier, and then create a password for the cacti database. The configuration
file for these parameters will be then located at /usr/share/cacti/site/include/config.php.
Cacti installation at the OS level is finished now, you can proceed to running the web
based Cacti setup script, which will configure the web user interface and setup database
connection; but if you want to run the plugin architecture, install it before proceeding to
web based setup.
-
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
5/11
CareNet 2012, Deploying Cacti and PHP Weathermap | Victor Tsarinenko, [email protected] 5 of 11
Installing Cacti plugin architecture
Download the latest plugin architecture from http://www.cacti.net/downloads/pia/ .
The version used for the project is 0.8.7h:
# wgethttp://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz
Untar the archive:
# tar xzf cacti-plugin-0.8.7h-PA-v3.0.tar.gz
# cd cacti-plugin-arch/
Now copy the contents of the files/ directory, the patch, and the pa.sql file from the
archive to the directory with Cacti installed:
# cp -r files/* /usr/share/cacti/site/
# cp cacti-plugin-0.8.7h-PA-v3.0.diff /usr/share/cacti/site/
# cp pa.sql /usr/share/cacti/site/
# cd /usr/share/cacti/site
Apply the patch:
# patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff
Add the database changes:
# mysql -u cacti -p cacti < pa.sql
Here, -u specifies the username for the database, which is cacti in our case, -p key
instructs mysql utility to prompt for the password, and cactiis the database name.
Next correct the paths in Cacti configuration file:
# nano include/global.php
# change the URL-path:# $url_path = ;
# to
$url_path = /cacti/;
# rra files path:
# change $config["rra_path"] = $config["base_path"] . /rra;
# to
$config["rra_path"] = /var/lib/cacti/rra;
# change the adodb module path:
# include_once($config["library_path"] . /adodb/adodb.inc.php);
# to
include_once(/usr/share/php/adodb/adodb.inc.php);
http://www.cacti.net/downloads/pia/http://www.cacti.net/downloads/pia/http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gzhttp://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gzhttp://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gzhttp://www.cacti.net/downloads/pia/ -
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
6/11
CareNet 2012, Deploying Cacti and PHP Weathermap | Victor Tsarinenko, [email protected] 6 of 11
Installing the Weathermap plugin
Tell Cacti to enable the plugin architecture and weathermap plugin (the plugin will be
installed during the next step) by adding the following lines to config.php file:
# nano include/config.php$plugins = array();
$plugins[] = 'weathermap';
Once the plugin architecture is enabled, proceed with installation of the actual plugins.
To install the Weathermap plugin download the package from http://www.network-
weathermap.com/download:
# cd
# wgethttp://www.network-weathermap.com/files/php-weathermap-0.97a.zip
Install the unzip utility (for the sake of simplicity):
# apt-get install unzip
Unzip and copy the plugin to /usr/share/cacti/site/plugins:
# unzip php-weathermap-0.97a.zip
# cp -r weathermap /usr/share/cacti/site/plugins
Making it all work together
Now, it is time to run the Cacti web based setup. Go to http://yoursite/cacti. Most
probably you will see the following message:
# FATAL: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified
a valid MySQL database name in 'include/config.php'
This is due to the incorrect username and password settings in the config.php file (will
most likely appear after patching and installing plugin architecture). To correct the
issue perform the following:
# cd /usr/share/cacti/site
# nano include/config.php
# supply the correct values you used during the setup here:
# $database_username = "cacti";
# $database_password = "cacti";
Now, the http://yoursite/cacti should point to the first run setup dialog or Cacti
Installation Guide. Go ahead and click Next. Choose the New Install at the next
screen. The setup will check if you have all the necessary components for the system.Click Finish to deploy the configuration.The next screen is the standard login screen
http://www.network-weathermap.com/downloadhttp://www.network-weathermap.com/downloadhttp://www.network-weathermap.com/downloadhttp://www.network-weathermap.com/downloadhttp://www.network-weathermap.com/files/php-weathermap-0.97a.ziphttp://www.network-weathermap.com/files/php-weathermap-0.97a.ziphttp://yoursite/cactihttp://yoursite/cactihttp://yoursite/cactihttp://yoursite/cactihttp://yoursite/cactihttp://yoursite/cactihttp://www.network-weathermap.com/files/php-weathermap-0.97a.ziphttp://www.network-weathermap.com/downloadhttp://www.network-weathermap.com/download -
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
7/11
-
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
8/11
CareNet 2012, Deploying Cacti and PHP Weathermap | Victor Tsarinenko, [email protected] 8 of 11
Then enable access to the editor.php file in web server configuration:
# nano /etc/apache2/conf.d/cacti.conf
# add the following:
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Restart the Apache server for the changes to take effect:
# service apache2 restart
Now the editor should be accessible via web interface: weathermap tab -> editor or
(http://yoursite/cacti/plugins/weathermap/editor.php).
If you use the same versions of the packages as described in this guide, you will end up
without required tables in the cacti database for the weatermap plugin. It has to be
added manually. The easiest way is to create a file with the following content:
# nano weathermap.sql
CREATE TABLE weathermap_maps (
id int(11) NOT NULL auto_increment,
sortorder int(11) NOT NULL default 0,
group_id int(11) NOT NULL default 1,
active set('on','off') NOT NULL default 'on',
configfile text NOT NULL,
imagefile text NOT NULL,
htmlfile text NOT NULL,
titlecache text NOT NULL,
filehash varchar (40) NOT NULL default '',
warncount int(11) NOT NULL default 0,
debug set('on','off','once') NOT NULL default 'off',
runtime double NOT NULL default 0,
lastrun datetime,
config text NOT NULL default '',
thumb_width int(11) NOT NULL default 0,
thumb_height int(11) NOT NULL default 0,
schedule varchar(32) NOT NULL default '*',
archiving set('on','off') NOT NULL default 'off',
PRIMARY KEY (id)
) ENGINE=MyISAM;
CREATE TABLE weathermap_auth (
userid mediumint(9) NOT NULL default '0',
mapid int(11) NOT NULL default '0'
) ENGINE=MyISAM;
http://yoursite/cacti/plugins/weathermap/editor.phphttp://yoursite/cacti/plugins/weathermap/editor.phphttp://yoursite/cacti/plugins/weathermap/editor.phphttp://yoursite/cacti/plugins/weathermap/editor.php -
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
9/11
CareNet 2012, Deploying Cacti and PHP Weathermap | Victor Tsarinenko, [email protected] 9 of 11
CREATE TABLE weathermap_groups (
`id` INT(11) NOT NULL auto_increment,
`name` VARCHAR( 128 ) NOT NULL default '',
`sortorder` INT(11) NOT NULL default 0,
PRIMARY KEY (id)
) ENGINE=MyISAM;
INSERT INTO weathermap_groups (id,name,sortorder) VALUES (1,'Weathermaps',1);
CREATE TABLE IF NOT EXISTS weathermap_data (id int(11) NOT NULL auto_increment,
rrdfile varchar(255) NOT NULL,data_source_name varchar(19) NOT NULL,
last_time int(11) NOT NULL,last_value varchar(255) NOT NULL,
last_calc varchar(255) NOT NULL, sequence int(11) NOT NULL, local_data_id
int(11) NOT NULL DEFAULT 0, PRIMARY KEY (id), KEY rrdfile (rrdfile),
KEY local_data_id (local_data_id), KEY data_source_name (data_source_name) )
ENGINE=MyISAM;
Now use the same way as with the pa.sql to parse the file to mysql:
# mysql -u cacti -p cacti < weathermap.sql
The username here is cacti(specified by the -uoption), -poption tells mysql to prompt
for the password, and cactiis the database name.
Now the whole system is ready to be utilized.
Side note:
If you want to export the map images created by the weathermap plugin add something
like the following to your web server configuration:
# nano /etc/apache2/conf.d/cacti.conf
AllowOverride None
Order allow,deny
Allow from all
Adding devices, graphs, maps
By default cacti supports SNMP for polling the devices. Within the context of the
CareNet projects we use SNMP daemons on routers running Bifrost and collect the
interface statistics, where SNMP proves very handy.
To add a host to Cacti go tohttp://yoursite/cacti-> console -> devices -> add. Fill in the
required data and set the correct community names if you are using SNMP for polling.
You will be able to collect data from the interfaces once the SNMP check against the host
is successful.
http://yoursite/cactihttp://yoursite/cactihttp://yoursite/cactihttp://yoursite/cacti -
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
10/11
CareNet 2012, Deploying Cacti and PHP Weathermap | Victor Tsarinenko, [email protected] 10 of 11
To create a graph go to console -> new graphs -> choose the host and a graph you want
to create and click Create.
To create a weathermap go to weathermap -> editor. After designing a map go to
weathermap -> weathermap management -> add and select the maps you want to setactive.
The process of adding new maps, devices, graphs, etc is pretty self-explanatory,
considering the web interface is used. Thus, these topics are slightly mentioned in the
report. If you want to use custom data collection methods utilizing custom written
scripts you can find some insights on the topic in the Power monitoring for Residential
Gateways report. [3]
SummaryThis report mainly focused on installing Cacti - The complete RRDTool-based Graphing
solution in the context of the CareNet 2012 project. While the solo Cacti installation is
trivial, making it work with PHP Weathermap plugin may sometimes turn to be a bit
trickier. This report focused on how to make the solutions work together, and provided
a step by step guide to deploy the system.
-
8/13/2019 DeployingCactiandPHPWeathermap_11Dec2012
11/11
CareNet 2012, Deploying Cacti and PHP Weathermap | Victor Tsarinenko, [email protected] 11 of 11
References
1 Cacti, The Complete RRDTool-based Graphing Solution, online, accessed Dec 8,2012, available athttp://www.cacti.net/.
2 RRDTool, RRDTool: Logging and Graphing, online, accessed Dec 8, 2012,available athttp://oss.oetiker.ch/rrdtool/.
3 CareNet 2012, Power monitoring for residential gateways, online, accessed Dec8. 2012, available athttp://ttaportal.org/wp-
content/uploads/2012/11/PowerMonitoringforRGs.pdf.
4 CareNet 2012, CareNet core links status, online, accessed Dec 8, 2012, availableathttp://ttaportal.org/menu/projects/carenet/carenet-fall-2012/network-
availability/.
5 Cacti Forums, Easy install, online, accessed Dec 8, 2012, available athttp://forums.cacti.net/viewtopic.php?f=6&t=48367.
http://www.cacti.net/http://www.cacti.net/http://www.cacti.net/http://oss.oetiker.ch/rrdtool/http://oss.oetiker.ch/rrdtool/http://oss.oetiker.ch/rrdtool/http://ttaportal.org/wp-content/uploads/2012/11/PowerMonitoringforRGs.pdfhttp://ttaportal.org/wp-content/uploads/2012/11/PowerMonitoringforRGs.pdfhttp://ttaportal.org/wp-content/uploads/2012/11/PowerMonitoringforRGs.pdfhttp://ttaportal.org/wp-content/uploads/2012/11/PowerMonitoringforRGs.pdfhttp://ttaportal.org/menu/projects/carenet/carenet-fall-2012/network-availability/http://ttaportal.org/menu/projects/carenet/carenet-fall-2012/network-availability/http://ttaportal.org/menu/projects/carenet/carenet-fall-2012/network-availability/http://ttaportal.org/menu/projects/carenet/carenet-fall-2012/network-availability/http://forums.cacti.net/viewtopic.php?f=6&t=48367http://forums.cacti.net/viewtopic.php?f=6&t=48367http://forums.cacti.net/viewtopic.php?f=6&t=48367http://ttaportal.org/menu/projects/carenet/carenet-fall-2012/network-availability/http://ttaportal.org/menu/projects/carenet/carenet-fall-2012/network-availability/http://ttaportal.org/wp-content/uploads/2012/11/PowerMonitoringforRGs.pdfhttp://ttaportal.org/wp-content/uploads/2012/11/PowerMonitoringforRGs.pdfhttp://oss.oetiker.ch/rrdtool/http://www.cacti.net/