The Cacti Manual: Ian Berry Tony Roman Larry Adams
The Cacti Manual: Ian Berry Tony Roman Larry Adams
The Cacti Manual by Ian Berry, Tony Roman, and Larry Adams Published 2005 Copyright 2005 The Cacti Group
This project is licensed under the terms of the GPL. 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. 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. All product names are property of their respective owners. Such names are used for identication purposes only and are not indicative of endorsement by or of any company, organization, product, or platform.
Table of Contents
I. Installation...................................................................................................................................................................................1 1. Requirements .....................................................................................................................................................................1 2. Installing Under Unix .......................................................................................................................................................2 3. Installing Under Windows...............................................................................................................................................3 4. Upgrading Cacti ................................................................................................................................................................8 II. Basics ...........................................................................................................................................................................................9 5. Graph Overview ................................................................................................................................................................9 6. How to Graph Your Network........................................................................................................................................10 6.1. Creating a Device................................................................................................................................................10 6.2. Creating the Graphs ...........................................................................................................................................11 7. Viewing Graphs ...............................................................................................................................................................12 7.1. Graph Trees..........................................................................................................................................................12 8. User Management ...........................................................................................................................................................13 8.1. Creating a New User ..........................................................................................................................................13 8.2. Realm Permissions..............................................................................................................................................14 8.3. Graph Permissions..............................................................................................................................................14 8.4. Graph Settings.....................................................................................................................................................14 III. Advanced Topics....................................................................................................................................................................15 9. Data Input Methods ........................................................................................................................................................15 9.1. Creating a Data Input Method..........................................................................................................................15 9.2. Making Your Scripts Work With Cacti.............................................................................................................16 10. Data Queries...................................................................................................................................................................17 10.1. Creating a Data Query .....................................................................................................................................17 10.2. SNMP Query XML Syntax ..............................................................................................................................18 10.3. Script Query XML Syntax................................................................................................................................20 11. Templates........................................................................................................................................................................23 11.1. Graph Templates ...............................................................................................................................................23 11.2. Data Templates..................................................................................................................................................26 11.3. Host Templates..................................................................................................................................................28 12. PHP Script Server ..........................................................................................................................................................29 12.1. Using the Script Server.....................................................................................................................................29 12.2. Upgrade Steps for the Example HostMib Data Queries .............................................................................29 12.3. Migration of Existing PHP Scripts to Script Server .....................................................................................29 12.4. Testing Your Script in the Script Server .........................................................................................................31 IV. Using Cacti..............................................................................................................................................................................32 13. How To............................................................................................................................................................................32 13.1. Graph a Single SNMP OID..............................................................................................................................32 13.2. Simplest Method of Going from Script to Graph (Walkthrough)..............................................................32 14. Frequently Asked Questions .......................................................................................................................................37 V. Reference ..................................................................................................................................................................................40 15. Variables..........................................................................................................................................................................40 15.1. Graph Variables.................................................................................................................................................40 15.2. Host Variables....................................................................................................................................................42 16. RRDTool Specic Features ...........................................................................................................................................44 16.1. GPRINT Presets.................................................................................................................................................44 16.2. CDEFs .................................................................................................................................................................44
List of Tables
6-1. SNMP Retrieval Types ..........................................................................................................................................................10 8-1. Field Description: User Management .................................................................................................................................13 9-1. Field Description: Data Input Methods..............................................................................................................................15 9-2. Field Description: Data Input Fields...................................................................................................................................15 10-1. Field Description: Data Queries ........................................................................................................................................17 10-2. Field Description: Associated Graph Templates .............................................................................................................17 10-3. SNMP Query XML Field Reference ..................................................................................................................................18 10-4. Script Query XML Field Reference ...................................................................................................................................20 11-1. Field Description: Graph Templates .................................................................................................................................23 11-2. Field Description: Graph Template Items ........................................................................................................................24 11-3. Field Description: Graph Template Items ........................................................................................................................25 11-4. Field Description: Data Templates ....................................................................................................................................26 11-5. Field Description: Data Source Items................................................................................................................................27 13-1. Field Description: SNMP - Generic OID Template .........................................................................................................32 15-1. Nth Percentile Argument Description..............................................................................................................................40 15-2. Nth Percentile Types ...........................................................................................................................................................41 15-3. Bandwidth Summation Argument Description..............................................................................................................42 15-4. Host Variables ......................................................................................................................................................................42 16-1. CDEF Item Types .................................................................................................................................................................44
Chapter 1. Requirements
Cacti requires that the following software is installed on your system.
RRDTool MySQL PHP
databases/mysql323-server
5. Edit include/config.php and specify the MySQL user, password and database for your Cacti conguration.
$database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cacti";
6. Set the appropriate permissions on cactis directories for graph/log generation. You should execute these commands from inside cactis directory to change the permissions.
shell> chown -R cactiuser rra/ log/
(Enter a valid username for cactiuser, this user will also be used in the next step for data gathering.) 7. Add a line to your /etc/crontab le similar to:
*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1
Replace cactiuser with the valid user specied in the previous step. Replace /var/www/html/cacti/ with your full Cacti path. 8. Point your web browser to:
http://your-server/cacti/
Log in the with a username/password of admin. You will be required to change this password immediately. Make sure to ll in all of the path variables carefully and correctly on the following screen.
If using PHP 4.3.5 or less include the following line. If using 4.3.6 or greater, you should remove this line if present.
session.save_path=c:\tmp
7. In earlier installation guides to PHP, they recommended moving certain DLLs to the c:\winnt\system32 directory. If so, you will have to remove those les. Please review the PHP installation documentation for instructions on removing those les. 8. If you want to allow template importing, uncomment the following line:
file_uploads = On
9. Give the user who will be running the scheduled task, modify rights to the .index le in the location pointed to by the MIBDIRS Windows System environment variable. Congure the Webserver (Apache) 1. Make sure you have stopped any IIS web servers before you proceed with Apache installation, or make sure Apache is congured on an alternate port. 2. If you are using Apache 1.3.x, installation of PHP 5 is not recommended. If using PHP 4, add the following lines to your httpd.conf le. You can edit that le by selecting Start | All Programs | Apache HTTP Server X.XX | Congure Server | Edit the httpd.conf le pick from the Taskbar.
Chapter 3. Installing Under Windows If using Apache 1.3.x and PHP 4, then add the following lines:
LoadModule php4_module c:\php\sapi\php4apache.dll AddModule mod_php4.c AddType application/x-httpd-php .php DirectoryIndex index.html index.htm index.php
If using Apache 2.x and PHP 4, then add the following lines:
LoadModule php4_module c:\php\sapi\php4apache2.dll AddType application/x-httpd-php .php DirectoryIndex index.html index.htm index.php
If using Apache 2.x and PHP 5, then add the following lines.
LoadModule php5_module c:\php\php5apache2.dll AddType application/x-httpd-php .php DirectoryIndex index.html index.htm index.php
Congure the Webserver (IIS) 1. Start the Internet Information Services (IIS) Manager, right click on the Default Web Site (in most cases) and select Properties. 2. Under the Home Directory tab, select Conguration and click Add. Browse to the path of php4isapi.dll or php5isapi.dll, and type in .php as the extension. Note: if using IIS6, Enable All Verbs and Script Engine. 3. Under the ISAPI Filters tab, click Add and browse to the php4isapi.dll or php5isapi.dll le. Name the lter "php" and click OK. 4. Under the Documents tab, add index.php to the list. 5. If using IIS6, goto Web Service Extensions and add a new Web Service Extension. Name the extension "php", and click Add and browse to the php4isapi.dll or php5isapi.dll le, enable Set Extension status to Enable, and click OK. 6. Give the IUSR_XXXX and IIS_WPG users read & execute permissions to the le %windir%\system32\cmd.exe. They will also need read permissions on cacti_web_root/cacti and its subfolders. 7. If using IIS6, give the IIS_WPG user modify permissions to the folders cacti_web_root/cacti/log and cacti_web_root/cacti/rrd. 8. Completely stop and start the IIS service using the following commands:
net stop iisadmin net start w3svc
Install Cygwin (optional) 1. 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 conicts. 2. Run setup.exe you previously download. 3. Once you reach the portion of setup entitled Select Packages, install the following:
Base (include all items) Libs libart_lgpl libfreetype26 libpng12 zlib openssl Utils patch Web wget
4. Add c:\cygwin\bin to your Windows System PATH environment variable. 5. Move setup.exe to c:\cygwin for future use. Install RRDTool 1. Extract the RRDTool zip le from the Cacti web site to c:\cacti\rrdtool.exe. Install MySQL 1. Extract the MySQL zip le to a temp directory and run setup.exe. 2. Install MySQL to the default directory, or for the purposes of this manual to the c:\mysql directory. 4
Chapter 3. Installing Under Windows 3. If running an older version of MySQL, start it by running c:\mysql\bin\winmysqladmin.exe. In more recent versions, this is not required. 4. Set a password for the root user
shell> cd mysql\bin shell> mysqladmin --user=root password somepassword shell> mysqladmin --user=root --password reload
8. 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 eld. Start it again once it has been added.
--old-password
You will also need to update the cactiuser account with the old password style.
shell> UPDATE mysql.user SET Password = OLD_PASSWORD(cactipwd) WHERE Host = localhost AND User = cactiuser mysql> FLUSH PRIVILEGES;
Install Net-SNMP 1. If you plan to use any hosts with SNMP v2c support, and are using early versions of PHP, you must download and install the Net-SNMP libraries. Net-SNMP provides installers to install their product. However, caution must be taken if you choose to use long le names as Cacti does not them as long le names. You will have to user 8.3 notation. For example c:\Program Files\Net-SNMP\bin becomes c:\progra~1\net-snmp\bin. Install Cactid 1. Extract the Cactid zip le to c:\cacti and modify the cactid.conf.dist le to include the following statements.
DB_Host 127.0.0.1 or hostname (not localhost) DB_Database cacti DB_User cactiuser DB_Password cacti DB_Port 3306
All other pre 0.8.6 settings are obsolete. 2. Cactid now comes with a binary distribution. However, we strongly suggest that you install Cygwin and then remove all the DLL les and sh.exe from the c:\cacti directory. Congure Cacti 1. Edit cacti_web_root/cacti/include/config.php and specify the MySQL user, password, database, and database port for your Cacti conguration.
$database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cacti"; $database_port = "3306";
Log in using the username and password of admin/admin. You will be required to change this password immediately. 3. From Cacti, go to Settings->Paths and verify/udate your paths to point to the correct locations. Recommended examples are posted below. If you plan on using Cactid, then it is very important that all paths include forward slashes instead of backslashes. PHP Binary Path:
c:/php/php.exe
Cactid Path:
c:/cacti/cactid.exe
4. 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.
Description: My Windows localhost Hostname: localhost Host Template: Windows 2000/XP
5. You should now be looking at the localhost device screen. Right under its name, there should be some SNMP information listed, if not you should double check the SNMP settings on the server and rewall 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. 6. Log into the user account youll be using for the scheduled task and verify starting a Cacti polling cycle works. Do this by running the following from the command prompt:
php c:/cacti_web_root/cacti/poller.php
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 HostsPerProces
After this has ran once, you should have cacti.log in /cacti/log/ and rrd les in /cacti/rra/. 7. You are going to need to schedule a task while logged on as an Administrator. This task is required to you can run poller.php every 5 minutes. Make sure the Task Scheduler service is started and follow the steps below to begin. Note: 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. a. Select Start --> Settings --> Control Panel and double click on Scheduled Tasks. b. Double click on Add Scheduled Task. c. Click Next and Browse on the following screen. Find c:\php and select php.exe. Choose Daily on and click Next. d. Click Next again without changing the time or date settings. e. When entering a username and password make sure the user has read and write access to the following directories:
cacti_web_root/cacti/rra cacti_web_root/log
Make sure the user has read, write, and execute access to the following directories:
c:\php c:\php\sapi
f. Click Next and Finish to close the wizard. g. Right click on the task you just created, and select Properties. h. Select the Schedule tab. i. Make sure Daily is selected and click the Advanced button. j. Check the Repeat checkbox, set it for 5 minutes and set the duration for 24 hours. 6
Chapter 3. Installing Under Windows k. Click Ok l. In the Run textbox enter the following text making sure to use the appropriate paths.
c:\php\php.exe c:\mycacti\website\cacti\poller.php
Apply Patches 1. There are two methods of applying patches to Cacti: a. If you have Cygwin installed, then the patch instructions which use wget and patch, will work. b. 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 les. 2. You might need to reapply le/folder security on the les patched. Double check they are correct.
Note: You will probably have to specify the -u and -p ags for the MySQL username and password. This user must have permission to read from Cactis database or you will end up with an empty backup. 2. Backup the old Cacti directory.
shell> mv cacti cacti_old
5. Edit include/config.php and specify the MySQL user, password and database for your Cacti conguration.
$database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cacti";
7. 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 dont exist or are newer than the distributions.
shell> cp -u cacti_old/scripts/* cacti/scripts/
8. Copy any relevant custom resource XML les from the old Cacti directory. Some resource XML les are updated between versions. Therefore, make sure you only over write if the XML les either dont exist or are newer than the distributions.
shell> cp -u -R cacti_old/resource/* cacti/resource/
9. Set the appropriate permissions on Cactis directories for graph/log generation. You should execute these commands from inside Cactis directory to change the permissions.
shell> chown -R cactiuser rra/ log/
(Enter a valid username for cactiuser, this user will also be used in the next step for data gathering.) 10. Point your web browser to:
http://your-server/cacti/
Follow the on-screen instructions so your database can be updated to the new version.
Notes
1. http://www.rrdtool.org/
Figure 6-1. Adding a New Device After saving your new device, you should be redirected back to the same edit form with some additional information. If you congured 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. Towards the bottom of the page there will be two addition boxes, Associated Data Queries, and Associated Graph Templates. 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.
Chapter 6. How to Graph Your Network Type External SNMP Description Calls the net-snmp snmpwalk and snmpget binaries that are installed on your system. Supported Options All SNMP options Places Used Web interface and PHP poller (poller.php)
Internal SNMP (php-snmp) Uses PHPs SNMP functions which are linked against net-snmp or ucd-snmp at compile time. Cactid SNMP
Links directly against All SNMP options net-snmp or ucd-snmp and calls the API directly.
Figure 6-2. Creating New Graphs 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 Create. 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 Create 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. Once you have selected the graphs that you want to create, simply click the Create 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 elds 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 Create button one last time to actually create your graphs. If you would like to edit or delete your graphs after they have been created, use the Graph Management item on the menu. Likewise, the Data Source menu item allows you to manage your data sources in Cacti.
11
Figure 7-1. Editing a Graph Tree To start adding items to your tree, click add in the Tree Items box. There are currently three different types of tree items you can choose from: header, graph, or host. Simply choose the type you want, ll in the value for that type, and click Create to make your new graph tree item. Clicking the Add 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 Parent Item eld.
Figure 8-1. Adding a User At minimum, you must specify a User Name and a Password for each user. Each user eld is described in more detail below. In addition to these elds, 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. Table 8-1. Field Description: User Management Name User Name Description This eld contains the actual login name for the user. There are no character limits this eld, but it would make sense to keep it to alphanumeric characters to maintain simplicity. (Optional) You can use this eld as a more descriptive identier for the user. It is currently only used for display on the user management page. 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.
Chapter 8. User Management Name Account Options Description There are currently two account related options that can be set for each user. The rst, 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. 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. These options dictate what occurs immediately after the user logs in. The rst 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.
Graph Options
Login Options
14
Output String
This eld is only here for legacy purposes and will probably go away in a future version of Cacti.
When you are nished lling in all necessary elds, click the Create button to continue. You will be redirected back to the same page, but this time with two new boxes, Input Fields and Output Fields. The Input Fields box is used to dene any elds that require information from the user. Any input elds referenced to in the input string must be dened here. The Output Fields box is used to dene each eld that you expect back from the script. All data input methods must have at least one output eld dened, but may have more for a script.
Chapter 9. Data Input Methods Name Update RRD File (Output Only) Description Check this box if you want Cacti to insert the return value from this eld into the RRD le. Obviously, this box needs to be checked for at least one output eld per data input source, but can be left blank to have Cacti store the value in the database instead.
When you are nished lling in all necessary elds, click the Create button to continue. You will be redirected back to the data input method edit page. From here you can continue to add additional elds, or click Save on this screen when nished.
So if I wrote a script that outputs the number of running processes, its output might look like the following: Example 9-1. Example script output using 1 eld
67
Data input methods with more than one output eld are handled a bit differently when writing scripts. Scripts that output more than one value should be formatted like the following:
<fieldname_1>:<value_1> <fieldname_2>:<value_2> ... <fieldname_n>:<value_n>
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 elds 1min, 5min, and 10min, respectively. Based on these two things, the output of the script should look like the following: Example 9-2. Example script output using 3 elds
1min:0.40 5min:0.32 10min:0.01
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.
Notes
1. data_input_methods.html
16
When you are nished lling in all necessary elds, click the Create button to continue. You will be redirected back to the same page, but this time with some additional information to ll in. If you receive a red warning that says XML File Does Not Exist, correct the value specied in the XML Path eld.
Chapter 10. Data Queries Name Graph Template Description Choose the actual graph template that you want to make the association with.
When you are nished lling in these elds, click the Create button. You will be redirected back to the same page with some additional information to ll in. Cacti will make a list of each data template referenced to in your selected graph template and display them under the Associated Data Templates box. For each data source item listed, you must selected the data query output eld that corresponds with it. Do not forget to check the checkbox to the right of each selection, or your settings will not be saved. The Suggested Values box gives you a way to control eld values of data sources and graphs created using this data query. If you specify multiple suggested values for the same eld, Cacti will evaluate them in order which you can control using the up or down arrow icons. For more information about valid eld names and variables, read the section on suggested values. When you are nished lling in all necessary elds on this form, click the Save 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 le. When you are nished with this, you should be ready to start adding your data query to hosts.
Table 10-3. SNMP Query XML Field Reference Field query->name query->description query->oid_index Description (Optional) You can enter a "friendly name" for the SNMP query here. It will not be used by Cacti, and is for identication only. (Optional) You can enter a description for the SNMP query here. It will not be used by Cacti, and is for identication only. 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 eld that uniquely identies each row returned by the query. In the example above, the oid_index points to the OID of ifIndex in the interface MIB. Note: 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 dened below, you must still specify an OID that can be walked by Cacti in order to obtain the list of OIDs. Any OID dened for one of your input elds should work in this case. The values returned from the snmpwalk walk will be completely disregarded.
18
Chapter 10. Data Queries Field query->oid_index_parse Description This eld should only be used if you are trying to parse the unique index from the OID itself. If this eld is dened, to obtain a list of indexes, Cacti walks the OID provided in the oid_index eld above. It then applies the regular expression provided in this eld to the list of OIDs that are returned. The matched substrings that remain become the list of indexes for this SNMP query. An OID that can be queried to determine the total number of available indexes. If specied, this will be used to determine when to automatically recache this SNMP query when it is attached to a device. As of version 0.8.6, Cacti will attempt to nd the best eld to index off of based on whether each row in the query is unique and non-null. If specied, Cacti will perform this check on the elds listed here in the order specied. Only input elds can be specied and multiple elds should be delimited with a colon. For sorting purposes, specify whether the index is numeric or alphanumeric. numeric: The indexes in this SNMP query are to be sorted numerically (ie. 1,2,3,10,20,31)
alphabetic: The indexes in this SNMP query are to be sorted alphabetically
query->oid_num_indexes
query->index_order
query->index_order_type
(1,10,2,20,3,31).
query->index_title_format
Specify the title format to use when representing an index to the user. Any input eld name can be used as a variable if enclosed in pipes (|). The variable |chosen_order_field| will be substituted with the eld chosen by Cacti to index off of (see index_order above). Each eld contained within the SNMP query must be dened under this tag. Each dened eld 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 identiable within Cacti. Here you can specify a "friendly name" for the eld. This name will be used by Cacti to help the user identify this eld. Tell Cacti how you want it to gather SNMP information for this eld. get: The get method obtains a list of indexes and does an snmpget for each index of the OID specied for this eld.
walk : The walk method does a walk of the OID specied for this eld.
query->elds query->elds->ifIndex
query->elds->ifIndex->name query->elds->ifIndex->method
Both methods will return the same values, even though the walk method is typically more efcient.
19
Chapter 10. Data Queries Field query->elds->ifIndex->source Description When Cacti obtains a list for this eld, you need to tell it how to derive its value for each row. value: The value option simply returns the result of the snmpget for each row.
OID/REGEXP:(regexp_match): 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 le. VALUE/REGEXP:(regexp_match): The OID/REGEXP:(regexp_match) op-
tion can be used to parse the value based on a regular expression, returning the rst match.
index : Simply use the value of the index for this row as the value. If the
index is being parsed from the OID using the oid_index_parse eld, you must specify index here.
query->elds->ifIndex->direction
input: 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. output: 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. A rule of thumb is that input elds contain semi-static data that is not graphable, while the output elds contain the data that will be graphed.
query->elds->ifIndex->oid
You must specify the actual OID that corresponds with the eld. Each value for this eld can be obtained by doing an snmpget on oid.(each)snmpindex.
<query> <name>Get Unix Mounted Partitions</name> <description>Queries a list of mounted partitions on a unix-based host with the df command.</descri <script_path>perl |path_cacti|/scripts/query_unix_partitions.pl</script_path> <arg_index>index</arg_index> <arg_query>query</arg_query> <arg_get>get</arg_get> <arg_num_indexes>num_indexes</arg_num_indexes> <output_delimeter>:</output_delimeter> <index_order>dskDevice:dskMount</index_order> <index_order_type>alphabetic</index_order_type> <index_title_format>|chosen_order_field|</index_title_format> <fields> <dskDevice> <name>Device Name</name> <direction>input</direction> <query_name>device</query_name> </dskDevice> </fields> </query>
Chapter 10. Data Queries Field query->name query->description query->script_path Description (Optional) You can enter a "friendly name" for the script query here. It will not be used by Cacti, and is for identication only. (Optional) You can enter a description for the script query here. It will not be used by Cacti, and is for identication only. 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. Enter the argument that is to be passed to the script to retrieve a list of indexes. Enter the argument that is to be passed to the script to retrieve a list of values given a eld name. Enter the argument that is to be passed to the script to retrieve a single value given a eld name and index value. Enter the argument that is to be passed to the script to determine the total number of available indexes. If specied, this will be used to determine when to automatically recache this script query when it is attached to a device. 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. As of version 0.8.6, Cacti will attempt to nd the best eld to index off of based on whether each row in the query is unique and non-null. If specied, Cacti will perform this check on the elds listed here in the order specied. Only input elds can be specied and multiple elds should be delimited with a comma. For sorting purposes, specify whether the index is numeric or alphanumeric. numeric: The indexes in this script query are to be sorted numerically (ie. 1,2,3,10,20,31)
alphabetic: The indexes in this script query are to be sorted alphabetically
query->output_delimeter
query->index_order
query->index_order_type
(1,10,2,20,3,31).
query->index_title_format
Specify the title format to use when representing an index to the user. Any input eld name can be used as a variable if enclosed in pipes (|). The variable |chosen_order_field| will be substituted with the eld chosen by Cacti to index off of (see index_order above). Each eld contained within the script query must be dened under this tag. Each dened eld 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 identiable within Cacti. Here you can specify a "friendly name" for the eld. This name will be used by Cacti to help the user identify this eld.
input: Input values are the "known" values that you will use to derive the
query->elds query->elds->dskDevice
query->elds->dskDevice->name query->elds->dskDevice>direction
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. output: 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. A rule of thumb is that input elds contain semi-static data that is not graphable, while the output elds contain the data that will be graphed.
21
Chapter 10. Data Queries Field query->elds->dskDevice>query_name Description Enter the name that Cacti must use when asking the script for information about this eld. For instance, the following should return values: (script_name) query (query_name).
22
Image Format
Choose whether you would prefer to output your graph images in PNG or GIF. According to the RRDTool graph manual1 PNG is preferred because it is both smaller and faster. The height of the graph area in pixels The width of the graph area in pixels 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. Choose whether you would like to use --alt-autoscale or --alt-autoscale-max on the graph. The RRDTool graph manual1 says: 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 dened on the command line, will be 0. This option can be useful when graphing router trafc when the WAN line uses compression, and thus the throughput may be higher than the WAN line speed. Choose if you want logarithmic y-axis scaling. From the RRDTool manual 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. 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. If you choose to use Cactis static HTML/image export, you can choose whether you want each individual graph to be exported. The maximum value that will be displayed on the y-axis. This value is ignored is auto-scaling is turned on. The minimum value that will be displayed on the y-axis. This value is ignored is auto-scaling is turned on. Whether you want to base the y-axis labels on 1000 or 1024. This eld will typically be set to 1024 for memory and 1000 for trafc measurements.
Auto Padding
Chapter 11. Templates Name Unit Value Unit Exponent Value Description Sets the unit value for the y-axis. You should probably keep the unit short as to keep it readable. Sets the 10^e scaling of the y-axis. Valid values for this eld 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). The text to print on the left edge of the graph. Usually is the units the data on the graph is measured in.
Vertical Label
Note: For most graph templates, you will want to check the Use Per-Graph Value checkbox for the title eld so each graph using this template has its own unique title. It also makes sense to enter an initial value in this eld that includes the variable |host_description| for organizational purposes. When you are nished lling in values for the graph template, click Create and you will be presented with a page similar to the graph edit page.
Color
24
Chapter 11. Templates Name Graph Item Type Description This eld is important because it denes 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 specic 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. Note:: You must always put an AREA item before using STACK or your graph will not render.
Consolidation Function
This tells RRDTool 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. 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. This eld 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. 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. You can enter text to be displayed on the legend here. This eld is applicable for all graph item types except for the virtual LEGEND type. Check this box to force graph items onto the next line.
Chapter 11. Templates Now any time a change is made to the graph template, it will be automatically propagated to the graphs attached to it.
The full path to the RRD le associated with this data source. When creating a new data source you will typically leave this eld blank as Cacti will generate one for you. If you are using an RRD le generated outside of Cacti, you need to specify it here. 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 le is being populated outside of cacti, make sure to leave this eld set to "None". You need to associate the data source with at least one RRA so RRDTool 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. This tells RRDTool how many seconds there will be between updates. The default is 300 seconds (5 minutes), and is sufcient for most installations. 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.
Associated RRAs
Note: For most data templates, you will want to check the Use Per-Graph Value checkbox for the name eld so each data source using this template has its own unique name. It also makes sense to enter an inital value in this eld that includes the variable |host_description| for organizational purposes. When you are nished lling in values for the data template, click Create and you will be presented with a screen similar to the data source edit screen.
26
Internal Data Source Name This is the name used by RRDTool to identify this particular data source within the RRD le. RRDTool places a limit of 19 alphanumeric characters (plus _ and -) on this eld. Minimum Value Here is where you specify the minimum value that is expected for this data source in the RRD le. If a value lower than the minimum is given, it will be stored as Unknown (U). Here is where you specify the maximum value that is expected for this data source in the RRD le. If a value higher than the maximum is given, it will be stored as Unknown (U). There are four types of data that RRDTool can represent for any given data source: COUNTER, GAUGE, ABSOLUTE, and DERIVE. A gauge is for numbers that are not continuously incrementing. A counter is for continuously incrementing values that might overow, while a derive does not overow. The absolute type is used for counters that are reset upon reading. As dened by RRDTool: The maximum amount of time that can pass before data is entered as "unknown". This eld is usually 600 or 2 data gathering intervals.
Maximum Value
Heartbeat
Chapter 11. Templates you want to apply the template to under Data Sources. Under the Data Template Selection box, select the data template that you want to apply to the data source and click Save. Once the template is applied to the data source, you will notice that you can only change values for the elds that you checked Use Per-Data Source Value for. Now any time a change is made to the data template, it will be automatically propagated to the data sources attached to it.
28
4. Update Your Data Templates - Goto Data Templates, locate the following two data templates and change their data input method to "Get Script Server Data (Indexed)". a. Host MIB - Hard Drive Space b. Host MIB - CPU Utilization 5. Re Enable the Poller - Go to Settings->Poller and check the Poller Enabled checkbox. Press Save. Following those steps should complete your migration to the new PHP Script Server for the two example HostMIB Data Queries.
3. 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:
<?php $a = 100; $b = $a / 10; print $b; ?>
Would become:
function ss_myfunction() { $a = 100; $b = $a / 10; Print $b; }
4. If you have any additional functions declared within your script le, you must prex them to make then unique amongst all functions. Our recommendation would be to prex 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 guarantees correct Script Server functionality. 5. 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.
2. Add the following two XML tags below the <script_path> tag. Replace ss_myfunction with your function name:
<script_function>ss_myfunction</script_function> <script_server>php</script_server>
30
NOTE: Due to a bug in Windows implementation of PHP, you must type the full path name to the script_server.php le. 2. Type in your command - Using the example from above, you would type in the following:
script server> <path_myfunction> my_function argument1 argument2 ...
3. If your function is operating properly, you should get a result. 4. To quit the script server, simply type "quit" <cr> at the command line. NOTE: If there are errors in your script, you must restart the script server before your retest your code.
31
When nished lling in values for these elds, click the Create button. Your new graph can now be accessed through the Graph Management page or the Graphs tab inside of Cacti.
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 difcult time understanding how to graph anything that wasnt 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. I do not use templates in this HOWTO. Templates provide a signicant advantage if you are graphing the output for multiple instances or creating graphs for multiple hosts. They help to maintain consistency and simplify setup. The example here is not realistic, but can be used and expanded upon as a model for creating your own graphs.
Chapter 13. How To Ive not put a lot of explanations in the procedures. Refer to the Cacti manual for more details. Have a tested script ready to go. I used the following script located in /home/cactiuser/bin called random2.pl:
#!/usr/bin/perl -w print int(rand(10));
This script simply prints out a random integer between 0 and 9 every time its called. The minimal steps to create a graph from a script are simply: 1. Create a Data Input Method to tell Cacti how to call the script and what to expect from it. 2. Create a Data Source to tell cacti how and where the data will be stored. 3. Create a Graph to tell cacti how the data will be presented in graph form. 4. Add Graph to Graph View so you can view the graph. 5. View the Graph The details are below: 1. Create Data Input Method
Click the Console tab at the top Click Data Input Methods under Management Click Add Name: Random 2 Input Input Type: Script/Command Input String: /home/cactiuser/bin/random2.pl Click Create Should see "Save Successful." at the top of the page. Click Add by Output Fields (there are no input elds for this example) Field [Output]: random_number Friendly Name: Random Number Update RRD File: checked Click Create Should see "Save Successful." and random_number listed under Output Fields. Click Save Should see "Save Successful." and Random Input listed in Data Input Methods.
Click Data Sources under Management Click Add in the top right The Data Template Section should be None and None, were not using templates for this example. Click Create. Name: random2ds Data Source Path: blank (Cacti will ll this in) Data Input Source: Random 2 Input (this is the data input method you created in step 1) Highlight each of the Associated RRAs using control-click Step: 300 (300 seconds = 5 minutes) Data Source Active: checked Describe the Data Source Item inside the RRA by... Internal Data Source Name: random_number Minimum Value: 0 33
Maximum Value: 0 Data Source Type: GAUGE Heartbeat: 600 Click Create Should see "Save Successful." at the top and the Data Source Path should now have a value (my example <path_rra>/random_number_286.rrd) Click Turn On Data Source Debugging Mode to see the results of this step. Click Save Should see "Save Successful" and your new Data Source listed.
3. Create Graph
Select Graph Management under Management Click Add Selected Graph Template: None Host: None Click Create Title: RANDOM NUMBERS Image Format: PNG Height: 120 Width: 500 Auto Scale: checked Auto Scale Options: Use --alt-autoscale-max Logarithmic Auto Scaling: unchecked Rigid Boundaries: unchecked Auto Padding: checked Allow Graph Export: checked Upper Limit: 100 Lower Limit: 0 Base Value: 1000 Unit Value: blank Unit Exponent Value: 0 Vertical Label: Random Number Click Create Should see "Save Successful." If you click "Turn On Graph Debug Mode." now you will see: "Error: cant make a graph without contents." We need to add Graph Items: Click Add by Graph Items Data Source: (from list) No Host - random2ds (random_number) Color: 0000FF (Blue) Graph Item Type: LINE2 Consolidation Function: AVERAGE CDEF Function: None Value: blank GPRINT Type: Normal Text Format: blank Insert Hard Return: unchecked 34
Click Create Should see "Save Successful.", Item #1 listed and a graph under debug (probably with nothing in it yet) To add a legend, click Add by Graph Items again Data Source: No Host - random2ds (random_number) Color: None Graph Item Type: GPRINT Consolidation Function: LAST CDEF Function: None Value: blank GPRINT Type: Normal Text Format: Cur: Insert Hard Return: unchecked Click Create 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. At the bottom of the page, click Save. Should see "Save Successful." and your graph listed.
Click Graph Trees under Management Well create a tree called "test" to place our graph Click Add Name: test Should see "Save Successful" Click Add beside Tree Items (to add our graph to this tree) Under Tree Items [graph]... Graph: RANDOM NUMBERS (we named this in step 3) Round Robin Archive: Daily (5 Minute Average) Click Create Should see "Save Successful." and RANDOM NUMBERS listed under Tree Items Click Save Should see "Save Successful." and test listed under Graph Trees
5. View Graph
Select Graphs tab Select tree view (Tree beside settings tab) Select test tree on left 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 rst data point and poll 3 to have graphable points. While waiting, you can click the RANDOM NUMBERS graph. Youll see place holders for 4 graphs. Select [source] under Daily (5 Minute Average). Youll see the source for the call to rrdtool graph. Give it a sanity check. Now be patient. Hit your refresh button every few minutes. After the rst poll I got a few empty graphs. A few minutes later data started showing up.
35
Notes
1. http://kdeuja.com/~kevin/
36
2. General I get a "Undened variable: _SERVER" error message from Cacti. Cacti 0.8.6 and above requires that you have at least PHP 4.1 or greater installed. I get a "Call to undened function: mysql_connect()" error message from Cacti. 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 le. I have forgotten my admin password to Cacti, how do I reset it? To reset the admin account password back to the default of admin, connect to your Cacti database at the command line.
shell> mysql -u root -p cacti
3. Monitoring I am polling thousands of items and poller.php takes more than 5 minutes to run. Give cactid, the future replacement for poller.php a try. Unlike poller.php, cactid is written in c and makes use of pthreads. On a typical installation, it is not uncommon for cactid to poll about 500 items in less then 10 seconds. I changed x, and now some of my graphs are not updating. The best thing to do here is to force Cacti to rebuild its poller cache. To do this click Utilities on the Cacti menu, and select Clear Poller Cache. I am using Redhat 8.0 and SNMP is not working.
their latest versions should x this problem. How do I congure net-snmp so it will work with Cacti? Run snmpconf -g basic_setup and follow the prompts. Also check that the le being used by snmpd is the correct cong le. For Redhat Linux, snmpconf creates the /etc/snmpd.conf, but snmpd uses /etc/snmpd/snmpd.conf. If this doesnt work a very simple cong le is:
# contact syslocation Something syscontact "[email protected]" # auth rocommunity public # disk monitoring disk /
4. Graphs I just installed Cacti and all of my graphs appear as broken images. For you to actually get graph images, poller.php must run at least once so it can create .rrd les in Cactis rra/ directory. Double check that you congured your /etc/crontab le to execute poller.php every ve minutes. Also make sure that the user poller.php runs as has permission to create new les in Cactis rra/ directory. If all of your settings appear correct, try running poller.php manually by cding to Cactis directory and typing:
shell> php poller.php
If you have les 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 Graph Management from the menu, select any graph listed, and select Turn On Graph Debug Mode.
My graphs render, but they do not contain any data. More often than not, this problems cause is permissions. For instance if you run poller.php manually as root for testing, any .rrd les that it creates will be owned by root. Now when poller.php runs from cron, it will not be able to update these .rrd les because they are owned by root. You can double check the owner of your .rrd les by running the following command in your Cacti directory:
shell> ls -al rra/
If only some of your graphs are not updating correctly, double check the Maximum Value eld for all data sources used by these graphs. If the value being fed to the .rrd le exceeds its Maximum Value, RRDTool will insert an Unknown and you will see no data on the graph.
A lot of my graphs contain long ifAlias names, but they are being truncated to 15 characters. Cacti does this by default to better control graph title formatting. You can change this limit, by going to Cacti Settings on the Cacti menu, selecting the Visual tab, and changing the value for Data Queries - Maximum Field Length. One of my devices rebooted and now I have a huge spike on my graph! This occurs because the reboot causes SNMPs counters to reset, which can cause a rather large spike on the graph when RRDTool 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. RRDTool will ignore any value that is larger than the maximum value. If you already have a spike on one or more of your graphs, there is a really useful Perl script1 that will remove them for you. 38
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 This occurs because the version of RRDTool that you are running does not match the RRDTool version Cacti is congured to use. Double check your Cacti Settings and make sure that the RRDTool version matches what version of RRDTool you are running. 5. Windows Related I get a "Fatal error: Cannot redeclare title_trim()" error message from Cacti. Contrary to previous versions of Cacti, you must not put Cacti in your PHP include path. Check your php.ini le to make sure there is not something like include_path = C:/Apache2/htdocs/cacti.
Notes
1. http://cricket.sourceforge.net/contrib/les/killspike2
39
15.1.1. Date/Time
|date_time|
This variable will place the date and time of the last poller run on the graph. It can be used to replicate MRTGs "graph last updated" feature.
You can place the value of any data query eld on the by including this variable. Make sure to substitute "eld_name" with the actual data query eld name. Example 15-1. Print the IP Address on a trafc graph
|query_ifIP|
|[0-9]:(bits|bytes):[0-9]:(current|total|max|total_peak|all_max_current|all_max_peak|aggregate_max|aggregate_sum|aggr
Nth percentile is often used by hosting providers to bill customers based on their peak trafc usage while ignoring their top (100 - Nth) percent. This way if a customer has a fairly consistent trafc pattern and decides to download a huge le one day, the large spike will be ignored. Common Nth percentile is 95, which would cut off the top 5% of the trafc. In Cacti, Nth percentile works just like any other graph variable. To use this variable you must give it ve arguments: Table 15-1. Nth Percentile Argument Description Name
[0-9] (bits|bytes) [0-9]
Description The rst argument is a number between 1 and 99. This number represents the Nth percentile that you would like to calculate. Choose whether you want to represent your Nth percentile in bits or bytes. The only valid values for this eld are bits and bytes. This eld 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.
Enter the number of digits to use for oating point precision when printing out the nal number. The default value for this eld is two decimal places.
Description 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 dened. 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 trafc_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 dened. 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 trafc_in, this will evaluate trafc_out and trafc_in for that selected data source (rrdtool le) 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 dened. Calculates the Nth percentile based on the max for each data source dened on the graph. Example, the max is taken for each data source dened on the graph, but its the max of trafc_in or trafc_out for that data source (rrdtool le). The resulting max values are summed and returned. 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 dened on the graph, the selected data source is trafc_in, all data sources for trafc_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 dened. Calculates the Nth percentile by selecting the highest (max) calculated max Nth percentile value for each data source (rrdtool le) selected on the graph. Example, 3 data sources are dened 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. 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 trafc_in and 18 trafc_out data sources. The trafc_in rows are summed together, then the trafc_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. 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 trafc_in and 3 trafc_out data sources dened. All the dened trafc_in and trafc_out are summed together and then the Nth percentile value is calculated from that set.
total
max
total_peak
all_max_current
all_max_peak
aggregate_max
aggregate_sum
41
Description Calculates the Nth percentile by summing like data source names row for row from each data source dened on the graph and then returning the highest Nth percent value calculated for like data source names. Example, you have a graph with 3 trafc_out and 5 trafc_in data sources dened. The trafc_in and trafc_out are summed then the Nth value is calculated and the higher of the 2 values is returned as the variable.
Concerning aggregate Nth percentile functions and rra denitions: All data sources used in a graph MUST have the same rra denitions. 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.
Example 15-3. Output in the following format, for 95th percentile: 42.58 mbit
|95:bits:6:max:2|
Bandwidth summation is useful for summing up all values in an RRD le for a given time range. This is typically useful on trafc graphs where you can see a total of all trafc that has gone through an interface in a given time period. In Cacti, bandwidth summation works just like any other graph variable. To use this variable you must give it three arguments: Table 15-3. Bandwidth Summation Argument Description Name
([0-9]|auto)
Description This eld 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 eld to have Cacti automatically scale the number and insert the appropriate label. 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 eld are current and total. Enter the number of digits to use for oating point precision when printing out the nal number. The default value for this eld is two decimal places. 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 eld to have Cacti use the graph timespan.
(current|total)
[0-9] ([0-9]+|auto)
Description Description Hostname SNMP Community SNMP Version SNMP Username (v3) SNMP Password (v3)
43
16.2. CDEFs
CDEFs allow you to apply mathematical functions to graph data to alter output. The concept of a CDEF comes straight from RRDTool, and are written in reverse polish notation (RPN). For more information regarding the syntax of CDEFs, check out the CDEF tutorial1.
Notes
1. http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdgraph_data.en.html