Kamis, 09 Januari 2014

Hello everyone. I have put together what I feel is a very straight forward guide that walks you through installing Cacti and Nagios on the same machine with every command needed. The purpose for this is to have trending data, monitoring and alerting all from within 1 GUI, Cacti. I am a beginner Linux user and I found it somewhat difficult to find information that was tailored to a beginner, so this is the compilation of all the research I did in order to obtain my desired end result. This guide isn't 100% complete yet, but the bulk of it is done and tested, so I wanted to share this in case someone out there is looking for such a guide to help them out. I don't really go into how to use or configure Cacti or Nagios, I just get you to the point where they are all working and configured at what I consider the minimum.

I used ESX 4.1 as my VM platform.

If you aren't comfortable enough installing an OS in your VM environment or on your dedicate machine, then I recommend taking a look at this excellent website run by a great group of people:
http://www.turnkeylinux.org/lampstack
This will skip you forward to the VMware Tools step.
*NOTE* The TKL lamp stack is based on Ubuntu 10.04.1 LTS, so there may be some variations not noted in my instructions.

Still in progress
--------------------------
Getting postfix setup correctly to use gmail to send notifications to email and sms (using providers email addresses, ie 1234567890@vzwireless.com).


Specifications
--------------------------
Virtual Machine (This is simply what I used, you can change this to your liking)
2 CPU
512MB RAM
80GB HD (Thin)

Ubuntu 11.04 Server x64
Apache
MySQL
PHP5
OpenSSH
PHPMyAdmin
Webmin
SNMP
RRDTool
VMTools
Build Essentials
Linux Headers

Cacti 0.8.7g
Spine 0.8.7g
0.8.7g Patches
Plugin Architecture 2.8
Monitor
Settings
MacTrack
SpikeKill
Nagios Plugin for Cacti
Discovery

