Setting Up Cacti On FreeBSD 7.0

nabsta

New Member

Reaction score: 9
Messages: 7

There seems to be a lot for Cacti on linux forums but none or very few on FreeBSD, so here you go,Comments are welcome.

About Cacti

Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices.

Assuming that freebsd has been installed on a machine,Installation instructions can be found at the FreeBSD Website: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/index.html.If you have not updated the ports tree, do this now by :

#portsnap fetch update
#portaudit -F
#portmaster -a

- Now you have the latest snapshot of the ports tree


Install Apache + PHP
Since Cacti needs a web server to serve its php based pages, we need to install Apache + PHP5

#cd /usr/ports/www/apache22
# make config

- make sure Mysql Support is enbaled as Cacti will use this its backend db.
# make install clean

Now install PHP 5
#cd /usr/ports/lang/php5
#make config

- make sure apache module is selected here or else PHP will not work
#make install clean

Now lets configure apache to work with PHP:

There will need to be some lines to /usr/local/etc/apache22/httpd.conf so that the php modules will work, and load php pages. At the end of the LoadModules section of httpd.conf:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Append this to the line for DirectoryIndex:
index.php

Add this to /etc/rc.conf to autostart Apache at boot:

apache22_enable="YES"

Now test if apache is working by starting it using :

# /usr/local/etc/rc.d/apache22 start

System Graphing, powered by MySQL & Cacti

Compile MySQL 5.0 Server
# cd /usr/ports/databases/mysql50-server; make install clean

- Configure MySQL server to load at boot, add this to /etc/rc.conf:
mysql_enable="YES"
and then start MySQL server by :
# /usr/local/etc/rc.d/mysql-server start

Install net-snmp
# cd /usr/ports/net-mgmt/net-snmp; make install clean

Cacti is a powerful network graphing utility that front ends Rrdtool. This process will compile Rrdtool and all of its dependencies for you.
# cd /usr/ports/net-mgmt/cacti; make install clean



By Now we have are almost there,check that we have installed all the dependencies and requirements:

- Apache
- PHP
- Cacti (this included its dependencies, rrd's etc)
- MySql
- Net-snmp

In order to access the Cacti web directory, we have to add a directory listing to our apache httpd-local.conf file . Edit the file /usr/local/etc/apache22/Includes/httpd-local.conf, and add these lines:

<Directory /usr/local/share/cacti>
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
Alias /graphs /usr/local/share/cacti/


The following needs to be added to your /etc/crontab, to poll your system information every 5 minutes.

*/5 * * * * cacti /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1


Setup The Database

#mysqladmin --user=root create cacti

Set the passwd for the cacti user.
# passwd cacti
Changing local password for cacti
New Password: [cactipasswd]
Retype New Password: [cactipasswd]

note that you may need to add a user with nologin

Edit the /usr/local/share/cacti/include/db-settings.php file for the proper database permissions:

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cactipasswd";
$database_port = "3306";


Set the Cacti database's permissions.

#echo "GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'cactipasswd'; FLUSH PRIVILEGES;" | mysql


Import the default tables.
#mysql cacti < /usr/local/share/cacti/cacti.sql

Finally, restart apache and mysql :), then log into the page, using the /graphs alias that was set up earlier. The default login and password is admin:admin, and you will be prompted to change it on your first successful login.

http://yourserver.yourdomain.com/graphs
 

lazyBSD

New Member

Reaction score: 4
Messages: 8

net-mgmt/cacti-spine poller is more preferable than internal one.
 

cnr

New Member


Messages: 3

[font="Trebuchet MS"]a faultless exposition for cacti.. thanks :stud[/font]
 

terminus

Member

Reaction score: 6
Messages: 38

He-he, fellow, AFAIK it is just retyping from oficial cacti's installation instructions? I know it because I have been installed cacti a couple of days ago ;) Anyway, thanks for this how-to - it is nice to have this kind of step-by-step instructions...

Right now I spend time to "get into" the logic of cacti - there is no trivial design (all this Data Input Methods, Data Queries, Templates and so on...) - I'm a litle confused because there is too many fresh concepts ;)

May be you can provide also step-by-step instructions about how-to build new custom graph in cacti and show there explanation/usage examples for all this misty things? I do not found any clear explanation jet in cactis's manuals (looks like I'm toooo lazy or they a hid some there)

P.S.
Sorry for my English if any...
 

APseudoUtopia

Member

Reaction score: 1
Messages: 20

terminus said:
May be you can provide also step-by-step instructions about how-to build new custom graph in cacti and show there explanation/usage examples for all this misty things?

I agree, something like that would be extremely helpful. Maybe a quick guide on how to setup some basic graphs and options, like memory usage, server load, stuff like that.

Thanks a lot for the guide!

Also:
lazyBSD said:
net-mgmt/cacti-spine poller is more preferable than internal one.
Any more info on that? I quickly read up about it, and it definitely seems like it would be much faster. The pkg-descr says: "Cactid is a replacement for the default cmd.php poller so you must decide if using Cactid makes sense for your installation."

So, is there any reason _NOT_ to use the spine poller?

Thanks for the info.
 

taromaru

New Member

Reaction score: 2
Messages: 19

APseudoUtopia said:
I agree, something like that would be extremely helpful. Maybe a quick guide on how to setup some basic graphs and options, like memory usage, server load, stuff like that.

Thanks a lot for the guide!

Count me in too :)

