====== Basics ======
===== Principles of Operation =====
The image below shows the building blocks of a Cacti infrastructure:
{{:manual:087:cacti_schema_small.png|Functional Scheme}}
Administration and usage is done via //browser//. When defining new Graphs and Templates and stuff, you log into the //Cacti web pages//. All administrative data will be stored in //MySQL tables//. On the same server, you'll find the //poller//. The poller will query the given target systems, be it a router, PBX, server or application. Results [[2_basics.0_principles_of_operation#data_retrieval|fetched]] from those targets are [[2_basics.0_principles_of_operation#data_storage|stored]] in //rrd files//. Cacti will use those rrd data to create nice [[2_basics.0_principles_of_operation#data_presentation|graphs]], then.\\
\\
Cacti operation may be divided into three different tasks:
{{:manual:087:principles_of_operation.png|Principles of Operation}}
==== Data Retrieval ====
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.
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.
[[3a_advanced_topics.0_overview#advanced_topics|Later on]], we demonstrate how to extend cacti's capabilities of retrieving data to
* [[3a_advanced_topics.1_data_input_methods#data_input_methods|scripts]] called //Data Input Method// in Cacti,
* [[3a_advanced_topics.2_php_script_server#php_script_server|script server scripts]] providing better performance,
* [[3a_advanced_topics.3a_snmp_data_queries#snmp_data_queries|SNMP data queries]] to query SNMP tables like e.g. interfaces and
* [[3a_advanced_topics.3d_script_data_query_walkthrough#script_data_query_walkthrough|script data queries]] to query non-SNMP table structures
==== Data Storage ====
There are lots of different approaches for this task. Some may use an (SQL) database, others flat files. Cacti uses [[http://oss.oetiker.ch/rrdtool/|RRDTool]] to store data.
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.
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.
==== Data Presentation ====
One of the most appreciated features of RRDTool is the built-in graphing function. This comes in useful when combining this with some commonly used webserver. As such, it is possible to access the graphs from nearly any browser on any platform.
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.
=== Cacti ===
Cacti glues all this together. It is mainly written in php, a widely-used general-purpose scripting language that is especially suited for Web development and can be easily embedded into HTML.
Cacti provides the Poller and uses RRDTool for Storage and Graphing. All administrative information are stored in a MySQL database.
=== Cacti to RRDTool Translation Table ===
When using cacti, be it with or without current rrdtool knowledge, you may become confused by all those technical expressions. Let's try to translate
^Cacti Notation^RRDTool Notation^Usage^
| **Data Template** | structure of an rrd file| Used to define the structure for storing data\\ This Template will be applied to specific hosts to create real RRD files|
| **Data Source Item**\\ as part of a Data Template | data source (ds) | A RRD file may hold data for more than one single variable.
Each one is named "data source" in RRDTool lingo |
| **Data Source**\\ as a real instantiation of a Data Template when applied to a Device | RRD file| Yep, this is an ugly one\\ When a Data Template is created, Cacti names it "Data Source".\\ RRDTool says it's an RRD file |
| **Graph Template** | structure of an rrdtool graph statement | Used to create a "raw rrdtool graph statement"\\ This Template will be applied to specific hosts to create real RRD graphs |
| **Graph Template Item**\\ as a part of a Graph Template | graph element | This is a complex one. Each item will create parts of an RRDTool graph statement. Typically, this will include