In order to try to cooperate with all the people help me, I consider a great way to thank those who helpme sharing this procedure with you.
I hope you can test and enjoy it.
Cacti - Plugins - NDOUtils - NPC - Nagios.
I’ve spent a good time trying to link Nagios with Cacti using NPC plugin and NDOUtils without success… But finally I did.
I’ve use a CentOS 6.3 (I guess architecture doesn’t matter as you procedure, but I use i386)
The Cacti version is 0.8.8a fom http://www.cacti.net with plugins architecture out-of-the-box
Thank you very very much Cacti development team.
Nagios was compiled from source, not downloaded from yum, I’ll tell you why after.
Warm-up
CACTI INSTALLATION
You will need to install
Code: Select all
[root@host]# yum install -y rrdtool rrdtool-devel ruby-rrdtool mysql-server mysql-devel php-mysql php-devel php php-snmp httpd net-snmp net-snmp-devel net-snmp-utils
http://www.cacti.net
Code: Select all
[root@host]# wget http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
Code: Select all
# tar zxvf cacti- cacti-0.8.8a.tar.gz
Code: Select all
# mv cacti-0.8.8a /usr/local/share/cacti/
CONFIGURE MySQL's Root Password
Code: Select all
# mysqladmin --user=root password cact1.123
Code: Select all
# mysqladmin --user=root --password reload
Code: Select all
# mysql -u root -pcact1.123
Code: Select all
mysql> CREATE USER cacti;
mysql> CREATE DATABASE cacti;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'cacti';
mysql> FLUSH PRIVILEGES;
The Cacti database is included in the tar.gz source file, with all the structure we need, then you need to replace the Database you’ve created in the previous step with the database that comes with your tar.
The database we will use is in the path you move cacti to (/usr/local/share/cacti in my case).
Code: Select all
mysql -u root -pcact1.123 cacti < cacti.sql
Code: Select all
# /usr/sbin/adduser cacti
Code: Select all
# chown -R cacti:apache /usr/local/share/cacti/
Code: Select all
#vi /usr/local/share/cacti/include/config.php
Code: Select all
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
Code: Select all
root@host]# /etc/init.d/httpd start
Iniciando httpd:
[root@host]# /etc/init.d/mysqld start
Iniciando MySQL: [ OK ]
[root@host]# /etc/init.d/snmpd start
Iniciando snmpd: [ OK ]
ADD SERVICES to startup process
Code: Select all
[root@host]# /sbin/chkconfig --level 352 httpd on
Code: Select all
[root@host]# /sbin/chkconfig --level 352 mysqld on
Code: Select all
[root@host]# /sbin/chkconfig --level 352 snmpd on
Code: Select all
# crontab –e
Code: Select all
*/5 * * * * /usr/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1
APACHE Configuration
Create a cacti.conf file in the conf.d folder - - - >
Code: Select all
vi /etc/httpd/conf.d/cacti.conf
Code: Select all
DocumentRoot "/usr/local/share/cacti"
Alias /cacti /usr/local/share/cacti
<Directory /usr/local/share/cacti>
Order allow,deny
Allow from all
</Directory>
Ensure to have the follow two lines, if you don’t, then add them to your file, save and proceed.
Code: Select all
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Go to your cacti URL:
http://IP/cacti/
Follow the steps in the installation wizard.
When you sign in for the first time, the admin password is ‘admin’, change it, just for securing the system.
NAGIOS INSTALLATION
If you trust me, you will prefer download your Nagios.tar.gz and compile it like a real man (kidding).
Why?
Ok, if you download it from EPEL Repo and install it using yum, maybe some paths will no match with OUR procedure.
Then the THIS won't work.
We will use Nagios 3.4.1 the latest version of Nagios and Nagios-Plugins
In order to install them we follow the steps on the Nagios Official documentation.
Create a Nagios user
Code: Select all
[root@host]# useradd -m -s /bin/bash nagios
Code: Select all
[root@host]# passwd nagios
Code: Select all
[root@host]# groupadd nagcmd
Code: Select all
[root@host]# usermod -G nagios,nagcmd nagios
Code: Select all
[root@host]# usermod -a -G nagios,nagcmd apache
Code: Select all
[root@host]# usermod -a -G nagios,nagcmd cacti
Code: Select all
[root@host]# cd /tmp
Code: Select all
[root@host]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz
Code: Select all
[root@host]# wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
Code: Select all
[root@host]# tar xvzf nagios-3.4.1.tar.gz
Code: Select all
[root@host]# tar xzf nagios-plugins-1.4.15.tar.gz
Code: Select all
[root@host]# cd nagios-3.4.1
Code: Select all
[root@host]#./configure --with-command-group=nagcmd
Code: Select all
[root@host]# make all
Code: Select all
[root@host]# make install
Code: Select all
[root@host]# make install-init
Code: Select all
[root@host]# make install-config
Code: Select all
[root@host]# make install-commandmode
Edit your Nagiosadmin information
Code: Select all
[root@host]# vi /usr/local/nagios/etc/objects/contacts.cfg
Code: Select all
[root@host]# make install-webconf
Code: Select all
[root@host]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
enter a great password
Code: Select all
[root@host]# /etc/rc.d/init.d/httpd reload
Go to /Nagios-Plugins-3.2.3 (remember you are in /tmp)
Code: Select all
[root@host]# cd /tmp/nagios-plugins-1.4.15/
Code: Select all
[root@host]#./configure --with-nagios-user=nagios --with-nagios-group=nagios
Code: Select all
[root@host]# make
Code: Select all
[root@host]# make install
Install NRPE
Code: Select all
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
Code: Select all
tar xzf nrpe-2.13.tar.gz
Code: Select all
cd nrpe-2.13
Code: Select all
./configure
Code: Select all
make all
Code: Select all
vi /usr/local/nagios/etc/objects/commands.cfg
Code: Select all
###NRPE
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
Code: Select all
/etc/rc.d/init.d/nagios restart
Check Nagios conf, you will use this command several times (remember it)
Code: Select all
[root@host]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Code: Select all
[root@host]# /etc/init.d/nagios start
CACTI PLUGINS
Cacti plugins will give your Cacti installation some additioanals features, you will love to work with.
The previous verions of Cacti needs to be patched to work with the plugins, even your database should be modified (ALTER TABLE... ) in order to work with the plugins.
As I said at the top of this document I'm very very happy with Cacti's
Go to Cacti plugins folder
[root@host]#cd /usr/local/share/cacti/plugins
Download some plugins for testing (Note: you always need to download Settings plugin, is the main plugin)
Settings Plugin
Code: Select all
[root@host]#wget http://docs.cacti.net/_media/plugin:settings-v0.7-1.tgz
Code: Select all
[root@host]#mv plugin\:settings-v0.7-1.tgz settings-v0.7-1.tgz
Code: Select all
[root@host]#tar zxvf settings-v0.7-1.tgz
Code: Select all
[root@host]#wget http://docs.cacti.net/_media/plugin:monitor-v1.2-1.tgz
Code: Select all
[root@host]#mv plugin\:monitor-v1.2-1.tgz monitor-v1.2-1.tgz
Code: Select all
[root@host]#tar zxvf monitor-v1.2-1.tgz
NPC (Nagios Plugin for Cacti) you can find it here http://www.mediafire.com/?iefyesb24ppsbwl,
Why I don’t put the full path?
Because the main URL gives you an unique resultant URL for each download you do.
In my case the URL was.
Code: Select all
[root@host]#wget http://205.196.123.83/ccuyad4sd6gg/iefyesb24ppsbwl/npc-2.0.4.tar.gz
Code: Select all
[root@host]#tar zxvf npc-2.0.4.tar.gz
Go to your downloads folder (/tmp)
Code: Select all
[root@host]#cd /tmp
Once you’ve downloaded ndoutils, untar the file and go to the uncompress folder.
Code: Select all
[root@host]#wget http://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b7/ndoutils-1.4b7.tar.gz
Code: Select all
[root@host]#tar xvfz ndoutils-1.4b7.tar.gz|
Code: Select all
[root@host]#cd ndoutils-1.4b7
Code: Select all
[root@host]#./configure
Code: Select all
[root@host]#make
Copy the files as suggest
Code: Select all
[root@host]#cp src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
Code: Select all
[root@host]#cp config/ndomod.cfg /usr/local/nagios/etc/ndomod.cfg
Ensure the file ends in the follow way. And save it.
Code: Select all
[root@host]#vi /usr/local/nagios/etc/ndomod.cfg
Code: Select all
output_type=tcpsocket
#output_type=unixsocket
output=127.0.0.1
#output=/usr/local/nagios/var/ndo.sock
Code: Select all
[root@host]#vi /usr/local/nagios/etc/nagios.cfg
Code: Select all
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
Code: Select all
process_performance_data=1
Code: Select all
[root@host]#cp src/ndo2db-3x /usr/local/nagios/bin/ndo2db
Code: Select all
[root@host]#cp config/ndo2db.cfg /usr/local/nagios/etc/ndo2db.cfg
The result must be as follows
Code: Select all
[root@host]#vim /usr/local/nagios/etc/ndo2db.cfg
Code: Select all
#socket_type=unix
socket_type=tcp
db_host=127.0.0.1
db_name=cacti
db_prefix=npc_
db_user=cacti
db_pass=***********
Code: Select all
[root@host]#chmod go+r /usr/local/nagios/etc/ndo2db.cfg
Code: Select all
[root@host]#chmod go+r /usr/local/nagios/etc/ndomod.cfg
We will create a script for ndo2db and obviously set +X permission
The file starts empty, you’ll need to fill it with the information you’ll find in the follow http://www.itpointofview.com/?p=191
Code: Select all
[root@host]#vi /etc/init.d/ndo2db
Code: Select all
[root@host]#chmod gou+x /etc/init.d/ndo2db
Code: Select all
[root@host]#/etc/init.d/ndo2db start
Code: Select all
[root@host]#chkconfig ndo2db on
Code: Select all
[root@host]#reboot
WEB PROCESS
Once your system started after the previous reboot go to your cacti’s URL http://ip/cacti/ use your admin user and password and go to “Plugins Management” on the left Menu bar.
Will appear the plugins you previously downloaded with a blue arrow looking below, click the arrow to expand the menu and after do this, press the green arrow.
Immediately, close to Console and Graphs labels will appear your Plugin in a new label/tag.
Go to Settings in the left-side menu and click the link and look for NPC.
Click NPC link and in the text box Nagios URL set the Nagios’s URL of your installation (in my case http://127.0.0.1/nagios/)
Enable the check “Remote Commands” and set the nagios command (/usr/local/nagios/var/rw/nagios.cmd) you can find it using find command
Code: Select all
# find / -name nagios.cmd
Click Save and you’re almost done.
After the previous process, if we have some hosts and hostgroups defined on Nagios (if you don’t, then do it… we’ll need hosts and hostgroups) we need to go to NPC label above your browser (close to Graphs), and in the left side you will see the "Reporting" folder, just below it you’ll find the N2C objetct, click it and you’ll see all the hostgroups you’ve defined in Nagios.
Suppose you have 3 servers (perhaps 3 Linux Servers) and now suppose your Hostgroup’s Name is "Linux Servers", click the HostGroup Check and choose a Template (in this case Local Linux Machine),then click the (+) sign to import.
If appears a message saying “Importing Host 1 of 3” we are good, then you can go to “Console” Tag of Cacti, go to devices and you’ll find your Nagios’s imported Servers.
I hope you can use this guide.... If you find some errors please let me know.
I will appreciate your feedback.
Enyoi it.
Seincerly
Eduardo Mejia Vizcarra.
Lima - Peru