Thanks for the guide and if somebody could provide some info on the first steps to create customs graphs... I would be thankful.

When using cacti, I also found that actually using it was the difficult thing, rather than installing it, which is pretty straight forward if you follow the documentation.
 
OP
nabsta

nabsta

New Member

Reaction score: 9
Messages: 7

If you need help on the graphing side of things i am always available for help, you can find my: Aim,Skype and msn Ids to nudge me.

cheers
 

chrcol

Well-Known Member

Reaction score: 53
Messages: 482

I found that the latest 1.3.x rrdtool produced graphs with misaligned legend text so am using rrdtool-1.2.28.

Then set title font file and Legend font file in the user preferences to this.

/usr/local/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf
 

vivek

Aspiring Daemon

Reaction score: 197
Messages: 805

Excellent, can you edit post and add use code tags for actual commands?
 

APseudoUtopia

Member

Reaction score: 1
Messages: 20

chrcol said:
I found that the latest 1.3.x rrdtool produced graphs with misaligned legend text

Is this what you're talking about?
http://img88.imageshack.us/img88/6886/graphimageec1.png

I added a few extra spaces in front of "Inbound", hoping it would align everything properly, but it didn't.

I'm using RRDTool v1.3.3 from the ports system.

Anyone know of a fix for that? Other than installing RRDTool v1.2.x. I'd rather not play around with switching versions and such...I just finished setting this up, I don't wanna break it already, haha.
 

chrcol

Well-Known Member

Reaction score: 53
Messages: 482

unfortenatly imageshack is very unreliable and for the last 30 minutes I have been trying to load the image but just times out :(

if it is the same problem then going down to rrdtool 1.2 should fix it as cacti wasnt coded for use with 1.3. Its a mistake on the port dependency config to move to 1.3.
 

coolest

New Member


Messages: 5

Hi,

I'm following all the instructions provided and completed all the installations but when I visit the URL locahost/graphs I have this error

Invalid PHP_SELF Path

Any Ideas?:q

I'm using 7.1 release...

Thanks.
 

blackjack

Member

Reaction score: 2
Messages: 23

For monitoring big traffic flow you can make snmp with counter64 and then use this to get counters value

Code:
cd /usr/ports/net-mgmt/net-snmp && make WITH_MFD_REWRITES=yes install clean

Code:
/usr/local/bin/snmpget -v2c -c admin -Oqv localhost F-MIB::ifHCInOctets.1
Code:
/usr/local/bin/snmpget -v2c -c admin -Oqv localhost F-MIB::ifHCOutOctets.1

or change configuration cacti to get counter value from ifHCInOctets, ifHCOutOctets
 

chrcol

Well-Known Member

Reaction score: 53
Messages: 482

APseudoUtopia said:
Is this what you're talking about?
http://img88.imageshack.us/img88/6886/graphimageec1.png

I added a few extra spaces in front of "Inbound", hoping it would align everything properly, but it didn't.

I'm using RRDTool v1.3.3 from the ports system.

Anyone know of a fix for that? Other than installing RRDTool v1.2.x. I'd rather not play around with switching versions and such...I just finished setting this up, I don't wanna break it already, haha.

yes I can confirm this is same problem.

rrdtool-1.2.28 is the fix unfortenatly.
 

dbolton

Member


Messages: 20

nabsta,
I know this original howto is 'old' at this point but wanted to add my two cents on getting it installed on FBSD version 8.2
Three things. Thanks for this write up as it helped me get about 90% there on installing/configuring Cacti. Two things missing though, and maybe a typo:
I had to remove "cacti" from the crontab as it error-ed out (right after the */5 * * * *...)
I had to install SNMP support into PHP5, this is available only in the php5-extensions port.
Lastly, cacti requires the rrdtool database as well.

I had everything configured and yet could not get rrdtool to create the graphs. I went back through my config files on each port install and noticed that SNMP was not checked on the php5-extensions port. After a renewal of the config file with SNMP support, cacti began graphing. correctly!
Thanks again
-David
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,683
Messages: 39,278

dbolton said:
I went back through my config files on each port install and noticed that SNMP was not checked on the php5-extensions port.
All this does is install net-mgmt/php5-snmp.
 

dbolton

Member


Messages: 20

SirDice, you are correct. I also saw that the correct version of RRDTool (1.4) was installed with the cacti port. Installing rrdtool directly caused other problems for me so I had to uninstall that package too. My cacti installation seems to be a little happier now.

Ah, the error's of one's ways and the humility to accept them...never gets old ;-P
 
OP
nabsta

nabsta

New Member

Reaction score: 9
Messages: 7

Hi Guys,

Yes the cacti install is quite old but the same concept. A point to note, Makefile in the ports directory already contains:

Code:
RUN_DEPENDS=    rrdtool:${PORTSDIR}/databases/rrdtool

so you dont have to install it separately. ;)

I dont know why the cron job did not run

Code:
*/5 * * * * cacti /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1

Maybe your paths were different. But anyway, I assume all works now.

Great to be of assistance.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,683
Messages: 39,278

nabsta said:
I dont know why the cron job did not run

Code:
*/5 * * * * cacti /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1

Not the best way to do it. It looks like you added it to /etc/crontab.
You should add it like so:
# crontab -u cacti -e
Then it needs to look like this:
Code:
*/5 * * * * /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1

Don't add things to /etc/crontab. It's mainly used for system related things and it might be modified when you update your system. Use the crontab(1) command.
 
Top