Nagios Core 3.2.3
Plugins 1.4.15
NRPE 2.12
NDOUtils 1.4b7 (b9 is reported to be very buggy and in fact didn't work for me, so this is why I chose b7)


Install
--------------------------
Ubuntu Server 11.04 x64
Boot ubuntu server ISO
Work through installation wizard
Hostname: Choose your hostname
Time Zone: Choose your timezone
Partition Disk: Guided - use entire disk and set up LVM (LVM makes it easier to resize in the future)
Username: Choose a username
Password: **********
Install security updates automatically (This is my preference, not necessarily your preference)
Software selection: OpenSSH server, LAMP server, Mail server
MySQL root password: **********
Postfix Configuration - type: Satellite
Postfix Configuration - mail name: Your FQDN
Assign IP Address

Update OS
sudo -i
apt-get update
apt-get full-upgrade -y
reboot

Connect over SSH now
sudo -i
passwd (this sets the root password, needed for webmin to work, so if you don't want webmin you can skip this part)
apt-get install php5-gd php5-mysql php5-cgi php5-snmp -y
apt-get install php-pear php5-ldap -y
apt-get install snmp snmpd libnet-snmp-perl libsnmp-perl -y
apt-get install rrdtool librrds-perl –y
apt-get install phpmyadmin -y
apt-get install libmysqlclient-dev -y
apt-get install sysv-rc-conf -y
apt-get install build-essential -y
apt-get install linux-headers-$(uname -r) -y
apt-get install libldap2-dev libsnmp-dev -y
apt-get install libconfig-inifiles-perl libcrypt-des-perl libdigest-hmac-perl libdigest-sha1-perl libgd-gd2-perl -y
apt-get install libgd2-xpm-dev -y
apt-get install ntp -y

Webmin
nano /etc/apt/sources.list
add the following lines at the end of the file
Code:
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

save and exit
cd /tmp
wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc
apt-get update
apt-get install webmin -y
wget https://webmin-theme-stressfree.googlec ... .10.tar.gz
login to webmin via https://IP:10000
Webmin > Webmin Configuration > Install theme > from local file
Browse to /tmp and choose theme-stressfree-2.10.tar.gz
Return to themes list
Current theme: StressFree theme

VMware Tools
In vCenter, right click VM and choose Guest > Install/Upgrade VMware tools
mount /dev/cdrom /media/cdrom
tar -zxf /media/cdrom/VMwareTools-8.3.2-257589.tar.gz
vmware-tools-distrib/vmware-install.pl
take all the defaults all the way through the installation
reboot

Cacti
cd /tmp
wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
tar –zxvf cacti-0.8.7g.tar.gz
mv /tmp/cacti-0.8.7g/ /var/www/cacti
groupadd cacti
useradd -g cacti cactiuser
chown –R cactiuser /var/www/cacti/rra
chown –R cactiuser /var/www/cacti/log
chmod –R 777 /var/www/cacti/log
chmod –R 777 /var/www/cacti/rra
login to phpmyadmin via http://IP/phpmyadmin
Click on the Priveledges tab > Add a new User
Username: cacti
Host: localhost
Password: *************
Select "Create database with same name and grant all privileges"
Click Go
Back to SSH window
mysql –u root –p cacti < /var/www/cacti/cacti.sql
Verify in phpmyadmin that the cacti db is no longer empty
nano /var/www/cacti/include/config.php
update the MySQL settings
nano /etc/crontab
add the following line to the end of the file:
Code:
*/5 * * * * cactiuser php5 /var/www/cacti/poller.php > /dev/null 2>&1


Spine
wget http://www.cacti.net/downloads/spine/ca ... .7g.tar.gz
tar –zxvf cacti-spine-0.8.7g.tar.gz
mv /tmp/cacti-spine-0.8.7g/ /usr/local/spine
cd /usr/local/spine
aclocal
libtoolize –f
autoheader
autoconf
automake –a
automake
./configure
make
make install
cp /usr/local/spine/spine.conf.dist /usr/local/spine/spine.conf
nano spine.conf
update the sql settings in this file to reflect correct settings
cd /var/www/cacti
wget http://www.cacti.net/downloads/patches/ ... vate.patch
wget http://www.cacti.net/downloads/patches/ ... view.patch
wget http://www.cacti.net/downloads/patches/ ... tput.patch
wget http://www.cacti.net/downloads/patches/ ... tion.patch
wget http://www.cacti.net/downloads/patches/ ... arse.patch
wget http://www.cacti.net/downloads/patches/ ... ping.patch
wget http://www.cacti.net/downloads/patches/ ... rval.patch
patch -p1 -N < data_source_deactivate.patch
patch -p1 -N < graph_list_view.patch
patch -p1 -N < html_output.patch
patch -p1 -N < ldap_group_authenication.patch
patch -p1 -N < script_server_command_line_parse.patch
patch -p1 -N < ping.patch
patch -p1 -N < poller_interval.patch
cd /usr/local/spine
wget http://www.cacti.net/downloads/spine/pa ... sues.patch
patch -p1 -N < unified_issues.patch

Plugin Architecture
cd /tmp
wget http://mirror.cactiusers.org/downloads/ ... 2.8.tar.gz
tar –zxvf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
cp -r /tmp/cacti-plugin-arch/files-0.8.7g/* /var/www/cacti
cd /var/www/cacti
patch -p1 -N --dry-run < /tmp/cacti-plugin-arch/cacti-plugin-0.8.7g-PA-v2.8.diff
patch -p1 -N < /tmp/cacti-plugin-arch/cacti-plugin-0.8.7g-PA-v2.8.diff
nano /var/www/cacti/include/global.php
set correct sql settings
nano /var/www/cacti/include/config.php
set the $url_path variable to /cacti/
mysql -u root -p cacti < /tmp/cacti-plugin-arch/pa.sql

Plugins (Skip any plugins you aren't interested in having)
cd plugins
wget http://docs.cacti.net/_media/plugin:settings-v0.7-1.tgz
mv plugin\:settings-v0.7-1.tgz settings-v0.7-1.tgz
tar –zxvf settings-v0.7-1.tgz
wget http://docs.cacti.net/_media/plugin:monitor-v1.2-1.tgz
mv plugin\:monitor-v1.2-1.tgz monitor-v1.2-1.tgz
tar –zxvf monitor-v1.2-1.tgz
mysql -u root -p cacti < /var/www/cacti/plugins/monitor/monitor.sql
wget http://docs.cacti.net/_media/plugin:dis ... v1.1-1.tgz
mv plugin\:discovery-v1.1-1.tgz discovery-v1.1-1.tgz
tar –zxvf discovery-v1.1-1.tgz
mysql -u root -p cacti < /var/www/cacti/plugins/discovery/discover.sql
wget http://docs.cacti.net/_media/plugin:mactrack-v2.9-1.tgz
mv plugin\:mactrack-v2.9-1.tgz mactrack-v2.9-1.tgz
tar –zxvf mactrack-v2.9-1.tgz
mysql -u root -p cacti < /var/www/cacti/plugins/mactrack/mactrack.sql
wget http://docs.cacti.net/_media/plugin:spi ... v1.2-1.tgz
mv plugin\:spikekill-v1.2-1.tgz spikekill-v1.2-1.tgz
tar –zxvf spikekill-v1.2-1.tgz
download this file http://www.mediafire.com/?iefyesb24ppsbwl and transfer it to your linux box to /var/www/cacti/plugins
tar -xf npc-2.0.4.tar.gz

Open a web browser and visit http://IP/cacti
Go through the install wizard and take all the defaults
change the admin password
Settings > Path > Spine Poller File Path = /usr/local/spine/spine > Save
Settings > Poller > change Poller Type to Spine > Save
User Management > admin > check Plugin Management > Save
Plugin Management > Install All Plugins (click blue arrow) and then Enable All Plugins you want to use (green arrow)
Settings > NPC tab > check Remote Commands
Insert: /usr/local/nagios/var/rw/nagios.cmd to "Nagios Command File Path" box
Insert the Nagios URL: http://IP/nagios/
Click Save
Settings > Misc > Subnet to scan - enter the subnet you want to scan
Enter the appropriate DNS server
Click Save

Nagios
useradd -m -s /bin/bash nagios
passwd nagios
groupadd nagcmd
usermod -G nagios,nagcmd nagios
usermod -a -G nagios,nagcmd www-data
usermod -a -G nagios,nagcmd cactiuser
cd /tmp
wget http://prdownloads.sourceforge.net/sour ... 2.3.tar.gz
wget http://prdownloads.sourceforge.net/sour ... .15.tar.gz
tar xvzf nagios-3.2.3.tar.gz
tar xzf nagios-plugins-1.4.15.tar.gz
cd nagios-3.2.3
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
nano /usr/local/nagios/etc/objects/contacts.cfg
change the email address to yours
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
enter a great password
/etc/init.d/apache2 reload
cd /tmp/nagios-plugins-1.4.15/
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
if there are errors, resolve them
/etc/init.d/nagios start
http://IP/nagios/
verify local services are OK

NDOUtils
cd /tmp
wget http://sourceforge.net/projects/nagios/ ... 4b7.tar.gz
tar xvfz ndoutils-1.4b7.tar.gz
cd ndoutils-1.4b7
./configure
make
cp src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
cp config/ndomod.cfg /usr/local/nagios/etc/ndomod.cfg
nano /usr/local/nagios/etc/ndomod.cfg
Code:
output_type=tcpsocket
#output_type=unixsocket

output=127.0.0.1
#output=/usr/local/nagios/var/ndo.sock

nano /usr/local/nagios/etc/nagios.cfg
add the following line in the broker section: broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
set to 1: process_performance_data=1
cp src/ndo2db-3x /usr/local/nagios/bin/ndo2db
cp config/ndo2db.cfg /usr/local/nagios/etc/ndo2db.cfg
nano /usr/local/nagios/etc/ndo2db.cfg
Code:
#socket_type=unix
socket_type=tcp

db_host=127.0.0.1
db_name=cacti
db_prefix=npc_
db_user=cacti
db_pass=***********

chmod go+r /usr/local/nagios/etc/ndo2db.cfg
chmod go+r /usr/local/nagios/etc/ndomod.cfg
nano /etc/init.d/ndo2db
Paste the script that is found in this page - look in the "NDO database configuration" section: http://www.itpointofview.com/?p=191
chmod gou+x /etc/init.d/ndo2db
reboot

Links
--------------------------
Cacti: http://YourIP/cacti
Nagios: http://YourIP/nagios
Webmin: https://YourIP:10000
PhpMyAdmin: http://YourIP/phpmyadmin

Let me know if I did anything wrong here, duplicated steps, could do things a better way. I am happy to learn and welcome feedback. I hope this can help a few of you out there. If you require assistance of any kind in relation to my guide, just post here and I will do my best to help out. I am still very limited in my knowledge, but have had a good time learning linux, cacti and nagios. I will be creating another guide soon as well but using CentOS instead of Ubuntu.

Thanks for stopping by!


Big thanks to the following authors/websites, they proved invaluable.
------------------------------------------------------------------

https://richardkok.wordpress.com/2010/1 ... p-by-step/
http://www.ubuntugeek.com/how-to-instal ... erver.html
http://www.linuxreaders.com/2009/04/19/ ... tallation/
http://www.itpointofview.com/?p=191
http://trac2.assembla.com/npc/wiki/QuickStartGuide
http://deedoubledub.phpnet.us/2009/03/n ... buntu-804/
http://www.turnkeylinux.org

0 komentar:

Posting Komentar