First, you'll need to install the needed dependencies:
sudo apt-get update -y sudo apt-get install -y apache2 libconfig-general-perl librrds-perl libregexp-common-perl libhtml-parser-perl collectd-core
Then we need to configure collectd to sample some data and store the data as RRDs. Drop this file in /etc/collectd/collectd.conf
LoadPlugin cpu LoadPlugin load LoadPlugin memory LoadPlugin disk LoadPlugin rrdtool <Plugin rrdtool> DataDir "/var/lib/collectd/rrd/" </Plugin>
Next we configure apache to use collection3. Copy this file into /etc/apache2/conf.d/collection3.conf
ScriptAlias /collectd/bin/ /usr/share/doc/collectd-core/examples/collection3/bin/ Alias /collectd/ /usr/share/doc/collectd-core/examples/collection3/ <Directory /usr/share/doc/collectd-core/examples/collection3/> AddHandler cgi-script .cgi DirectoryIndex bin/index.cgi Options +ExecCGI Order Allow,Deny Allow from all </Directory>
Now let's start collectd and restart apache:
sudo /etc/init.d/apache2 reload sudo /etc/init.d/collectd start
It'll take collectd a minute to gather enough data to usefully graph. Then you can point your browser to http://your.host.name/collectd/
And you'll be able to graph data!
Note 1: You may need to choose "hour" from the pulldown if you just started collectd, since it doesn't have enough data to graph a day yet
Note 2: The apache configuration is not secure; anyone could just navigate to your machine and see those graphs. Use SSL/.htaccess or other methods to lock down access
Great Blog post, found it very useful. One problem I ran into, was that I was missing a perl module, which I had to run ...
ReplyDeletesudo apt-get -y install libhtml-parser-perl
This is in the Wiki, but might be worth adding your own post. Wish I have recorded the error, but it was something about HTML/Entities.pm missing.
Thanks again.
LeeT of LeeNX
Thanks
ReplyDeleteShort and helpful
Thanks Lee. You are correct. Post updated!
ReplyDeleteFor those trying this out on Trusty 14.04, there are a few minor changes:
ReplyDeleteThe location to write collection3.conf to has changed to /etc/apache2/conf-available, and you'll need to symlink this from conf-enabled.
Also, you'll need to symlink ../mods-available/cgi.load from /etc/apache2/mods-enabled