Installing Cacti on Solaris HOWTO

Javier Vidal Postigo, zanaguara at yahoo dot es

V0.2, 2004-DEC-14

This document explains how to install all the required components by Cacti on a Solaris host.

Introduction

Disclaimer

Use the information in this document at your own risk. I disavow any potential liability for the contents of this document. Use of the concepts, examples, and/or other content of this document is entirely at your own risk.

All copyrights are owned by their owners, unless specifically noted otherwise. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark. Naming of particular products or brands should not be seen as endorsements.

You are strongly recommended to take a backup of your system before major installation and backups at regular intervals.

Software Versions

In my case, I have been able to install Cacti on a Solaris host using the software versions listed below. It does not mean you should use those versions. Version numbers are provided as a reference.

autoconf-2.59
automake-1.9
bash-3.0
bison-1.875d
flex-2.5.31
gcc-3.4.2
libiconv-1.8
libtool-1.5
make-3.80
sed-4.1.1

Install Solaris

  1. Install Solaris following the instructions in http://docs.sun.com/
  2. Install the lastest recommended patch cluster from http://sunsolve.sun.com/

Notes:

Install sunfreeware.com Packages

Solaris does not provide a C compiler, so it is necessary to install some development tools. I recommend to install at least the following packages from http://www.sunfreeware.com/. Be sure to pick the packages that have been compiled for your OS version and architecture.

autoconf-2.59
automake-1.9
bash-3.0
bison-1.875d
flex-2.5.31
gcc-3.4.2
libiconv-1.8
libtool-1.5
make-3.80
sed-4.1.1

Cacti User Account

It is highly recommended to run any application with a non-root user, so create a specific group and user for Cacti. For example:

# mkdir /export/home
# groupadd -g 100 cacti
# useradd -u 100 -g cacti -s /usr/bin/bash -d /export/home/cacti -m cacti
# passwd cacti

From here, a command entered by root will have the "#" prompt, and if the user is cacti, the shell prompt will be "$".


Before start compiling, it is extremely important to have both PATH and LD_LIBRARY_PATH environment variables properly set. This is my .bash_profile:

PATH=/opt/perl/bin:/usr/local/bin:/usr/bin:/usr/sbin:/usr/ccs/bin
PATH=$PATH:/opt/php/bin:/opt/mysql/bin:/opt/rrdtool/bin
PATH=$PATH:/opt/net-snmp/bin

LD_LIBRARY_PATH=/opt/libxml2/lib:/usr/lib:/etc/lib:/opt/zlib/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/sparcv9

MANPATH=/usr/man:/usr/local/man:/opt/rrdtool/man:/opt/net-snmp/man

PS1="`/usr/ucb/whoami`@"`hostname`"$ "
PS2="`/usr/ucb/whoami`@"`hostname`"> "

export PATH LD_LIBRARY_PATH MANPATH
export PS1 PS2

Install Perl (5.8.5)

Solaris provides a version of Perl (/usr/bin/perl), but I prefer to install mine. In my case, I have compiled 5.8.5 from http://perl.org/ and installed it on /opt/perl:

cacti$ rm -f config.sh Policy.sh
cacti$ sh Configure -Dprefix=/opt/perl -des
cacti$ make
cacti$ make test
# make install

Install RRDtool (1.0.49)

Download RRDtool from http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/ and:

cacti$ sh configure --prefix=/opt/rrdtool
cacti$ make
# make install

Install Apache (2.0.52)

Download Apache from http://www.apache.org/ and:

cacti$ configure --prefix=/opt/apache --enable-so
cacti$ make
# make install

(Optional) I have edited my /opt/apache/conf/httpd.conf so:

User cacti
Group cacti
...
ServerName 'hostname'
...
ServerRoot /opt/cacti/cacti-0.8.6b

Notes:

Install MySQL (4.1.7)

  1. First of all, you need to create a group and a user for MySQL:

