In Part 1, I discussed about how to use Cacti, a great open-source monitoring tool, for the purpose of monitoring your webpages. More specifically, the time it takes for a webserver to receive the request to the point where the last byte is sent out. I walked through the custom scripts needed by Cacti and how to test that the scripts are working.
In this post, I’m going to cover how to configure Cacti to use the custom scripts I posted in Part 1 and start collecting data for your webpages. In Part 3, I will touch on how to start graphing with the data collected.
So without further delay, let’s get started!
For those of you who are familiar with Cacti, you might find this tutorial a bit basic. I will not be using Templates etc. I’m going to assume you have never laid eyes on Cacti before and just walk through a basic install for 1 monitoring agent to monitor 1 webpage.
Some Cacti Basics
To get this going, there are 3 steps we need to do with Cacti.
- Setup a Data Input Method
- Define a Data Source
- Create a Graph (which will be covered in Part 3)
Simple right? Before we move on, make sure you have done Part 1 and have the agent installed and working. After that, log into your copy of Cacti.
Step 1: Setup a Data Input Method
Select the Data Input Method from the menu under Collection Methods on the left and click ‘Add’ to create a new Data Input Method.
You should get a the Data Input Method webform to fill up.
Make sure you select the “Script/Command” option for
Input Type field. For the
Input String field, make sure you specify the full path to your agent script, followed by the <url> as an input parameter. In my case, it’s something like
After you hit ‘Create’ button, your next step is to specify the input and output fields. For the
pageload-agent.php, it takes in 1 input field but returns 7 output fields (see Part 1 for what parameters are returned by the agent). Once you have setup the Input and Output fields, you should get something like this:
That’s all for the Data Input Method.
Step2: Define a Data Source
Now that you have a Data Input Method set up, the next thing to do is to create a Data Source. What exactly is the data source? You can think of it as the database file where the data collected by the agent is stored. It is essentially an rrd archive file.
To start, choose Data Sources under Management from the left menu.
Data Template Selection webform, just leave them as “None”, and hit the “create” button, and you should see a form like the below. Fill up the form accordingly.
Choose a name you can identify the data source, in my case, it’s “Page Load Demo”. Leave the
Data Source Path empty because Cacti will automatically fill that in for you.
Associated RRAs, just choose all the available options you have. (Note that my screenshots have different RRAs of my own. The standard ones are Hourly (1 min average), Daily (5 min average) etc… ). After that specify ‘con’ as the
Internal Data Source Name.
For the moment just click the ‘Create’ button. You will notice that Cacti would have automatically filled in your data source path. You will also notice that ‘con’ data source item has been created and you can choose which
Output Field to associate to this data source. You will need to create a data source item for every parameter you want to collect data for. Also, make sure you have set the
Maximum Value, something like 100 should be enough.
There is also a field for the URL which corresponds to the input field for you agent. Put in the URL of your page you want to monitor into this field.
Once you have done the data source item for each agent output parameter you should get something like this:
Once that’s done. You can go take a 5-10 minute break while Cacti starts collecting data for you.
And that brings us to the end of this post. I will continue in Part 3 where I will touch on how to start graphing the data you are collecting.