Files
cacti/docs/build/manual.sgml
T

6804 lines
311 KiB
Plaintext

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
<book>
<bookinfo>
<title>The Cacti Manual</title>
<authorgroup>
<author>
<firstname>Ian</firstname>
<surname>Berry</surname>
</author>
<author>
<firstname>Tony</firstname>
<surname>Roman</surname>
</author>
<author>
<firstname>Larry</firstname>
<surname>Adams</surname>
</author>
<author>
<firstname>J.P.</firstname>
<surname>Pasnak</surname>
</author>
<author>
<firstname>Jimmy</firstname>
<surname>Conner</surname>
</author>
<author>
<firstname>Reinhard</firstname>
<surname>Scheck</surname>
</author>
<author>
<firstname>Andreas</firstname>
<surname>Braun</surname>
</author>
</authorgroup>
<pubdate>2017</pubdate>
<copyright>
<year>2017</year>
<holder>The Cacti Group</holder>
</copyright>
<legalnotice id="license">
<para>This project is licensed under the terms of the GPL.</para>
<para>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
</para>
<para>
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
</para>
<para>
All product names are property of their respective owners. Such names are used
for identification purposes only and are not indicative of endorsement by or of
any company, organization, product, or platform.
</para>
</legalnotice>
</bookinfo>
<part id="installation">
<title>Installation</title>
<chapter id="requirements">
<title>Requirements</title>
<para>Cacti requires that the following software is installed on your system.</para>
<itemizedlist>
<listitem>
<para>
<application>RRDTool</application> 1.0.49 or greater, 1.4+ recommended
</para>
</listitem>
<listitem>
<para>
<application>MySQL</application> 5.x or greater
</para>
</listitem>
<listitem>
<para>
<application>PHP</application> 5.1 or greater
</para>
</listitem>
<listitem>
<para>
<application>Web Server that supports PHP</application> e.g. Apache or IIS
</para>
</listitem>
</itemizedlist>
</chapter>
<chapter id="install-unix">
<title>Installing Under Unix</title>
<para>
Please make sure, the following packages are installed
according to your operating systems requirements. Verify,
that <application>httpd</application> and
<application>mysqld</application> are started at system
startup.
</para>
<sect1 id="rpm-packages">
<title>Required Packages for RPM-based Operating Systems</title>
<itemizedlist>
<listitem>
<para>
<filename>httpd</filename>
</para>
</listitem>
<listitem>
<para>
<filename>php</filename>
</para>
</listitem>
<listitem>
<para>
<filename>php-mysql</filename>
</para>
</listitem>
<listitem>
<para>
<filename>php-snmp</filename>
</para>
</listitem>
<listitem>
<para>
<filename>mysql</filename>
</para>
</listitem>
<listitem>
<para>
<filename>mysql-server</filename>
</para>
</listitem>
<listitem>
<para>
<filename>net-snmp</filename>
</para>
</listitem>
</itemizedlist>
</sect1>
<sect1 id="bsd-ports">
<title>Ports for FreeBSD</title>
<itemizedlist>
<listitem>
<para>
<filename>www/apache2</filename>
</para>
</listitem>
<listitem>
<para>
<filename>net/rrdtool</filename>
</para>
</listitem>
<listitem>
<para>
<filename>net/net-snmp</filename>
</para>
</listitem>
<listitem>
<para>
<filename>www/php-cgi</filename>
</para>
</listitem>
<listitem>
<para>
<filename>lang/php</filename> (With <application>MySQL</application> and SNMP Support)
</para>
</listitem>
<listitem>
<para>
<filename>databases/mysql-server</filename>
</para>
</listitem>
</itemizedlist>
</sect1>
<sect1 id="unix-configure-php">
<title>Configure PHP</title>
<para>Please ensure, that PHP support is either builtin or installed for the following PHP extension modules:</para>
<itemizedlist>
<listitem>
<para>
<application>PDO</application>
</para>
</listitem>
<listitem>
<para>
<application>pdo-mysql</application>
</para>
</listitem>
<listitem>
<para>
<application>snmp</application> (Optional, but recommended)
</para>
</listitem>
<listitem>
<para>
<application>xml</application>
</para>
</listitem>
<listitem>
<para>
<application>session</application>
</para>
</listitem>
<listitem>
<para>
<application>posix</application> (Linux only)
</para>
</listitem>
<listitem>
<para>
<application>sockets</application>
</para>
</listitem>
<listitem>
<para>
<application>ldap</application>
</para>
</listitem>
<listitem>
<para>
<application>json</application>
</para>
</listitem>
<listitem>
<para>
<application>pcre</application>
</para>
</listitem>
<listitem>
<para>
<application>mbstring</application>
</para>
</listitem>
<listitem>
<para>
<application>openssl</application>
</para>
</listitem>
<listitem>
<para>
<application>gd</application>
</para>
</listitem>
<listitem>
<para>
<application>zlib</application>
</para>
</listitem>
<listitem>
<para>
<application>gmp</application> (Recommened for plugins)
</para>
</listitem>
<listitem>
<para>
<application>com_dotnet</application> (Windows PHP 5.4.5+)
</para>
</listitem>
</itemizedlist>
<para> You may run the following command to get the list of all available PHP modules</para>
<screen><userinput>php -m</userinput></screen>
<para>Please verify, that the modules are installed and configured correctly.
There are several ways to do so, please consult <ulink url="http://www.php.net/manual/en/configuration.php">PHP configuration instructions</ulink>
for a complete description.</para>
<para>
We will continue using the most recommended way of configuring php extension modules.
Please find the file <filename>/etc/php.ini</filename>
and make the following changes to it:
</para>
<screen><userinput>extension_dir = /etc/php.d</userinput></screen>
<para>
This will enable PHP to find more configuration directives in that very directory. Other distros point to <filename>/usr/lib/php/modules</filename> instead. In each case, you should locate e.g. <filename>mysql.so</filename> in that directory.
</para>
<para>
Activate the <application>MySQL</application> extension
via /etc/php.d/mysql.ini
</para>
<screen><userinput>; Enable mysql extension module
extension=mysql.so</userinput></screen>
<para>
Activate the <application>SNMP</application> extension
via /etc/php.d/snmp.ini
</para>
<screen><userinput>; Enable snmp extension module
extension=snmp.so</userinput></screen>
<para>
If you want to allow template importing, uncomment the following line:
</para>
<screen><userinput>file_uploads = On</userinput></screen>
</sect1>
<sect1 id="unix-configure-httpd">
<title>Configure the Webserver (Apache)</title>
<para>
Please find the file <filename>/etc/httpd/conf/httpd.conf</filename>
or equivalent and make the following changes to it:
</para>
<screen><userinput># Load config files from the config directory "/etc/httpd/conf.d".
Include conf.d/*.conf</userinput></screen>
<para>
Now, please locate the PHP configuration file at
<filename>/etc/httpd/conf.d/php.conf</filename>
</para>
<screen><userinput># PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
LoadModule php_module modules/libphp.so
#
# Cause the PHP interpreter to handle files with a .php extension.
AddHandler php-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
DirectoryIndex index.php</userinput></screen>
</sect1>
<sect1 id="unix-configure-mysql">
<title>Configure MySQL</title>
<para>
Set a password for the root user
</para>
<screen><prompt>shell&gt;</prompt> <userinput>mysqladmin --user=root password somepassword</userinput>
<prompt>shell&gt;</prompt> <userinput>mysqladmin --user=root --password reload</userinput></screen>
<para>
Galera clustering: There are several tables which are set to use the MEMORY storage engine which do not get replicated among nodes which can cause problems. If you configure Cacti to only connect to one node of your cluster and are not load balancing this does not apply to you.
</para>
<para>
If you are running multiple nodes in a load-balanced environment where you connect to a VIP you should remove all but one node from rotation during Cacti installation or update. After the installation/update login to your MySQL server and execute the following commands to update those tables to use the InnoDB engine:
</para>
<para>
<screen>
<prompt>MariaDB [(none)]&gt;</prompt> <userinput>use cacti;</userinput>
<prompt>MariaDB [cacti]>&gt;</prompt> <userinput>ALTER TABLE `automation_ips` ENGINE=InnoDB;</userinput>
<prompt>MariaDB [cacti]>&gt;</prompt> <userinput>ALTER TABLE `automation_processes` ENGINE=InnoDB;</userinput>
<prompt>MariaDB [cacti]>&gt;</prompt> <userinput>ALTER TABLE `data_source_stats_hourly_cache` ENGINE=InnoDB;</userinput>
<prompt>MariaDB [cacti]>&gt;</prompt> <userinput>ALTER TABLE `data_source_stats_hourly_last` ENGINE=InnoDB;</userinput>
<prompt>MariaDB [cacti]>&gt;</prompt> <userinput>ALTER TABLE `poller_output` ENGINE=InnoDB;</userinput>
<prompt>MariaDB [cacti]>&gt;</prompt> <userinput>ALTER TABLE `poller_output_boost_processes` ENGINE=InnoDB;</userinput>
</screen>
</para>
<para>
These changes should replicate to the other nodes in your cluster. Allow Cacti to run at least two or three full polling cycles before placing the other nodes back into rotation.
</para>
</sect1>
<sect1 id="unix-configure-cacti">
<title>Install and Configure Cacti</title>
<orderedlist>
<listitem>
<para>Extract the distribution tarball.</para>
<screen><prompt>shell&gt;</prompt> <userinput>tar xzvf cacti-version.tar.gz</userinput></screen>
</listitem>
<listitem>
<para>Create the MySQL database:</para>
<screen><prompt>shell&gt;</prompt> <userinput>mysqladmin --user=root create cacti</userinput></screen>
</listitem>
<listitem>
<para>Import the default cacti database:</para>
<screen><prompt>shell&gt;</prompt> <userinput>mysql cacti &lt; cacti.sql</userinput></screen>
</listitem>
<listitem>
<para>
Optional: Create a MySQL username and password for Cacti.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>mysql --user=root mysql</userinput>
<prompt>mysql&gt;</prompt> <userinput>GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';</userinput>
<prompt>mysql&gt;</prompt> <userinput>flush privileges;</userinput></screen>
</listitem>
<listitem>
<para>
Edit <filename>include/config.php</filename> and specify the database type, name, host, user and password for your Cacti configuration.
</para>
<screen><userinput>$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";</userinput></screen>
</listitem>
<listitem>
<para>
Set the appropriate permissions on cacti's directories for graph/log generation. You
should execute these commands from inside cacti's directory to change the permissions.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>chown -R cactiuser rra/ log/</userinput></screen>
<para>
(Enter a valid username for <emphasis>cactiuser</emphasis>, this user will also be used in the next step for
data gathering.)
</para>
</listitem>
<listitem>
<para>
Add a line to your <filename>/etc/crontab</filename> file similar to:
</para>
<screen>*/5 * * * * cactiuser php /var/www/html/cacti/poller.php &gt; /dev/null 2&gt;&amp;1</screen>
<simpara>
Replace <emphasis>cactiuser</emphasis> with the valid user specified in the previous step.
</simpara>
<simpara>
Replace <filename>/var/www/html/cacti/</filename> with your full Cacti path.
</simpara>
</listitem>
<listitem>
<para>
Point your web browser to:
</para>
<blockquote>
<para>
http://your-server/cacti/
</para>
</blockquote>
<para>
Log in the with a username/password of <emphasis>admin</emphasis>. You will be required to change this
password immediately. Make sure to fill in all of the path variables carefully and
correctly on the following screen.
</para>
</listitem>
</orderedlist>
</sect1>
<sect1 id="unix-configure-spine">
<title>(Optional) Install and Configure <application>Spine</application></title>
<para>
<application>Spine</application> is a very fast poller engine, written in C.
It is an optional replacement for cmd.php. If you decide
to use it, you will have to install it explicitely. It
does not come with cacti itself.
</para>
<para>
The easiest way is to install <application>Spine</application> using rpm or ports.
You will find packages for <application>Spine</application> at the main cacti site
or from your distribution.
</para>
<para>To compile <application>Spine</application>, please download
it to any location of your liking. Then, please issue from the downloaded
directory following commands</para>
<screen><prompt>shell&gt;</prompt>aclocal</screen>
<screen><prompt>shell&gt;</prompt>libtoolize --force (glibtoolize --force on Max OS)</screen>
<screen><prompt>shell&gt;</prompt>autoheader</screen>
<screen><prompt>shell&gt;</prompt>autoconf</screen>
<screen><prompt>shell&gt;</prompt>automake</screen>
<screen><prompt>shell&gt;</prompt>./configure</screen>
<screen><prompt>shell&gt;</prompt>make</screen>
<screen><prompt>shell&gt;</prompt>make install</screen>
<para>
Assuming, you've managed to install <application>Spine</application> correctly,
you will have to configure it. The configuration file
may be placed in the same directory as <application>Spine</application> itself or
at /etc/<application>Spine</application>.conf.
</para>
<screen><userinput>DB_Host 127.0.0.1 or hostname (not localhost)
DB_Database cacti
DB_User cactiuser
DB_Password cacti
DB_Port 3306</userinput></screen>
</sect1>
<sect1 id="unix-apply-patches">
<title>Apply Patches</title>
<para>
Please visit the Cacti website at http://www.cacti.net/download_patches.php
If any patch has been released, you will find installation
instructions there.
</para>
<para>
As an example, please find patch installation instructions
for cacti 0.8.8 here.
Do not apply those patches to recent releases!
</para>
<screen><userinput>wget http://www.cacti.net/downloads/patches/0.8.8a/snmpv3_priv_proto_none.patch
patch -p1 -N < snmpv3_priv_proto_none.patch</userinput></screen>
<para>
You might need to reapply file/folder security
on the files patched. Double check they are correct.
</para>
<para>Please pay attention not to break cacti when using SELinux or using NTFS file security.
If you encounter</para><para><computeroutput>PHP Warning: include_once(./lib/html_tree.php) [&lt;a href='function.include-once'&gt;function.include-once&lt;/a&gt;]: failed to open stream: Permission denied in /var/www/cacti/graphs.php on line 33, referer: http://localhost/cacti/graphs.php </computeroutput></para>
<para>or the like, it is very likely that your permissions are wrong.</para>
</sect1>
</chapter>
<chapter id="install-windows">
<title>Installing Under Windows</title>
<orderedlist>
<title>Software Components Required</title>
<listitem>
<para>
(Optional) Apache> - This software is optional if running Windows Internet Information Server.
</para>
</listitem>
<listitem>
<para>
Cacti - Install from the zip distribution and install in the web root or your choice.
Many choose to install into a "Cacti" sub folder.
</para>
</listitem>
<listitem>
<para>
Spine - Install from the zip distribution into the <filename>c:\cacti</filename>
directory. Make sure your <filename>spine.conf.dist</filename> is located in that directory as well.
</para>
</listitem>
<listitem>
<para>
RRDTool - Install from the Cacti website. Install it into the <filename>c:\cacti</filename> directory.
</para>
</listitem>
<listitem>
<para>
PHP 5.x - Install into the <filename>c:\php</filename> folder. If you choose
to install into <filename>c:\Program Files\php</filename>, you will have to use 8.3 filenames
to reference it's binaries in Cacti.
</para>
</listitem>
<listitem>
<para>
MySQL 5.x - Install into the default location. This is typically
<filename>c:\Program Files\MySQL\MySQL Server X.XX</filename>.
</para>
</listitem>
<listitem>
<para>
(Optional) Cygwin - Download and execute <filename>setup.exe</filename> from the Cygwin
website. Keep the <filename>setup.exe</filename> file for later use.
</para>
</listitem>
<listitem>
<para>
(Optional) Net-SNMP - Install to the <filename>c:\net-snmp</filename> directory. If you
choose to use <filename>c:\Program Files\net-snmp</filename> you will have tu use 8.3 filenames
to reference it's binaries in Cacti.
</para>
</listitem>
</orderedlist>
<orderedlist>
<title>Configure PHP</title>
<listitem>
<para>
Add the following directory to the existing Windows System <userinput>PATH</userinput> environment variable:
<filename>c:\php</filename>. The Windows path can be accessed via the Control Panel at: System |
Advanced | Environment Variables | System Variables.
</para>
</listitem>
<listitem>
<para>
Add the following directory to a new Windows System environment variable called <userinput>PHPRC</userinput>:
<filename>c:\php</filename>.
</para>
</listitem>
<listitem>
<para>
Add a new Windows System environment variable called <userinput>MIBDIRS</userinput>
set it to <filename>c:\php\extras\mibs</filename>
</para>
</listitem>
<listitem>
<para>
Rename the file <filename>c:\php\php.ini.dist</filename> to <filename>php.ini</filename>, and make the
following changes to it:
</para>
<para>
Uncomment the following lines.
</para>
<screen><userinput>extension_dir = c:\php\ext
extension=php_mysql.dll
extension=php_snmp.dll
extension=php_sockets.dll
cgi.force_redirect = 0</userinput></screen>
</listitem>
<listitem>
<para>
In earlier installation guides to PHP, they recommended moving certain DLL's to the <filename>
c:\winnt\system32</filename> directory. If so, you will have to remove those files. Please
review the PHP installation documentation for instructions on removing those files.
</para>
</listitem>
<listitem>
<para>
If you want to allow template importing, uncomment the following line:
</para>
<screen><userinput>file_uploads = On</userinput></screen>
</listitem>
<listitem>
<para>
Give the user who will be running the scheduled task, modify rights to the <filename>.index</filename>
file in the location pointed to by the <userinput>MIBDIRS</userinput> Windows System environment variable.
</para>
</listitem>
</orderedlist>
<orderedlist>
<title>Configure the Webserver (Apache)</title>
<listitem>
<para>
Make sure you have stopped any IIS web servers before you proceed with Apache installation, or make
sure Apache is configured on an alternate port.
</para>
</listitem>
<listitem>
<para>
If using Apache 2.x and PHP 5, then add the following lines.
</para>
<screen><userinput>LoadModule php5_module c:\php\php5apache2.dll
AddType application/x-httpd-php .php
DirectoryIndex index.html index.htm index.php</userinput></screen>
</listitem>
</orderedlist>
<orderedlist>
<title>Configure the Webserver (IIS)</title>
<listitem>
<para>
Start the Internet Information Services (IIS) Manager, right click on the <guilabel>Default Web Site</guilabel> (in most cases) and select <guilabel>Properties</guilabel>.
</para>
</listitem>
<listitem>
<para>
Under the <guilabel>Home Directory</guilabel> tab, select <guilabel>Configuration</guilabel>
and click <guilabel>Add</guilabel>. Browse to the path of <filename>php4isapi.dll</filename> or
<filename>php5isapi.dll</filename>, and type in .php as the extension. Note: if using IIS6,
Enable All Verbs and Script Engine.
</para>
</listitem>
<listitem>
<para>
Under the <guilabel>ISAPI Filters</guilabel> tab, click <guilabel>Add</guilabel> and browse
to the <filename>php4isapi.dll</filename> or <filename>php5isapi.dll</filename> file. Name the filter
"php" and click OK.
</para>
</listitem>
<listitem>
<para>
Under the <guilabel>Documents</guilabel> tab, add <filename>index.php</filename> to the list.
</para>
</listitem>
<listitem>
<para>
If using IIS6, goto <guilabel>Web Service Extensions</guilabel> and add a new Web Service Extension.
Name the extension "php", and click <guilabel>Add</guilabel> and browse to the <filename>php4isapi.dll</filename>
or <filename>php5isapi.dll</filename> file, enable <guilabel>Set Extension</guilabel> status to Enable, and click OK.
</para>
</listitem>
<listitem>
<para>
Give the IUSR_XXXX and IIS_WPG users read & execute permissions to the file <filename>%windir%\system32\cmd.exe</filename>.
They will also need read permissions on <filename>cacti_web_root/cacti</filename> and it's subfolders.
</para>
</listitem>
<listitem>
<para>
If using IIS6, give the IIS_WPG user modify permissions to the folders <filename>cacti_web_root/cacti/log</filename>
and <filename>cacti_web_root/cacti/rrd</filename>.
</para>
</listitem>
<listitem>
<para>
Completely stop and start the IIS service using the following commands:
</para>
<screen><userinput>net stop iisadmin
net start w3svc</userinput></screen>
</listitem>
</orderedlist>
<orderedlist>
<title>Install Cygwin (optional)</title>
<listitem>
<para>
Installing a single instance of Cygwin, and using it for all applications that require it is
recommended so you do not have different versions of the Cygwin dlls laying around on your system,
which can cause conflicts.
</para>
</listitem>
<listitem>
<para>
Run <filename>setup.exe</filename> you previously download.
</para>
</listitem>
<listitem>
<para>
Once you reach the portion of setup entitled Select Packages, install the following:
</para>
<screen><userinput>Base (include all items)
Libs
libart_lgpl
libfreetype26
libpng12
zlib
openssl
Utils
patch
Web
wget</userinput></screen>
</listitem>
<listitem>
<para>
Add <filename>c:\cygwin\bin</filename> to your Windows System PATH environment variable.
</para>
</listitem>
<listitem>
<para>
Move <filename>setup.exe</filename> to <filename>c:\cygwin</filename> for future use.
</para>
</listitem>
</orderedlist>
<orderedlist>
<title>Install RRDTool</title>
<listitem>
<para>
Extract the RRDTool zip file from the Cacti web site to <filename>c:\cacti\rrdtool.exe</filename>.
</para>
</listitem>
</orderedlist>
<orderedlist>
<title>Install MySQL</title>
<listitem>
<para>
Extract the MySQL zip file to a temp directory and run <filename>setup.exe</filename>.
</para>
</listitem>
<listitem>
<para>
Install MySQL to the default directory, or for the purposes of this manual to the <filename>c:\mysql</filename> directory.
</para>
</listitem>
<listitem>
<para>
If running an older version of MySQL, start it by running <filename>c:\mysql\bin\winmysqladmin.exe</filename>.
In more recent versions, this is not required.
</para>
</listitem>
<listitem>
<para>
Set a password for the root user
</para>
<screen><prompt>shell&gt;</prompt> <userinput>cd mysql\bin</userinput>
<prompt>shell&gt;</prompt> <userinput>mysqladmin --user=root password somepassword</userinput>
<prompt>shell&gt;</prompt> <userinput>mysqladmin --user=root --password reload</userinput></screen>
</listitem>
<listitem>
<para>
Create the MySQL database:
</para>
<screen><prompt>shell&gt;</prompt> <userinput>mysqladmin --user=root --password create cacti</userinput></screen>
</listitem>
<listitem>
<para>
Import the default Cacti database:
</para>
<screen><prompt>shell&gt;</prompt> <userinput>mysql --user=root --password cacti &lt; c:\apache2\htdocs\cacti\cacti.sql</userinput></screen>
</listitem>
<listitem>
<para>
Create a MySQL username and password for Cacti.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>mysql --user=root --password mysql</userinput>
<prompt>mysql&gt;</prompt> <userinput>GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';</userinput>
<prompt>mysql&gt;</prompt> <userinput>flush privileges;</userinput></screen>
</listitem>
<listitem>
<para>
If you are running MySQl 4.1 and above, you will need to apply the old password setting in order
to authenticate with Cacti. To make this change, stop the MySQL service and add the following to
the Start Parameter field. Start it again once it has been added.
</para>
<screen><userinput>--old-password</userinput></screen>
<para>
You will also need to update the cactiuser account with the old password style.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>UPDATE mysql.user SET Password = OLD_PASSWORD('cactipwd')
WHERE Host = 'localhost' AND User = 'cactiuser';</userinput>
<prompt>mysql&gt;</prompt> <userinput>FLUSH PRIVILEGES;</userinput></screen>
</listitem>
</orderedlist>
<orderedlist>
<title>Install Net-SNMP</title>
<listitem>
<para>
If you plan to use any hosts with SNMP v2c support, and are using early versions of PHP, you must
download and install the <application>Net-SNMP</application> libraries. <application>Net-SNMP</application>
provides installers to install their product. However, caution must be taken if you choose to use
long file names as Cacti does not them as long file names. You will have to user 8.3 notation. For
example <filename>c:\Program Files\Net-SNMP\bin</filename> becomes <filename>c:\progra~1\net-snmp\bin</filename>.
</para>
</listitem>
</orderedlist>
<orderedlist>
<title>Install <application>Spine</application></title>
<listitem>
<para>
Extract the <application>Spine</application> zip file to <filename>c:\cacti</filename> and modify the <filename>spine.conf.dist</filename> file to
include the following statements.
</para>
<screen><userinput>DB_Host 127.0.0.1 or hostname (not localhost)
DB_Database cacti
DB_User cactiuser
DB_Password cacti
DB_Port 3306</userinput></screen>
<para>
All other pre 0.8.6 settings are obsolete.
</para>
</listitem>
<listitem>
<para>
<application>Spine</application> now comes with a binary distribution. However, we strongly suggest that you install
Cygwin and then remove all the DLL files and <filename>sh.exe</filename> from the
<filename>c:\cacti</filename> directory.
</para>
</listitem>
</orderedlist>
<orderedlist>
<title>Configure Cacti</title>
<listitem>
<para>
Edit <filename>cacti_web_root/cacti/include/config.php</filename> and specify the MySQL user,
password, database, and database port for your Cacti configuration.
</para>
<screen><userinput>$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";
$database_port = "3306";</userinput></screen>
</listitem>
<listitem>
<para>
Point your web browser to:
</para>
<screen>http://your-server/cacti/</screen>
<para>
Log in using the username and password of admin/admin. You will be required to change this
password immediately.
</para>
</listitem>
<listitem>
<para>
From Cacti, go to <guilabel>Settings</guilabel>-&gt;<guilabel>Paths</guilabel> and verify/udate
your paths to point to the correct locations. Recommended examples are posted below. If you
plan on using <application>Spine</application>, then it is very important that all paths include forward slashes instead
of backslashes.
</para>
<para>
<emphasis>PHP Binary Path:</emphasis>
</para>
<screen>c:/php/php.exe</screen>
<para>
<emphasis>RRDTool Binary Path:</emphasis>
</para>
<screen>c:/cacti/rrdtool.exe</screen>
<para>
<emphasis>SNMPGET, SNMPWALK, SNMPBULKWALK, SNMPGETNEXT Paths:</emphasis>
</para>
<screen>c:/progra~1/net-snmp/bin/snmpget.exe</screen>
<screen>c:/progra~1/net-snmp/bin/snmpwalk.exe</screen>
<screen>c:/progra~1/net-snmp/bin/snmpbulkwalk.exe</screen>
<screen>c:/progra~1/net-snmp/bin/snmpgetnext.exe</screen>
<para>
<emphasis>Cacti Logfile Path:</emphasis>
</para>
<screen>c:/mycacti/website/cacti/log/cacti.log</screen>
<para>
<emphasis><application>Spine</application> Path:</emphasis>
</para>
<screen>c:/cacti/<application>Spine</application>.exe</screen>
</listitem>
<listitem>
<para>
Click on Devices. Delete the Localhost devices as it intended for Linux environments In the upper
right corner, click Add. Fill in the following information and then click Add.
</para>
<screen><userinput>Description: My Windows localhost
Hostname: localhost
Host Template: Windows 2000/XP</userinput></screen>
</listitem>
<listitem>
<para>
You should now be looking at the localhost device screen. Right under it's name, there should be
some SNMP information listed, if not you should double check the SNMP settings on the server and
firewall settings. In the upper right-hand corner, click on Create Graphs for this Host. On the
following screen, select a disk partition and network interface. At the bottom of the page,
click on Create.
</para>
</listitem>
<listitem>
<para>
Log into the user account you'll be using for the scheduled task and verify starting a Cacti
polling cycle works. Do this by running the following from the command prompt:
</para>
<screen><userinput>php c:/cacti_web_root/cacti/poller.php</userinput></screen>
<para>
The output should look something like the following:
</para>
<screen><userinput>C:\>php c:\inetpub\wwwroot\cacti\poller.php
OK u:0.00 s:0.06 r:1.32
OK u:0.00 s:0.06 r:1.32
OK u:0.00 s:0.16 r:2.59
OK u:0.00 s:0.17 r:2.62
10/28/2005 04:57:12 PM - SYSTEM STATS: Time:4.7272 Method:cmd.php Processes:1 Threads:N/A Hosts:1 HostsPerProcess:2 DataSources:4 RRDsProcessed:2</userinput></screen>
<para>
After this has ran once, you should have <filename>cacti.log</filename> in <filename>/cacti/log/</filename>
and rrd files in /cacti/rra/.
</para>
</listitem>
<listitem>
<para>
You are going to need to schedule a task while logged on as an Administrator. This task is
required to you can run <filename>poller.php</filename> every 5 minutes. Make sure the
Task Scheduler service is started and follow the steps below to begin.
</para>
<para>
<emphasis>Note:</emphasis> The following instructions are based on Windows XP and Windows Server
2003. You should be able to follow these instructions close enough for Windows 2000 as well.
</para>
<orderedlist>
<listitem>
<para>
Select <guilabel>Start</guilabel> --> <guilabel>Settings</guilabel> --> <guilabel>Control Panel</guilabel> and double
click on <guilabel>Scheduled Tasks</guilabel>.
</para>
</listitem>
<listitem>
<para>
Double click on <guilabel>Add Scheduled Task</guilabel>.
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Next</guilabel> and <guilabel>Browse</guilabel> on the following screen. Find <filename>c:\php</filename> and select
<filename>php.exe</filename>. Choose <guilabel>Daily</guilabel> on and click <guilabel>Next</guilabel>.
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Next</guilabel> again without changing the time or date settings.
</para>
</listitem>
<listitem>
<para>
When entering a username and password make sure the user has read and write access to the following directories:
</para>
<screen><userinput>cacti_web_root/cacti/rra
cacti_web_root/log</userinput></screen>
<para>
Make sure the user has read, write, and execute access to the following directories:
</para>
<screen><userinput>c:\php
c:\php\sapi</userinput></screen>
</listitem>
<listitem>
<para>
Click <guilabel>Next</guilabel> and <guilabel>Finish</guilabel> to close the wizard.
</para>
</listitem>
<listitem>
<para>
Right click on the task you just created, and select <guilabel>Properties</guilabel>.
</para>
</listitem>
<listitem>
<para>
Select the <guilabel>Schedule</guilabel> tab.
</para>
</listitem>
<listitem>
<para>
Make sure <guilabel>Daily</guilabel> is selected and click the <guilabel>Advanced</guilabel> button.
</para>
</listitem>
<listitem>
<para>
Check the <guilabel>Repeat</guilabel> checkbox, set it for 5 minutes and set the duration for 24 hours.
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Ok</guilabel>
</para>
</listitem>
<listitem>
<para>
In the <guilabel>Run</guilabel> textbox enter the following text making sure to use the appropriate paths.
</para>
<screen>c:\php\php.exe c:\mycacti\website\cacti\poller.php</screen>
<para>
The start in box should say <filename>c:\mycacti\website\cacti</filename>.
</para>
</listitem>
</orderedlist>
</listitem>
</orderedlist>
<orderedlist>
<title>Apply Patches</title>
<listitem>
<para>
There are two methods of applying patches to Cacti:
</para>
<orderedlist>
<listitem>
<para>
If you have Cygwin installed, then the patch instructions which use wget and patch, will work.
</para>
</listitem>
<listitem>
<para>
The other method requires you to visit http://www.cacti.net/downloads/patches/0.8.6h/pre-patched/
and manually download and replace the patched files.
</para>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para>
You might need to reapply file/folder security on the files patched. Double check they are correct.
</para>
</listitem>
</orderedlist>
</chapter>
<chapter id="upgrade">
<title>Upgrading Cacti</title>
<orderedlist>
<listitem>
<para>
Backup the old Cacti database.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>mysqldump -l --add-drop-table cacti &gt; mysql.cacti</userinput></screen>
<para>
Note: You will probably have to specify the -u and -p flags for the MySQL username and password. This user
must have permission to read from Cacti's database or you will end up with an empty backup.
</para>
</listitem>
<listitem>
<para>
Backup the old Cacti directory.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>mv cacti cacti_old</userinput></screen>
</listitem>
<listitem>
<para>
Extract the distribution tarball.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>tar xzvf cacti-version.tar.gz</userinput></screen>
</listitem>
<listitem>
<para>
Rename the new Cacti directory to match the old one.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>mv cacti-version cacti</userinput></screen>
</listitem>
<listitem>
<para>
Edit <filename>include/config.php</filename> and specify the MySQL user, password and database for your Cacti configuration.
</para>
<screen><userinput>$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";</userinput></screen>
</listitem>
<listitem>
<para>
Copy the *.rrd files from the old Cacti directory.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>cp cacti_old/rra/* cacti/rra/</userinput></screen>
</listitem>
<listitem>
<para>
Copy any relevant custom scripts from the old Cacti directory. Some script are updated between versions. Therefore, make sure you only over write if the scripts either don't exist or are newer than the distribution's.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>cp -u cacti_old/scripts/* cacti/scripts/</userinput></screen>
</listitem>
<listitem>
<para>
Copy any relevant custom resource XML files from the old Cacti directory. Some resource XML files are updated between versions. Therefore, make sure you only over write if the XML files either don't exist or are newer than the distribution's.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>cp -u -R cacti_old/resource/* cacti/resource/</userinput></screen>
</listitem>
<listitem>
<para>
Set the appropriate permissions on Cacti's directories for graph/log generation. You
should execute these commands from inside Cacti's directory to change the permissions.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>chown -R cactiuser rra/ log/</userinput></screen>
<para>
(Enter a valid username for cactiuser, this user will also be used in the next step for data
gathering.)
</para>
</listitem>
<listitem>
<para>
Point your web browser to:
</para>
<blockquote>
<para>
http://your-server/cacti/
</para>
</blockquote>
<para>
Follow the on-screen instructions so your database can be updated to the new version.
</para>
</listitem>
</orderedlist>
</chapter>
</part>
<part id="basics">
<title>Basics</title>
<chapter id="operating-principles">
<title>Principles of Operation</title>
<para>
Cacti operation may be divided into three different tasks:
</para>
<figure id="principles-of-operation">
<title>Principles of Operation</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/principles_of_operation.png" format="PNG">
</imageobject>
</mediaobject>
</figure>
<sect1 id="Data-Retrieval">
<title>Data Retrieval</title>
<para>
First task is to retrieve data. Cacti will do so using its Poller.
The Poller is executed from the operating system's scheduler,
e.g. crontab for Unix flavored OSes.
</para>
<para>
In current IT installations, you're dealing with lots of devices
of different kind, e.g. servers, network equipment, appliances
and the like. To retrieve data from remote targets/hosts,
cacti will mainly use the Simple Network Management Protocol SNMP.
Thus, all devices capable of using SNMP will be eligible to be
monitored by cacti.
</para>
<para>
Later on, we demonstrate how to extend cacti's capabilities of
retrieving data to scripts, script queries and more.
</para>
</sect1>
<sect1 id="Data-Storage">
<title>Data Storage</title>
<para>
There are lots of different approaches for this task. Some may
use an (SQL) database, others flat files. Cacti uses <ulink url="http://www.rrdtool.org/"><application>RRDTool</application>
</ulink> to store data.
</para>
<para>
RRD is the acronym for Round Robin Database.
RRD is a system to store and display time-series data
(i.e. network bandwidth, machine-room temperature, server load average).
It stores the data in a very compact way that will not expand
over time, and it can create beautiful graphs.
This keeps storage requirements at bay.
</para>
<para>
Likewise, rrdtool will perform some specific tasks.
It performs consolidation to combine raw data (a primary data point in rrdtool lingo)
to consolidated data (a consolidated data point). This way, historical data
is compressed to save space. rrdtool knows different consolidation functions:
AVERAGE, MAXIMUM, MINIMUM and LAST.
</para>
</sect1>
<sect1 id="Data-Presentation">
<title>Data Presentation</title>
<para>
One of the most appreciated features of <ulink url="http://www.rrdtool.org/"><application>RRDTool</application>
</ulink> is the built-in
graphing function. This comes in useful when combining this with
some commonly used webserver. Such, it is possible to access
the graphs from merely any browser on any plattform.
</para>
<para>
Graphing can be done in very different ways. It is possible,
to graph one or many items in one graph. Autoscaling is supported
and logarithmic y-axis as well. You may stack items onto another
and print pretty legends denoting characteristics such as
minimum, average, maximum and lots more.
</para>
</sect1>
</chapter>
<chapter id="graph-overview">
<title>Graph Overview</title>
<para>
Almost everything in Cacti is somehow related to a graph. At any time, you can list all available
graphs by clicking on the <guilabel>Graph Management</guilabel> menu item. While it is possible to
manually create graphs through this screen, new users should follow the instructions provided in the
next chapter for creating new graphs in Cacti.
</para>
<para>
For users that are familiar with <ulink url="http://www.rrdtool.org/"><application>RRDTool</application>
</ulink>, you will immediately recognize that a graph in Cacti is closely modeled after <application>RRDTool</application>'s graphs.
This makes sense since Cacti provides a user friendly interface to <application>RRDTool</application> without requiring users to
understand how <application>RRDTool</application> works. With this in mind, every graph in Cacti has certain settings and at least
one graph item associated with it. While graph settings define the overall properties of a graph, the graph
items define the data that is to be represented on the graph. So the graph items define which data to display
and how it should displayed, and also define what should be displayed on the legend.
</para>
<para>
Each graph and graph item has a set of parameters which control various aspects of the graph.
Fortunately through the use of graph templates, it is not necessary to understand the function
of each field to create graphs for your network. When you are ready to take on the task of
creating your own graph templates, extensive field descriptions for both graphs and graph items
are provided in that section of the manual.
</para>
</chapter>
<chapter id="graph-howto">
<title>How to Graph Your Network</title>
<para>
At this point, you probably realize that graphing is Cacti's greatest strength. Cacti has many powerful
features that provide complex graphing and data acquisition, some which have a slight learning curve.
Do not let that stop you however, because graphing your network is incredibly simple.
</para>
<para>
The next two sections will outline the two basic steps which are typically required to create graphs for
most devices.
</para>
<sect1 id="new-device">
<title>Creating a Device</title>
<para>
The first step to creating graphs for your network is adding a device for each network device that
you want to create graphs for. A device specifies important details such as the network
hostname, SNMP parameters, and host type.
</para>
<para>
To manage devices within Cacti, click on the <guilabel>Devices</guilabel> menu item.
Clicking <guilabel>Add</guilabel> will bring up a new device form. The first two fields,
<guilabel>Description</guilabel> and <guilabel>Hostname</guilabel> are the only two fields that
require your input beyond the defaults. If your host type is defined under the host template
dropdown, be sure to select it here. You can always choose "Generic SNMP-enabled Host" if you are
just graphing traffic or "None" if you are unsure. It is important to remember that the host
template you choose will not lock you into any particular configuration, it will just provide
more intelligent defaults for that type of host.
</para>
<figure id="img-device-new">
<title>Adding a New Device</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/new_device.png" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
The field definitions are as follows
</para>
<table frame='all'>
<title>Device Field Definitions</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Field</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Description</entry>
<entry>This description will show up in the first column of the device list.
You may refer to it e.g. in graph titles</entry>
</row>
<row>
<entry>Hostname</entry>
<entry>Either an IP address or a hostname.
The hostname will be resolved using the standard host resolving mechanisms,
e.g. Dynamic Name Services (DNS)</entry>
</row>
<row>
<entry>Host Template</entry>
<entry>A Host Template is a container for a list of graph templates
that will be related to this host.</entry>
</row>
<row>
<entry>Notes</entry>
<entry>New with cacti 0.8.7.
Add notes to a host to add arbitrary text.</entry>
</row>
<row>
<entry>Disable Host</entry>
<entry>Exclude this host from being polled.
This is of particular value, if a device is no longer available,
but should be kept e.g. as a reference.</entry>
</row>
<row>
<entry><emphasis>Availability/Reachability Options</emphasis></entry>
<entry></entry>
</row>
<row>
<entry>Downed Device Detection</entry>
<entry><para>NONE: Deactivate downed host detection
</para><para>PING and SNMP: perform both tests
</para><para>SNMP: verify SNMP check on OID .1 and .1.3
</para><para>ICMP: perform a ping test, see below
</para></entry>
</row>
<row>
<entry>Ping Method</entry>
<entry><para>Available only for "PING and SNMP" or "PING"
</para><para>ICMP: perform ICMP tests. Requires permissions
</para><para>UDP: perform a UDP test
</para><para>TCP: perform a TCP test</para></entry>
</row>
<row>
<entry>Ping Port</entry>
<entry><para>Available only for UDP/TCP PING test types.
</para><para>Please define the port to be tested here.
Make sure, that no firewall intercepts the tests</para></entry>
</row>
<row>
<entry>Ping Timeout Value</entry>
<entry>After this time, the test fails. Measured
in units of milliseconds</entry>
</row>
<row>
<entry>Ping Retry Count</entry>
<entry>The number of times Cacti will attempt to ping a host before failing.</entry>
</row>
<row>
<entry><emphasis>SNMP Options</emphasis></entry>
<entry></entry>
</row>
<row>
<entry>SNMP Version</entry>
<entry><para>Version 1: Use SNMP Version 1.
Be aware, that 64bit counters are not supported in this SNMP version
</para><para>Version 2: Referred to as SNMP V2c in most SNMP documentations
</para><para>Version 3: SNMP V3, supporting authentication and encryption</para></entry>
</row>
<row>
<entry>SNMP Community</entry>
<entry>SNMP read community for this device.</entry>
</row>
<row>
<entry>SNMP Port</entry>
<entry>Enter the UDP port number to use for SNMP (default is 161).</entry>
</row>
<row>
<entry>SNMP Timeout</entry>
<entry>The maximum number of milliseconds Cacti will wait for an SNMP response
(does not work with php-snmp support).</entry>
</row>
<row>
<entry>Maximum OID's Per Get Request</entry>
<entry><para>This is a performance feature. Specifies the number of
OID's that can be obtained in a single SNMP Get request.
</para><para>NOTE: This feature only works when using <application>Spine</application>
</para><para>NOTE: Some devices do not support values &gt; 1</para></entry>
</row>
<row>
<entry><emphasis>Security Options for SNMP V3</emphasis></entry>
<entry></entry>
</row>
<row>
<entry>SNMP Username</entry>
<entry>The <userinput>username</userinput> of an SNMP V3 <userinput>createUser</userinput> statement
or equivalent</entry>
</row>
<row>
<entry>SNMP Password</entry>
<entry>The <userinput>authpassphrase</userinput> of an SNMP V3 <userinput>createUser</userinput> statement
or equivalent</entry>
</row>
<row>
<entry>SNMP Auth Protocol</entry>
<entry>The <userinput>authentication type</userinput> of an SNMP V3 <userinput>createUser</userinput> statement
or equivalent. Select either MD5 or SHA. This entry defaults to MD5.</entry>
</row>
<row>
<entry>SNMP Privacy Passphrase</entry>
<entry>The <userinput>privacy passphrase</userinput> of an SNMP V3 <userinput>createUser</userinput> statement
or equivalent.</entry>
</row>
<row>
<entry>SNMP Privacy Protocol</entry>
<entry>The <userinput>privacy protocol</userinput> of an SNMP V3 <userinput>createUser</userinput> statement
or equivalent. Select either DES or AES. This entry defaults to DES.</entry>
</row>
<row>
<entry>SNMP Context</entry>
<entry>When using the View-Based Access Control Model (VACM), it is possible to specify
an SNMP Context when mapping a community name to a security name with a
<userinput>com2sec</userinput> directive, with the <userinput>group</userinput>
directive and the <userinput>access</userinput> directive. This allows
for defining special access models. If using such a parameter with your
target's SNMP configuration, specify the context name to be used to access
that target here.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
After saving your new device, you should be redirected back to the same edit form with some
additional information. If you configured SNMP for this host by providing a valid community string,
you should see various statistics listed at the top of the page. If you see "SNMP error" instead,
this indicates an SNMP problem between Cacti and your device.
</para>
<para>
Towards the bottom of the page there will be two addition boxes, <guilabel>Associated Data
Queries</guilabel>, and <guilabel>Associated Graph Templates</guilabel>. If you selected a host
template on the previous page, there will probably be a few items in each box. If there is nothing
listed in either box, you will need to associate at least one data query or graph template with
your new device or you will not be able to create graphs in the next step. If no available
graph template or data query applies to your device, you can check the Cacti templates repository
or create your own if nothing currently exists.
</para>
<sect2 id='snmp-info'>
<title>A Word About SNMP</title>
<para>
The SNMP version that you choose can have a great effect on how SNMP works for you in
Cacti. Version 1 should be used for everything unless you have reason to choose otherwise.
If you plan on utilizing (and your device supports) high-speed (64-bit) counters, you must
select version 2. Starting with Cacti 0.8.7, version 3 is fully implemented.
</para>
<para>
The way in which Cacti retrieves SNMP information from a host has an effect on which
SNMP-related options are supported. Currently there are three types of SNMP retrieval
methods in Cacti and are outlined below.
</para>
<table frame='all'>
<title>SNMP Retrieval Types</title>
<tgroup cols='4' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colnum="2">
<colspec colnum="3">
<colspec colnum="4">
<thead>
<row>
<entry align="center">Type</entry>
<entry align="center">Description</entry>
<entry align="center">Supported Options</entry>
<entry align="center">Places Used</entry>
</row>
</thead>
<tbody>
<row>
<entry>External SNMP</entry>
<entry>Calls the net-snmp snmpwalk and snmpget binaries that are installed on your system.</entry>
<entry>All SNMP options</entry>
<entry>Web interface and PHP poller (poller.php)</entry>
</row>
<row>
<entry>Internal SNMP (php-snmp)</entry>
<entry>Uses PHP's SNMP functions which are linked against net-snmp or ucd-snmp at compile time.</entry>
<entry>Version 1 Only (Community and Port)</entry>
<entry>Web interface and PHP poller (poller.php)</entry>
</row>
<row>
<entry><application>Spine</application> SNMP</entry>
<entry>Links directly against net-snmp or ucd-snmp and calls the API directly.</entry>
<entry>All SNMP options</entry>
<entry>C-Based Poller (<application>Spine</application>)</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2 id='snmp-v3'>
<title>SNMP V3 Options Explained</title>
<para>SNMP supports authentication and encryption features
when using SNMP protocol version 3 known as
<emphasis>View-Based Access Control Model (VACM)</emphasis>.
This requires, that the
target device in question supports and is configured for
SNMP V3 use. In general, configuration of V3 options is
target type dependant. The following is cited from
<userinput>man snmpd.conf</userinput> concerning user definitions</para>
<para><screen><citation> <emphasis>SNMPv3 Users</emphasis>
createUser [-e ENGINEID] username (MD5|SHA) authpassphrase [DES|AES] [privpassphrase]
MD5 and SHA are the authentication types to use. DES and AES are the privacy
protocols to use. If the privacy passphrase is not specified, it is assumed
to be the same as the authentication passphrase. Note that the users created will
be useless unless they are also added to the VACM access control tables
described above.
SHA authentication and DES/AES privacy require OpenSSL to be installed and the
agent to be built with OpenSSL support. MD5 authentication may be used without
OpenSSL.
Warning: the minimum pass phrase length is 8 characters.</citation></screen></para>
<para>VACM directives are explained from
<userinput>man snmpd.conf</userinput> as follows</para>
<para><screen><citation> <emphasis>VACM Configuration</emphasis>
The full flexibility of the VACM is available using four configuration directives -
com2sec, group, view and access. These provide direct configuration of the underlying
VACM tables.
com2sec [-Cn CONTEXT] SECNAME SOURCE COMMUNITY
map an SNMPv1 or SNMPv2c community string to a security name - either from a
particular range of source addresses, or globally ("default"). A restricted
source can either be a specific hostname (or address), or a subnet -
represented as IP/MASK (e.g. 10.10.10.0/255.255.255.0), or IP/BITS
(e.g. 10.10.10.0/24), or the IPv6 equivalents.
The same community string can be specified in several separate directives
(presumably with different source tokens), and the first source/community
combination that matches the incoming request will be selected. Various
source/community combinations can also map to the same security name.
If a CONTEXT is specified (using -Cn), the community string will be mapped
to a security name in the named SNMPv3 context. Otherwise the default
context ("") will be used.
group GROUP {v1|v2c|usm} SECNAME
maps a security name (in the specified security model) into a named group.
Several group directives can specify the same group name, allowing a single
access setting to apply to several users and/or community strings.
Note that groups must be set up for the two community-based models separately -
a single com2sec (or equivalent) directive will typically be accompanied by two
group directives.
view VNAME TYPE OID [MASK]
defines a named "view" - a subset of the overall OID tree. This is most commonly
a single subtree, but several view directives can be given with the same view
name, to build up a more complex collection of OIDs. TYPE is either included
or excluded, which can again define a more complex view (e.g by excluding certain
sensitive objects from an otherwise accessible subtree).
MASK is a list of hex octets (separated by <quote>.</quote> or <quote>:</quote>)
with the set bits indicating which subidentifiers in the view OID to match against.
This can be used to define a view covering a particular row (or rows) in a table.
If not specified, this defaults to matching the OID exactly (all bits set), thus
defining a simple OID subtree.
access GROUP CONTEXT {any|v1|v2c|usm} LEVEL PREFX READ WRITE NOTIFY
maps from a group of users/communities (with a particular security model
and minimum security level, and in a specific context) to one of three views,
depending on the request being processed.
LEVEL is one of noauth, auth, or priv. PREFX specifies how CONTEXT should be
matched against the context of the incoming request, either exact or prefix.
READ, WRITE and NOTIFY specifies the view to be used for GET*, SET and
TRAP/INFORM requests (althought the NOTIFY view is not currently used). For
v1 or v2c access, LEVEL will need to be noauth.</citation></screen></para>
<para>As an example, following definitions in the snmpd configuration
create a set of definitions for use with SNMP V3</para>
<screen># sample configuration for SNMP V3
# create an SNMP V3 user with an authpassphrase and a privacy passphrase
## username authProto authpassphrase privProto privpassphrase
## -------- --------- -------------- --------- --------------
createUser gandalf MD5 myauthpass DES myprivpass
# Second, map the security name into a group name:
## groupName securityModel securityName
## --------- ------------- ------------
group groupv3 usm gandalf
# Third, create a view for us to let the group have rights to:
## incl/excl subtree mask
## --------- ------- ----
view all included .iso 80
# Fourth, create the access for that group without context
## context sec.model sec.level prefix read write notif
## ------- --------- --------- ------ ---- ----- -----
access groupv3 "" any auth exact all all all</screen>
<para>When adding this stuff to your snmp configuration, please
remember to restart the agent. Verify this setting using</para>
<screen><prompt>shell&gt;</prompt>snmpwalk -v 3 -a MD5 -A myauthpass -x DES \
-X myprivpass -u gandalf -l authpriv localhost interface
IF-MIB::ifNumber.0 = INTEGER: 3
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.3 = INTEGER: 3
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: irda0
IF-MIB::ifDescr.3 = STRING: eth0
IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
IF-MIB::ifType.2 = INTEGER: other(1)
IF-MIB::ifType.3 = INTEGER: ethernetCsmacd(6)
...</screen>
</sect2>
</sect1>
<sect1 id="new-graphs">
<title>Creating the Graphs</title>
<para>
Now that you have created some devices, it is time to create graphs for these devices. To
do this, select the <guilabel>New Graphs</guilabel> menu option under the <guilabel>Create</guilabel>
heading. If you're still at the device edit screen, select <guilabel>Create Graphs for this Host</guilabel> to
see a screen similar to the image pictured below.
</para>
<figure id="img-graph-new">
<title>Creating New Graphs</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/new_graphs" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
The dropdown menu that contains each device should be used to select the host that you
want to create new graphs for. The basic concept to this page is simple, place a check in each
row that you want to create a graph for and click <guilabel>Create</guilabel>.
</para>
<para>
If you are creating graphs from inside a "Data Query" box, there are a few additional things to
keep in mind. First is that you may encounter the situation as pictured above with the "SNMP -
Interface Statistics" data query. If this occurs you may want to consult the section on debugging
data queries to see why your data query is not returning any results. Also, you may see a "Select
a graph type" dropdown box under some data query boxes. Changing the value of this dropdown box
affects which type of graph Cacti will make after clicking the <guilabel>Create</guilabel> button.
Cacti only displays this dropdown box when there is more than one type to choose from, so it may
not be displayed in all cases.
</para>
<para>
Once you have selected the graphs that you want to create, simply click the <guilabel>Create</guilabel>
button at the bottom of the page. You will be taken to a new page that allows you to specify
additional information about the graphs you are about to create. You only see the fields here
that are not part of each template, otherwise the value automatically comes from the template.
When all of the values on this page look correct, click the <guilabel>Create</guilabel> button
one last time to actually create your graphs.
</para>
<para>
If you would like to edit or delete your graphs after they have been created, use the
<guilabel>Graph Management</guilabel> item on the menu. Likewise, the <guilabel>Data Source
</guilabel> menu item allows you to manage your data sources in Cacti.
</para>
</sect1>
</chapter>
<chapter id="graph-viewing">
<title>Viewing Graphs</title>
<sect1 id="new-graph-trees">
<title>Graph Trees</title>
<para>
A graph tree can be thought of as a hierarchical way of organizing your graphs. Each graph tree
consists of zero or more headers or branch nodes that contain leaf nodes such as graphs or trees.
Multiple graph trees or branches within a single tree can be combined to form a very powerful way
of organizing your graphs.
</para>
<sect2 id="new-graph-tree">
<title>Creating a Graph Tree</title>
<para>
To create a new graph tree, select the <guilabel>Graph Trees</guilabel> menu item under the
<guilabel>Management</guilabel> header. Select <guilabel>Add</guilabel> on this page to create a
new tree. The following page will prompt you for a tree name, which will be used to identify the
graph tree throughout Cacti.
Along with the <guilabel>Name</guilabel>, you may select one of four currently supported
<guilabel>Sorting Types</guilabel></para>
<table frame='all'>
<title>Tree Sporting Type Definitions</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Field</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Name</entry>
<entry>Name of the tree entry.
The sort order of all trees themselves is
always alphabetical</entry>
</row>
<row>
<entry>Sorting Type</entry>
<entry><para>Manual Ordering (No Sorting): You may chance the sequence at your will
</para><para>Alphabetical Ordering: All subtrees are ordered alphabetically, unless specifies otherwise (you may chance sort options at subtree lebel), i.e. 1, Ab, ab
</para><para>Natural Ordering: ie. ab1, ab2, ab7, ab10, ab20
</para><para>Numeric Ordering: Leading zeroes are not taken into account when ordering numerically, i.e. 01, 02, 4, 04
</para></entry>
</row>
</tbody>
</tgroup>
</table>
<para>Once you type a name, click the <guilabel>Create</guilabel> button to
continue. You will be redirected to a page similar to the one below, but without all of the items.
</para>
<figure id="img-graph-tree-new">
<title>Editing a Graph Tree</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/graph_tree" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
To start adding items to your tree, click add in the <guilabel>Tree Items</guilabel> box. There are
currently three different types of tree items you can choose from: header, graph, or host. Simply
choose the type you want, fill in the value for that type, and click <guilabel>Create</guilabel> to
make your new graph tree item. Clicking the <guilabel>Add</guilabel> link to the right of any branch
will add the new item below that branch, you can change the branch that any item belongs to by changing
its <guilabel>Parent Item</guilabel> field.
</para>
<para>
Please note the "++" and the "--" buttons. They will help you managing large trees.
Pressing the "--" will collapse all tree levels while "++" expands all of them.
You may expand each single subtree of a collapsed tree to reorder, add or delete entries
without much scrolling.
</para>
</sect2>
</sect1>
</chapter>
<chapter id="user-management">
<title>User Management</title>
<para>
In addition to giving you the tools to create sophisticated graphs, Cacti enables you to create users
that are tailored specifically to their requirements. Each user has certain settings such as login
actions, as well as graph viewing settings. There are also two levels of permissions control, realm
permissions and graph permissions which enable you to control what the user can see and change.
</para>
<figure id="img-user-list">
<title>User Management</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_list" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
Out of the box, there are two users that come with every Cacti installation. The "admin" user, is the
main user that by default has access to see and change everything in Cacti. This is the user that you
first login with in Cacti, and is probably a good idea to keep around unless you know otherwise. The
second user is the "guest" user, which controls which areas/graphs are allowed for unauthenticated
users. By default this user only has rights to view, but not change all graphs. This enables any
unauthenticated user to visit 'graph_view.php' and view your graphs. This behavior can be changed by
either changing the realm permissions for the "guest" user, or disabling the guest user altogether
under <guilabel>Cacti Settings</guilabel>. By default in 0.8.7 and later, the "guest" user is not
set in the setting, effectively disabling "guest" (Unauthenticated) access to Cacti.
</para>
<sect1 id="edit-existing-user">
<title>Editing an existing User</title>
<para>
To edit an existing user, select the <guilabel>User Management</guilabel> item under the
<guilabel>Utilities</guilabel> heading on the Cacti menu. Once at the user management screen,
click username of the user you wish to edit. You will see a screen that looks similar to the image below.
</para>
<figure id="img-user-edit">
<title>Editing a User</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_edit" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
At minimum, you must specify a <guilabel>User Name</guilabel> and
a <guilabel>Password</guilabel> for each user. Each user field is described in more detail
below. In addition to these fields, each user can have their own realm permissions", graph
permissions, and graph settings. Each of these items are described in this section of the
manual.
</para>
<table frame='all'>
<title>Field Description: User Management</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>User Name</entry>
<entry>This field contains the actual login name for the user. There are no character limits this field, but it would make sense to keep it to alphanumeric characters to maintain simplicity.</entry>
</row>
<row>
<entry>Full Name</entry>
<entry>(Optional) You can use this field as a more descriptive identifier for the user. It is currently only used for display on the user management page.</entry>
</row>
<row>
<entry>Password</entry>
<entry>Enter the password for the user twice, once in each text box. Keep in mind that passwords are case sensitive and the password will remain unchanged if the boxes are both left empty.</entry>
</row>
<row>
<entry>Account Options</entry>
<entry>There are currently two account related options that can be set for each user. The first, 'User Must Change Password at Next Login', forces a password change immediately after the user logs in. The second option, 'Allow this User to Keep Custom Graph Settings', dictates whether the user can maintain their own custom graph viewing settings which includes expanding and collapsing trees.</entry>
</row>
<row>
<entry>Graph Options</entry>
<entry>There are three permission related options that can be set for each user here. The 'User Has Rights to {Tree,List,Preview} View' checkboxes dictate which graph viewing areas the user can see.</entry>
</row>
<row>
<entry>Login Options</entry>
<entry>These options dictate what occurs immediately after the user logs in. The first option, 'Show the page that user pointed their browser to.' will point the user to whatever page they were heading to before being interrupted by the login page. The 'Show the default console screen.' option will always point the user to 'index.php' after a successful login. The last option, 'Show the default graph screen.' will point the user to 'graph_view.php' after a successful login.</entry>
</row>
<row>
<entry>Authentication Realm</entry>
<entry>Multiple types of users can exist in Cacti. This setting allows you to specify a user for use with Local, Web Basic or LDAP Authentication. Template users must be Local. </entry>
</row>
</tbody>
</tgroup>
</table>
<sect2 id="realm-permissions">
<title>Realm Permissions</title>
<para>
Realm permissions control which areas of Cacti a user can access. You can edit a user's realm
permissions by selecting <guilabel>User Management</guilabel> and choosing the user you
want to edit the permissions for. The <guilabel>Realm Permissions</guilabel> box will be displayed
in the lower part of the screen. Each "realm" is a grouping that represents common tasks in Cacti,
making it easier to fine tune each user's access.
</para>
<para>
If you want to create a user that can only view graphs, you should select the <guilabel>View
Graphs</guilabel> realm and leave everything else unchecked. See the <guilabel>Graph
Permissions</guilabel> section for more information about how to fine tune this even more on a per-graph
basis. Conversely, if the user needs to access the console, they will need <guilabel>Console
Access</guilabel> and any additional realms that you see fit.
</para>
</sect2>
<sect2 id="graph-permissions">
<title>Graph Permissions</title>
<para>
Graph permissions control which graphs a user is allowed to view, it does not apply to editing graphs.
You can edit a user's graph permissions by selecting <guilabel>User Management</guilabel> and choosing
the user you want to edit the permissions for. Now select the <guilabel>Graph Permissions</guilabel> tab
to view this user's graph permissions. There are three different ways that you can apply graph permissions,
by graph, by host, or by graph template. This works by allowing or denying the user to all graphs associated
with the particular group. So you can deny a user to a single graph, all graphs associated with a particular
host, or all graphs associated with a particular graph template. Combining these three types of assigning
graph permissions results in a very powerful graph policy editor.
</para>
<para>
Each assignment type contains a <guilabel>Default Policy</guilabel> dropdown which can be used to control
whether the user should be allowed to view everything or be denied from everything by default in the particular
group. It is very important to remember that these policies are evaluated in the order: graph, host, graph
template. Therefore, if you set graph's default policy to <guilabel>Deny</guilabel>, but kept host and graph
template at <guilabel>Allow</guilabel>, the user's effective policy would be <guilabel>Deny</guilabel> since
the graph assignment type is evaluated first. You typically either want to set all default policies to
<guilabel>Deny</guilabel> for a restrictive user, or <guilabel>Allow</guilabel> for a non-restrictive user.
If you thoroughly understand Cacti's graph permissions system, these default policies can be combined to provide
very complex results.
</para>
</sect2>
<sect2 id="graph-settings">
<title>Graph Settings</title>
<para>
Cacti stores certain graph viewing settings for each user, which enables each user to view graphs in an optimal
way. These preferences controls things such as the preview graph size or the default graph viewing mode to use.
In addition to managing these settings here under user management, each user can change their own settings by
clicking on the <guilabel>Graphs</guilabel> tab and selecting the <guilabel>Settings</guilabel> tab on the
following page. If you want to prevent a user from being able to keep their own graph preferences, uncheck the
<guilabel>Allow this User to Keep Custom Graph Settings</guilabel> checkbox in user management. The user will be
presented with an "Access Denied" error message if they attempt to click the <guilabel>Settings</guilabel> tab
when this box is checked.
</para>
</sect2>
</sect1>
<sect1 id="create-new-user">
<title>Creating a New User</title>
<para>
To create a new user, select the <guilabel>User Management</guilabel> item under the
<guilabel>Utilities</guilabel> heading on the Cacti menu. Once at the user management screen,
click <guilabel>Add</guilabel>.
</para>
<figure id="img-user-new">
<title>Adding a User</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_new" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
At minimum, you must specify a <guilabel>User Name</guilabel> and
a <guilabel>Password</guilabel> for each user. Each user field is described in more detail
in the Editing an existing User section previous to this one. In addition to these fields,
each user can have their own realm permissions", graph permissions, and graph settings. Each
of these items are described in editing existing users section of the manual.
</para>
</sect1>
<sect1 id="copying-user">
<title>Copying a user</title>
<figure id="img-user-copy-1">
<title>Copy a User Part 1</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_copy_1" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
To copy a user to a new user, select the <guilabel>User Management</guilabel> item under the
<guilabel>Utilities</guilabel> heading on the Cacti menu. Once at the user management screen,
select the user you would like to copy from and select copy from the <guilabel>Action</guilabel>
selection box, click <guilabel>Go</guilabel> to continue. If you select multiple users,
only the first selected user will be used as the source user.
</para>
<figure id="img-user-copy-2">
<title>Copy a User Part 2</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_copy_2" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
Specify the <guilabel>New Username</guilabel>, <guilabel>New Full Name</guilabel> and
<guilabel>New Realm</guilabel> of the new user. Click <guilabel>Yes</guilabel> to copy the
selected template user to the the designated new user. An error will be returned if you attempt
to copy over an existing user. If you would like to copy over an existing user, use
<guilabel>Batch Copy</guilabel>.
</para>
</sect1>
<sect1 id="enable-disable-users">
<title>Enable/Disable Users</title>
<figure id="img-user-enable-disable-1">
<title>Enable/Disable Users Part 1</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_enable_disable_1" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
To enable or disable a set of or a single user, select the <guilabel>User Management</guilabel>
item under the <guilabel>Utilities</guilabel> heading on the Cacti menu. Once at the user management
screen, select the user(s) you would like to enable or disable and select enable or disable from the
<guilabel>Action</guilabel> selection box, click <guilabel>Go</guilabel> to continue.
</para>
<figure id="img-user-enable-disable-2">
<title>Enable/Disable Users Part 2</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_enable_disable_2" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
Confirm that you want to disable or enable the listed users. Click <guilabel>Yes</guilabel> to
perform the action. Disabling your own account is possible and not recommended, as once you logoff
you will not be able to return.
</para>
</sect1>
<sect1 id="batch-copy-users">
<title>Batch Copy Users</title>
<para>
Batch Copy is a helpful utility that helps Cacti Administrators maintain users. Because Cacti
does not yet support groups, it is important that there is some way to mass update users. This
what Batch Copy does for you.
</para>
<figure id="img-user-batch-copy-1">
<title>Batch Copy Users Part 1</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_batch_copy_1" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
To Batch Copy a set of or a single user, select the <guilabel>User Management</guilabel>
item under the <guilabel>Utilities</guilabel> heading on the Cacti menu. Once at the user management
screen, select the user(s) you would like to batch copy information to and select "Batch Copy" from the
<guilabel>Action</guilabel> selection box, click <guilabel>Go</guilabel> to continue.
</para>
<figure id="img-user-batch-copy-2">
<title>Batch Copy Users Part 2</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_batch_copy_2" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
Select the <guilabel>Template User</guilabel> and confirm that you want to Batch Copy the listed users.
Click <guilabel>Yes</guilabel> to perform the action.
</para>
<para>
It is important to note that when using <guilabel>Batch Copy</guilabel> the original user(s) Full Name,
Password, Realm and Enable status will be retained, all other fields will be overwritten with values from
the selected template user.
</para>
</sect1>
<sect1 id="delete-users">
<title>Delete Users</title>
<figure id="img-user-delete-1">
<title>Delete Users Part 1</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_delete_1" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
To delete a set of or a single user, select the <guilabel>User Management</guilabel>
item under the <guilabel>Utilities</guilabel> heading on the Cacti menu. Once at the user management
screen, select the user(s) you would like to delete and select delete from the
<guilabel>Action</guilabel> selection box, click <guilabel>Go</guilabel> to continue.
</para>
<figure id="img-user-delete-2">
<title>Delete Users Part 2</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/user_management_delete_2" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>
Confirm that you want to delete the listed users. Click <guilabel>Yes</guilabel> to
perform the action. Deleting your own account is possible and not recommended.
</para>
</sect1>
<sect1 id="guest-access">
<title>Guest (Anonymous) Access </title>
<para>
By default in 0.8.7 and later of Cacti, Guest or Anonymous access is disabled. This is
shift from previous release that came with the "Guest" user enabled and set.
</para>
<para>
Enabling "Guest" access is easy. But, you must understand that you should only allow the
designated "Guest" user access to what you authorized. It is not sugguested that you give
the designated "Guest" user more than just access to graphs. To enable guest access, first,
need a designated "Guest" user. Cacti by default comes with one already created that has
access to only graphs. It is important to note that the default guest user has access to all
graphs on the system. Once you have created the "Guest" user, you need to tell Cacti what
the "Guest" user is. This is done by updating the Authenication Settings and selecting the
"Guest" user you have designated. The "Guest" user must be enabled and be set as the guest
user for anonymous access to work.
</para>
</sect1>
</chapter>
</part>
<part id="advanced-topics">
<title>Advanced Topics</title>
<chapter id="graph-snmp-oid">
<title>Graph a Single SNMP OID</title>
<para>
When dealing with SNMP-enabled devices, there are often times when you want to graph the value of a single
OID. This tutorial explains how to do this in Cacti. It also assumes that you have the "SNMP - Generic OID
Template" graph template, which is now included in Cacti as of version 0.8.5. If you do not see this
template listed under <guilabel>Graph Templates</guilabel>, download the template from the Cacti website
in XML form and import it using the <guilabel>Import Templates</guilabel> menu item.
</para>
<para>
To start the process of creating a new graph for your OID, click the <guilabel>New Graphs</guilabel> menu
item and select the host that contains the target OID from the dropdown. Under the <guilabel>Graph
Templates</guilabel> box, you will see a dropdown on the last line that reads <guilabel>(Select a graph
type to create)</guilabel>. From this dropdown, choose "SNMP - Generic OID Template" and click the
<guilabel>Create</guilabel> button at the bottom of the page.
</para>
<para>
You will be presented with several fields that will require input before the new graph can be created.
They are described in more detail below.
</para>
<table frame='all'>
<title>Field Description: SNMP - Generic OID Template</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>(Graph) Title</entry>
<entry>The title that is to be used for the new graph. It is generally a good idea to keep |host_description| in the title, as to make the graph easier to identify later.</entry>
</row>
<row>
<entry>(Graph) Vertical Label</entry>
<entry>The text that will be printed along the y-axis of the graph. It is generally used to describe units, such as 'bytes' or 'percent'.</entry>
</row>
<row>
<entry>(Graph Items) Legend Color</entry>
<entry>The color that will be used to represent the data on the graph.</entry>
</row>
<row>
<entry>(Graph Items) Opacity/Alpha Channel</entry>
<entry>This optionally provides an opacity (not available with rrdtool-1.0.x) for a colored item.</entry>
</row>
<row>
<entry>(Graph Items) Legend Text</entry>
<entry>The text that will be used to describe the data on the graph legend.</entry>
</row>
<row>
<entry>(Data Source) Name</entry>
<entry>The title that is to be used for the new data source. It is generally a good idea to keep |host_description| in the title, as to make the data source easier to identify later.</entry>
</row>
<row>
<entry>(Data Source) Maximum Value [snmp_oid]</entry>
<entry>The maximum value that will be accepted from the OID. Make sure you choose a value that is reasonable for the data you are trying to graph because anything larger than the maximum will be ignored. If you are graphing a percentage, you should use '100' as the value should never exceed this.</entry>
</row>
<row>
<entry>(Data Source) Data Source Type [snmp_oid]</entry>
<entry>How the data from the OID should be stored by RRDTool and interpreted on the graph. If the value of the OID represents the actual data, you should use <guilabel>GAUGE</guilabel> for this field. If the OID value is a constantly incrementing number, you should use <guilabel>COUNTER</guilabel> for this field. The two remaining field values, <guilabel>DERIVE</guilabel> and <guilabel>ABSOLUTE</guilabel> can be ignored in most situations.</entry>
</row>
<row>
<entry>(Custom Data) OID</entry>
<entry>The actual SNMP OID to graph. It is typically a good idea to enter the number OID here as opposed to using MIB names. For instance, to get the number of open files on a Netware server, you would use ".1.3.6.1.4.1.23.2.28.2.7.0" as the OID.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
When finished filling in values for these fields, click the <guilabel>Create</guilabel> button. Your new graph can
now be accessed through the <guilabel>Graph Management</guilabel> page or the <guilabel>Graphs</guilabel> tab
inside of Cacti.
</para>
</chapter>
<chapter id="data-input-methods">
<title>Data Input Methods</title>
<para>
Data input methods allow Cacti to retrieve data to insert into data sources and ultimately put on a graph.
There are different ways for Cacti to retrieve data, the most popular being through an external script or from
SNMP.
</para>
<sect1 id="new-data-input-method">
<title>Creating a Data Input Method</title>
<para>
To create a new data input method, select the <guilabel>Data Input Methods</guilabel> option under
the <guilabel>Management</guilabel> heading. Once on that screen, click <guilabel>Add</guilabel> on the
right. You will be presented with a few fields to populate on the following screen.
</para>
<table frame='all'>
<title>Field Description: Data Input Methods</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Name</entry>
<entry>Give the data query a name that you will use to identify it. This name will be used throughout Cacti to identify the data input method.</entry>
</row>
<row>
<entry>Input Type</entry>
<entry>Select the type of data input method you are trying to create. Valid options here are 'Script/Command', 'SNMP', 'SNMP Query', and 'Script Query'.</entry>
</row>
<row>
<entry>Input String</entry>
<entry><para>This field is only used when the <guilabel>Input Type</guilabel> is set to 'Script/Command'. It specifies the full path to the script including any per data source variables inside &lt;&gt;'s from the user. For instance, if you are passing an IP address to a script, your input string might look something like:</para><para><emphasis>/path/to/script.pl &lt;ip&gt;</emphasis></para><para>When the user creates a data source based on this data input method, they will be prompted for an IP address to pass onto the script.</para></entry>
</row>
<row>
<entry>Output String</entry>
<entry>This field is only here for legacy purposes and will probably go away in a future version of Cacti.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
When you are finished filling in all necessary fields, click the <guilabel>Create</guilabel> button to continue. You will
be redirected back to the same page, but this time with two new boxes, <guilabel>Input Fields</guilabel> and <guilabel>Output
Fields</guilabel>. The <guilabel>Input Fields</guilabel> box is used to define any fields that require information from the
user. Any input fields referenced to in the input string must be defined here. The <guilabel>Output Fields</guilabel> box
is used to define each field that you expect back from the script. <emphasis>All data input methods must have at least one output field
defined</emphasis>, but may have more for a script.
</para>
<sect2 id='data-input-fields'>
<title>Data Input Fields</title>
<para>
To define a new field, click <guilabel>Add</guilabel> next to the input or output field boxes. You
will be presented with some or all of the fields below depending on whether you are adding an input or
output field.
</para>
<table frame='all'>
<title>Field Description: Data Input Fields</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Field/Field Name</entry>
<entry>Either select or type in the name of the field you want to define. No spaces or other non-alphanumeric characters (except '-' or '_') should be used in this field.</entry>
</row>
<row>
<entry>Friendly Name</entry>
<entry>Enter a more descriptive name for this field which will be used for identification throughout Cacti.</entry>
</row>
<row>
<entry>Regular Expression Match (Input Only)</entry>
<entry>If you want to enforce a certain regular expression pattern when the user enters a value for this field, enter it here. The regular expression must follow POSIX syntax as it will be passed to PHP's ereg() function.</entry>
</row>
<row>
<entry>Allow Empty Input (Input Only)</entry>
<entry>Select whether you want to allow the user to leave the value of this field blank or not.</entry>
</row>
<row>
<entry>Special Type Code (Input Only) </entry>
<entry>Sometimes Cacti needs to reference a field internally, but needs to rely on more than just the field name. For instance, if your field requires an IP address from the user, you can enter 'management_ip' here and Cacti will fill this field in with the current IP address of the selected host. Valid values for this field are: 'hostname', 'management_ip', 'snmp_community', 'snmp_username', 'snmp_password', and 'snmp_version'.</entry>
</row>
<row>
<entry>Update RRD File (Output Only)</entry>
<entry>Check this box if you want Cacti to insert the return value from this field into the RRD file. Obviously, this box needs to be checked for at least one output field per data input source, but can be left blank to have Cacti store the value in the database instead.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
When you are finished filling in all necessary fields, click the <guilabel>Create</guilabel> button to continue. You
will be redirected back to the data input method edit page. From here you can continue to add additional fields, or
click <guilabel>Save</guilabel> on this screen when finished.
</para>
</sect2>
</sect1>
<sect1 id="making-scripts-work-with-cacti">
<title>Making Your Scripts Work With Cacti</title>
<para>
The simplest way to extend Cacti's data gathering functionality is through external scripts. Cacti comes
with a number of scripts out of the box which are located in the <filename>scripts/</filename> directory.
These scripts are used by the data input methods that are present in a new installation of Cacti.
</para>
<para>
To have Cacti call an external script to gather data you must create a new data input method, making sure
to specify <guilabel>Script/Command</guilabel> for the <guilabel>Input Type</guilabel> field. See the
previous section, <ulink url="data_input_methods.html">Creating a Data Input Method</ulink> for more
information about how to create a data input method. To gather data using your data input method, Cacti
simply executes the shell command specified in the <guilabel>Input String</guilabel> field. Because of
this, you can have Cacti run any shell command or call any script which can be written in almost any
language.
</para>
<para>
What Cacti is concerned with is the output of the script. When you define your data input method, you are
required to define one or more output fields. The number of output fields that you define here is important
to your script's output. For a data input method with only one output field, your script should output its
value in the following format:
</para>
<screen><userinput>&lt;value_1&gt;</userinput></screen>
<para>
So if I wrote a script that outputs the number of running processes, its output might look like the
following:
</para>
<example>
<title>Example script output using 1 field</title>
<para>
<userinput>67</userinput>
</para>
</example>
<para>
Data input methods with more than one output field are handled a bit differently when writing scripts.
Scripts that output more than one value should be formatted like the following:
</para>
<screen><userinput>&lt;fieldname_1&gt;:&lt;value_1&gt; &lt;fieldname_2&gt;:&lt;value_2&gt; ... &lt;fieldname_n&gt;:&lt;value_n&gt;</userinput></screen>
<para>
Lets say that I write a script that outputs the 1, 5, and 10 minute load average of a Unix machine. In Cacti,
I name the output fields '1min', '5min', and '10min', respectively. Based on these two things, the output of
the script should look like the following:
</para>
<example>
<title>Example script output using 3 fields</title>
<para>
<userinput>1min:0.40 5min:0.32 10min:0.01</userinput>
</para>
</example>
<para>
One last thing to keep in mind when writing scripts for Cacti is that they will be executed as the user the
data gatherer runs as. Sometimes a script may work correctly when executed as root, but fails due to permissions
problems when executed as a less privileged user.
</para>
</sect1>
</chapter>
<chapter id="data-queries">
<title>Data Queries</title>
<para>
Data queries are not a replacement for data input methods in Cacti. Instead they provide an easy way to
query, or list data based upon an index, making the data easier to graph. The most common use of a data query
within Cacti is to retrieve a list of network interfaces via SNMP. If you want to graph the traffic of a network
interface, first Cacti must retrieve a list of interfaces on the host. Second, Cacti can use that
information to create the necessary graphs and data sources. Data queries are only concerned with the
first step of the process, that is obtaining a list of network interfaces and not creating the graphs/data
sources for them. While listing network interfaces is a common use for data queries, they also have other
uses such as listing partitions, processors, or even cards in a router.
</para>
<para>
One requirement for any data query in Cacti, is that it has some unique value that defines each row in the list.
This concept follows that of a 'primary key' in SQL, and makes sure that each row in the list can be uniquely
referenced. Examples of these index values are 'ifIndex' for SNMP network interfaces or the device name for
partitions.
</para>
<para>
There are two types of data queries that you will see referred to throughout Cacti. They are script
queries and SNMP queries. Script and SNMP queries are virtually identical in their functionality and
only differ in how they obtain their information. A script query will call an external command or
script and an SNMP query will make an SNMP call to retrieve a list of data.
</para>
<para>
All data queries have two parts, the XML file and the definition within Cacti. An XML file must be
created for each query, that defines where each piece of information is and how to retrieve it. This
could be thought of as the actual query. The second part is a definition within Cacti, which tells
Cacti where to find the XML file and associates the data query with one or more graph templates.
</para>
<sect1 id="new-data-query">
<title>Creating a Data Query</title>
<para>
Once you have created the XML file that defines your data query, you must add the data query
within Cacti. To do this you must click on <guilabel>Data Queries</guilabel> under the <guilabel>Data
Gathering</guilabel> heading, and select <guilabel>Add</guilabel>. You will be prompted for some
basic information about the data query, described in more detail below.
</para>
<table frame='all'>
<title>Field Description: Data Queries</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Name</entry>
<entry>Give the data query a name that you will use to identify it. This name will be used throughout Cacti when presented with a list of data queries.</entry>
</row>
<row>
<entry>Description</entry>
<entry>(Optional) Enter a more detailed description of the data query including the information it queries or additional requirements.</entry>
</row>
<row>
<entry>XML Path</entry>
<entry>Fill in the full path to the XML file that defines this query. You can optionally use the &lt;path_cacti&gt; variable that will be substituted with the full path to Cacti. On the next screen, Cacti will check to make sure that it can find the XML file.</entry>
</row>
<row>
<entry>Data Input Method</entry>
<entry>This is how you tell Cacti to handle the data it receives from the data query. Typically, you will select "Get SNMP Data (Indexed)" for an SNMP query and "Get Script Data (Indexed)" for a script query.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
When you are finished filling in all necessary fields, click the <guilabel>Create</guilabel> button
to continue. You will be redirected back to the same page, but this time with some additional
information to fill in. If you receive a red warning that says 'XML File Does Not Exist', correct
the value specified in the 'XML Path' field.
</para>
<sect2 id="data-queries-associated-graph-templates">
<title>Associated Graph Templates</title>
<para>
Every data query must have at least one graph template associated with it, and possibly
more depending on the number of output fields specified in the XML file. This is where
you get to choose what kind of graphs to generate from this query. For instance, the
interface data query has multiple graph template associations, used to graph traffic,
errors, or packets. To add a new graph template association, simply click <guilabel>Add</guilabel>
at the right of the <guilabel>Associated Graph Templates</guilabel> box. You will be presented
with a few fields to fill in:
</para>
<table frame='all'>
<title>Field Description: Associated Graph Templates</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Name</entry>
<entry>Give a name describing what kind of data you are trying to represent or graph. When the user creates a graph using this data query, they will see a list of graph template associations that they will have to choose from.</entry>
</row>
<row>
<entry>Graph Template</entry>
<entry>Choose the actual graph template that you want to make the association with.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
When you are finished filling in these fields, click the <guilabel>Create</guilabel> button.
You will be redirected back to the same page with some additional information to fill in. Cacti
will make a list of each data template referenced to in your selected graph template and display
them under the <guilabel>Associated Data Templates</guilabel> box. For each data source item
listed, you must selected the data query output field that corresponds with it. <emphasis>Do not forget to
check the checkbox to the right of each selection, or your settings will not be saved.</emphasis>
</para>
<para>
The <guilabel>Suggested Values</guilabel> box gives you a way to control field values of data sources and graphs
created using this data query. If you specify multiple suggested values for the same field, Cacti will evaluate
them in order which you can control using the up or down arrow icons. For more information about valid field names
and variables, read the section on suggested values.
</para>
<para>
When you are finished filling in all necessary fields on this form, click the <guilabel>Save</guilabel> button to
return to the data queries edit screen. Repeat the steps under this heading as many times as necessary to represent
all data in your XML file. When you are finished with this, you should be ready to start adding your data query to
hosts.
</para>
</sect2>
</sect1>
<sect1 id="snmp-query-xml">
<title>SNMP Query XML Syntax</title>
<programlisting>&lt;query&gt;
&lt;name&gt;Get SNMP Interfaces&lt;/name&gt;
&lt;description&gt;Queries a host for a list of monitorable interfaces&lt;/description&gt;
&lt;oid_uptime&gt;.1.3.x.x.x&lt;/oid_uptime&gt;
&lt;oid_index&gt;.1.3.6.1.2.1.2.2.1.1&lt;/oid_index&gt;
&lt;oid_index_parse&gt;OID/REGEXP:.*\.([0-9]{1,3}\.[0-9]{1,3})$&lt;/oid_index_parse&gt;
&lt;oid_num_indexes&gt;.1.3.6.1.2.1.2.1.0&lt;/oid_num_indexes&gt;
&lt;index_order&gt;ifDescr:ifName:ifIndex&lt;/index_order&gt;
&lt;index_order_type&gt;numeric&lt;/index_order_type&gt;
&lt;index_title_format&gt;|chosen_order_field|&lt;/index_title_format&gt;
&lt;fields&gt;
&lt;ifIndex&gt;
&lt;name&gt;Index&lt;/name&gt;
&lt;method&gt;walk&lt;/method&gt;
&lt;source&gt;value&lt;/source&gt;
&lt;direction&gt;input&lt;/direction&gt;
&lt;oid&gt;.1.3.6.1.2.1.2.2.1.1&lt;/oid&gt;
&lt;/ifIndex&gt;
&lt;/fields&gt;
&lt;/query&gt;</programlisting>
<table frame='all'>
<title>SNMP Query XML Field Reference</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="2*" colnum="2">
<thead>
<row>
<entry align="center">Field</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>query-&gt;name</entry>
<entry>(Optional) You can enter a "friendly name" for the SNMP query here. It will not be used by Cacti, and is for identification only.</entry>
</row>
<row>
<entry>query-&gt;description</entry>
<entry>(Optional) You can enter a description for the SNMP query here. It will not be used by Cacti, and is for identification only.</entry>
</row>
<row>
<entry>query-&gt;oid_uptime</entry>
<entry><para>New with 0.8.7: If you have another OID that contains timetics, say for example a Java VM. Then, you can create a data query that specifies an alternate Uptime OID. To implement this for a data query, simply add the oid_uptime
XML parameter to your XML file. Then, if you select your re-index method to be Uptime Goes Backaward, Cacti will use that OID to detect whether it is time to re-index the host instead of the standard snmp OID for uptime.</para></entry>
</row>
<row>
<entry>query-&gt;oid_index</entry>
<entry><para>Every SNMP query must have an OID that represents the index values for the query when walked. As described above, any data query in Cacti must contain a field that uniquely identifies each row returned by the query. In the example above, the oid_index points to the OID of ifIndex in the interface MIB.</para><para><emphasis>Note:</emphasis> Starting with version 0.8.6c, Cacti is able to parse unique indexes from the OID itself. While the regular expression used for parsing the value from the OID is defined below, you must still specify an OID that can be walked by Cacti in order to obtain the list of OID's. Any OID defined for one of your input fields should work in this case. The values returned from the snmpwalk walk will be completely disregarded.</para></entry>
</row>
<row>
<entry>query-&gt;oid_index_parse</entry>
<entry>This field should only be used if you are trying to parse the unique index from the OID itself. If this field is defined, to obtain a list of indexes, Cacti walks the OID provided in the <property>oid_index</property> field above. It then applies the regular expression provided in this field to the list of OID's that are returned. The matched substrings that remain become the list of indexes for this SNMP query.</entry>
</row>
<row>
<entry>query-&gt;oid_num_indexes</entry>
<entry>An OID that can be queried to determine the total number of available indexes. If specified, this will be used to determine when to automatically recache this SNMP query when it is attached to a device.</entry>
</row>
<row>
<entry>query-&gt;index_order</entry>
<entry>As of version 0.8.6, Cacti will attempt to find the best field to index off of based on whether each row in the query is unique and non-null. If specified, Cacti will perform this check on the fields listed here in the order specified. Only input fields can be specified and multiple fields should be delimited with a colon.</entry>
</row>
<row>
<entry>query-&gt;index_order_type</entry>
<entry><para>For sorting purposes, specify whether the index is numeric or alphanumeric.</para><para><parameter>numeric</parameter>: The indexes in this SNMP query are to be sorted numerically (ie. 1,2,3,10,20,31)</para><para><parameter>alphabetic</parameter>: The indexes in this SNMP query are to be sorted alphabetically (1,10,2,20,3,31).</para></entry>
</row>
<row>
<entry>query-&gt;index_title_format</entry>
<entry>Specify the title format to use when representing an index to the user. Any input field name can be used as a variable if enclosed in pipes (|). The variable <parameter>|chosen_order_field|</parameter> will be substituted with the field chosen by Cacti to index off of (see index_order above).</entry>
</row>
<row>
<entry>query-&gt;fields</entry>
<entry>Each field contained within the SNMP query must be defined under this tag.</entry>
</row>
<row>
<entry>query-&gt;fields-&gt;ifIndex</entry>
<entry>Each defined field in the SNMP query must have a unique name given to it. Do not use spaces or any non-alphanumeric characters, this name must be identifiable within Cacti.</entry>
</row>
<row>
<entry>query-&gt;fields-&gt;ifIndex-&gt;name</entry>
<entry>Here you can specify a "friendly name" for the field. This name will be used by Cacti to help the user identify this field.</entry>
</row>
<row>
<entry>query-&gt;fields-&gt;ifIndex-&gt;method</entry>
<entry><para>Tell Cacti how you want it to gather SNMP information for this field.</para><para><parameter>get</parameter>: The 'get' method performs an snmpget for the OID specified for this field appended by the index values derived from &lt;oid_index&gt;/&lt;oid_index_parse&gt;.</para><para><parameter>walk</parameter>: The 'walk' method does a walk of the OID specified for this field.</para><para>If all OIDs belong to the same SNMP table, both methods will return the same values, even though the 'walk' method is typically more efficient.</para></entry>
</row>
<row>
<entry>query-&gt;fields-&gt;ifIndex-&gt;source</entry>
<entry><para>When Cacti obtains a list for this field, you need to tell it how to derive its value for each row.</para><para><parameter>value</parameter>: The 'value' option simply returns the result of the snmpget for each row.</para><para><parameter>OID/REGEXP:(regexp_match)</parameter>: The 'OID/REGEXP:(regexp_match)' can be used when you need to use a POSIX-based regular expression to derive the value from the OID. The most common example of this is to retreive the IP address of an interface, and can be seen in the 'interface.xml' file.</para><para><parameter>VALUE/REGEXP:(regexp_match)</parameter>: The 'OID/REGEXP:(regexp_match)' option can be used to parse the value based on a regular expression, returning the first match.</para><para><parameter>index</parameter>: Simply use the value of the index for this row as the value. If the index is being parsed from the OID using the <property>oid_index_parse</property> field, you must specify <parameter>index</parameter> here. Omit the &lt;oid&gt;...&lt;/oid&gt; field, then.</para></entry>
</row>
<row>
<entry>query-&gt;fields-&gt;ifIndex-&gt;direction</entry>
<entry><para><parameter>input</parameter>: Input values are the "known" values that you will use to derive the output values, this is where the "query" part of SNMP query comes in. When you create a graph based on an SNMP query, Cacti will prompt you to choose the input value to base the graph on.</para><para><parameter>output</parameter>: Output values are "unknown" values that are returned from the script. An SNMP query may return multiple statistics for a single index. For instance, a single interface could return bytes/sec in, errors, packets/sec, etc.</para><para>A rule of thumb is that input fields contain semi-static data that is not graphable, while the output fields contain the data that will be graphed.</para></entry>
</row>
<row>
<entry>query-&gt;fields-&gt;ifIndex-&gt;oid</entry>
<entry>You must specify the actual OID that corresponds with the field. Each value for this field can be obtained by doing an snmpget on 'oid.(each)snmpindex'.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
<sect1 id="script-query-xml">
<title>Script Query XML Syntax</title>
<programlisting>&lt;query&gt;
&lt;name&gt;Get Unix Mounted Partitions&lt;/name&gt;
&lt;description&gt;Queries a list of mounted partitions on a unix-based host with the 'df' command.&lt;/description&gt;
&lt;script_path&gt;perl |path_cacti|/scripts/query_unix_partitions.pl&lt;/script_path&gt;
&lt;arg_index&gt;index&lt;/arg_index&gt;
&lt;arg_query&gt;query&lt;/arg_query&gt;
&lt;arg_get&gt;get&lt;/arg_get&gt;
&lt;arg_num_indexes&gt;num_indexes&lt;/arg_num_indexes&gt;
&lt;output_delimeter&gt;:&lt;/output_delimeter&gt;
&lt;index_order&gt;dskDevice:dskMount&lt;/index_order&gt;
&lt;index_order_type&gt;alphabetic&lt;/index_order_type&gt;
&lt;index_title_format&gt;|chosen_order_field|&lt;/index_title_format&gt;
&lt;fields&gt;
&lt;dskDevice&gt;
&lt;name&gt;Device Name&lt;/name&gt;
&lt;direction&gt;input&lt;/direction&gt;
&lt;query_name&gt;device&lt;/query_name&gt;
&lt;/dskDevice&gt;
&lt;/fields&gt;
&lt;/query&gt;</programlisting>
<table frame='all'>
<title>Script Query XML Field Reference</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="2*" colnum="2">
<thead>
<row>
<entry align="center">Field</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>query-&gt;name</entry>
<entry>(Optional) You can enter a "friendly name" for the script query here. It will not be used by Cacti, and is for identification only.</entry>
</row>
<row>
<entry>query-&gt;description</entry>
<entry>(Optional) You can enter a description for the script query here. It will not be used by Cacti, and is for identification only.</entry>
</row>
<row>
<entry>query-&gt;script_path</entry>
<entry>Enter the complete path to the script or executable that is going to handle your script query. When in doubt, specify the pull path to all binaries referenced in this path, the query may not execute otherwise.</entry>
</row>
<row>
<entry>query-&gt;arg_index</entry>
<entry>Enter the argument that is to be passed to the script to retrieve a list of indexes.</entry>
</row>
<row>
<entry>query-&gt;arg_query</entry>
<entry>Enter the argument that is to be passed to the script to retrieve a list of values given a field name.</entry>
</row>
<row>
<entry>query-&gt;arg_get</entry>
<entry>Enter the argument that is to be passed to the script to retrieve a single value given a field name and index value.</entry>
</row>
<row>
<entry>query-&gt;arg_num_indexes</entry>
<entry>Enter the argument that is to be passed to the script to determine the total number of available indexes. If specified, this will be used to determine when to automatically recache this script query when it is attached to a device.</entry>
</row>
<row>
<entry>query-&gt;output_delimeter</entry>
<entry>Enter the one character delimiter that will be used to separate output values. This is only used when you "query" the script in which case it outputs 'index(delimiter)value'.</entry>
</row>
<row>
<entry>query-&gt;index_order</entry>
<entry>As of version 0.8.6, Cacti will attempt to find the best field to index off of based on whether each row in the query is unique and non-null. If specified, Cacti will perform this check on the fields listed here in the order specified. Only input fields can be specified and multiple fields should be delimited with a comma.</entry>
</row>
<row>
<entry>query-&gt;index_order_type</entry>
<entry><para>For sorting purposes, specify whether the index is numeric or alphanumeric.</para><para><parameter>numeric</parameter>: The indexes in this script query are to be sorted numerically (ie. 1,2,3,10,20,31)</para><para><parameter>alphabetic</parameter>: The indexes in this script query are to be sorted alphabetically (1,10,2,20,3,31).</para></entry>
</row>
<row>
<entry>query-&gt;index_title_format</entry>
<entry>Specify the title format to use when representing an index to the user. Any input field name can be used as a variable if enclosed in pipes (|). The variable <parameter>|chosen_order_field|</parameter> will be substituted with the field chosen by Cacti to index off of (see index_order above).</entry>
</row>
<row>
<entry>query-&gt;fields</entry>
<entry>Each field contained within the script query must be defined under this tag.</entry>
</row>
<row>
<entry>query-&gt;fields-&gt;dskDevice</entry>
<entry>Each defined field in the script query must have a unique name given to it. Do not use spaces or any non-alphanumeric characters, this name must be identifiable within Cacti.</entry>
</row>
<row>
<entry>query-&gt;fields-&gt;dskDevice-&gt;name</entry>
<entry>Here you can specify a "friendly name" for the field. This name will be used by Cacti to help the user identify this field.</entry>
</row>
<row>
<entry>query-&gt;fields-&gt;dskDevice-&gt;direction</entry>
<entry><para><parameter>input</parameter>: Input values are the "known" values that you will use to derive the output values, this is where the "query" part of script query comes in. When you create a graph based on a script query, Cacti will prompt you to choose the input value to base the graph on.</para><para><parameter>output</parameter>: Output values are "unknown" values that are returned from the script. A script query may return multiple statistics for a single index. For instance, a single partition could return free disk space, total disk space, fragmentation percentage, etc.</para><para>A rule of thumb is that input fields contain semi-static data that is not graphable, while the output fields contain the data that will be graphed.</para></entry>
</row>
<row>
<entry>query-&gt;fields-&gt;dskDevice-&gt;query_name</entry>
<entry>Enter the name that Cacti must use when asking the script for information about this field. For instance, the following should return values: '(script_name) query (query_name)'.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
</chapter>
<chapter id="templates">
<title>Templates</title>
<para>
The real strength of Cacti is unleashed by using templates.
There are three different types of templates with the basic Cacti installation:
<emphasis>Data Templates</emphasis>, <emphasis>Graph Templates</emphasis> and <emphasis>Host Templates</emphasis>.
While it is perfectly fine to define all data sources and graphs without using
Templates at all, the burden of this approach is high. In most installations,
there are lots of devices of the same kind. And there are lots of data of the
same kind, e.g. traffic information is needed for almost every device.
Therefor, the parameters needed to create a traffic rrd file are defined
by a <emphasis>Data Template</emphasis>, in this case known as "Interface - Traffic".
These definitions are used by all Traffic-related rrd files.
</para>
<para>
The same approach is used for defining <emphasis>Graph Templates</emphasis>.
This is done only once. And all parameters defined within such a <emphasis>Graph Template</emphasis>
are copied to all Graphs that are created using this Template.
</para>
<para>
The last type of Templates are the <emphasis>Host Templates</emphasis>.
They are not related to some rrdtool stuff. The purpose of <emphasis>Host Templates</emphasis>
is to group all Graph Templates and Data Queries (these are explained later)
for a given device type. So you will make up a <emphasis>Host Template</emphasis>
e.g. for a specific type of router, switch, host and the like.
By assigning the correct <emphasis>Host Template</emphasis> to each new Device,
you'll never forget to create all needed Graphs.
</para>
<para>There's no need to create all Templates on your own! Apart from the fact,
that many common templates are provided out-of-the-box, there's a very simple
machnism to <guimenu>Import Templates</guimenu> and to <guimenu>Export Templates</guimenu>.</para>
<sect1 id="data-templates">
<title>Data Templates</title>
<para>
In Cacti, a data template provides a skeleton for an actual data source. If you have many data
sources that share most of their characteristics, using a data template would probably make sense.
No change of a Data Template is propagated to already existing rrd files.
But most of them may be changed by using <command>rrdtool tune</command> from command line.
Pay attention to not append new Data Source Items to already existing rrd files.
There's no <command>rrdtool</command> command to achieve this!
</para>
<sect2 id="creating-data-templates">
<title>Creating a Data Template</title>
<para>
To create a new data template, select <guilabel>Data Templates</guilabel> under the
<guilabel>Templates</guilabel> heading and click <guilabel>Add</guilabel>.
</para>
<para>
The first thing you must do is give the template a name. This name has nothing to do with the
data source name, but is what you will use to identify the template throughout Cacti.
</para>
<para>
Second,
you will notice a list of data source/data source item field names with Use <guilabel>Per-Data
Source Value</guilabel> checkboxes next to each one. The nice thing about templates in Cacti is
that you can choose whether to template each field on a per-field basis. If you leave the checkbox
unchecked, every data source attached to the template will inherit its value from the template. If
the checkbox is checked, every data source attached to the template will contain its own value for
that particular field. When generating a real data source, you will be prompted to fill those
non-templated fields.
</para>
<table frame='all'>
<title>Data Templates: Field Description of the Data Source Section</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2" >
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Name</entry>
<entry>The name of the Data Source that will be created by using this Template.
You can use the keyword |host_description| in this field, which will be
automatically substituted with the current host description.</entry>
</row>
<row>
<entry>Data Input Method</entry>
<entry>Here is where you tell cacti how it is supposed to fetch data
for this data source. There are several data input sources that come
with cacti, and you can add your own by going to Data Input Methods.
If this RRD file is being populated outside of cacti, make sure to
leave this field set to "None".</entry>
</row>
<row>
<entry>Associated RRAs</entry>
<entry>You need to associate the data source with at least one RRA
so <application>RRDTool</application> knows how often and for how
long to keep its data. You will almost always want to select all
of these values however so you can render daily, weekly, monthly,
and yearly graphs.</entry>
</row>
<row>
<entry>Step</entry>
<entry>This tells <application>RRDTool</application> how many seconds
there will be between updates. The default is 300 seconds (5 minutes),
and is sufficient for most installations.</entry>
</row>
<row>
<entry>Data Source Active</entry>
<entry>This is a quick and easy to tell Cacti to stop gathering data
for this data source. The data source can still be used on graphs,
but no data will be fed to it until it is made active again.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
<emphasis>Note:</emphasis> For most data templates, you will want to check the <guilabel>Use
Per-Graph Value</guilabel> checkbox for the name field so each data source using this template has its
own unique name. It also makes sense to enter an inital value in this field that includes the variable
|host_description| for organizational purposes.
</para>
<para>
When you are finished filling in values for the data template, click <guilabel>Create</guilabel> and
you will be presented with a screen similar to the data source edit screen.
</para>
<figure id="img-data-template-new">
<title>Adding a Data Template</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/data_template" format="PNG">
</imageobject>
</mediaobject>
</figure>
<sect3 id="data-template-items">
<title>Data Source Items</title>
<para>
Like a graph, a data source can have more than one items. This is useful in situations where a
script returns more than piece of data at one time. This also applies to data queries, so you
can have a single data template that contains both inbound and outbound traffic, rather than
having to create a separate data template for each.
</para>
<table frame='all'>
<title>Data Templates: Field Description of the Data Source Items Section</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Internal Data Source Name</entry>
<entry>This is the name used by <application>RRDTool</application> to identify this particular data source within the RRD file. <application>RRDTool</application> places a limit of 19 alphanumeric characters (plus '_' and '-') on this field.</entry>
</row>
<row>
<entry>Minimum Value</entry>
<entry>Here is where you specify the minimum value that is expected for this data source in the RRD file. If a value lower than the minimum is given, it will be stored as Unknown (U).</entry>
</row>
<row>
<entry>Maximum Value</entry>
<entry><para>Here is where you specify the maximum value that is expected for this data source in the RRD file. If a value higher than the maximum is given, it will be stored as Unknown (U).
</para><para><emphasis>Note:</emphasis> It often makes sense to define
a reasonable maximum value here to avoid spikes in case of a COUNTER wrap</para></entry>
</row>
<row>
<entry>Data Source Type</entry>
<entry><para>Cacti currently supports four types of data that <application>RRDTool</application> can represent for any given data source:
</para><para>COUNTER: is for continuous incrementing counters like the ifInOctets counter in a router. The COUNTER
data source assumes that the counter never decreases, except when a counter overflows. It is always a whole INTEGER,
floating point numbers are invalid.
The update function takes the overflow into account. The counter is stored as a per-second rate.
When the counter overflows, <application>RRDTool</application> checks if the overflow happened at the 32bit or 64bit
border and acts accordingly by adding an appropriate value to the result.
</para><para>GAUGE: numbers that are not continuously incrementing, e.g. a temperature reading.
Floating point numbers are accepted.
</para><para>ABSOLUTE: counters that are reset upon reading
</para><para>DERIVE: like COUNTER but without overflow checks</para></entry>
</row>
<row>
<entry>Heartbeat</entry>
<entry>As defined by <application>RRDTool</application>: <quote>The maximum amount of time that can pass before data is entered as "unknown". This field is usually '600' or 2 data gathering intervals</quote>.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect3>
<sect3 id="custom-data">
<title>Custom Data</title>
<para>
Assuming you selected a data input source on the previous screen, you should now be presented
with a <guilabel>Custom Data</guilabel> box. It will show a single line for every single
parameter required for that very data input method. This is how the Data Source glues together
with the data input method to provide all run time parameters.
</para>
<para>
Each custom data field is per-field templatable as
all of the other data source fields are. Even if you select the <guilabel>Use Per-Data Source
Value</guilabel> checkbox, it might be useful to specify a value that will be used as an "inital
value" for any data source using this data template.
</para>
</sect3>
</sect2>
<sect2 id="applying-data-templates">
<title>Applying Data Templates to Data Sources</title>
<para>
Applying a data template to a data source is a very simple process. The first thing you
must do is select the data source you want to apply the template to under <guilabel>Data
Sources</guilabel>. Under the <guilabel>Data Template Selection</guilabel> box, select
the data template that you want to apply to the data source and click <guilabel>Save</guilabel>.
</para>
<para>
Once the template is applied to the data source, you will notice that you can only change
values for the fields that you checked Use <guilabel>Per-Data Source Value</guilabel> for.
</para>
<para>
<emphasis>Now any time a change is made to the data template, it will be automatically
propagated to the data sources attached to it.</emphasis>
</para>
<caution>
<title>No change of existing rrd files</title>
<para>When changing parameters of a Data Template, existing rrd files
will never be changed. If this is required, you will have to apply
<command>rrdtool tune</command> commands to any related rrd file manually.</para>
</caution>
</sect2>
</sect1>
<sect1 id="graph-templates">
<title>Graph Templates</title>
<para>
In Cacti, a graph template provides a skeleton for an actual graph. If you have many graphs that
share most of their characteristics, using a graph template would probably make sense. After a
graph is attached to a particular graph template, all changes made to the graph template will
propagate out to all of its graphs, unless <guilabel>Use Per-Graph Value</guilabel> has been checked.
</para>
<sect2 id="creating-graph-templates">
<title>Creating a Graph Template</title>
<para>
To create a new graph template, select <guilabel>Graph Templates</guilabel> under the
<guilabel>Templates</guilabel> heading and click <guilabel>Add</guilabel>.
</para>
<para>
The first thing you must do is give the template a name. This name has nothing to do with
the graph title, but is what you will use to identify the template throughout Cacti.
Second, you will notice a list of graph field names with Use Per-Graph Value checkboxes
next to each one. The nice thing about templates in Cacti is that you can choose whether
to template each field on a per-field basis. If you leave the checkbox uncheked, every
graph attached to the template will inherit its value from the template. If the checkbox
is checked, every graph attached to the template will contain its own value for that
particular field.
</para>
<table frame='all'>
<title>Field Description: Graph Templates</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Title</entry>
<entry><para>The title of the graph within Cacti and the title that will be printed on the actual graph itself.</para><para><emphasis>Note:</emphasis> You can use the keyword |host_description| in this field, which will be automatically substituted with the current host description.</para></entry>
</row>
<row>
<entry>Image Format</entry>
<entry>Choose whether you would prefer to output your graph images in PNG or SVG. GIF is supported only with rrdtool 1.0.x and has been deleted from rrdtool 1.2.x and later</entry>
</row>
<row>
<entry>Height</entry>
<entry>The height of the graph area in pixels</entry>
</row>
<row>
<entry>Width</entry>
<entry>The width of the graph area in pixels</entry>
</row>
<row>
<entry>Slope Mode</entry>
<entry>RRDtool graphs are composed of stair case curves by default.
This is in line with the way RRDtool
calculates its data. Some people favor a more "organic" look for their graphs.
<application>RRDTool</application> version 1.2 and above
support smoothing of graphs, know as <guilabel>slope mode</guilabel>.</entry>
</row>
<row>
<entry>Auto Scale</entry>
<entry>Enable auto scale for the graph. This option must be check to use the next two options. Upper/Lower limit values are ignored when using autoscale since these boundaries are determined automatically.</entry>
</row>
<row>
<entry>Auto Scale Options</entry>
<entry><para>Choose whether you would like to use
<itemizedlist>
<listitem><para>--alt-autoscale (ignoring given limits),</para></listitem>
<listitem><para>--alt-autoscale-max (accepting a lower limit),</para></listitem>
<listitem><para>--alt-autoscale-min (accepting an upper limit, requires rrdtool 1.2.x) or</para></listitem>
<listitem><para>--alt-autoscale (accepting both limits, rrdtool default) on the graph.</para></listitem></itemizedlist>
The <ulink url="http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html">RRDTool graph manual</ulink> says:
</para><para> <emphasis>Limits</emphasis>
</para><para> [-u|--upper-limit value] [-l|--lower-limit value] [-r|--rigid]
</para><para>
By default the graph will be autoscaling so that it will adjust the y-axis to the range of the data.
You can change this behaviour by explicitly setting the limits. The displayed y-axis will then range
at least from lower-limit to upper-limit. Autoscaling will still permit those boundaries to be
stretched unless the rigid option is set.
</para><para> [-A|--alt-autoscale]
</para><para>
Sometimes the default algorithm for selecting the y-axis scale is not satisfactory. Normally the
scale is selected from a predefined set of ranges and this fails miserably when you need to graph
something like "260 + 0.001 * sin(x)". This option calculates the minimum and maximum y-axis from the
actual minimum and maximum data values. Our example would display slightly less than "260-0.001" to
slightly more than "260+0.001" (this feature was contributed by Sasha Mikheev).
</para><para> [-J|--alt-autoscale-min]
</para><para>
Where "--alt-autoscale" will modify both the absolute maximum AND minimum values, this option will
only affect the minimum value. The maximum value, if not defined on the command line, will be 0. This
option can be useful when graphing router traffic when the WAN line uses compression, and thus the
throughput may be higher than the WAN line speed.
</para><para> [-M|--alt-autoscale-max]
</para><para>
Where "--alt-autoscale" will modify both the absolute maximum AND minimum values, this option will
only affect the maximum value. The minimum value, if not defined on the command line, will be 0. This
option can be useful when graphing router traffic when the WAN line uses compression, and thus the
throughput may be higher than the WAN line speed.</para></entry>
</row>
<row>
<entry>Logarithmic Scaling</entry>
<entry>Choose if you want logarithmic y-axis scaling.</entry>
</row>
<row>
<entry>Scientific Units for Logarithmic Scaling</entry>
<entry>This option is not available for rrdtool-1.0.x. For linear graphs,
scientific units (in magnitudes of k=kilo, M=mega, ...) is default. But
for logarithmic graphs, exponential notation is default.
Choose if you want logarithmic y-axis scaling and scientific units.</entry>
</row>
<row>
<entry>Rigid Boundaries Mode</entry>
<entry>From the RRDTool manual
<quote>Normally rrdgraph will automatically expand the lower and upper
limit if the graph contains a value outside the valid range.
With this option you can disable this behavior</quote>.</entry>
</row>
<row>
<entry>Auto Padding</entry>
<entry>If you have ever created RRDTool-based graphs manually,
you may have realized how annoying it can be to get text to
line up properly. With this option Cacti will do its best to
make the columns on your graph legend line up. This option
works best when your graph legend has a consistent number of columns.</entry>
</row>
<row>
<entry>Allow Graph Export</entry>
<entry>If you choose to use Cacti's static HTML/image export, you can
choose whether you want each individual graph to be exported.</entry>
</row>
<row>
<entry>Upper Limit</entry>
<entry>The maximum value that will be displayed on the y-axis.
This value is ignored is auto-scaling is turned on.</entry>
</row>
<row>
<entry>Lower Limit</entry>
<entry>The minimum value that will be displayed on the y-axis.
This value is ignored is auto-scaling is turned on.</entry>
</row>
<row>
<entry>Base Value</entry>
<entry>Whether you want to base the y-axis labels on 1000 or 1024.
This field will typically be set to 1024 for memory and 1000
for traffic measurements.</entry>
</row>
<row>
<entry>Unit Grid Value</entry>
<entry>Sets the unit value for the y-axis (--y-grid). You should probably
keep the unit short as to keep it readable.</entry>
</row>
<row>
<entry>Unit Exponent Value</entry>
<entry>Sets the 10^e scaling of the y-axis. Valid values for
this field are between -18 and 18. For example, you could use
3 to display everything in 'k' (kilo) or -6 to display everything in 'u' (micro).</entry>
</row>
<row>
<entry>Vertical Label</entry>
<entry>The text to print on the left edge of the graph. Usually
is the units the data on the graph is measured in.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
<emphasis>Note:</emphasis> For most graph templates, you will want to check the Use
<guilabel>Per-Graph Value</guilabel> checkbox for the title field so each graph using this
template has its own unique title. It also makes sense to enter an initial value in this
field that includes the variable |host_description| for organizational purposes.
</para>
<para>
When you are finished filling in values for the graph template, click <guilabel>Create</guilabel>
and you will be presented with a page similar to the graph edit page.
</para>
<figure id="img-graph-template-new">
<title>Adding a Graph Template</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/graph_template" format="PNG">
</imageobject>
</mediaobject>
</figure>
<sect3 id="graph-items">
<title>Graph Items</title>
<para>
The first thing you should do is create graph items for this graph template, just like for a regular graph.
One difference you will notice is that the <guilabel>Data Sources</guilabel> dropdown will contain a list
of data template items rather than data source items. It is important that Cacti can make this association
here, so that Cacti doesn't have to make unnecessary assumptions later.
</para>
<table frame='all'>
<title>Field Description: Graph Template Items</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Data Source</entry>
<entry>If this graph item is to represent some sort of data, you must select a your data source here. Keep in mind that not all graph items have a data source. Graph item types such as COMMENT, VRULE, and HRULE typically do not.</entry>
</row>
<row>
<entry>Color</entry>
<entry>Depending on the graph item type, you can select a color for the graph item. This field only applies to the graph item types AREA, STACK, LINE1, LINE2, and LINE3.</entry>
</row>
<row>
<entry>Opacity/Alpha Channel</entry>
<entry>For a colored graph item, you may optionally select an opacity (alpha channel).
This option is not available with rrdtool-1.0.x.</entry>
</row>
<row>
<entry>Graph Item Type</entry>
<entry><para>This field is important because it defines what kind of graph item this is. Types such as AREA, STACK, LINE1, LINE2, and LINE3 are used to represent data on the graph, while COMMENT and GPRINT are used put on the legend. The LEGEND type is specific to Cacti only and can be used if you want to Cacti to automatically create a GPRINT-LAST/GPRINT-AVERAGE/GPRINT-MAXIMUM graph item for you.</para><para><emphasis>Note:</emphasis>: You must always put an AREA item before using STACK or your graph will not render.</para></entry>
</row>
<row>
<entry>Consolidation Function</entry>
<entry>This tells <application>RRDTool</application> which consolidation function to use when representing this data on the graph. You will typically use AVERAGE for most things on the graph area, and LAST/MAXIMUM as well for GPRINT items.</entry>
</row>
<row>
<entry>CDEF Function</entry>
<entry>If you want to apply a CDEF function to the graph item, select one here. Check out the CDEF section of the manual for more information.</entry>
</row>
<row>
<entry>Value</entry>
<entry>This field is only used with the HRULE/VRULE graph item types. Type any valid integer to draw the line at for HRULE or the time of the day HH:MM for VRULE.</entry>
</row>
<row>
<entry>GPRINT Type</entry>
<entry>If this item is a GPRINT, you can choose how you want the number to be formatted. You can add your own in the GPRINT Presets section of Cacti.</entry>
</row>
<row>
<entry>Text Format</entry>
<entry>You can enter text to be displayed on the legend here. This field is applicable for all graph item types except for the virtual LEGEND type.</entry>
</row>
<row>
<entry>Hard Return</entry>
<entry>Check this box to force graph items onto the next line.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect3>
<sect3 id="graph-item-inputs">
<title>Graph Item Inputs</title>
<para>
After creating graph items for your template, you will need to create some graph item inputs. Graph item inputs are
unique to graph templates because of the large number of items they sometimes contain. Graph item inputs enable you to
take one graph item field, and associate it with multiple graph items.
</para>
<para>
To create a new graph item input, click <guilabel>Add</guilabel> on the right of the <guilabel>Graph Item
Inputs</guilabel> box. There are various fields that must be filled in for every graph item input:
</para>
<table frame='all'>
<title>Field Description: Graph Template Items</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Name</entry>
<entry>This will be the name used to identify the graph item input on both the graph template and graph edit pages.</entry>
</row>
<row>
<entry>Description</entry>
<entry>(Optional) This description will be displayed on the graph edit page of any graph using this template if specified.</entry>
</row>
<row>
<entry>Field Type</entry>
<entry>You must choose the field that you are going to associate with one or more graph items.</entry>
</row>
<row>
<entry>Associated Graph Items</entry>
<entry>Choose one or more graph items to associate with the field selected for "Field Type". When the user specifies a value for the field, it will be applied to all of the items you select here.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect3>
</sect2>
<sect2 id="applying-graph-templates">
<title>Applying Graph Templates to Graphs</title>
<para>
Applying a graph template to a graph is a very simple process. The first thing you must do is select the graph you
want to apply the template to under <guilabel>Graph Management</guilabel>. Under the <guilabel>Graph Template
Selection</guilabel> box, select the graph template that you want to apply to the graph and click
<guilabel>Save</guilabel>. If this is a new graph or the graph and graph template contains an equal number of
graph items, the graph template will be automatically applied. If number of graph items varies from the graph to
the target graph template, you will be propmted with a warning that your graph will be changed.
</para>
<para>
Once the template is applied to the graph, you will notice that you can only change values for the fields that
you checked Use Per-Graph Value for. You will also notice a new box, called <guilabel>Graph Item Inputs</guilabel>.
This is where you can specify values for the graph items inputs that you defined in the graph template. The values
specified here will be applied to each graph item tied to the graph item input.
</para>
<para>
<emphasis>Now any time a change is made to the graph template, it will be automatically propagated to the graphs
attached to it.</emphasis>
</para>
</sect2>
</sect1>
<sect1 id="host-templates">
<title>Host Templates</title>
<para>
Host templates in Cacti serve a different purpose then data and graph templates. Instead of
abstracting the fields of a host, a host template allows you to associate graph templates and
data queries with a given host type. This way when you assign a host template to a host, all
of the relevant graphs to that host type are only one click away from the user.
</para>
<sect2 id="host-template-new">
<title>Adding a Host Template</title>
<para>
To create a new host template in Cacti, select the <guilabel>Host Templates</guilabel>
option under the <guilabel>Templates</guilabel> heading. Once on that screen, click
<guilabel>Add</guilabel> on the right. Type a unique name for the host template and
click the <guilabel>Create</guilabel> button. You will be redirected back to the edit
page with the <guilabel>Associated Graph Templates</guilabel> and <guilabel>Associated
Data Queries</guilabel> boxes. These two boxes allow you to associate certain graph
templates or data queries with the host template. Simply select something from the
dropdown menu and click <guilabel>Add</guilabel> to associate it with your host template.
</para>
<figure id="img-host-template-new">
<title>Adding a Host Template</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/host_template" format="PNG">
</imageobject>
</mediaobject>
</figure>
</sect2>
</sect1>
<sect1 id="template-import">
<title>Import Templates</title>
<para>Assume, you're searching for a specific set of templates to
monitor a special type of device. Apart from designing templates
from scratch, there's a good chance to find a solution in the
<ulink url="http://forums.cacti.net/forum-12.html">Scripts and Templates Forum</ulink>.
The set of templates is usually provided as a single XML file holding all
required definitions for a data template and a graph template. Depending on
the goal of the original author, he/she may have provided a host template
as well as part of this XML file.</para>
<figure id="img-import-templates">
<title>Import Templates</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/import_template" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>If the XML file was downloaded, you may import it from the filesystem
via the search button. As an alternative, you may want to cut and paste
the XML into the textbox.</para>
<para>Please pay attention the the <emphasis>Import RRA Settings</emphasis>.
By default, current RRA settings will be preserved, even if the imported
XML file specifies different settings. This is recommended to avoid accidentally
overwriting these global RRA definitions. If you are sure, you may override
this default.</para>
<para>For a single OID based template, this will be all. For a script based
template, the author will provide the script that has to be downloaded
to the Cacti <filename>./scripts</filename> directory. For a SNMP/SCRIPT Data Query,
a second XML file holding the Data Query definitions will have to be downloaded
to the appropriate directory under <filename>./resources</filename>.</para>
<para>When importing templates, Cacti will perform a version check. All XML templates
hold the version of the Cacti system that generated this XML set. Cacti will
import only, if your current Cacti version equals or is higher than the exporting one.</para>
</sect1>
<sect1 id="template-export">
<title>Export Templates</title>
<para>Now that you know how to import, you may want to know in which way to
export as well. Selecting the <guimenu>Export Templates</guimenu> gives</para>
<figure id="img-export-templates">
<title>Export Templates</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/export_template" format="PNG">
</imageobject>
</mediaobject>
</figure>
<para>You may select to export a graph template, a data template, a host template
or a data query. When selecting <userinput>Include Dependencies</userinput>, e.g. a host template
will include all referred templates (graph template, data template and, if defined,
data query). Output may be written to the browser or to a file for uploading.</para>
</sect1>
</chapter>
<chapter id="php-script-server">
<title>PHP Script Server</title>
<para>
The PHP Script Server is a new feature in Cacti 0.8.6. This new feature allows for the rapid
execution of PHP based Data Queries in Cacti. The Script Server process is launched by the poller
during every polling cycle. It listens for commands from the poller, executes them, and then waits
for an quit signal.
</para>
<para>
The reason that it is so fast is that PHP is started in memory only one time, and for every Data
Query called, it's code is interpreted only once. The resulting Data Query binaries are therefore
very efficient. Using the Script Server process over the traditional POPEN process nets a 20+ fold
speed improvement in Cacti.
</para>
<para>
Since PHP scripts are so powerful, this new feature in Cacti, makes it an excellent choice for
collecting non-SNMP and SNMP based data.
</para>
<sect1 id="using-script-server">
<title>Using the Script Server</title>
<para>
Cacti 0.8.6 contains two sample script server routines. They are for the collection of HostMib CPU
and Disk Partition information. These two examples are based off the traditional POPEN version of
the HostMib functions found in earlier versions of Cacti.
</para>
<para>
For new installs, the HostMib functions are defaulted to using the PHP Script Server, therefore,
you don't need to do anything to use it.
</para>
<para>
For upgrades, you must make several changes to start using the PHP Script Server for the HostMib
CPU and HostMib Partitions Data Queries. To migrate you must follow the step below.
</para>
</sect1>
<sect1 id="upgrade-using-hostmib-data-queries">
<title>Upgrade Steps for the Example HostMib Data Queries</title>
<para>
If you are using the two built in script queries, "SNMP - Get Mounted Partitions" and "SNMP - Get
Processor Information", you can migrate to the PHP Script Server using the steps below:
</para>
<orderedlist>
<listitem>
<para>
Verify the existence of New Data Input Method - Go to <guilabel>Data Input Methods</guilabel>,
verify that you see the "Get Script Server Data (Indexed)" Data Input Method exists and that
it is using the "Script Query - Script Server" method.
</para>
</listitem>
<listitem>
<para>
Disable the Poller - Goto <guilabel>Settings</guilabel>-><guilabel>Poller</guilabel> and
uncheck the <guilabel>Poller Enabled</guilabel> checkbox. Press <guilabel>Save</guilabel>.
</para>
</listitem>
<listitem>
<para>
Update Your Data Queries - Go to <guilabel>Data Queries</guilabel> and Edit the two Data
Queries below. Change both their Data Input Method to "Get Script Server Data (Indexed)"
and in the XML path replace "script_query" with "script_server" as shown below:
</para>
<orderedlist>
<listitem>
<para>
SNMP - Get Mounted Partitions
</para>
<para>
<userinput>&lt;path_cacti&gt;/resource/script_server/host_disk.xml</userinput>
</para>
</listitem>
<listitem>
<para>
SNMP - Get Processor Information
</para>
<para>
<userinput>&lt;path_cacti&gt;/resource/script_server/host_cpu.xml</userinput>
</para>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para>
Update Your Data Templates - Goto <guilabel>Data Templates</guilabel>, locate the following two
data templates and change their data input method to "Get Script Server Data (Indexed)".
</para>
<orderedlist>
<listitem>
<para>
Host MIB - Hard Drive Space
</para>
</listitem>
<listitem>
<para>
Host MIB - CPU Utilization
</para>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para>
Re Enable the Poller - Go to <guilabel>Settings</guilabel>-><guilabel>Poller</guilabel>
and check the <guilabel>Poller Enabled</guilabel> checkbox. Press <guilabel>Save</guilabel>.
</para>
</listitem>
</orderedlist>
<para>
Following those steps should complete your migration to the new PHP Script Server for the two
example HostMIB Data Queries.
</para>
</sect1>
<sect1 id="migration-php-scripts-to-script-server">
<title>Migration of Existing PHP Scripts to Script Server</title>
<para>
If you have other PHP scripts that you wish to migrate, you must follow the steps below to
migrate your scripts to the PHP Script Server required format.
</para>
<sect2 id='script-file-changes'>
<title>Script File Changes</title>
<para>
Each PHP Script file must be changed to the new Script Server format. The changes are
not dramatic, but required for the proper operation of the PHP Script Server. Follow the
steps below to complete.
</para>
<orderedlist>
<listitem>
<para>
Copy you existing script to a new name. The name must begin "ss_" followed by your script
name. The "ss_" identifies the script as being a script server variety of the a PHP script.
For example, if you previously had a script called "get_mysql_stats.php", it's new name would
be "ss_get_mysql_stats.php".
</para>
</listitem>
<listitem>
<para>
Edit the new PHP script and add the following required lines to the file, where "ss_myfunction"
is the same as your filename.
</para>
<programlisting>&lt;?php
$no_http_headers = true;
/* display No errors */
error_reporting(E_ERROR);
include_once(dirname(__FILE__) . "/../include/config.php");
include_once(dirname(__FILE__) . "/../lib/snmp.php");
if (!isset($called_by_script_server)) {
array_shift($_SERVER["argv"]);
print call_user_func_array("ss_myfunction", $_SERVER["argv"]);
}</programlisting>
</listitem>
<listitem>
<para>
What was originally just mainline code, must be replaced with a function name. For example,
if your program previously contained the following three lines of code:
</para>
<programlisting>&lt;?php
$a = 100;
$b = $a / 10;
print $b;
?&gt;</programlisting>
<para>
Would become:
</para>
<programlisting>function ss_myfunction() {
$a = 100;
$b = $a / 10;
Print $b;
}</programlisting>
</listitem>
<listitem>
<para>
If you have any additional functions declared within your script file, you must prefix them to
make them unique amongst all functions. Our recommendation would be to prefix all functions with
the name of the main function. For example if you have a function called "meme" you would rename
it to "ss_myfunction_meme". This guarantee's correct Script Server functionality.
</para>
</listitem>
<listitem>
<para>
The last step is to change the function call that could have traditionally returned the value to the
Cacti poller using the PRINT function. You must change that line or lines in your code to utilize
the RETURN function instead. However, this does not apply to PRINT statements that are not called
from the Poller. For a simple script, this results in
</para>
<programlisting>function ss_myfunction() {
$a = 100;
$b = $a / 10;
Return $b;
}</programlisting>
<para>
Be careful, when writing <guilabel>Script Server Data Queries</guilabel>.
Use the RETURN function for returning results of the GET operation.
But use PRINT for INDEX and QUERY operations, e.g.
</para>
<programlisting> if (($cmd == "index")) {
...
print $some_index_data . "\n";
}
} elseif ($cmd == "query") {
...
print $some_query_data . "\n";
} elseif ($cmd == "get") {
...
result $some_get_data;
}
</programlisting>
</listitem>
</orderedlist>
</sect2>
<sect2 id='xml-file-changes'>
<title>XML File Changes</title>
<para>
If you are using a "Script Query" type function, then you must also change your XML file. Please reference
the XML files in the <filename>&lt;path_cacti&gt;/resource/script_server</filename> directory for the
specifics related to your required modifications. However, you may also follow the instructions below:
</para>
<orderedlist>
<listitem>
<para>
Modify the &lt;script_path&gt; tag. Change it from:
</para>
<programlisting>&lt;script_path&gt;|path_php_binary| -q |path_cacti|/scripts/myfucntion.php&lt;/script_path&gt;</programlisting>
<para>
to simply the following:
</para>
<programlisting>&lt;script_path&gt;|path_cacti|/scripts/ss_myfunction.php&lt;/script_path&gt;</programlisting>
</listitem>
<listitem>
<para>
Add the following two XML tags below the &lt;script_path&gt; tag. Replace <emphasis>ss_myfunction</emphasis>
with your function name:
</para>
<programlisting>&lt;script_function&gt;ss_myfunction&lt;/script_function&gt;
&lt;script_server&gt;php&lt;/script_server&gt;</programlisting>
</listitem>
<listitem>
<para>
Save the XML file.
</para>
</listitem>
</orderedlist>
</sect2>
<sect2 id='data-query-data-template-changes'>
<title>Data Query & Data Template Changes</title>
<para>
Your Data Queries and Data Templates must be also changed. Although somewhat self explanatory by
now, you must make the following changes:
</para>
<orderedlist>
<listitem>
<para>
Change it's Input Method to "Get Script Server Data" or "Get Script Server Data (Index)" depending
on it's type.
</para>
<para>
Change the XML file path to point to the new XML file in the <filename>&lt;path_cacti&gt;/resources/script_server/*.xml</filename> path.
</para>
<para>
For all data templates that use the data query you must change their "Data Input Method" accordingly.
</para>
</listitem>
</orderedlist>
<para>
Your final step is to go to the <guilabel>System Utilities</guilabel> and <guilabel>Clear
Poller Cache</guilabel> to apply the new settings. If you script is operating correctly,
you should now be migrated to the script server.
</para>
</sect2>
</sect1>
<sect1 id="testing-script-in-script-server">
<title>Testing Your Script in the Script Server</title>
<para>
To test your script in the script server, simply follow the instructions below. When you have
finished you testing, simply type "quit" &lt;cr&lt; at the Script Server command line to exit the
script server.
</para>
<orderedlist>
<listitem>
<para>
Start the script server - You can do this by typing the following command:
</para>
<screen><prompt>shell&gt;</prompt> <userinput>php &lt;path_cacti&gt;/script_server.php</userinput></screen>
<para>
<emphasis>NOTE</emphasis>: Due to a bug in Windows implementation of PHP, you must type the full path name to the <filename>script_server.php</filename> file.
</para>
</listitem>
<listitem>
<para>
Type in your command - Using the example from above, you would type in the following:
</para>
<screen><prompt>script server&gt;</prompt> <userinput>&lt;path_myfunction&gt; my_function argument1 argument2 ...</userinput></screen>
<para>
In the Windows environment, your example could be the following:
</para>
<screen><prompt>script server&gt;</prompt> <userinput>c:\wwwroot\cacti\scripts\ss_myfunction.php ss_myfunction localhost public 1 get duddle</userinput></screen>
</listitem>
<listitem>
<para>
If your function is operating properly, you should get a result.
</para>
</listitem>
<listitem>
<para>
To quit the script server, simply type "quit" &lt;cr&gt; at the command line.
</para>
</listitem>
</orderedlist>
<para>
<emphasis>NOTE</emphasis>: If there are errors in your script, you must restart the script server before
your retest your code.
</para>
</sect1>
</chapter>
<chapter id="using-spine">
<title><application>Spine</application></title>
<para>
<application>Spine</application> is the fast replacement for cmd.php. It is written in C to ensure ultimate
performance for device polling. Expect a decrease in polling time of an order of magnitude.
Polling times far less than 60 seconds for about 20,000 data sources are achievable
e.g. on a dual XEON system supplied with 4 GB RAM and standard local disks.
</para>
<para>
When using <application>Spine</application>, don't change crontab settings! Always use poller.php with crontab!
To activate <application>Spine</application> instead of cmd.php, please visit <guilabel>Settings</guilabel>
and select the <guilabel>Poller</guilabel> tab. Select <application>Spine</application>
and save. Now, poller.php will use <application>Spine</application> on all subsequent polling cycles.
</para>
<para>
While <application>Spine</application> is really fast, choosing the correct setup will ensure, that all processor
resources are used. Required settings for <guilabel>Maximum Concurrent Poller Processes</guilabel>
are 1-2 times the number of CPU cores available for <application>Spine</application>.
</para>
<table frame='all'>
<title><application>Spine</application> Specific Execution Parameters</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Maximum Threads per Process</entry>
<entry>The maximum threads allowed per process.
Using a higher number when using <application>Spine</application> will improve performance.
Required settings are 10-15. Values above 50 are most often insane
and may degrade preformance</entry>
</row>
<row>
<entry>Number of PHP Script Servers</entry>
<entry>The number of concurrent script server processes to run per <application>Spine</application> process.
Settings between 1 and 10 are accepted.
Script Servers will pre-load a PHP environment.
Then, the Script Server Scripts are included into that environment to
save the overhead of reloading PHP each and every time.</entry>
</row>
<row>
<entry>Script and Script Server Timeout Value</entry>
<entry>The maximum time that <application>Spine</application> will wait on a script to complete, in units of seconds.
If a Script Server Script is terminated due to timeout conditions,
the value entered into the rrd file will be NaN</entry>
</row>
<row>
<entry>The Maximum SNMP OID's Per SNMP Get Request</entry>
<entry>The maximum number of snmp get OID's to issue per snmp request.
Increasing this value speeds poller performance over slow links.
The maximum value is 60 OID's. Please bear in mind, that some
type of devices do not accept huge OID numbers and may fail if set above 1.
That's why cacti 0.8.7 allows to define this value at device level</entry>
</row>
</tbody>
</tgroup>
</table>
</chapter>
</part>
<part id="cacti-help">
<title>Help</title>
<chapter id="how-to">
<title>How To</title>
<sect1 id="script-to-graph">
<title>Simplest Method of Going from Script to Graph (Walkthrough)</title>
<authorblurb>
<para>
<emphasis>Written by Kevin der Kinderen, <ulink url="http://kdeuja.com/~kevin/">http://kdeuja.com/~kevin/</ulink></emphasis>
</para>
</authorblurb>
<para>
This HOWTO walks you through the simplest steps of graphing the output of a single value from a script.
As a new user of cacti, I had a difficult time understanding how to graph anything that wasn't canned with
the original load. After a lot of playing around, I came up with these procedures which can be built upon for
more sophisticated collections and graphs.
</para>
<para>
I do not use templates in this HOWTO. Templates provide a significant advantage if you are graphing the output
for multiple instances or creating graphs for multiple hosts. They help to maintain consistency and simplify
setup.
</para>
<para>
The example here is not realistic, but can be used and expanded upon as a model for creating your own graphs.
</para>
<para>
I've not put a lot of explanations in the procedures. Refer to the Cacti manual for more details.
</para>
<para>
Have a tested script ready to go. I used the following script located in <filename>/home/cactiuser/bin</filename>
called <filename>random2.pl</filename>:
</para>
<programlisting>#!/usr/bin/perl -w
print int(rand(10));</programlisting>
<para>
This script simply prints out a random integer between 0 and 9 every time it's called.
</para>
<orderedlist>
<title>The minimal steps to create a graph from a script are simply:</title>
<listitem>
<para>
Create a Data Input Method to tell Cacti how to call the script and what to expect from it.
</para>
</listitem>
<listitem>
<para>
Create a Data Source to tell cacti how and where the data will be stored.
</para>
</listitem>
<listitem>
<para>
Create a Graph to tell cacti how the data will be presented in graph form.
</para>
</listitem>
<listitem>
<para>
Add Graph to Graph View so you can view the graph.
</para>
</listitem>
<listitem>
<para>
View the Graph
</para>
</listitem>
</orderedlist>
<orderedlist>
<title>The details are below:</title>
<listitem>
<para>
Create Data Input Method
</para>
<itemizedlist>
<listitem>
<para>
Click the <guilabel>Console</guilabel> tab at the top
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Data Input Methods</guilabel> under <guilabel>Management</guilabel>
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Add</guilabel>
</para>
</listitem>
<listitem>
<para>
Name: Random 2 Input
</para>
</listitem>
<listitem>
<para>
Input Type: Script/Command
</para>
</listitem>
<listitem>
<para>
Input String: /home/cactiuser/bin/random2.pl
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Create</guilabel>
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful." at the top of the page.
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Add</guilabel> by Output Fields (there are no input fields for this example)
</para>
</listitem>
<listitem>
<para>
Field [Output]: random_number
</para>
</listitem>
<listitem>
<para>
Friendly Name: Random Number
</para>
</listitem>
<listitem>
<para>
Update RRD File: checked
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Create</guilabel>
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful." and random_number listed under <guilabel>Output Fields</guilabel>.
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Save</guilabel>
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful." and Random Input listed in <guilabel>Data Input Methods</guilabel>.
</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>
Create a Data Source
</para>
<itemizedlist>
<listitem>
<para>
Click <guilabel>Data Sources</guilabel> under <guilabel>Management</guilabel>
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Add</guilabel> in the top right
</para>
</listitem>
<listitem>
<para>
The <guilabel>Data Template</guilabel> Section should be None and None, we're not using templates for this example.
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Create</guilabel>.
</para>
</listitem>
<listitem>
<para>
Name: random2ds
</para>
</listitem>
<listitem>
<para>
Data Source Path: blank (Cacti will fill this in)
</para>
</listitem>
<listitem>
<para>
Data Input Source: Random 2 Input (this is the data input method you created in step 1)
</para>
</listitem>
<listitem>
<para>
Highlight each of the Associated RRA's using control-click
</para>
</listitem>
<listitem>
<para>
Step: 300 (300 seconds = 5 minutes)
</para>
</listitem>
<listitem>
<para>
Data Source Active: checked
</para>
</listitem>
<listitem>
<para>
Describe the Data Source Item inside the RRA by...
</para>
</listitem>
<listitem>
<para>
Internal Data Source Name: random_number
</para>
</listitem>
<listitem>
<para>
Minimum Value: 0
</para>
</listitem>
<listitem>
<para>
Maximum Value: 0
</para>
</listitem>
<listitem>
<para>
Data Source Type: GAUGE
</para>
</listitem>
<listitem>
<para>
Heartbeat: 600
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Create</guilabel>
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful." at the top and the Data Source Path should now have a value (my example &lt;path_rra&gt;/random_number_286.rrd)
</para>
</listitem>
<listitem>
<para>
Click Turn On Data Source Debugging Mode to see the results of this step.
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Save</guilabel>
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful" and your new Data Source listed.
</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>
Create Graph
</para>
<itemizedlist>
<listitem>
<para>
Select <guilabel>Graph Management</guilabel> under <guilabel>Management</guilabel>
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Add</guilabel>
</para>
</listitem>
<listitem>
<para>
Selected Graph Template: None
</para>
</listitem>
<listitem>
<para>
Host: None
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Create</guilabel>
</para>
</listitem>
<listitem>
<para>
Title: RANDOM NUMBERS
</para>
</listitem>
<listitem>
<para>
Image Format: PNG
</para>
</listitem>
<listitem>
<para>
Height: 120
</para>
</listitem>
<listitem>
<para>
Width: 500
</para>
</listitem>
<listitem>
<para>
Auto Scale: checked
</para>
</listitem>
<listitem>
<para>
Auto Scale Options: Use --alt-autoscale-max
</para>
</listitem>
<listitem>
<para>
Logarithmic Scaling: unchecked
</para>
</listitem>
<listitem>
<para>
Rigid Boundaries: unchecked
</para>
</listitem>
<listitem>
<para>
Auto Padding: checked
</para>
</listitem>
<listitem>
<para>
Allow Graph Export: checked
</para>
</listitem>
<listitem>
<para>
Upper Limit: 100
</para>
</listitem>
<listitem>
<para>
Lower Limit: 0
</para>
</listitem>
<listitem>
<para>
Base Value: 1000
</para>
</listitem>
<listitem>
<para>
Unit Value: blank
</para>
</listitem>
<listitem>
<para>
Unit Exponent Value: 0
</para>
</listitem>
<listitem>
<para>
Vertical Label: Random Number
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Create</guilabel>
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful."
</para>
</listitem>
<listitem>
<para>
If you click "Turn On Graph Debug Mode." now you will see: "Error: can't make a graph without contents." We need to add Graph Items:
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Add</guilabel> by <guilabel>Graph Items</guilabel>
</para>
</listitem>
<listitem>
<para>
Data Source: (from list) No Host - random2ds (random_number)
</para>
</listitem>
<listitem>
<para>
Color: 0000FF (Blue)
</para>
</listitem>
<listitem>
<para>
Graph Item Type: LINE2
</para>
</listitem>
<listitem>
<para>
Consolidation Function: AVERAGE
</para>
</listitem>
<listitem>
<para>
CDEF Function: None
</para>
</listitem>
<listitem>
<para>
Value: blank
</para>
</listitem>
<listitem>
<para>
GPRINT Type: Normal
</para>
</listitem>
<listitem>
<para>
Text Format: blank
</para>
</listitem>
<listitem>
<para>
Insert Hard Return: unchecked
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Create</guilabel>
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful.", Item #1 listed and a graph under debug (probably with nothing in it yet)
</para>
</listitem>
<listitem>
<para>
To add a legend, click <guilabel>Add</guilabel> by <guilabel>Graph Items</guilabel> again
</para>
</listitem>
<listitem>
<para>
Data Source: No Host - random2ds (random_number)
</para>
</listitem>
<listitem>
<para>
Color: None
</para>
</listitem>
<listitem>
<para>
Graph Item Type: GPRINT
</para>
</listitem>
<listitem>
<para>
Consolidation Function: LAST
</para>
</listitem>
<listitem>
<para>
CDEF Function: None
</para>
</listitem>
<listitem>
<para>
Value: blank
</para>
</listitem>
<listitem>
<para>
GPRINT Type: Normal
</para>
</listitem>
<listitem>
<para>
Text Format: Cur:
</para>
</listitem>
<listitem>
<para>
Insert Hard Return: unchecked
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Create</guilabel>
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful." and the graph will have a legend showing the current value. Note: your integer random number has been averaged over the past 5 minutes. At the bottom of the page, click save.
</para>
</listitem>
<listitem>
<para>
At the bottom of the page, click <guilabel>Save</guilabel>.
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful." and your graph listed.
</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>
Add graph to the graph view
</para>
<itemizedlist>
<listitem>
<para>
Click <guilabel>Graph Trees</guilabel> under <guilabel>Management</guilabel>
</para>
</listitem>
<listitem>
<para>
We'll create a tree called "test" to place our graph
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Add</guilabel>
</para>
</listitem>
<listitem>
<para>
Name: test
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful"
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Add</guilabel> beside <guilabel>Tree Items</guilabel> (to add our graph to this tree)
</para>
</listitem>
<listitem>
<para>
Under Tree Items [graph]...
</para>
</listitem>
<listitem>
<para>
Graph: RANDOM NUMBERS (we named this in step 3)
</para>
</listitem>
<listitem>
<para>
Round Robin Archive: Daily (5 Minute Average)
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Create</guilabel>
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful." and RANDOM NUMBERS listed under <guilabel>Tree Items</guilabel>
</para>
</listitem>
<listitem>
<para>
Click <guilabel>Save</guilabel>
</para>
</listitem>
<listitem>
<para>
Should see "Save Successful." and test listed under <guilabel>Graph Trees</guilabel>
</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>
View Graph
</para>
<itemizedlist>
<listitem>
<para>
Select <guilabel>Graphs</guilabel> tab
</para>
</listitem>
<listitem>
<para>
Select tree view (Tree beside settings tab)
</para>
</listitem>
<listitem>
<para>
Select test tree on left
</para>
</listitem>
<listitem>
<para>
You may see "Random Graph" but no graph. It takes two or three polls (10 - 15 minutes) to see a graph. I believe poll 1 to create the rrd, poll 2 to get the first data point and poll 3 to have graphable points.
</para>
</listitem>
<listitem>
<para>
While waiting, you can click the RANDOM NUMBERS graph. You'll see place holders for 4 graphs. Select [source] under Daily (5 Minute Average). You'll see the source for the call to rrdtool graph. Give it a sanity check.
</para>
</listitem>
<listitem>
<para>
Now be patient. Hit your refresh button every few minutes. After the first poll I got a few empty graphs. A few minutes later data started showing up.
</para>
</listitem>
</itemizedlist>
</listitem>
</orderedlist>
</sect1>
</chapter>
<chapter id="faq">
<title>Frequently Asked Questions</title>
<qandaset defaultlabel="none">
<qandadiv>
<title>Using Cacti</title>
<qandaentry>
<question>
<para>
How do I create traffic graphs?
</para>
</question>
<answer>
<para>
Before you can create traffic graphs, Cacti must have working SNMP support. One way to do this is to compile
PHP with SNMP support built in, many times you can install the 'php-snmp' package to do this. The second option
is to have Cacti call the snmpget and snmpwalk binaries from your ucd-snmp or <application>net-snmp</application>
installation. You can use the about page to determine whether to are using "built-in" or "external" SNMP support.
</para>
<para>
Now that you have working SNMP support, follow these steps.
</para>
<orderedlist>
<listitem>
<para>Click <guilabel>Devices</guilabel> on Cacti's menu.</para>
</listitem>
<listitem>
<para>Click <guilabel>Add</guilabel> to add a new device.</para>
</listitem>
<listitem>
<para>Type a description, hostname, management IP, and SNMP community. Make sure to select "Generic SNMP-enabled Host" under <guilabel>Host Template</guilabel> and click <guilabel>Create</guilabel>.</para>
</listitem>
<listitem>
<para>Click <guilabel>Create Graphs for this Host</guilabel> at the top of the page.</para>
</listitem>
<listitem>
<para>You should see one or more interfaces listed under the <guilabel>Data Query [SNMP - Interface Statistics]</guilabel> box. Place a check next to each interface that you want to graph. Below the box, select type of graph that you want to create (bits, bytes, summation, etc).</para>
</listitem>
<listitem>
<para>Click <guilabel>Create</guilabel>, and <guilabel>Create</guilabel> again on the following screen to create your graphs.</para>
</listitem>
</orderedlist>
</answer>
</qandaentry>
</qandadiv>
<qandadiv>
<title>General</title>
<qandaentry>
<question>
<para>
I get a "Undefined variable: _SERVER" error message from Cacti.
</para>
</question>
<answer>
<para>
Cacti 0.8.6 and above requires that you have at least PHP 4.1 or greater installed.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>
I get a "Call to undefined function: mysql_connect()" error message from Cacti.
</para>
</question>
<answer>
<para>
Your installation of PHP does not have MySQL installed or enabled. On binary-based distributions, make
sure you have the 'php-mysql' package installed. Also make sure that 'extension=mysql.so' is uncommented
in your php.ini file.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>
I have forgotten my 'admin' password to Cacti, how do I reset it?
</para>
</question>
<answer>
<para>
To reset the admin account password back to the default of 'admin', connect to your Cacti database at the
command line.
</para>
<screen><prompt>shell&gt;</prompt> <userinput>mysql -u root -p cacti</userinput></screen>
<para>
Now execute the following SQL:
</para>
<screen><prompt>mysql&gt;</prompt> <userinput>update user_auth set password=md5('admin') where username='admin';</userinput></screen>
</answer>
</qandaentry>
</qandadiv>
<qandadiv>
<title>Monitoring</title>
<qandaentry>
<question>
<para>
I am polling thousands of items and poller.php takes more than 5 minutes to run.
</para>
</question>
<answer>
<para>
Give <application>Spine</application>, the fast replacement for poller.php a try. Unlike poller.php, <application>Spine</application> is written in c and makes use
of pthreads. On a typical installation, it is not uncommon for <application>Spine</application> to poll about 500 items in less then 10
seconds.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>
I changed x, and now some of my graphs are not updating.
</para>
</question>
<answer>
<para>
The best thing to do here is to force Cacti to rebuild its poller cache. To do this click <guilabel>Utilities</guilabel> on the Cacti menu, and select <guilabel>Clear Poller Cache</guilabel>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>
I am using <application>Redhat 8.0</application> and SNMP is not working.
</para>
</question>
<answer>
<para>
<application>Redhat 8.0</application> comes with a broken php-snmp package. Updating your 'php-snmp' and 'net-snmp'
packages to their latest versions should fix this problem.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>
How do I configure <application>net-snmp</application> so it will work with Cacti?
</para>
</question>
<answer>
<para>
Run <command>snmpconf -g basic_setup</command> and follow the prompts. Also check that the file being used by snmpd
is the correct config file. For Redhat Linux, snmpconf creates the <filename>/etc/snmpd.conf</filename>, but snmpd
uses <filename>/etc/snmpd/snmpd.conf</filename>.
</para>
<para>
If this doesn't work a very simple config file is:
</para>
<screen><userinput># contact
syslocation Something
syscontact "root@someone.com"
# auth
rocommunity public
# disk monitoring
disk /</userinput></screen>
</answer>
</qandaentry>
</qandadiv>
<qandadiv>
<title>Graphs</title>
<qandaentry>
<question>
<para>
I just installed Cacti and all of my graphs appear as broken images.
</para>
</question>
<answer>
<para>
For you to actually get graph images, poller.php must run at least once so it can create .rrd files in Cacti's 'rra/'
directory. Double check that you configured your <filename>/etc/crontab</filename> file to execute poller.php every
five minutes. Also make sure that the user poller.php runs as has permission to create new files in Cacti's 'rra/'
directory.
</para>
<para>
If all of your settings appear correct, try running poller.php manually by cd'ing to Cacti's directory and typing:
</para>
<screen><prompt>shell&gt;</prompt> <userinput>php poller.php</userinput></screen>
<para>
If you have files in your 'rra/' directory, but your graphs still appear as broken images, you should enable graph
debug mode see exactly why the graphs are not rendering. To do this go into Cacti, select <guilabel>Graph Management</guilabel>
from the menu, select any graph listed, and select <guilabel>Turn On Graph Debug Mode</guilabel>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>
My graphs render, but they do not contain any data.
</para>
</question>
<answer>
<para>
More often than not, this problem's cause is permissions. For instance if you run poller.php manually as root for testing, any
.rrd files that it creates will be owned by root. Now when poller.php runs from cron, it will not be able to update these .rrd
files because they are owned by root. You can double check the owner of your .rrd files by running the following command in
your Cacti directory:
</para>
<screen><prompt>shell&gt;</prompt> <userinput>ls -al rra/</userinput></screen>
<para>
If only some of your graphs are not updating correctly, double check the <guilabel>Maximum Value</guilabel> field for all data
sources used by these graphs. If the value being fed to the .rrd file exceeds its <guilabel>Maximum Value</guilabel>, RRDTool
will insert an <guilabel>Unknown</guilabel> and you will see no data on the graph.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>
A lot of my graphs contain long ifAlias names, but they are being truncated to 15 characters.
</para>
</question>
<answer>
<para>
Cacti does this by default to better control graph title formatting. You can change this limit, by going to <guilabel>Cacti
Settings</guilabel> on the Cacti menu, selecting the <guilabel>Visual</guilabel> tab, and changing the value for <guilabel>Data
Queries - Maximum Field Length</guilabel>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>
One of my devices rebooted and now I have a huge spike on my graph!
</para>
</question>
<answer>
<para>
This occurs because the reboot causes SNMP's counters to reset, which can cause a rather large spike on the graph when
<application>RRDTool</application> tries to determine the change between the new small counter value and the large
previous value. One way to combat this issue is to specify realistic maximum values for your data sources.
<application>RRDTool</application> will ignore any value that is larger than the maximum value.
</para>
<para>
If you already have a spike on one or more of your graphs, there is a really <ulink url="http://cricket.sourceforge.net/contrib/files/killspike2">useful Perl script</ulink> that will remove them for you.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>
RRDTool Says: ERROR: unknown option '--slope-mode' or RRDTool Says: ERROR: Garbage ':39:24 To 2005/10/22 16:39:24\c' after command: COMMENT:From 2005/10/21 16:39:24 To 2005/10/22 16:39:24\c
</para>
</question>
<answer>
<para>
This occurs because the version of RRDTool that you are running does not match the RRDTool version Cacti is configured to use. Double check your Cacti Settings and make sure that the RRDTool version matches what version of RRDTool you are running.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv>
<title>Windows Related</title>
<qandaentry>
<question>
<para>
I get a "Fatal error: Cannot redeclare title_trim()" error message from Cacti.
</para>
</question>
<answer>
<para>
Contrary to previous versions of Cacti, you must not put Cacti in your PHP include path. Check your <filename>php.ini</filename> file to make sure there is not something like <userinput>include_path = C:/Apache2/htdocs/cacti</userinput>.
</para>
</answer>
</qandaentry>
</qandadiv>
</qandaset>
</chapter>
</part>
<part id="reference">
<title>Reference</title>
<chapter id="variables">
<title>Variables</title>
<sect1 id="graph-variables">
<title>Graph Variables</title>
<para>
The following variables can be used in the <guilabel>Text Format</guilabel> and <guilabel>Value</guilabel> graph
item fields. Below is a description of each of these variables.
</para>
<sect2 id="variable-date-time">
<title>Date/Time</title>
<screen><userinput>|date_time|</userinput></screen>
<para>
This variable will place the date and time of the last poller run on the graph. It can be used to replicate
<application>MRTG</application>'s "graph last updated" feature.
</para>
</sect2>
<sect2 id="variable-data-source-title">
<title>Data Source Title</title>
<screen><userinput>|data_source_title|</userinput></screen>
<para>
This variable, |data_source_title|, gets replaced with the name of the data source associated with a particular
graph item in a graph template. This change allows the creation of generic
graph templates (2-variable line graph, 3-variable stack, etc.)
which can be reused with large numbers of data sources.
See attached examples to understand usage.
</para>
<figure id="data-source-title-template">
<title>Example of a Graph Template using |data_source_title|</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/data_source_title_template.png" format="PNG">
</imageobject>
</mediaobject>
</figure>
<figure id="data-source-title-example1">
<title>Example 1 of a Graph making use of |data_source_title|</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/data_source_title_example1.png" format="PNG">
</imageobject>
</mediaobject>
</figure>
<figure id="data-source-title-example2">
<title>Example 2 of a Graph making use of |data_source_title|</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/data_source_title_example2.png" format="PNG">
</imageobject>
</mediaobject>
</figure>
</sect2>
<sect2 id="variable-data-query">
<title>Data Query Fields</title>
<screen><userinput>|query_field_name|</userinput></screen>
<para>
You can place the value of any data query field on the by including this variable. Make sure
to substitute "field_name" with the actual data query field name.
</para>
<example>
<title>Print the IP Address on a traffic graph</title>
<para>
<userinput>|query_ifIP|</userinput>
</para>
</example>
<example>
<title>Print the mount point on net-snmp disk graph</title>
<para>
<userinput>|query_dskPath|</userinput>
</para>
</example>
</sect2>
<sect2 id="variable-Nth-percentile">
<title>Nth Percentile</title>
<screen><userinput>|[0-9]:(bits|bytes):[0-9]:(current|total|max|total_peak|all_max_current|all_max_peak|aggregate_max|aggregate_sum|aggregate_current|aggregate):[0-9]|</userinput></screen>
<para>
Nth percentile is often used by hosting providers to bill customers based on their peak traffic usage while
ignoring their top (100 - Nth) percent. This way if a customer has a fairly consistent traffic pattern and
decides to download a huge file one day, the large spike will be ignored. Common Nth percentile is 95, which
would cut off the top 5% of the traffic.
</para>
<para>
In Cacti, Nth percentile works just like any other graph variable. To use this variable you must give it five
arguments:
</para>
<table frame='all'>
<title>Nth Percentile Argument Description</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><function>[0-9]</function></entry>
<entry>The first argument is a number between 1 and 99. This number represents the Nth percentile that you would like to calculate.</entry>
</row>
<row>
<entry><function>(bits|bytes)</function></entry>
<entry>Choose whether you want to represent your Nth percentile in bits or bytes. The only valid values for this field are 'bits' and 'bytes'.</entry>
</row>
<row>
<entry><function>[0-9]</function></entry>
<entry>This field determines the power of 10 divisor that will be applied to your Nth percentile number. Enter '0' to leave the number alone, '3' for kilo or '6' for mega, etc.</entry>
</row>
<row>
<entry><function>( current | total | max | total_peak | all_max_current | all_max_peak | aggregate_max | aggregate_sum | aggregate_current | aggregate )</function></entry>
<entry>Nth Percentile Type - Refer to Nth Types</entry>
</row>
<row>
<entry><function>[0-9]</function></entry>
<entry>Enter the number of digits to use for floating point precision when printing out the final number. The default value for this field is two decimal places.</entry>
</row>
</tbody>
</tgroup>
</table>
<table frame='all'>
<title>Nth Percentile Types</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Type</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><function>current</function></entry>
<entry>Calculates the Nth percentile based off the selected data source on the graph item wich the variable is used. This type requires a selected Data Source Item in the graph item in which it is defined.</entry>
</row>
<row>
<entry><function>total</function></entry>
<entry>Calculates the Nth percentile based off the selected data source on the graph item wich the variable is used. But unlike current, this function totals the Nth percentile results of all same named data source names on the graph. Example, all traffic_in would have their Nth percentile calculated and then totaled. This type requires a selected Data Source Item in the graph item in which it is defined.</entry>
</row>
<row>
<entry><function>max</function></entry>
<entry>Calculates the Nth percentile based off the selected data source on the graph item which the variable is used, but it is important to note that it selects the higher of the values for each row in data source and then uses the resulting set to calculate the Nth percentile. Example, you have selected a interface data source for traffic_in, this will evaluate traffic_out and traffic_in for that selected data source (rrdtool file) and select the higher of the two values for each row of data. The resulting max values are used to calculate the Nth percentile value. This type requires a selected Data Source Item in the graph item in which it is defined.</entry>
</row>
<row>
<entry><function>total_peak</function></entry>
<entry>Calculates the Nth percentile based on the max for each data source defined on the graph. Example, the max is taken for each data source defined on the graph, but it's the max of traffic_in or traffic_out for that data source (rrdtool file). The resulting max values are summed and returned.</entry>
</row>
<row>
<entry><function>all_max_current</function></entry>
<entry>Calculates the Nth percentile based off the selected data source on the graph item which the variable is used, but it only selects the highest (max) value of all the data source items on the graph. Example, there are 3 data sources defined on the graph, the selected data source is traffic_in, all data sources for traffic_in will be compared against each other and the highest Nth value of all graph items will be selected as the result. This type requires a selected Data Source Item in the graph item in which it is defined.</entry>
</row>
<row>
<entry><function>all_max_peak</function></entry>
<entry>Calculates the Nth percentile by selecting the highest (max) calculated max Nth percentile value for each data source (rrdtool file) selected on the graph. Example, 3 data sources are defined on the graph, for each data source, the max Nth percentile is calculated, and out of the resulting set of values, the highest value is selected and returned.</entry>
</row>
<row>
<entry><function>aggregate_max</function></entry>
<entry>Calculates the Nth percentile by selecting the highest value for each summed value of like data sources and selecting the maximum value of that set to calculate the Nth percentile value. Example, you have a graph with 5 traffic_in and 18 traffic_out data sources. The traffic_in rows are summed together, then the traffic_out rows are summed together, then for each row, the higher of the 2 values is selected. The Nth percentile is calculated from the resulting maximum values.</entry>
</row>
<row>
<entry><function>aggregate_sum</function></entry>
<entry>Calculates the Nth percentile by summing all data sources on the graph row for row and calculates the Nth value on the resulting summed data. Example, you have a graph with 4 traffic_in and 3 traffic_out data sources defined. All the defined traffic_in and traffic_out are summed together and then the Nth percentile value is calculated from that set.</entry>
</row>
<row>
<entry><function>aggregate_current</function></entry>
<entry>Calculates the Nth percentile by summing items matching the selected data source name row for row from each data source defined on the graph with the same data source name and then returning the Nth percent value calculated. Example, you have a graph with 3 traffic_out and 5 traffic_in data sources defined. The traffic_in is selected on the graph item where this variable is used, so all graph items for traffic_in are summed and then the Nth value is calculated and returned as the variable.</entry>
</row>
<row>
<entry><function>aggregate</function></entry>
<entry>Calculates the Nth percentile by summing like data source names row for row from each data source defined on the graph and then returning the highest Nth percent value calculated for like data source names. Example, you have a graph with 3 traffic_out and 5 traffic_in data sources defined. The traffic_in and traffic_out are summed then the Nth value is calculated and the higher of the 2 values is returned as the variable.</entry>
</row>
</tbody>
</tgroup>
</table>
<note><title>Concerning aggregate Nth percentile functions and rra definitions</title>
<para>All data sources used in a graph MUST have the same rra definitions. If the number of rows do not match when calculations are attempted, the results may produce errors and invalid results. Please also be aware the aggregate functions take more memory and processor power when used. Recommended minimum of 64 megs memory limit for php when querying large ranges or graphs with a large ammount of aggregated data sources.</para>
</note>
<example>
<title>Output in the following format, for 95th percentile: 42.58 mbit</title>
<para>
<userinput>|95:bits:6:max:2|</userinput>
</para>
</example>
</sect2>
<sect2 id="variable-bandwidth-summation">
<title>Bandwidth Summation</title>
<screen><userinput>|sum:([0-9]|auto):(current|total):([0-9]):([0-9]+|auto)|</userinput></screen>
<para>
Bandwidth summation is useful for summing up all values in an RRD file for a given time range. This is typically
useful on traffic graphs where you can see a total of all traffic that has gone through an interface in a given
time period.
</para>
<para>
In Cacti, bandwidth summation works just like any other graph variable. To use this variable you must give it three
arguments:
</para>
<table frame='all'>
<title>Bandwidth Summation Argument Description</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><function>([0-9]|auto)</function></entry>
<entry>This field determines the power of 10 divisor that will be applied to your number. Enter '0' to leave the number alone, '3' for kilo or '6' for mega, etc. You can also enter 'auto' for this field to have Cacti automatically scale the number and insert the appropriate label.</entry>
</row>
<row>
<entry><function>(current|total)</function></entry>
<entry>You can choose to calculate the summation based on the current data source or a total of all data sources used on the graph. The only valid values for this field are 'current' and 'total'.</entry>
</row>
<row>
<entry><function>[0-9]</function></entry>
<entry>Enter the number of digits to use for floating point precision when printing out the final number. The default value for this field is two decimal places.</entry>
</row>
<row>
<entry><function>([0-9]+|auto)</function></entry>
<entry>Enter the number of seconds in the past to perform the summation calculation for. For instance '86400' for 24 hours, '172800' for 48 hours, etc. You can also enter 'auto' for this field to have Cacti use the graph timespan.</entry>
</row>
</tbody>
</tgroup>
</table>
<example>
<title>Output in the following format: 36.47 GB</title>
<para>
<userinput>|sum:auto:current:2:auto|</userinput>
</para>
</example>
</sect2>
</sect1>
<sect1 id="host-variables">
<title>Host Variables</title>
<para>
Host variables represent host data and can be placed in graph or data source titles. The following
table describes which host variables can be used and which host fields the correspond to.
</para>
<table frame='all'>
<title>Host Variables</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Variable Name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><function>|host_description|</function></entry>
<entry>Description</entry>
</row>
<row>
<entry><function>|host_hostname|</function></entry>
<entry>Hostname</entry>
</row>
<row>
<entry><function>|host_snmp_community|</function></entry>
<entry>SNMP Community</entry>
</row>
<row>
<entry><function>|host_snmp_version|</function></entry>
<entry>SNMP Version</entry>
</row>
<row>
<entry><function>|host_snmp_username|</function></entry>
<entry>SNMP Username (v3)</entry>
</row>
<row>
<entry><function>|host_snmp_password|</function></entry>
<entry>SNMP Password (v3)</entry>
</row>
<row>
<entry><function>|host_snmp_auth_protocol|</function></entry>
<entry>SNMP Authetication Protocol (v3)</entry>
</row>
<row>
<entry><function>|host_snmp_priv_passphrase|</function></entry>
<entry>SNMP Privacy Passphrase (v3)</entry>
</row>
<row>
<entry><function>|host_snmp_priv_protocol|</function></entry>
<entry>SNMP Privace Protocol (v3)</entry>
</row>
<row>
<entry><function>|host_snmp_context|</function></entry>
<entry>SNMP Context (v3)</entry>
</row>
<row>
<entry><function>|host_snmp_port|</function></entry>
<entry>SNMP Port</entry>
</row>
<row>
<entry><function>|host_snmp_timeout|</function></entry>
<entry>SNMP Timeout</entry>
</row>
<row>
<entry><function>|host_ping_retries|</function></entry>
<entry>SNMP Retries</entry>
</row>
<row>
<entry><function>|host_max_oids|</function></entry>
<entry>SNMP Maximum OIDs on a bulkwalk (v2, v3)</entry>
</row>
<row>
<entry><function>|host_id|</function></entry>
<entry>Cacti internal ID for that Host</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
</chapter>
<chapter id="rrdtool-features">
<title>RRDTool Specific Features</title>
<sect1 id="gprint-presets">
<title>GPRINT Presets</title>
<para>
A GPRINT is a graph item type that enables you to print the values of data sources on a graph.
They are typically used to represent legend values on the graph. The output format of these
numbers are controlled by a printf-like format string. Cacti enables you to keep a global list
of these strings that can be applied to any graph item throughout Cacti.
</para>
<sect2 id="add-new-gprint-preset">
<title>Creating a GPRINT Preset</title>
<para>
To create a new GPRINT preset, select the <guilabel>Graph Management</guilabel> menu item under the
<guilabel>Management</guilabel> heading, and select <guilabel>GPRINT Presets</guilabel>. Click
<guilabel>Add</guilabel> to the right and you will be presented with an edit page containing two fields.
Enter a name for your GPRINT preset, and the actual printf-like string in the <guilabel>GPRINT
Text</guilabel> field. When you are finished, click the <guilabel>Create</guilabel> button to create
your new GPRINT preset.
</para>
</sect2>
</sect1>
<sect1 id="cdefs">
<title>CDEFs</title>
<para>
CDEFs allow you to apply mathematical functions to graph data to alter output. The concept of a
CDEF comes straight from <application>RRDTool</application>, and are written in reverse polish notation (RPN). For more
information regarding the syntax of CDEFs, check out the <ulink url="http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdgraph_data.en.html">CDEF tutorial</ulink>.
</para>
<sect2 id="add-new-cdef">
<title>Creating a CDEF</title>
<para>
To create a new CDEF in Cacti, select the <guilabel>Graph Management</guilabel> option under
the <guilabel>Management</guilabel> heading, and select <guilabel>CDEFs</guilabel>. Once at
this screen, click <guilabel>Add</guilabel> to the right. You will be prompted for a CDEF
name, for which you can type anything used to describe your CDEF. Click the <guilabel>Create</guilabel>
button so you are redirected back to the edit page, now with an empty <guilabel>CDEF Items</guilabel>
box. Construct your CDEF by adding an item for each element in the CDEF string, common types such as
operators and functions are enumerated for your convenience. Below is a basic description of each
CDEF item type.
</para>
<table frame='all'>
<title>CDEF Item Types</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Type</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Function</entry>
<entry>You can choose a CDEF function to use as the item. The <ulink url="http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdgraph.en.html">RRDTool graph manual</ulink> describes the purpose of each CDEF function.</entry>
</row>
<row>
<entry>Operator</entry>
<entry>Just your standard math operators, including modulo (%).</entry>
</row>
<row>
<entry>Special Data Source</entry>
<entry>A special data source is basically a flag to tell Cacti to do some special processing when it encounters this CDEF item. The "Current Graph Item Data Source" type basically inserts the name of the data source that is referenced by the graph item that references to this CDEF. Both of the "All Data Sources" types insert a summation of all data sources used on a graph.</entry>
</row>
<row>
<entry>Another CDEF</entry>
<entry>You can recursively use another CDEF within this CDEF.</entry>
</row>
<row>
<entry>Custom String</entry>
<entry>Sometimes it's just easier to type out the literal CDEF string manually. When referencing to data sources on the graph, remember that Cacti names them 'a', 'b', 'c', '...', starting with the first data source on the graph.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2 id="cdef-special-data-source">
<title>Special Data Source</title>
<para>The <guilabel>Special Data Souce</guilabel> selection introduces some variables not known
to plain vanilla rrdtool. Let's spend some few words of them to unleash their power.</para>
<table frame='all'>
<title>CDEF Special Data Source</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Special Data Source</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Current Graph Item Data Source</entry>
<entry>Will be replaced by the DEF name of the rrdtool data source referred by the graph item this CDEF is associated to.</entry>
</row>
<row>
<entry>All Data Sources (Don't Include Duplicates)</entry>
<entry>Will add up all data sources of the whole graph to form a total. A data source that appears more than once will be counted only once. Data sources that differ by consolidation functions only are NOT counted as different data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted only once). It is NOT required to associate the graph item to any data source!</entry>
</row>
<row>
<entry>All Data Sources (Include Duplicates)</entry>
<entry>Will add up all data sources of the whole graph to form a total. A data source that appears more than once will be counted for each time of it's appearance. Data sources that differ by consolidation functions only are NOT counted as different data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted only once). It is NOT required to associate the graph item to any data source!</entry>
</row>
<row>
<entry>Similar Data Sources (Don't Include Duplicates)</entry>
<entry>It is REQUIRED to associate the graph item to the data source that shall be totalled! Let's assume the data source is named "traffic_in". Then, cacti will add up all data sources "traffic_in" of the whole graph to form a data source specific total (e.g. Total traffic In). Data sources with different consolidation functions are counted as same data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted once)</entry>
</row>
<row>
<entry>Similar Data Sources (Include Duplicates)</entry>
<entry>It is REQUIRED to associate the graph item to the data source that shall be totalled! If a data source appears multiple times, it will be added this many times.</entry>
</row>
<row>
<entry>Current Data Source Item: Minimum Value</entry>
<entry>Taken from the Data Template - Data Source Item related to this graph item: fetches the minimum value defined for the given data template. Caution: This is NOT the smallest entry of the given data source!</entry>
</row>
<row>
<entry>Current Data Source Item: Maximum Value</entry>
<entry>Taken from the Data Template - Data Source Item related to this graph item: fetches the maximum value defined for the given data template. Caution: This is NOT the highest entry of the given data source!</entry>
</row>
<row>
<entry>Graph: Lower Limit</entry>
<entry>Taken from the Graph Template: fetches the Lower Limit defined to the Graph Template. This is independant of all --alt-autoscaling options. It is NOT the dynamically determined lower boundary of the graph!</entry>
</row>
<row>
<entry>Graph: Upper Limit</entry>
<entry>Taken from the Graph Template: fetches the Upper Limit defined to the Graph Template. This is independant of all --alt-autoscaling options. It is NOT the dynamically determined upper boundary of the graph!</entry>
</row>
<row>
<entry>Count of All Data Sources (Don't Include Duplicates)</entry>
<entry>Will count the number of all data sources of the whole graph. A data source that appears more than once will be counted only once. Data sources that differ by consolidation functions only are NOT counted as different data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted only once). It is NOT required to associate the graph item to any data source!</entry>
</row>
<row>
<entry>Count of All Data Sources (Include Duplicates)</entry>
<entry>Will count the number of all data sources of the whole graph. A data source that appears more than once will be counted for each time of it's appearance. Data sources that differ by consolidation functions only are NOT counted as different data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted only once). It is NOT required to associate the graph item to any data source!</entry>
</row>
<row>
<entry>Count of Similar Data Sources (Don't Include Duplicates)</entry>
<entry>It is REQUIRED to associate the graph item to the data source that shall be counted! Let's assume the data source is named "traffic_in". Then, cacti will count all data sources "traffic_in" of the whole graph. Data sources with different consolidation functions are counted as same data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted once)</entry>
</row>
<row>
<entry>Count of Similar Data Sources (Include Duplicates)</entry>
<entry>It is REQUIRED to associate the graph item to the data source that shall be counted! If a data source appears multiple times, it will be counted this many times.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>While the <parameter>All Data Sources/Similar Data Sources</parameter> pseudo CDEF variables
perform <emphasis>totaling</emphasis>, the <parameter>Count All Data Sources/Count Similar Data Sources</parameter>
pseudo CDEF Variables simply <emphasis>count</emphasis> the occurences of the related data sources.
Thus, it is easy to compute e.g. an average of all similar data sources by creating the CDEF
</para>
<screen>CDEF=SIMILAR_DATA_SOURCES_NODUPS,COUNT_SIMILAR_DS_NODUPS,/</screen>
</sect2>
<sect2 id="cdef-special-data-source-examples">
<title>Using Special Data Source</title>
<para>Let's have some examples:</para>
<example>
<title>Sum up all Data Sources Omitting Duplicates</title>
<para>This is the list of graph items defined. Please note,
that Item#17-20 are duplicates of Item#1-4. Even if it usually does not make sense, for this
discussion it is very valuable. Item#21-24 are related to a
<emphasis>cdef=ALL_DATA_SOURCES_NODUPS</emphasis></para>
<screen>
Graph Item Data Source Graph Item Type CF Type
Item # 1 (traffic_in): 1. Target Traffic In LINE1 AVERAGE
Item # 2 (traffic_in): Current: GPRINT LAST
Item # 3 (traffic_in): Average: GPRINT AVERAGE
Item # 4 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 5 (traffic_in): 2. Target Traffic In LINE1 AVERAGE
Item # 6 (traffic_in): Current: GPRINT LAST
Item # 7 (traffic_in): Average: GPRINT AVERAGE
Item # 8 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 9 (traffic_out): 1. Target Traffic Out LINE1 AVERAGE
Item # 10 (traffic_out): Current: GPRINT LAST
Item # 11 (traffic_out): Average: GPRINT AVERAGE
Item # 12 (traffic_out): Maximum:[HR] GPRINT MAX
Item # 13 (traffic_out): 2. Target Traffic Out LINE1 AVERAGE
Item # 14 (traffic_out): Current: GPRINT LAST
Item # 15 (traffic_out): Average: GPRINT AVERAGE
Item # 16 (traffic_out): Maximum:[HR] GPRINT MAX
Item # 17 (traffic_in): 1. Target Again Traffic In LINE1 AVERAGE
Item # 18 (traffic_in): Current: GPRINT LAST
Item # 19 (traffic_in): Average: GPRINT AVERAGE
Item # 20 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 21 (No Task): AllDsNoDups LINE1 AVERAGE
Item # 22 (No Task): Current: GPRINT LAST
Item # 23 (No Task): Average: GPRINT AVERAGE
Item # 24 (No Task): Maximum:[HR] GPRINT MAX</screen>
<para>And this is the rrd graph statement:</para>
<screen>/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Traffic AllDsNoDups" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:AVERAGE \
DEF:b="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:MAX \
DEF:c="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:AVERAGE \
DEF:d="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:MAX \
DEF:e="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:AVERAGE \
DEF:f="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:MAX \
DEF:g="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:AVERAGE \
DEF:h="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:MAX \
CDEF:cdefca=TIME,1202925514,GT,a,a,UN,0,a,IF,IF,TIME,1202925514,GT,c,c,UN,0,c,IF,IF,TIME,1202925514,GT,e,e,UN,0,e,IF,IF,TIME,1202925514,GT,g,g,UN,0,g,IF,IF,+,+,+ \
LINE1:a#FFFF00FF:"1. Target Traffic In" \
GPRINT:a:LAST:" Current\:%8.2lf%s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:c#FFD660FF:"2. Target Traffic In" \
GPRINT:c:LAST:" Current\:%8.2lf%s" \
GPRINT:c:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:d:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:e#CAF100FF:"1. Target Traffic Out" \
GPRINT:e:LAST:" Current\:%8.2lf%s" \
GPRINT:e:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:f:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:g#CCBB00FF:"2. Target Traffic Out" \
GPRINT:g:LAST:" Current\:%8.2lf%s" \
GPRINT:g:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:h:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:a#FF0000FF:"1. Target Again Traffic In" \
GPRINT:a:LAST:"Current\:%8.2lf%s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:cdefca#000000FF:"AllDsNoDups" \
GPRINT:cdefca:LAST:" Current\:%8.2lf%s" \
GPRINT:cdefca:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:cdefca:MAX:"Maximum\:%8.2lf%s\n"</screen>
<para>The data sources are denoted by the letters <guilabel>a</guilabel> to <guilabel>h</guilabel>.
<guilabel>cdefca</guilabel> represents the important part. You surely notice, that
all data sources using consolidation function AVERAGE are taken into account while MAX is skipped.
Please pay attention to the data source denoted by <guilabel>a</guilabel>. Even though the data source appears twice,
the cdef shows it only once. This is due to the duplicate suppression.</para>
</example>
<example>
<title>Sum up all Data Sources Including Duplicates</title>
<para>This is the list of graph items defined. Please note,
that Item#17-20 are duplicates of Item#1-4. Even if it usually does not make sense, for this
discussion it is very valuable. Item#21-24 are related to a
<emphasis>cdef=ALL_DATA_SOURCES_DUPS</emphasis></para>
<screen>
Graph Item Data Source Graph Item Type CF Type
Item # 1 (traffic_in): 1. Target Traffic In LINE1 AVERAGE
Item # 2 (traffic_in): Current: GPRINT LAST
Item # 3 (traffic_in): Average: GPRINT AVERAGE
Item # 4 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 5 (traffic_in): 2. Target Traffic In LINE1 AVERAGE
Item # 6 (traffic_in): Current: GPRINT LAST
Item # 7 (traffic_in): Average: GPRINT AVERAGE
Item # 8 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 9 (traffic_out): 1. Target Traffic Out LINE1 AVERAGE
Item # 10 (traffic_out): Current: GPRINT LAST
Item # 11 (traffic_out): Average: GPRINT AVERAGE
Item # 12 (traffic_out): Maximum:[HR] GPRINT MAX
Item # 13 (traffic_out): 2. Target Traffic Out LINE1 AVERAGE
Item # 14 (traffic_out): Current: GPRINT LAST
Item # 15 (traffic_out): Average: GPRINT AVERAGE
Item # 16 (traffic_out): Maximum:[HR] GPRINT MAX
Item # 17 (traffic_in): 1. Target Again Traffic In LINE1 AVERAGE
Item # 18 (traffic_in): Current: GPRINT LAST
Item # 19 (traffic_in): Average: GPRINT AVERAGE
Item # 20 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 21 (No Task): AllDsDups LINE1 AVERAGE
Item # 22 (No Task): Current: GPRINT LAST
Item # 23 (No Task): Average: GPRINT AVERAGE
Item # 24 (No Task): Maximum:[HR] GPRINT MAX</screen>
<para>And this is the rrd graph statement:</para>
<screen>/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Traffic AllDsDups" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:AVERAGE \
DEF:b="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:MAX \
DEF:c="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:AVERAGE \
DEF:d="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:MAX \
DEF:e="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:AVERAGE \
DEF:f="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:MAX \
DEF:g="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:AVERAGE \
DEF:h="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:MAX \
CDEF:cdefca=TIME,1202925583,GT,a,a,UN,0,a,IF,IF,TIME,1202925583,GT,c,c,UN,0,c,IF,IF,TIME,1202925583,GT,e,e,UN,0,e,IF,IF,TIME,1202925583,GT,g,g,UN,0,g,IF,IF,TIME,1202925583,GT,a,a,UN,0,a,IF,IF,+,+,+,+ \
LINE1:a#FFFF00FF:"1. Target Traffic In" \
GPRINT:a:LAST:" Current\:%8.2lf%s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:c#FFD660FF:"2. Target Traffic In" \
GPRINT:c:LAST:" Current\:%8.2lf%s" \
GPRINT:c:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:d:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:e#CAF100FF:"1. Target Traffic Out" \
GPRINT:e:LAST:" Current\:%8.2lf%s" \
GPRINT:e:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:f:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:g#CCBB00FF:"2. Target Traffic Out" \
GPRINT:g:LAST:" Current\:%8.2lf%s" \
GPRINT:g:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:h:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:a#FF0000FF:"1. Target Again Traffic In" \
GPRINT:a:LAST:"Current\:%8.2lf%s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:cdefca#000000FF:"AllDsDups" \
GPRINT:cdefca:LAST:" Current\:%8.2lf%s" \
GPRINT:cdefca:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:cdefca:MAX:"Maximum\:%8.2lf%s\n"</screen>
<para>Again, the data sources are denoted by the letters <guilabel>a</guilabel> to <guilabel>h</guilabel> and
<guilabel>cdefca</guilabel> represents the important part. Please pay attention to the data source
denoted by <guilabel>a</guilabel> appearing twice in this cdef.
This is, because it appears twice (Item#17-20) in the graph item list
and duplicate suppression is not in effect.</para>
</example>
<example>
<title>Sum up Similar Data Sources Omitting Duplicates</title>
<para>Everything is very much like the above; again
Item#17-20 are duplicates of Item#1-4. Item#21-24 are related to a
<emphasis>cdef=SIMILAR_DATA_SOURCES_NODUPS</emphasis> and are associated with the
data source <emphasis>traffic_in</emphasis> of the 1. target (it does not matter, which target is chosen,
as long as you only choose a traffic_in data source)</para>
<screen>
Graph Item Data Source Graph Item Type CF Type
Item # 1 (traffic_in): 1. Target Traffic In LINE1 AVERAGE
Item # 2 (traffic_in): Current: GPRINT LAST
Item # 3 (traffic_in): Average: GPRINT AVERAGE
Item # 4 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 5 (traffic_in): 2. Target Traffic In LINE1 AVERAGE
Item # 6 (traffic_in): Current: GPRINT LAST
Item # 7 (traffic_in): Average: GPRINT AVERAGE
Item # 8 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 9 (traffic_out): 1. Target Traffic Out LINE1 AVERAGE
Item # 10 (traffic_out): Current: GPRINT LAST
Item # 11 (traffic_out): Average: GPRINT AVERAGE
Item # 12 (traffic_out): Maximum:[HR] GPRINT MAX
Item # 13 (traffic_out): 2. Target Traffic Out LINE1 AVERAGE
Item # 14 (traffic_out): Current: GPRINT LAST
Item # 15 (traffic_out): Average: GPRINT AVERAGE
Item # 16 (traffic_out): Maximum:[HR] GPRINT MAX
Item # 17 (traffic_in): 1. Target Again Traffic In LINE1 AVERAGE
Item # 18 (traffic_in): Current: GPRINT LAST
Item # 19 (traffic_in): Average: GPRINT AVERAGE
Item # 20 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 21 (traffic_in): SimilarDsNoDups LINE1 AVERAGE
Item # 22 (traffic_in): Current: GPRINT LAST
Item # 23 (traffic_in): Average: GPRINT AVERAGE
Item # 24 (traffic_in): Maximum:[HR] GPRINT MAX</screen>
<para>And this is the rrd graph statement:</para>
<screen>/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Traffic SimilarDsNoDups" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:AVERAGE \
DEF:b="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:MAX \
DEF:c="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:AVERAGE \
DEF:d="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:MAX \
DEF:e="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:AVERAGE \
DEF:f="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:MAX \
DEF:g="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:AVERAGE \
DEF:h="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:MAX \
CDEF:cdefca=TIME,1202924474,GT,a,a,UN,0,a,IF,IF,TIME,1202924474,GT,c,c,UN,0,c,IF,IF,+ \
CDEF:cdefcd=TIME,1202924474,GT,b,b,UN,0,b,IF,IF,TIME,1202924474,GT,d,d,UN,0,d,IF,IF,+ \
LINE1:a#FFFF00FF:"1. Target Traffic In" \
GPRINT:a:LAST:" Current\:%8.2lf%s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:c#FFD660FF:"2. Target Traffic In" \
GPRINT:c:LAST:" Current\:%8.2lf%s" \
GPRINT:c:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:d:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:e#CAF100FF:"1. Target Traffic Out" \
GPRINT:e:LAST:" Current\:%8.2lf%s" \
GPRINT:e:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:f:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:g#CCBB00FF:"2. Target Traffic Out" \
GPRINT:g:LAST:" Current\:%8.2lf%s" \
GPRINT:g:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:h:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:a#FF0000FF:"1. Target Again Traffic In" \
GPRINT:a:LAST:"Current\:%8.2lf%s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:cdefca#000000FF:"SimilarDsNoDups" \
GPRINT:cdefca:LAST:" Current\:%8.2lf%s" \
GPRINT:cdefca:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:cdefcd:MAX:"Maximum\:%8.2lf%s\n" </screen>
<para><guilabel>cdefca</guilabel> calculates the SUM of all traffic_in data sources, but
pays attention only to consolidation function AVERAGE. Duplicate suppression makes sure, that the second
occurrence of the 1. target is not taken into account. So it's only summing data source
<guilabel>a</guilabel> and <guilabel>c</guilabel>. <guilabel>cdefca</guilabel> is used the the LINE1
graph item with exact match for consolidation function AVERAGE as well as for the best matched
consolidation functions LAST and MIN.</para>
<para><guilabel>cdefcd</guilabel> calculates the SUM of all traffic_in data sources, but
pays attention only to consolidation function MAX. Again, duplicate suppression is in effect.
So it's only summing data source
<guilabel>b</guilabel> and <guilabel>d</guilabel>. <guilabel>cdefcd</guilabel> is used for the
graph item with exact match for consolidation function MAX only. This is, because my rra settings
only define AVERAGE and MAX, where LAST and MIN are omitted. This may differ for installations
defining LAST and MIN as well.</para>
</example>
<example>
<title>Sum up Similar Data Sources Including Duplicates</title>
<para>Again, please note,
that Item#17-20 are duplicates of Item#1-4. Item#21-24 are related to a
<emphasis>cdef=SIMILAR_DATA_SOURCES_DUPS</emphasis> and are associated with the
data source <emphasis>traffic_in</emphasis> of the 1. target (it does not matter, which target is chosen,
as long as you only choose a traffic_in data source)</para>
<screen>
Graph Item Data Source Graph Item Type CF Type
Item # 1 (traffic_in): 1. Target Traffic In LINE1 AVERAGE
Item # 2 (traffic_in): Current: GPRINT LAST
Item # 3 (traffic_in): Average: GPRINT AVERAGE
Item # 4 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 5 (traffic_in): 2. Target Traffic In LINE1 AVERAGE
Item # 6 (traffic_in): Current: GPRINT LAST
Item # 7 (traffic_in): Average: GPRINT AVERAGE
Item # 8 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 9 (traffic_out): 1. Target Traffic Out LINE1 AVERAGE
Item # 10 (traffic_out): Current: GPRINT LAST
Item # 11 (traffic_out): Average: GPRINT AVERAGE
Item # 12 (traffic_out): Maximum:[HR] GPRINT MAX
Item # 13 (traffic_out): 2. Target Traffic Out LINE1 AVERAGE
Item # 14 (traffic_out): Current: GPRINT LAST
Item # 15 (traffic_out): Average: GPRINT AVERAGE
Item # 16 (traffic_out): Maximum:[HR] GPRINT MAX
Item # 17 (traffic_in): 1. Target Again Traffic In LINE1 AVERAGE
Item # 18 (traffic_in): Current: GPRINT LAST
Item # 19 (traffic_in): Average: GPRINT AVERAGE
Item # 20 (traffic_in): Maximum:[HR] GPRINT MAX
Item # 21 (traffic_in): SimilarDsDups LINE1 AVERAGE
Item # 22 (traffic_in): Current: GPRINT LAST
Item # 23 (traffic_in): Average: GPRINT AVERAGE
Item # 24 (traffic_in): Maximum:[HR] GPRINT MAX</screen>
<para>And this is the rrd graph statement:</para>
<screen>/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Traffic SimilarDsDups" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:AVERAGE \
DEF:b="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:MAX \
DEF:c="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:AVERAGE \
DEF:d="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:MAX \
DEF:e="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:AVERAGE \
DEF:f="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:MAX \
DEF:g="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:AVERAGE \
DEF:h="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:MAX \
CDEF:cdefca=TIME,1202925634,GT,a,a,UN,0,a,IF,IF,TIME,1202925634,GT,c,c,UN,0,c,IF,IF,TIME,1202925634,GT,a,a,UN,0,a,IF,IF,+,+ \
CDEF:cdefcd=TIME,1202925634,GT,b,b,UN,0,b,IF,IF,TIME,1202925634,GT,d,d,UN,0,d,IF,IF,TIME,1202925634,GT,b,b,UN,0,b,IF,IF,+,+ \
LINE1:a#FFFF00FF:"1. Target Traffic In" \
GPRINT:a:LAST:" Current\:%8.2lf%s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:c#FFD660FF:"2. Target Traffic In" \
GPRINT:c:LAST:" Current\:%8.2lf%s" \
GPRINT:c:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:d:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:e#CAF100FF:"1. Target Traffic Out" \
GPRINT:e:LAST:" Current\:%8.2lf%s" \
GPRINT:e:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:f:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:g#CCBB00FF:"2. Target Traffic Out" \
GPRINT:g:LAST:" Current\:%8.2lf%s" \
GPRINT:g:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:h:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:a#FF0000FF:"1. Target Again Traffic In" \
GPRINT:a:LAST:"Current\:%8.2lf%s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n" \
LINE1:cdefca#000000FF:"SimilarDsDups" \
GPRINT:cdefca:LAST:" Current\:%8.2lf%s" \
GPRINT:cdefca:AVERAGE:"Average\:%8.2lf%s" \
GPRINT:cdefcd:MAX:"Maximum\:%8.2lf%s\n" </screen>
<para><guilabel>cdefca</guilabel> and <guilabel>cdefcd</guilabel> represents the important part. You surely notice, that
all data sources using consolidation function AVERAGE are taken into account for calculation <guilabel>cdefca</guilabel>,
while MAX is calculated with <guilabel>cdefcd</guilabel>.
Please pay attention to the data source denoted by <guilabel>a</guilabel> and <guilabel>b</guilabel>, respectively,
appearing twice in those cdefs as expected.</para>
</example>
</sect2>
<sect2 id="cdef-more-examples">
<title>More CDEF Examples</title>
<example>
<title>Disk Usage as a Percentage</title>
<para>This example is based on the standard data template <emphasis>ucd/net - Hard Drive Space</emphasis>.
Cacti ships an associated graph template named <emphasis>ucd/net - Available Disk Space</emphasis>.
Often, users complain about the fact, tha tthis template prints free and used space as absolute figures only.
But instead of knowing, that your data partition has about 10GB used space, you may be interested in the
percentage used. So let's create a simple example to show the power of the recently introduced special data sources.</para>
<para>To make it work, we need two new CDEFs. The first one may come in useful for a bunch of
different graph templates. It's named <emphasis>Make Current Data Source 0</emphasis>. On a first glance,
you may wonder why this CDEF is needed. It is used for those data sources, that will be used
for calculations but shall not show up themselves. Here's the definition</para>
<screen>cdef=CURRENT_DATA_SOURCE,0,*</screen>
<para>Now, the other one, named <emphasis>Current DS as Percentage of all DS</emphasis></para>
<screen>cdef=CURRENT_DATA_SOURCE,ALL_DATA_SOURCES_NODUPS,/,100,*</screen>
<para>Here's a short discussion. The first three elements read: Take the current data source and
divide it by "The Sum of All Data Sources (Don't include Duplicates)". To form a percentage, you will have
to multiply by 100. This is done by adding the elements four and five.</para>
<para>Now, let's build up the new graph</para>
<screen>
Graph Item Data Source Graph Item Type CF Type Item Color
Item#1 (hdd_used): LINE1 AVERAGE
Item#2 (hdd_free): LINE1 AVERAGE
Item#3 (hdd_used): % Used AREA AVERAGE FF0000
</screen>
<para>Item#1+2 in most cases will exceed the maximum percentage of 100 by magnitudes.
So they are associated with the CDEF named <emphasis>Make Current Data Source 0</emphasis> to make them zero.
This adds the data sources to the graph but avoids them showing up. The pseudo-color of "None" is associated to
both of them.</para>
<para>Iten#3 is associated to the data source <emphasis>hdd_used</emphasis> as we want to print the
"% Used" of the partition. The CDEF is <emphasis>Current DS as Percentage of all DS</emphasis>, the
color is set to "red (FF0000)".</para>
<para>And this is the rrd graph statement:</para>
<screen>/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="gandalf - Disk Space - / %used" \
--rigid \
--base=1024 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Percent" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/target1_hdd_free_236.rrd":hdd_used:AVERAGE \
DEF:b="/var/www/html/cacti/rra/target1_hdd_free_236.rrd":hdd_free:AVERAGE \
CDEF:cdefa=a,0,* \
CDEF:cdefb=b,0,* \
CDEF:cdefc=a,TIME,1203272123,GT,a,a,UN,0,a,IF,IF,TIME,1203272123,GT,b,b,UN,0,b,IF,IF,+,/,100,* \
LINE1:cdefa:"" \
LINE1:cdefb:"" \
AREA:cdefc#FF0000FF:"% Used"</screen>
<para><guilabel>cdefa</guilabel> and <guilabel>cdefb</guilabel> are used to make the according graph
items zero. <guilabel>cdefc</guilabel> performs the percentage calculation.</para>
<para>You may of cource add GPRINT legends as usual. If you do this for the "% Used" entry only, you
will get surprising results, if your rrd file holds either MAXIMUM, LAST and/or MINIMUM
consolidation function(s). This is left as an exercise to you ;-)</para>
</example>
<example>
<title>Background Colors for Day and Night</title>
<para>This set of CDEFs is used to colorize the background of a graph with different colors for day, night and weekends.
The CDEFs are created as usual, we will show the CDEF definition only. Examples are taken from rrdtool-users mailing list
courtesy Erik de Mare. Here are the definitions</para>
<para><emphasis>Background for Daytime</emphasis></para>
<screen>cdef=LTIME,86400,%,28800,GT,LTIME,86400,%,64800,LT,INF,UNKN,CURRENT_DATA_SOURCE,*,IF,UNKN,CURRENT_DATA_SOURCE,*,IF</screen>
<para><emphasis>Background for Nighttime</emphasis></para>
<screen>cdef=LTIME,86400,%,28800,LT,INF,LTIME,86400,%,64800,GT,INF,UNKN,CURRENT_DATA_SOURCE,*,IF,IF</screen>
<para><emphasis>Background for Weekend</emphasis></para>
<screen>cdef=LTIME,604800,%,172800,GT,LTIME,604800,%,345600,LT,INF,UNKN,CURRENT_DATA_SOURCE,*,IF,UNKN,CURRENT_DATA_SOURCE,*,IF</screen>
<para>The value of <emphasis>86400</emphasis> represents the number of seconds of a day, whereas
<emphasis>28800</emphasis> represents 8:00, defined as the start of the day. End of the day, <emphasis>64800</emphasis> is
assumed at 18:00. Please replace those values if required. For weekends, same logic applies.</para>
<para>Now, let's apply those new CDEFs to a Graph Template. For this example, I've chosen the <emphasis>Unix - Processes</emphasis>
that applies to localhost only. In turn, please create three new graph items, associate the processes data source,
make them AREAs, select a color and opacity. Choose the daytime , nighttime and weekend CDEF in this sequence.
As a last step, move those three new graph items to the top. I've chosen opacity of 20% for Item#1 to 3.</para>
<screen>
Graph Item Data Source Graph Item Type CF Type Item Color
Item # 1 (proc): AREA AVERAGE FFFF00
Item # 2 (proc): AREA AVERAGE 0000FF
Item # 3 (proc): AREA AVERAGE 2E3127
Item # 4 (proc): Running Processes AREA AVERAGE F51D30
Item # 5 (proc): Current: GPRINT LAST
Item # 6 (proc): Average: GPRINT AVERAGE
Item # 7 (proc): Maximum: GPRINT MAX</screen>
</example>
</sect2>
</sect1>
</chapter>
<chapter id=Scripts>
<title>Command Line Scripts</title>
<para>Cacti support a number of command line scripts.
Please find them in the <filename>./cli</filename> directory.
As of current, following scripts are supported:</para>
<screen>add_device.php
add_data_query.php
add_graph_template.php
add_graphs.php
add_perms.php
add_tree.php
copy_user.php
poller_graphs_reapply_names.php
poller_output_empty.php
poller_reindex_hosts.php
rebuild_poller_cache.php</screen>
<caution>
<title>Numbers may vary!</title>
<para>In the following examples, several numbers are shown
as output from various scripts. They will vary between different
installations. So don't bother, if your numbers will vary</para>
</caution>
<sect1 id="cli-rebuild-poller-cache">
<title>Rebuild Poller Cache</title>
<para>The poller cache holds all commands that cacti will issue during
the polling process in an internal format. It is possible, to review
the currenty contents of the poller cache by visiting <userinput>System Utilities</userinput>,
<userinput>View Poller Cache</userinput>. It is possible to apply filters
to this view; it will show up like</para>
<screen>Localhost - Hard Drive Space Script Server: /var/www/html/cacti/scripts/ss_host_disk.php ss_host_disk 127.0.0.1 1 1:161:500:somesecret:::::: get total 6
RRD: /var/www/html/cacti/rra/localhost_hdd_total_61.rrd
Localhost - Load Average Script: /usr/bin/perl /var/www/html/cacti/scripts/loadavg_multi.pl
RRD: /var/www/html/cacti/rra/localhost_load_1min_5.rrd
Localhost - Logged in Users Script: /usr/bin/perl /var/www/html/cacti/scripts/unix_users.pl
RRD: /var/www/html/cacti/rra/localhost_users_6.rrd
Localhost - Memory - Free Script: /usr/bin/perl /var/www/html/cacti/scripts/linux_memory.pl MemFree:
RRD: /var/www/html/cacti/rra/localhost_mem_buffers_3.rrd
Localhost - Memory - Free Swap Script: /usr/bin/perl /var/www/html/cacti/scripts/linux_memory.pl SwapFree:
RRD: /var/www/html/cacti/rra/localhost_mem_swap_4.rrd
Localhost - mtaReceivedMessages SNMP Version: 1, Community: somesecret, OID: .1.3.6.1.2.1.28.1.1.1.1
RRD: /var/www/html/cacti/rra/localhost_mtareceivedmessages_47.rrd
Localhost - mtaReceivedVolume SNMP Version: 1, Community: somesecret, OID: .1.3.6.1.2.1.28.1.1.4.1
RRD: /var/www/html/cacti/rra/localhost_mtareceivedvolume_49.rrd</screen>
<para>There are several circumstances, that may result in the poller cache
being out of sync. An example would be a change of the name of a script used in a
<userinput>Data Input Method</userinput>. This change is <emphasis>not</emphasis>
automatically propagated to the poller cache. It is required, to run
<application>php -q rebuild poller_cache.php</application> manually.</para>
<para>Calling the script with the parameter <userinput>--help</userinput> yields</para>
<screen><prompt>shell&gt;</prompt>php -q rebuild_poller_cache.php --help
Cacti Rebuild Poller Cache Script 1.0, Copyright 2004-2017 - The Cacti Group
usage: rebuild_poller_cache.php [-d] [-h] [--help] [-v] [--version]
-d - Display verbose output during execution
-v --version - Display this help message
-h --help - Display this help message</screen>
<para>Debug mode lists the data sources items that are worked upon.</para>
<screen><prompt>shell&gt;</prompt>php -q rebuild_poller_cache.php -d
WARNING: Do not interrupt this script. Rebuilding the Poller Cache can take quite some time
DEBUG: There are '38' data source elements to update.
DEBUG: Data Source Item '1' of '38' updated
DEBUG: Data Source Item '2' of '38' updated
DEBUG: Data Source Item '3' of '38' updated
DEBUG: Data Source Item '4' of '38' updated
....</screen>
<para>Without any parameter, some dots are shown as progress indicators.</para>
<screen><prompt>shell&gt;</prompt>php -q rebuild_poller_cache.php
WARNING: Do not interrupt this script. Rebuilding the Poller Cache can take quite some time
......................................
<prompt>shell&gt;</prompt></screen>
<caution>
<title>Stop the Poller when Rebuilding the Poller Cache</title>
<para>Rebuilding the poller cache interferes with the poller operation.
Please make sure, that the poller is not running and will not start
during a rebuild operation</para>
</caution>
</sect1>
<sect1 id="cli-poller-reindex-hosts">
<title>Re-Index Hosts</title>
<para>Re-Indexing is required only for SNMP/Script Data Queries.
Remember, that whan applying a Data Query to a Host, a
<userinput>Re-Index Method</userinput> has to be chosen. This reindex method
governs the automatic re-indexing based on specific events.</para>
<table frame='all'>
<title>Re_Index Methods</title>
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
<colspec colnum="1">
<colspec colwidth="3*" colnum="2">
<thead>
<row>
<entry align="center">Re-Index Method</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Uptime Goes Backwards</entry>
<entry>Refers to a system reboot. Cacti will detect
if the target has been rebootet by querying
sysUptime (.1.3.6.1.2.1.1.3.0).
If the current value for the uptime is lower
than the previous one (uptime goes backwards),
a reboot is assumed and a re-index is performed</entry>
</row>
<row>
<entry>Index Count Changed</entry>
<entry>Refers to a change of the number of indexed
items, e.g. interfaces, without checking sysUptime.
It is of particular interest in cases, where indexed
entries may change without the need of a reboot.
As modern operating systems seldom require reboots for
system configuration changes, you may want to consider
this setting for many cases (e.g. creating of a new
filesystem without a reboot). The index to be considered
is defined by the according XML file.</entry>
</row>
<row>
<entry>Verify All Fields</entry>
<entry>All index fields of the according XML file are checked
for changes. This is of particular interest e.g. in cases, where
the index is non-numeric (e.g. a MAC address).</entry>
</row>
</tbody>
</tgroup>
</table>
<para>If you feel the need for manual re-indexing, you may run it from cli.
Calling the script with the parameter <userinput>--help</userinput> yields</para>
<screen><prompt>shell&gt;</prompt>php -q poller_reindex_hosts.php --help
Cacti Reindex Host Script 1.2, Copyright 2004-2017 - The Cacti Group
usage: poller_reindex_hosts.php --id=[host_id|All] [--qid=[ID|All]] [--host-descr=[description]]
[-d] [-h] [--help] [-v] [--version]
--id=host_id - The host_id to have data queries reindexed or 'All' to reindex all hosts
--qid=query_id - Only index on a specific data query id; defaults to 'All'
--host-descr=description - The host description to filter by (SQL filters acknowledged)
--debug - Display verbose output during execution
-v --version - Display this help message
-h --help - Display this help message</screen>
<para>Running it in debug mode for the host with <userinput>id=2</userinput> may yield</para>
<screen><prompt>shell&gt;</prompt>php -q poller_reindex_hosts.php -id=2 -d
WARNING: Do not interrupt this script. Reindexing can take quite some time
DEBUG: There are '1' data queries to run
DEBUG: Data query number '1' host: '2' SNMP Query Id: '1' starting
DEBUG: Data query number '1' host: '2' SNMP Query Id: '1' ending</screen>
<para>A silent run for all devices is issued by</para>
<screen><prompt>shell&gt;</prompt>php -q poller_reindex_hosts.php -id=All
WARNING: Do not interrupt this script. Reindexing can take quite some time
.....<prompt>shell&gt;</prompt></screen>
<para>You may run this script against a specific data query id using <userinput>--qid=[data query id]</userinput> like</para>
<screen><prompt>shell&gt;</prompt>php -q poller_reindex_hosts.php --id=All --qid=1 -d
WARNING: Do not interrupt this script. Reindexing can take quite some time
DEBUG: There are '3' data queries to run
DEBUG: Data query number '1' host: '1' SNMP Query Id: '1' starting
DEBUG: Data query number '1' host: '1' SNMP Query Id: '1' ending
DEBUG: Data query number '2' host: '2' SNMP Query Id: '1' starting
DEBUG: Data query number '2' host: '2' SNMP Query Id: '1' ending
DEBUG: Data query number '3' host: '15' SNMP Query Id: '1' starting
DEBUG: Data query number '3' host: '15' SNMP Query Id: '1' ending</screen>
<para>It is possible, to select a host based on its host description using <userinput>--host-descr=[host description]</userinput>.
It is allowed to apply an SQL filter expression for the description like <userinput>--qid=some%descr</userinput>.
Use this parameter in conjunction with either <userinput>--id=[host id]</userinput> or
<userinput>--qid=[data query id]</userinput> or both:</para>
<screen><prompt>shell&gt;</prompt>php -q poller_reindex_hosts.php --id=All --qid=1 --host-descr=ga%f -d
WARNING: Do not interrupt this script. Reindexing can take quite some time
DEBUG: There are '1' data queries to run
DEBUG: Data query number '1' host: '2' SNMP Query Id: '1' starting
DEBUG: Data query number '1' host: '2' SNMP Query Id: '1' ending</screen>
<caution>
<title>Stop the Poller during Re-Indexing</title>
<para>Re-Indexing interferes with the poller operation.
Please make sure, that the poller is not running and will not start
during a reindex operation</para>
</caution>
</sect1>
<sect1 id="cli-poller-output-empty">
<title>Empty Poller Output Table</title>
<para>During normal poller operation, all retrieved results
are intermediately stored in the table named <structname>poller_output</structname>
After execution of <application>cmd.php</application> or <application>Spine</application>,
this table holds all results. The <application>poller.php</application> finally
issues all <application>rrdtool update</application> operations. Thus,
after polling has completed, the table should be empty.</para>
<para>Conditions may arise, where the table is not (completely) emptied.
The most often known issue is lack of php memory. In those cases, the
table is bigger than the php memory size, thus not all items are handled
correctly. If that issue occurs, you may save all pending updates
<emphasis>after increasing PHP memory appropriately</emphasis> by running
this very script. Calling the script with the parameter <userinput>--help</userinput> yields</para>
<screen><prompt>shell&gt;</prompt>php -q poller_output_empty.php --help
Cacti Empty Poller Output Table Script 1.0, Copyright 2004-2017 - The Cacti Group
usage: poller_output_empty.php [-h] [--help] [-v] [--version]
-v --version - Display this help message
-h --help - Display this help message</screen>
<para>You see, no parameter is required for operating successfully.
Under normal circumstances, running this script should yield</para>
<screen><prompt>shell&gt;</prompt>php -q poller_output_empty.php
There were 0, RRD updates made this pass
<prompt>shell&gt;</prompt></screen>
<para>In case, you hit the poller process or if the table was really
not fully processed, you may find</para>
<screen><prompt>shell&gt;</prompt>php -q poller_output_empty.php
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.01 r:0.06
There were 21, RRD updates made this pass
<prompt>shell&gt;</prompt></screen>
<para>If logging level verbosity was switched to <userinput>DEBUG</userinput>
you may find additional debug messages that usually show up in
<filename>cacti.log</filename></para>
</sect1>
<sect1 id="cli-poller-graphs-reapply-names">
<title>Reapply Suggested Names to Graphs</title>
<para>For a general understanding of suggested names used with data queries,
please see <xref linkend="data-queries-associated-graph-templates"/>.
Be aware, that changes to the <userinput>Suggested Names</userinput>
section of a data query will not automatically be propagated to
all existing graphs. This is, where <application>poller_graphs_reapply_names.php</application>
drops in. Calling the script with the parameter <userinput>--help</userinput> yields</para>
<screen><prompt>shell&gt;</prompt>php -q poller_graphs_reapply_names.php --help
Cacti Reapply Graph Names Script 1.0, Copyright 2004-2017 - The Cacti Group
usage: poller_graphs_reapply_names.php -id=[host_id|All][host_id1|host_id2|...] [-s=[search_string] [-d] [-h] [--help] [-v] [--version]
-id=host_id - The host_id or 'All' or a pipe delimited list of host_id's
-s=search_str - A graph template name or graph title to search for
-d - Display verbose output during execution
-v --version - Display this help message
-h --help - Display this help message</screen>
<para>Assume a situation, where the suggested names where changed
for the standard data query named <userinput>SNMP - Get Mounted Partitions</userinput>.
In this case, you will want to rework all graphs for this data query only. A verbose
run will yield</para>
<screen><prompt>shell&gt;</prompt>php -q poller_graphs_reapply_names.php -id=All -d -s="Used space"
WARNING: Do not interrupt this script. Interrupting during rename can cause issues
DEBUG: There are '6' Graphs to rename
DEBUG: Graph Name 'Localhost - Used Space - Memory Buffers' starting
DEBUG: Graph Rename Done for Graph 'Localhost - Used Space - Memory Buffers'
DEBUG: Graph Name 'Localhost - Used Space - Real Memory' starting
DEBUG: Graph Rename Done for Graph 'Localhost - Used Space - Real Memory'
DEBUG: Graph Name 'Localhost - Used Space - Swap Space' starting
DEBUG: Graph Rename Done for Graph 'Localhost - Used Space - Swap Space'
DEBUG: Graph Name 'Localhost - Used Space - /' starting
DEBUG: Graph Rename Done for Graph 'Localhost - Used Space - /'
DEBUG: Graph Name 'Localhost - Used Space - /sys' starting
DEBUG: Graph Rename Done for Graph 'Localhost - Used Space - /sys'
DEBUG: Graph Name 'Localhost - Used Space - /boot' starting
DEBUG: Graph Rename Done for Graph 'Localhost - Used Space - /boot'</screen>
<para>Please notice my miss-spelling of the word <quote>Space</quote>.
The <userinput>-s=</userinput> option is not case sensitive.</para>
</sect1>
<sect1 id="cli-copy-user">
<title>Copy Local Cacti Users</title>
<para>For use and understanding the
limitation of this script, it is of importance to read <xref linkend="user-management">.
In case you're using local cacti user definitions, you may copy
a template user to a new user. Don't use this script for
<application>LDAP</application> or Web Basic users.</para>
<para>Calling the script with the parameter <userinput>--help</userinput> yields</para>
<screen><prompt>shell&gt;</prompt>php -q copy_user.php --help
It is highly recommended that you use the web interface to copy users as this script will only copy Local Cacti users.
Syntax:
php copy_cacti_user.php &lt;template user&gt; &lt;new user&gt;</screen>
<para>Now let's create a new user <userinput>Harry Potter</userinput> as follows</para>
<screen><prompt>shell&gt;</prompt>php -q copy_user.php guest "Harry Potter"
It is highly recommended that you use the web interface to copy users as this script will only copy Local Cacti users.
Cacti User Copy Utility
Template User: guest
New User: Harry Potter
Copying User...
User copied...</screen>
<para>Find the results of this program call at <guimenu>User Management</guimenu></para>
<screen>User Name** Full Name Enabled Realm Default Graph Policy Last Login
admin Administrator Yes Local ALLOW Sunday, October 07, 2007 14:59:32
guest Guest Account Yes Local ALLOW N/A
Harry Potter Guest Account Yes Local ALLOW N/A</screen>
</sect1>
<sect1 id="cli-add-device">
<title>Add a New Device</title>
<para>While it is an easy task to add a new device from the panels,
this would be a tedious task for creating dozens of hundreds of devices
in one turn. This is, where the script <filename>add_device.php</filename>
comes in. First, let's have a look at the whole list of features
it provides. Calling the script with the parameter <userinput>--help</userinput> yields</para>
<screen><prompt>shell&gt;</prompt>php -q add_device.php --help
Add Device Script 1.0, Copyright 2004-2017 - The Cacti Group
A simple command line utility to add a device in Cacti
usage: add_device.php --description=[description] --ip=[IP] --template=[ID] [--notes="[]"] [--disable]
[--avail=[ping]] --ping_method=[icmp] --ping_port=[N/A, 1-65534] --ping_retries=[2]
[--version=[1|2|3]] [--community=] [--port=161] [--timeout=500]
[--username= --password=] [--authproto=] [--privpass= --privproto=] [--context=]
[--quiet]
Required:
--description the name that will be displayed by Cacti in the graphs
--ip self explanatory (can also be a FQDN)
Optional:
--template 0, is a number (read below to get a list of templates)
--notes '', General information about this host. Must be enclosed using double quotes.
--disable 0, 1 to add this host but to disable checks and 0 to enable it
--avail pingsnmp, [ping][none, snmp, pingsnmp]
--ping_method tcp, icmp|tcp|udp
--ping_port '', 1-65534
--ping_retries 2, the number of time to attempt to communicate with a host
--version 1, 1|2|3, snmp version
--community '', snmp community string for snmpv1 and snmpv2. Leave blank for no community
--port 161
--timeout 500
--username '', snmp username for snmpv3
--password '', snmp password for snmpv3
--authproto '', snmp authentication protocol for snmpv3
--privpass '', snmp privacy passphrase for snmpv3
--privproto '', snmp privacy protocol for snmpv3
--context '', snmp context for snmpv3
List Options:
--list-host-templates
--list-communities
--quiet - batch mode value return</screen>
<para>Wow, that's quite a lot of options. To better understand it's use,
let's first stick to the listing options</para>
<sect2 id="cli-add-device-list-host-template">
<title>List all Host Templates</title>
<screen><prompt>shell&gt;</prompt>php -q add_device.php --list-host-templates
Valid Host Templates: (id, name)
1 Generic SNMP-enabled Host
3 ucd/net SNMP Host
4 Karlnet Wireless Bridge
5 Cisco Router
6 Netware 4/5 Server
7 Windows 2000/XP Host
8 Local Linux Machine</screen>
<para>Why are those <userinput>Host Templates</userinput> of such importance for this
script? Well, when using this script to add a new device, there are 3 required
parameters. The <userinput>description</userinput> and the <userinput>device ip address</userinput>
are of course left to you. But for assigning the correct <userinput>Host Template Id</userinput>,
you should first know the correct id of that very parameter. For the purpose of this
chapter we assume to add a device that will be associated to a <userinput>ucd/net SNMP Host</userinput>,
so the id of <userinput>3</userinput> is required.</para>
<para>If you do not want to associate the host to any <userinput>Host Template Id</userinput>, known
as host template <guimenuitem>None</guimenuitem>, please provide the parameter
<userinput>--template=0</userinput> or omit this parameter.</para>
</sect2>
<sect2 id="cli-add-device-list-communities">
<title>List all Community Strings</title>
<screen><prompt>shell&gt;</prompt>php -q add_device.php --list-communities
Known communities are: (community)
public
snmp-get</screen>
<para>Of course, your list will vary</para>
</sect2>
<sect2 id="cli-add-device-simple">
<title>Create a New Device</title>
<para>Now, let's set up the most basic command to add a new device. The description shall be
<userinput>"Device Add Test"</userinput>, the ip will be given as a FQDN, <userinput>router.mydomain.com</userinput>.
As a SNMP enabled device, surely a community string has to be provided; in this case given
as <userinput>public</userinput>.
In total, this makes the following command</para>
<screen><prompt>shell&gt;</prompt>php -q add_device.php --description="Device Add Test" --ip="router.mydomain.com" --template=3 --community="public"
Adding Device Add Test (router.mydomain.com) as "ucd/net SNMP Host" using SNMP v1 with community "public"
Success - new device-id: (11)</screen>
<para>Please visit <guimenu>Devices</guimenu> to see the result:</para>
<screen>Description** Graphs Data Sources Status Hostname Current (ms) Average (ms) Availability
Device Add Test 0 0 Unknown router.mydomain.com 0 0 100</screen>
<para>Please use any other combination of parameters in the same way
as via the web browser console. You may want to remember the new device id, <userinput>11</userinput>
in this case, for the next steps.</para>
</sect2>
</sect1>
<sect1 id="cli-add-data-query">
<title>Associate a Data Query to an existing Host</title>
<para>It is recommended to maintain data query associations by maintaining
host templates. Each time, a data query is added to a host template,
it will automatically associated with all hosts related to that very
host template. The data query will be executed as well; this way the
snmp cache will be filled with all values related to that query.</para>
<para>Nevertheless, it is sometimes suitable to manually associate a certain
data query with a single host only without changing any host template.
This is, where the script <filename>add_data_query.php</filename>
comes in. First, let's have a look at the whole list of features
it provides. Calling the script with the parameter <userinput>--help</userinput> yields</para>
<screen><prompt>shell&gt;</prompt>php -q add_data_query.php --help
Add Data Query Script 1.0, Copyright 2004-2017 - The Cacti Group
A simple command line utility to add a data query to an existing device in Cacti
usage: add_data_query.php --host-id=[ID] --data-query-id=[dq_id] --reindex-method=[method] [--quiet]
Required:
--host-id the numerical ID of the host
--data-query-id the numerical ID of the data_query to be added
--reindex-method the reindex method to be used for that data query
0|None = no reindexing
1|Uptime = Uptime goes Backwards
2|Index = Index Count Changed
3|Fields = Verify all Fields
List Options:
--list-hosts
--list-data-queries
--quiet - batch mode value return
If the data query was already associated, it will be reindexed.</screen>
<para>Let's first stick to the listing options</para>
<sect2 id="cli-add-data-query-list-hosts">
<title>List all Hosts</title>
<screen><prompt>shell&gt;</prompt>php -q add_data_query.php --list-hosts
Known Hosts: (id, hostname, template, description)
1 127.0.0.1 8 Localhost
11 router 3 router.mydomain.com</screen>
</sect2>
<sect2 id="cli-add-data-query-list-data-queries">
<title>List all Data Queries</title>
<screen><prompt>shell&gt;</prompt>php -q add_data_query.php --list-data-queries
Known SNMP Queries:(id, name)
1 SNMP - Interface Statistics
2 ucd/net - Get Monitored Partitions
3 Karlnet - Wireless Bridge Statistics
4 Netware - Get Available Volumes
6 Unix - Get Mounted Partitions
7 Netware - Get Processor Information
8 SNMP - Get Mounted Partitions
9 SNMP - Get Processor Information</screen>
</sect2>
<sect2 id="cli-add-data-query-example">
<title>Add a Data Query</title>
<screen><prompt>shell&gt;</prompt>php -q add_data_query.php --host-id=11 --data-query-id=1 --reindex-method=fields
Success - Host (11: router.mydomain.com) data query (1: SNMP - Interface Statistics) reindex method (3: Verify All Fields)</screen>
<para>This example shows the use of a string <parameter>"fields"</parameter> for specifying the reindex method. As given
by the help text, the use of the numeric value of <parameter>"3"</parameter> would have given
the exact same result. When visiting the device edit panel, you will find non-zero values for the data query status
column, e.g. <emphasis>Success [41 Items, 5 Rows]</emphasis>.</para>
</sect2>
</sect1>
<sect1 id="cli-add-graph-template">
<title>Associate a Graph Template to an existing Host</title>
<para>It is recommended to maintain graph template associations by maintaining
host templates. Each time, a graph template is added to a host template,
it will automatically associated with all hosts related to that very
host template.</para>
<para>Nevertheless, it is sometimes suitable to manually associate a certain
graph template with a single host only without changing any host template.
This is, where the script <filename>add_graph_template.php</filename>
comes in. First, let's have a look at the whole list of features
it provides. Calling the script with the parameter <userinput>--help</userinput> yields</para>
<screen><prompt>shell&gt;</prompt>php -q add_graph_template.php --help
Add Graph Template Script 1.0, Copyright 2004-2017 - The Cacti Group
A simple command line utility to associate a graph template with a host in Cacti
usage: add_graph_template.php --host-id=[ID] --graph-template-id=[ID]
[--quiet]
Required:
--host-id the numerical ID of the host
--graph_template-id the numerical ID of the graph template to be added
List Options:
--list-hosts
--list-graph-templates
--quiet - batch mode value return</screen>
<para>Let's first stick to the listing options</para>
<sect2 id="cli-add-graph-template-list-hosts">
<title>List all Hosts</title>
<screen><prompt>shell&gt;</prompt>php -q add_graph_template.php --list-hosts
Known Hosts: (id, hostname, template, description)
1 127.0.0.1 8 Localhost
11 router 3 router.mydomain.com</screen>
</sect2>
<sect2 id="cli-add-graph-template-list-graph-templates">
<title>List all Graph Template</title>
<screen><prompt>shell&gt;</prompt>php -q add_graph_template.php --list-graph-templates
Known Graph Templates:(id, name)
2 Interface - Traffic (bits/sec)
3 ucd/net - Available Disk Space
4 ucd/net - CPU Usage
5 Karlnet - Wireless Levels
6 Karlnet - Wireless Transmissions
7 Unix - Ping Latency
8 Unix - Processes
9 Unix - Load Average
10 Unix - Logged in Users
11 ucd/net - Load Average
...</screen>
</sect2>
<sect2 id="cli-add-graph-template-example">
<title>Add a Graph Template</title>
<screen><prompt>shell&gt;</prompt>php -q add_graph_template.php --host-id=11 --graph-template-id=7
Success: Graph Template associated for host: (11: router) - graph-template: (7: Unix - Ping Latency)</screen>
</sect2>
</sect1>
<sect1 id="cli-add-graphs">
<title>Add a New Graph</title>
<para>You won't stop now as you've just created a device from cli.
Surely, the task of setting up graphs is the next step. This is done using
<filename>add_graphs.php</filename>. Calling the script with the parameter <userinput>--help</userinput> yields</para>
<screen><prompt>shell&gt;</prompt>php -q add_graphs.php
Add Graphs Script 1.2, Copyright 2008 - The Cacti Group
A simple command line utility to add graphs in Cacti
usage: add_graphs.php --graph-type=[cg|ds] --graph-template-id=[ID]
--host-id=[ID] [--graph-title=title] [graph options] [--force] [--quiet]
For cg graphs:
[--input-fields="[data-template-id:]field-name=value ..."] [--force]
--input-fields If your data template allows for custom input data, you may specify that
here. The data template id is optional and applies where two input fields
have the same name.
--force If you set this flag, then new cg graphs will be created, even though they
may already exist
For ds graphs:
--snmp-query-id=[ID] --snmp-query-type-id=[ID] --snmp-field=[SNMP Field] --snmp-value=[SNMP Value]
[--graph-title=] Defaults to what ever is in the graph template/data-source template.
[--reindex-method=] the reindex method to be used for that data query
if data query already exists, the reindex method will not be changed
0|None = no reindexing
1|Uptime = Uptime goes Backwards (Default)
2|Index = Index Count Changed
3|Fields = Verify all Fields
List Options:
--list-hosts
--list-graph-templates [--host_template=[ID]]
--list-input-fields --graph-template-id=[ID]
--list-snmp-queries
--list-query-types --snmp-query-id [ID]
--list-snmp-fields --host-id=[ID] [--snmp-query-id=[ID]]
--list-snmp-values --host-id=[ID] [--snmp-query-id=[ID]] --snmp-field=[Field]
'cg' graphs are for things like CPU temp/fan speed, while
'ds' graphs are for data-source based graphs (interface stats etc.)
</screen>
<para>Like the graph creation from the console, this task is split
into two different ones:</para>
<itemizedlist>
<listitem><para><guimenuitem>Associated Graph Templates</guimenuitem>:
These are named <userinput>cg</userinput> graph_type for this script.</para></listitem>
<listitem><para><guimenuitem>Associated Data Queries</guimenuitem>:
These are named <userinput>ds</userinput> graph_type for this script.
Additional SNMP parameters are required to define those graphs.</para></listitem>
</itemizedlist>
<caution>
<title>Exact typing required</title>
<para>When running this cli script, caution must be taken
to avoid typos. Sometimes, list options take an ending <quote>s</quote>,
where the option for graph creation comes without <quote>s</quote>.
Error messages are not issued to indicate this typo; instead you will
see the general help screen.</para>
</caution>
<sect2 id="cli-add-graphs-list-cg">
<title>List Options for Associated Graph Templates</title>
<para>The first list option, <userinput>--list-hosts</userinput>,
is required only if you do not know the <userinput>id</userinput>
of the device you want to add graphs for. It will produce output as follows</para>
<screen><prompt>shell&gt;</prompt>php -q add_graphs.php --list-hosts
Known Hosts: (id, hostname, template, description)
...
11 router.mydomain.com 3 Device Add Test</screen>
<para>You surely recognize the device we've just added?</para>
<para>The next list option, <userinput>--list-graph-templates</userinput>,
is required to identify the number of an <userinput>Associated Graph Templates</userinput>.</para>
<screen><prompt>shell&gt;</prompt>php -q add_graphs.php --list-graph-templates
Known Graph Templates:(id, name)
2 Interface - Traffic (bits/sec)
3 ucd/net - Available Disk Space
4 ucd/net - CPU Usage
5 Karlnet - Wireless Levels
6 Karlnet - Wireless Transmissions
7 Unix - Ping Latency
8 Unix - Processes
9 Unix - Load Average
...</screen>
<para>We will need the graph template id of the <userinput>ucd/net - CPU Usage</userinput>
template later. So note the number <userinput>4</userinput> for it.</para>
<para>It is possible to reduce the listing to the graph templates associated with
a specific host template by using <userinput>--list-graph-templates --host-template-id=[id]</userinput>.
For a "ucd/net SNMP Host" this yields</para>
<screen><prompt>shell&gt;</prompt>php -q add_graphs.php --list-graph-templates --host-template-id=3
Known Graph Templates:(id, name)
4 ucd/net - CPU Usage
11 ucd/net - Load Average
13 ucd/net - Memory Usage...
</screen>
</sect2>
<sect2 id="cli-add-graphs-list-ds">
<title>List Options for Associated Data Queries</title>
<para>First task is to find all id's for available data queries.</para>
<screen><prompt>shell&gt;</prompt>php -q add_graphs.php --host-id=2 --list-snmp-queries
Known SNMP Queries:(id, name)
1 SNMP - Interface Statistics
2 ucd/net - Get Monitored Partitions
3 Karlnet - Wireless Bridge Statistics
4 Netware - Get Available Volumes
6 Unix - Get Mounted Partitions
7 Netware - Get Processor Information
8 SNMP - Get Mounted Partitions
9 SNMP - Get Processor Information</screen>
<para>For standard interface statistics, we note the id of
<userinput>1</userinput></para>
<para>Next task is to find the query_type as done by issuing</para>
<screen><prompt>shell&gt;</prompt>php -q add_graphs.php --snmp-query-id=1 --list-query-types
Known SNMP Query Types: (id, name)
2 In/Out Errors/Discarded Packets
3 In/Out Non-Unicast Packets
4 In/Out Unicast Packets
9 In/Out Bytes (64-bit Counters)
13 In/Out Bits
14 In/Out Bits (64-bit Counters)
16 In/Out Bytes
20 In/Out Bits with 95th Percentile
21 In/Out Bits with Total Bandwidth
22 In/Out Bytes with Total Bandwidth
23 In/Out Bits 1 min
24 In/Out Bits 1 min (64-bit Counters)</screen>
<para>For a standard <userinput>In/Out Bits</userinput> type, we
note the id of <userinput>13</userinput></para>
<para>Next issue is to select the <userinput>SNMP Field</userinput>
that shall be used for a new graph.</para>
<screen><prompt>shell&gt;</prompt>php -q add_graphs.php --host-id=11 --list-snmp-fields
Known SNMP Fields for host-id 11: (name)
ifAlias
ifDescr
ifHwAddr
ifIndex
ifIP
ifName
ifOperStatus
ifSpeed
ifType</screen>
<para>For our graph, we will use the field <userinput>ifOperStatus</userinput>
to select the correct interfaces.</para>
<para>In general, you will next determine the values available for the <userinput>SNMP Field</userinput>,
in our case <userinput>ifOperStatus</userinput>. This is done by</para>
<screen><prompt>shell&gt;</prompt>php -q add_graphs.php --host-id=11 --snmp-field=ifOperStatus --list-snmp-values
Known values for ifOperStatus for host 11: (name)
Down
Up</screen>
<para>This is no surprise, of course. Now, all paarmeters required for
creating a new graph are determined.</para>
</sect2>
<sect2 id="cli-add-graphs-cg">
<title>Add Non-Indexed Graphs</title>
<para>We will create a graph for <userinput>ucd/net - CPU Usage</userinput>. Above,
we've identified the graph template it to be <userinput>4</userinput>.
In total, that makes up for the following command</para>
<screen><prompt>shell&gt;</prompt>php -q add_graphs.php --host-id=11 --graph-type=cg --graph-template-id=4
Graph Added - graph-id: (39) - data-source-id: (63)</screen>
<para>Find the result when visiting <guimenu>Graph Management</guimenu></para>
<screen>Graph Title** Template Name Size
Device Add Test - CPU Usage ucd/net - CPU Usage 120x500</screen>
<para>If the graph template was not associated with that host before, it is now added
to the list of <guimenu>Associated Graph Templates</guimenu>.</para>
</sect2>
<sect2 id="cli-add-graphs-ds">
<title>Add Indexed Graphs</title>
<para>First, let's sum up the id's of all resources required for this
task:</para>
<table frame='all'>
<title>Parametes required for an Interface Traffic Graph</title>
<tgroup cols='3' align='left' colsep='1' rowsep='1'>
<colspec colnum="2">
<colspec colwidth="1" colnum="2">
<colspec colwidth="3*" colnum="3">
<thead>
<row>
<entry align="center">Object</entry>
<entry align="center">Value</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Graph Template Id</entry>
<entry align="right">2</entry>
<entry>Interface - Traffic (bits/sec)</entry>
</row>
<row>
<entry>SNMP Query Id</entry>
<entry align="right">1</entry>
<entry>SNMP - Interface Statistics</entry>
</row>
<row>
<entry>SNMP Query Type Id</entry>
<entry align="right">13</entry>
<entry>In/Out Bits</entry>
</row>
<row>
<entry>SNMP Field</entry>
<entry align="right">ifOperStatus</entry>
<entry></entry>
</row>
<row>
<entry>SNMP Value</entry>
<entry align="right">Up</entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
<para>This will make up for the following command</para>
<screen><prompt>shell&gt;</prompt>php -q add_graphs.php --host-id=11 --graph-type=ds --graph-template-id=2 --snmp-query-id=1 --snmp-query-type-id=13 --snmp-field=ifOperStatus --snmp-value=Up
Graph Added - graph-id: (40) - data-source-id: (65)</screen>
<para>Find the result when visiting <guimenu>Graph Management</guimenu></para>
<screen>Graph Title** Template Name Size
Device Add Test - CPU Usage ucd/net - CPU Usage 120x500
Device Add Test - Traffic - lo Interface - Traffic (bits/sec) 120x500</screen>
<para>If the data query was not associated with that host before, it is now added
to the list of <guimenu>Associated Graph Templates</guimenu>. In this case, the
<guimenu>Re-Index Method</guimenu> of <parameter>Uptime Goes Backwards</parameter>
is defaulted if not given otherwise. You may provide a different <guimenu>Re-Index Method</guimenu>
by entering the optional parameter <parameter>--reindex-method</parameter>.</para>
</sect2>
</sect1>
<sect1 id="cli-add-tree">
<title>Add Items to a Tree</title>
<para>Now, that we've created some nice graphs, they should be put
the graph trees. This is done using <filename>add_tree.php</filename>.
As you will notice soon, it is possible to even add header items,
hosts and graphs to a tree as well as adding a new tree itself.
But let us first see the help output.
Calling the script with the parameter <userinput>--help</userinput> yields</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --help
Add Tree Script 1.0, Copyright 2004-2017 - The Cacti Group
A simple command line utility to add objects to a tree in Cacti
usage: add_tree.php --type=[tree|node] [type-options] [--quiet]
Tree options:
--name=[Tree Name]
--sort-method=[manual|alpha|natural|numeric]
Node options:
--node-type=[header|host|graph]
--tree-id=[ID]
[--parent-node=[ID] [Node Type Options]]
Header node options:
--name=[Name]
Host node options:
--host-id=[ID]
[--host-group-style=[1|2]]
(host group styles:
1 = Graph Template,
2 = Data Query Index)
Graph node options:
--graph-id=[ID]
[--rra-id=[ID]]
List Options:
--list-hosts
--list-trees
--list-nodes --tree-id=[ID]
--list-rras
--list-graphs --host-id=[ID]</screen>
<sect2 id="cli-add-tree-list-hosts">
<title>List Hosts</title>
<para>The first try is dedicated to the list option
<userinput>--list-hosts</userinput>. It goes like</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --list-hosts
Known Hosts: (id, hostname, template, description)
1 127.0.0.1 8 Localhost
2 gandalf 3 gandalf
...
11 router.mydomain.com 3 Device Add Test</screen>
</sect2>
<sect2 id="cli-add-tree-list-trees">
<title>List Trees</title>
<para>Now, let us
<userinput>--list-trees</userinput>. It goes like</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --list-trees
Known Trees:
id sort method name
1 Manual Ordering (No Sorting) Default Tree</screen>
</sect2>
<sect2 id="cli-add-tree-list-nodes">
<title>List Nodes</title>
<para>Listing all existend node of a given tree is done by</para
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --list-nodes --tree-id=1
Known Tree Nodes:
type id text
Host 7 127.0.0.1 Graph Template
Host 9 gandalf Graph Template
Host 12 gandalf Graph Template</screen>
</sect2>
<sect2 id="cli-add-tree-list-rras">
<title>List RRAs</title>
<para>For special tree add options, you will require the id of
the RRA definition to completly specify the add request. That's
why the corresponding <userinput>--list-rras</userinput> option is
implemented. It goes this way</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --list-rras
Known RRAs:
id steps rows timespan name
1 1 600 86400 Daily (5 Minute Average)
2 6 700 604800 Weekly (30 Minute Average)
3 24 775 2678400 Monthly (2 Hour Average)
4 288 797 33053184 Yearly (1 Day Average)</screen>
</sect2>
<sect2 id="cli-add-tree-list-graphs">
<title>List Graphs for given Hosts</title>
<para>To be able to add a Graph, the id of that very graph is required.
Thus, a <userinput>--list-graphs --host-id=[id]</userinput> option was implemented</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --list-graphs --host-id=1
Known Host Graphs: (id, name, template)
1 Localhost - Memory Usage Linux - Memory Usage
2 Localhost - Load Average Unix - Load Average
3 Localhost - Logged in Users Unix - Logged in Users
4 Localhost - Processes Unix - Processes
5 Localhost - Traffic - eth0 Interface - Traffic (bits/sec, 95th Percentile)
33 Localhost - Used Space - Memory Buffers Host MIB - Available Disk Space
34 Localhost - Used Space - Real Memory Host MIB - Available Disk Space
35 Localhost - Used Space - Swap Space Host MIB - Available Disk Space
36 Localhost - Used Space - / Host MIB - Available Disk Space
37 Localhost - Used Space - /sys Host MIB - Available Disk Space
38 Localhost - Used Space - /boot Host MIB - Available Disk Space</screen>
</sect2>
<sect2 id="cli-add-tree-tree">
<title>Add a new Tree</title>
<para>Cacti comes with a single tree, named
<guimenuitem>Default Tree</guimenuitem>. Console entry
<guimenu>Graph Trees</guimenu> is used to add more trees. With
<filename>add_tree.php</filename>, you may now do so from command line as well:</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --type=tree --name="Test Tree Add" --sort-method=manual
Tree Created - tree-id: (6)</screen>
<para>Verify this from console, <guimenu>Graph Trees</guimenu>
to find</para>
<screen>Default Tree
Test Tree Add</screen>
<para>as expected.</para>
</sect2>
<sect2 id="cli-add-tree-header">
<title>Add a new Header Node to a Tree</title>
<para>Now, that a new tree has been created, you may want to add
a new header to that very tree. Use</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --type=node --node-type=header --tree-id=6 --name="Header Test"
Added Node node-id: (21)</screen>
<para>You will want to save the id returned if willing to add further
nodes to exactly this new Header Node</para>
<para>Please pay attention, that it is currently not possible to
add another header with the same options even if this is possible
from console</para>
<para>But it is possible to add a subheader to an already defined header.
Even in this case, the <userinput>name</userinput> has to be unique</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --type=node --node-type=header --tree-id=6 --parent-node=21 --name="SubHeader Test"
Added Node node-id: (22)</screen>
</sect2>
<sect2 id="cli-add-tree-host">
<title>Add a new Host Node to a Tree</title>
<para>We will distinguish several options adding a host to a tree.
First, let's add a Host directly to a tree. For this example, we use
the tree id returned from adding our own <userinput>Test Tree Add</userinput>
known with <userinput>id=6</userinput></para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --type=node --node-type=host --tree-id=6 --host-id=1
Added Node node-id: (23)</screen>
<para>As no <userinput>--parent-node</userinput> was given, this host
is directly added to the tree itself. If you wish to add a host to
a (sub)header, please specify as follows</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --type=node --node-type=host --tree-id=6 --parent-node=21 --host-id=1
Added Node node-id: (24)</screen>
<para>Both example come without a <userinput>--host-group-style</userinput> option.
For those cases, <userinput>Graph Template</userinput> host group style is default.
Here's an example for providing a host group option of
<userinput>Data Query Index</userinput> instead</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --type=node --node-type=host --tree-id=6 --parent-node=22 --host-id=1 --host-group-style=2
Added Node node-id: (25)</screen>
</sect2>
<sect2 id="cli-add-tree-graph">
<title>Add a new Graph Node to a Tree</title>
<para>Like above, instead of hosts it is possible to add a single
graph to a tree or a (sub)header of any tree. Of course, you again will
require the <userinput>id</userinput> of the tree and optionally of the
<userinput>header</userinput>. This results in</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --type=node --node-type=graph --tree-id=6 --graph-id=5
Added Node node-id: (26)</screen>
<para>Like above, this graph now was added directly to the tree itself.
To add a graph to a header, proceed as follows</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --type=node --node-type=graph --tree-id=6 --parent-node=21 --graph-id=5
Added Node node-id: (27)</screen>
<para>In both cases, no explicit <userinput>--rra-id</userinput>
was given. This will default to the <guimenuitem>Daily (5 Minute Average)</guimenuitem>.
Specify any other <userinput>--rra-id</userinput> as given</para>
<screen><prompt>shell&gt;</prompt>php -q add_tree.php --type=node --node-type=graph --tree-id=6 --parent-node=21 --graph-id=1 --rra-id=4
Added Node node-id: (28)</screen>
<para>to provide the <userinput>--rra-id</userinput> for a rra of
<guimenuitem>Yearly (1 Day Average)</guimenuitem>.</para>
</sect2>
</sect1>
<sect1 id="cli-add-perms">
<title>Add Graph Permissions</title>
<para>This script is used to specify special graph permissions to users.
The list of parameters is displyed as usual when calling the script with
the parameter <userinput>--help</userinput></para>
<screen><prompt>shell&gt;</prompt>php -q add_perms.php --help
Add Permissions Script 1.0, Copyright 2004-2017 - The Cacti Group
A simple command line utility to add permissions to tree items in Cacti
usage: add_perms.php [ --user-id=[ID] ]
--item-type=[graph|tree|host|graph_template]
--item-id [--quiet]
Where item-id is the id of the object of type item-type
List Options:
--list-users
--list-trees
--list-graph-templates
--list-graphs --host-id=[ID]</screen>
<sect2 id="cli-add-perms-list-users">
<title>List Users</title>
<para>The list of users is retrieved by calling the script with the parameter
<userinput>--list-users</userinput>. It goes like</para>
<screen><prompt>shell&gt;</prompt>php -q add_perms.php --list-users
Known Users:
id username full_name
1 admin Administrator
3 guest Guest Account</screen>
</sect2>
<sect2 id="cli-add-perms-list-trees">
<title>List Trees</title>
<para>The list of trees is retrieved by calling the script with the parameter
<userinput>--list-trees</userinput>. It goes like</para>
<screen><prompt>shell&gt;</prompt>php -q add_perms.php --list-trees
Known Trees:
id sort method name
1 Manual Ordering (No Sorting) Default Tree</screen>
</sect2>
<sect2 id="cli-add-perms-list-graph-templates">
<title>List Graph Templates</title>
<para>The list of available graph templates is retrieved by calling the script with the parameter
<userinput>--list-graph-templates</userinput>. It goes like</para>
<screen><prompt>shell&gt;</prompt>php -q add_perms.php --list-graph-templates
Known Graph Templates:(id, name)
2 Interface - Traffic (bits/sec)
3 ucd/net - Available Disk Space
4 ucd/net - CPU Usage
5 Karlnet - Wireless Levels
6 Karlnet - Wireless Transmissions
7 Unix - Ping Latency
8 Unix - Processes
9 Unix - Load Average
...</screen>
</sect2>
<sect2 id="cli-add-perms-list-graphs">
<title>List Graphs for given Hosts</title>
<para>To be able to add a permissions to a specific Graph,
the id of that very graph is required.
Thus, a <userinput>--list-graphs --host-id=[id]</userinput> option was implemented</para>
<screen><prompt>shell&gt;</prompt>php -q add_perms.php --list-graphs --host-id=1
Known Host Graphs: (id, name, template)
1 Localhost - Memory Usage Linux - Memory Usage
2 Localhost - Load Average Unix - Load Average
3 Localhost - Logged in Users Unix - Logged in Users
4 Localhost - Processes Unix - Processes
5 Localhost - Traffic - eth0 Interface - Traffic (bits/sec, 95th Percentile)
33 Localhost - Used Space - Memory Buffers Host MIB - Available Disk Space
34 Localhost - Used Space - Real Memory Host MIB - Available Disk Space
35 Localhost - Used Space - Swap Space Host MIB - Available Disk Space
36 Localhost - Used Space - / Host MIB - Available Disk Space
37 Localhost - Used Space - /sys Host MIB - Available Disk Space
38 Localhost - Used Space - /boot Host MIB - Available Disk Space</screen>
</sect2>
<sect2 id="cli-add-perms-user">
<title>Add Graph Permissions to specific Users</title>
<para>There are various ways to define graph permissions
to specific users. First, we will add graph permissions
for a given host. This is done using the parameter
<userinput>--item-type=host</userinput> as follows</para>
<screen><prompt>shell&gt;</prompt>php -q add_perms.php --user-id=4 --item-type=host --item-id=1</screen>
<para><userinput>--user-id=4</userinput> must specify an existing users.
Else, an error message will be printed. As <userinput>--item-type=host</userinput> is given,
<userinput>--item-id=1</userinput> must specify a valid host. Again, if no host
with this specific id exists, an error message will be printed.
No output is produced on successful operations.</para>
<para>Next, we will add graph permissions
for a given tree. This is done using the parameter
<userinput>--item-type=tree</userinput> as follows</para>
<screen><prompt>shell&gt;</prompt>php -q add_perms.php --user-id=4 --item-type=tree --item-id=1</screen>
<para><userinput>--user-id=4</userinput> must specify an existing users.
Else, an error message will be printed. As <userinput>--item-type=tree</userinput> is given,
<userinput>--item-id=1</userinput> must specify a valid tree (the <guimenuitem>Default Tree</guimenuitem>
in this case). Again, if no tree
with this specific id exists, an error message will be printed.
No output is produced on successful operations.</para>
<para>Adding graph permissions
for a given graph template is done using the parameter
<userinput>--item-type=graph_template</userinput> as follows</para>
<screen><prompt>shell&gt;</prompt>php -q add_perms.php --user-id=4 --item-type=graph_template --item-id=25</screen>
<para><userinput>--user-id=4</userinput> must specify an existing users.
Else, an error message will be printed. As <userinput>--item-type=graph_template</userinput> is given,
<userinput>--item-id=1</userinput> must specify a valid graph_template (the <guimenuitem>Interface - Traffic (bytes/sec)</guimenuitem>
in this case). Again, if no graph template
with this specific id exists, an error message will be printed.
No output is produced on successful operations.</para>
<para>Last but not least we add graph permissions
for a given graph by using the parameter
<userinput>--item-type=graph</userinput> as follows</para>
<screen><prompt>shell&gt;</prompt>php -q add_perms.php --user-id=4 --item-type=graph --item-id=8</screen>
<para><userinput>--user-id=4</userinput> must specify an existing users.
Else, an error message will be printed. As <userinput>--item-type=graph</userinput> is given,
<userinput>--item-id=1</userinput> must specify a valid graph.
Again, if no graph template
with this specific id exists, an error message will be printed.
No output is produced on successful operations.</para>
</sect2>
</sect1>
</chapter>
<chapter id=Debugging>
<title>Debugging</title>
<para>Cacti users sometimes complain about NaN's in their graphs.
Unfortunately, there are several reasons for this result.
The following is a step-by-step procedure recommended for debugging.</para>
<sect1 id="check-log-file">
<title>Check Cacti Log File</title>
<para>Please have a look at your cacti log file.
Usually, you'll find it at <filename>&lt;path_cacti&gt;/log/cacti.log</filename>.
Else see <userinput>Settings</userinput>, <userinput>Paths</userinput>.
Check for this kind of error:</para>
<screen>CACTID: Host[...] DS[....] WARNING: SNMP timeout detected [500 ms], ignoring host '........'</screen>
<para>For "reasonable" timeouts, this may be related
to a snmpbulkwalk issue. To change this, see
<userinput>Settings</userinput>, <userinput>Poller</userinput>
and lower the value for
<userinput>The Maximum SNMP OID's Per SNMP Get Request</userinput>.
Start at a value of 2 and increase it again,
if the poller starts working.
(1 or less disables snmpbulkwalk)
Some agent's don't have the horsepower
to deliver that many OID's at a time. Therefore,
we can reduce the number for those older/underpowered devices.</para>
</sect1>
<sect1 id="check-data-gathering">
<title>Check Basic Data Gathering</title>
<para>For scripts, run them as cactiuser from cli to
check basic functionality. E.g. for a perl script
named <filename>your-perl-script.pl</filename>
with parameters "p1 p2" under *nix this would look like:</para>
<screen>su - cactiuser
/full/path/to/perl your-perl-script.pl p1 p2
... (check output)</screen>
<para>For snmp, snmpget the _exact_ OID you're asking for,
using same community string and snmp version as defined
within cacti. For an OID of <userinput>.1.3.6.1.4.something</userinput>,
community string of <userinput>very-secret</userinput>
and version 2 for target host <userinput>target-host</userinput>
this would look like</para>
<screen>snmpget -c very-secret -v 2c target-host .1.3.6.1.4.something
.... (check output)</screen>
</sect1>
<sect1 id="check-cacti-poller">
<title>Check cacti's poller</title>
<para>First make sure that crontab always shows poller.php.
This program will either call cmd.php, the PHP based poller
_or_ cactid, the fast alternative, written in C.
Define the poller you're using at
<userinput>Settings</userinput>, <userinput>Poller</userinput>.
Cactid has to be implemented seperately, it does not
come with cacti by default.</para>
<para>Now, clear <filename>./log/cacti.log</filename>
(or rename it to get a fresh start)</para>
<para>Then, change <userinput>Settings</userinput>, <userinput>Poller Logging Level</userinput>
to DEBUG for _one_ polling cycle. You may rename
this log as well to avoid more stuff added to it with
subsequent polling cycles.</para>
<para>Now, find the host/data source in question.
The <userinput>Host[&lt;id&gt;]</userinput>
is given numerically, the &lt;id&gt; being a specific
number for that host. Find this &lt;id&gt;
from the <userinput>Devices</userinput> menue when
editing the host: The url contains a string like</para>
<screen>id=&lt;id&gt;</screen>
<para>Check, whether the output is as expected.
If not, check your script (e.g. <filename>/full/path/to/perl</filename>).
If ok, proceed to next step</para>
<para>This procedure may be replaced by running the
poller manually for the failing host only.
To do so, you need the &lt;id&gt;, again.
If you're using cmd.php, set the DEBUG logging level as
defined above and run</para>
<screen>php -q cmd.php &lt;id&gt; &lt;id&gt;</screen>
<para>If you're using cactid, you may override
logging level when calling the poller:</para>
<screen>./cactid --verbosity=5 &lt;id&gt; &lt;id&gt;</screen>
<para>All output is printed to STDOUT in both cases.
This procdure allows for repeated tests without waiting
for the next polling interval. And there's no need to manually
search for the failing host between hundreds of lines of output.</para>
</sect1>
<sect1 id="check-mysql-updating">
<title>Check MySQL updating</title>
<para>In most cases, this step make be skipped.
You may want to return to this step, if the next one
fails (e.g. no rrdtool update to be found)</para>
<para>From debug log, please find the MySQL update statement
for that host concerning table
<userinput>poller_output</userinput>.
On very rare occasions, this will fail. So please copy
that sql statement and paste it to a mysql session started
from cli. This may as well be done from some tool like
phpMyAdmin. Check the sql return code.</para>
</sect1>
<sect1 id="check-rrd-updating">
<title>Check rrd file updating</title>
<para>Down in the same log, you should find some</para>
<screen>rrdtool update &lt;filename&gt; --template ...</screen>
<para>You should find exactly one update statement for each file.</para>
<para>RRD files should be created by the poller.
If it does not create them, it will not fill them either.
If it does, please check your
<userinput>Poller Cache</userinput>
from Utilities and search for your target.
Does the query show up here?</para>
</sect1>
<sect1 id="check-rrd-owner">
<title>Check rrd file ownership</title>
<para>If rrd files were created e.g. with root ownership,
a poller running as cactiuser will not be able to update
those files</para>
<screen>cd /var/www/html/cacti/rra
ls -l localhost*
-rw-r--r-- 1 root root 463824 May 31 12:40 localhost_load_1min_5.rrd
-rw-r--r-- 1 cactiuser cactiuser 155584 Jun 1 17:10 localhost_mem_buffers_3.rrd
-rw-r--r-- 1 cactiuser cactiuser 155584 Jun 1 17:10 localhost_mem_swap_4.rrd
-rw-r--r-- 1 cactiuser cactiuser 155584 Jun 1 17:10 localhost_proc_7.rrd
-rw-r--r-- 1 cactiuser cactiuser 155584 Jun 1 17:10 localhost_users_6.rrd</screen>
<para>Run the following command to cure this problem</para>
<screen>chown cactiuser:cactiuser *.rrd</screen>
</sect1>
<sect1 id="check-rrd-numbers">
<title>Check rrd file numbers</title>
<para>You're perhaps wondering about this step,
if the former was ok. But due to data sources
MINIMUM and MAXIMUM definitions, it is possible,
that valid updates for rrd files are suppressed,
because MINIMUM was not reached or MAXIMUM was exceeded.</para>
<para>Assuming, you've got some valid
<userinput>rrdtool update</userinput> in step 3, perform a</para>
<screen>rrdtool fetch &lt;rrd file&gt; AVERAGE</screen>
<para>and look at the last 10-20 lines. If you find NaN's there,
perform</para>
<screen>rrdtool info &lt;rrd file&gt;</screen>
<para>and check the
<userinput>ds[...].min</userinput> and
<userinput>ds[...].max</userinput> entries, e.g.</para>
<screen>ds[loss].min = 0.0000000000e+00
ds[loss].max = 1.0000000000e+02</screen>
<para>In this example, MINIMUM = 0 and MAXIMUM = 100. For a
<userinput>ds.[...].type=GAUGE</userinput>
verify, that e.g. the number returned by the script does
not exceed
<userinput>ds[...].MAX</userinput>
(same holds for MINIMUM, respectively).</para>
<para>If you run into this, please do not only update
the data source definition within the Data Template,
but perform a</para>
<screen>rrdtool tune &lt;rrd file&gt; --maximum &lt;ds-name&gt;:&lt;new ds maximum&gt;</screen>
<para>for all existing rrd files belonging to that Data Template.</para>
<para>At this step, it is wise to check
<userinput>step</userinput> and <userinput>heartbeat</userinput>
of the rrd file as well. For standard 300 seconds
polling intervals (step=300), it is wise to set
<userinput>minimal_heartbeat</userinput> to 600 seconds.
If a single update is missing and the next one occurs in
less than 600 seconds from the last one, rrdtool will
interpolate the missing update. Thus, gaps are
"filled" automatically by interpolation.
Be aware of the fact, that this is no "real" data!
Again, this must be done in the Data Template itself
and by using rrdtool tune for all existing rrd files
of this type.</para>
</sect1>
<sect1 id="check-rrd-graph">
<title>Check rrdtool graph statement</title>
<para>Last resort would be to check, that the correct
data sources are used.
Goto <userinput>Graph Management</userinput> and select
your Graph. Enable DEBUG Mode to find the whole
<userinput>rrdtool graph</userinput> statement. You should
notice the <userinput>DEF</userinput> statements. They specify
the rrd file and data source to be used. You may check, that
all of them are as wanted.</para>
</sect1>
<sect1 id="debug-miscellaneous">
<title>Miscellaneous</title>
<para>Up to current cacti 0.8.6h, table
<userinput>poller_output</userinput> may increase beyond
reasonable size.</para>
<para>This is commonly due to php.ini's memory settings of
8MB default. Change this to at least 64 MB.</para>
<para>To check this, please run following sql from mysql
cli (or phpmyadmin or the like)</para>
<screen>select count(*) from poller_output;</screen>
<para>If the result is huge, you may get rid of those
stuff by</para>
<screen>truncate table poller_output;</screen>
<para>As of current SVN code for upcoming cacti 0.9,
I saw measures were taken on both issues
(memory size, truncating poller_output).</para>
</sect1>
<sect1 id="debug-rpm-installation">
<title>RPM Installation?</title>
<para>Most rpm installations will setup the crontab entry now.
If you've followed the installation instructions to the
letter (which you should always do ;-) ),
you may now have two poller running. That's not a good thing,
though. Most rpm installations will setup cron in
<filename>/etc/cron.d/cacti</filename></para>
<para>Now, please check all your crontabs, especially
<filename>/etc/crontab</filename> and crontabs of
users root and cactiuser. Leave only one poller entry for
all of them. Personally, I've chosen
<filename>/etc/cron.d/cacti</filename> to avoid problems
when updating rpm's. Mosten often, you won't remember this
item when updating lots of rpm's, so I felt more secure to
put it here. And I've made some slight modifications, see</para>
<screen><prompt>shell&gt;</prompt> vi /etc/cron.d/cacti
*/5 * * * * cactiuser /usr/bin/php -q /var/www/html/cacti/poller.php > /var/local/log/poller.log 2>&1</screen>
<para>This will produce a file
<filename>/var/local/log/poller.log</filename>, which includes
some additional informations from each poller's run, such as
rrdtool errors. It occupies only some few bytes and will be
overwritten each time.</para>
<para>If you're using the crontab of user "cactiuser" instead,
this will look like</para>
<screen><prompt>shell&gt;</prompt> crontab -e -u cactiuser
*/5 * * * * /usr/bin/php -q /var/www/html/cacti/poller.php > /var/local/log/poller.log 2>&1</screen>
</sect1>
<sect1 id="check-zero-values">
<title>Not NaN, but 0 (zero) values?</title>
<para>Pay attention to custom scripts. It is required,
that external commands called from there are in the <filename>$PATH</filename>
of the cactiuser running the poller. It is therefor recommended to provide
<filename>/full/path/to/external/command</filename></para>
<para>User "criggie" reported an issue with running smartctl.
It was complaining "you are not root" so a quick
<userinput>chmod +s</userinput> on the script fixed that
problem.</para>
<para>Secondly, the script was taking several seconds to run.
So cacti was logging a "U" for unparseable in the debug
output, and was recording NAN. So my fix there was to make
the script run faster - it has to complete in less than one
second, and the age of my box made it difficult to accomplish.</para>
</sect1>
</chapter>
</part>
</book>