# groupadd -g 101 mysql
# useradd -u 101 -g mysql -s /usr/bin/bash -d /export/home/mysql -m mysql
# passwd mysql
  1. Download MySQL from http://www.mysql.com/ and:
cacti$ ./configure --prefix=/opt/mysql
cacti$ make
# make install
# cp support-files/my-large.cnf /etc/my.cnf
# cd /opt/mysql
# bin/mysql_install_db --user=mysql
# chown -R root .
# chown -R mysql var
# chgrp -R mysql .
  1. Start MySQL:
# bin/mysqld_safe --user=mysql &
  1. Set a password for the root user:
cacti$ mysqladmin -u root password 'new-password'
cacti$ mysqladmin -u root -h 'hostname' password 'new-password'

Note:

Install libxml2 (2.6.16)

PHP 5 requires a recent version of libxml2. The version that comes with Solaris 9 is too old. Download it from http://xmlsoft.org/ and:

cacti$ ./configure --prefix=/opt/libxml2
cacti$ make
# make install

Install zlib (1.2.1)

zlib is also required by PHP 5. Download it from http://www.gzip.org/zlib/ and:

cacti$ ./configure --prefix=/opt/zlib
cacti$$ make
# make install

Install PHP (5.0.2)

I have not been able to compile PHP 5 with SNMP support, it is in my 'to do' list. If you do not have PHP support activated Cacti will use NET-SNMP instead.

  1. Download PHP from http://www.php.net/ and:
cacti$ ./configure --with-apxs2=/opt/apache/bin/apxs \ 
> --with-mysql=/opt/mysql --prefix=/opt/php \
> --with-libxml-dir=/opt/libxml2 --with-zlib=/opt/zlib
cacti$ make
# make install
  1. You have to add several lines to your Apache configuration file (/opt/apache/conf/httpd.conf):
AddType application/x-httpd-php .php 
DirectoryIndex index.html index.html.var index.php
  1. Be sure PHP installation have added:
LoadModule php5_module        modules/libphp5.so
  1. And add index.php to the DirectoryIndex directive:
DirectoryIndex index.html index.php
  1. Now restart Apache:
# ./apachectl stop
# ./apachectl start

In the Apache error_log file you should see a message saying "PHP/5.0.2 configured".

Install NET-SNMP (5.1.2)

  1. Stop Solaris SNMP daemons:
# cd /etc/rc3.d
# ./S76snmpdx stop
# ./S77dmi stop
# mv S76snmpdx _S76snmpdx
# mv S77dmi _S77dmi

Note:

  1. Download NET-SNMP from http://www.net-snmp.org/ and:
cacti$ ./configure --prefix=/opt/net-snmp \
> --with-default-snmp-version=3 \
> [email protected] \
> --with-sys-location=somelocation \
> --with-logfile=/opt/net-snmp/log/snmpd.log \
> --with-persistent-directory=/opt/net-snmp/var
cacti$ make
cacti$ make test
# make install
# cd /opt/net-snmp
# mkdir var
# mkdir log
# ./snmpconf -g basic_setup
  1. Answer to all questions asked. Then start NET-SNMP:
# /opt/net-snmp/sbin/snmpd -c /opt/net-snmp/bin/snmpd.conf 
  1. And check whether NET-SNMP agent is working fine:
cacti$ /opt/net-snmp/bin/snmpget -v 1 -c community localhost sysUpTime.0

Install Cacti (0.8.6b)

Once you have installed all the required components you can follow Chapter 2 of Cacti documentation (Installing Under Unix).

If you try to execute 'php poller.php' directly in the crontab is not going to work because php can not find all the dynamic
libraries needed. The simplest solution is to have in the crontab the following line:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * . /path/profile; /opt/php/bin/php /opt/cacti/cacti-0.8.6b/poller.php
being '/path/profile' the full path to the user's profile file (i.e. /export/home/cacti/.bash_profile).