Cacti.v7
Contents
Howto Cacti
This whole section needs updating from version 0.8. The version running on our Raspberry Pi is v 1.2.2.
What is 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.
Extra things
- Upgrade cacti moving an exciting cacti system over to a new server.
- Cacti v8.8a Install Cacti with the new directory settings
- Cacti & MailScanner setting up templates and graphs for MailScanner
- Cacti & Trango setting up templates and graphs for Trango
Installing
yum
yum install cacti net-snmp-utils net-snmp php rrdtool php-snmp
This may run a whole bull pucky pile of stuff. Just let it do it's thing. This will have created a user called cacti that we will use later!
Setup the cacti Database
mysqladmin --user=root create cacti -p
Import the default cacti database:
mysql -uroot cacti -p< /var/www/cacti/cacti.sql
Create a MySQL username and password for Cacti.
mysql --user=root mysql -p mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword'; mysql> flush privileges;
Edit /var/www/cacti/include/config.php and specify this MySQL user
emacs /var/www/cacti/include/config.php
$database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "somepassword";
Set the appropriate permissions on cacti's directories for graph/log generation.
chown -R cacti /var/www/cacti/rra/ /var/www/cacti/log/
Crontabs
DONOT add a line to your /etc/crontab file similar to:
*/5 * * * * cactiuser php /var/www/cacti/poller.php > /dev/null 2>&1
I actually use this and it was wrong
*/5 * * * * su cactiuser -c "php /var/www/cacti/poller.php" > /dev/null 2>&1
The yum install has already added a cron job in /etc/cron.d
Setting up cactid
yum install cacti-cactid
Edit the config file for cactid
pico /etc/cactid.conf
DB_Host localhost DB_Database cacti DB_User cactiuser DB_Pass somepassword DB_Port 3306
Edit the configuration of Cacti so you have the path to the cactid file setup.
Edit the configuration of Cacti to using the cactid to get the data.
Setting up snmp
yum install net-snmp-utils net-snmp
If snmp is now already set my then there are a number of things that do need to be set.
/etc/init.d/snmpd start
Check that it is running
ps aux | grep snmp
Will give:
root 16042 0.0 0.4 11708 4264 ? S 16:29 0:00 /usr/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd -a
OR
lsof -i :199
Will give:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME snmpd 16042 root 9u IPv4 2541093 TCP *:smux (LISTEN)
Okay, not what is the tree of information about this network entity?
snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
Will give:
IP-MIB::ipAdEntIfIndex.10.0.0.3 = INTEGER: 4 IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1 IP-MIB::ipAdEntIfIndex.192.168.19.3 = INTEGER: 3 IP-MIB::ipAdEntIfIndex.192.168.20.3 = INTEGER: 2
Or maybe NOTHING!
If NOTHING Do the following:
emacs /etc/hosts.allow
snmpd: 127.0.0.1
or
emacs /etc/snmp/snmpd.conf
And change the following: config
com2sec notConfigUser default public com2sec local localhost public com2sec mynetwork 192.168.0.0/24 public Change 192.168.0.0/24 with your networks IP range group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork view systemview included .1.3.6.1.2.1.1 view systemview included .1.3.6.1.2.1.25.1.1 view all included .1 access notConfigGroup "" any noauth exact systemview none none access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none syslocation Unknown (edit /etc/snmp/snmpd.conf) syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf) syslocation Linux (Version Here), Purpose Here. syscontact Just A. Geek <you@email.whatever>
/etc/init.d/snmpd start
Okay, now let's run this command again. What do we get?
snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1 IP-MIB::ipAdEntIfIndex.xxx.xxx.xxx.xxx = INTEGER: 2
Can we run this command a against an external server?
snmpwalk -v 1 -c public ipaddress IP-MIB::ipAdEntIfIndex
To set snmpd to start on a restart:
chkconfig --add snmpd
Firewall for snmp
echo -n ...snmp $IPT -A INPUT -p TCP -i $EXTETH -s $i --destination-port 161:162 -j ACCEPT $IPT -A INPUT -p UDP -i $EXTETH -s $i --destination-port 161:162 -j ACCEPT
Where $IPT is the path to iptables. Where $i is an external ipaddress that you let in. Where $EXTETH is the external ethernet card.
Setting up The Web Site
Go to http://your.site/cacti/ Most likely you can not see anything. So add this file...
emacs /etc/httpd/conf.d/cacti.conf
Alias /cacti/ /var/www/cacti/ <Directory /var/www/cacti/> DirectoryIndex index.php Options -Indexes AllowOverride all order deny,allow
- deny from all
- allow from 127.0.0.1
allow from all OR deny from all allow from 127.0.0.1 allow from xxx.xxx.xxx.xxx
AddType application/x-httpd-php .php php_flag magic_quotes_gpc on php_flag track_vars on </Directory>
php.ini
sed -ie 's/.*memory_limit.*$/memory_limit = 128M/' /etc/php.ini \ && grep memory_limit /etc/php.ini
emacs /etc/php.ini
[Date] ; Defines the default timezone used by the date functions ; http://www.php.net/manual/en/datetime.configuration.php date.timezone = Pacific/Auckland
/etc/init.d/https restart
Using yum to install was nice and straight forward. The only issue was that the rrd files did not get created.
They were created when I ran:
su cactiuser php /var/www/cacti/poller.php
Cacti, SNMP & Windows
XP
These steps were taken from http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sag_snmptopnode.mspx?mfr=true
To install the SNMP service
You must be logged on as an administrator or a member of the Administrators group in order to complete this procedure. If your computer is connected to a network, network policy settings may also prevent you from completing this procedure. Open Windows Components wizard To open the Windows Components Wizard, click Start, click Control Panel, click Add or Remove Programs, and then click Add/Remove Windows Components.
- In Components, click Management and Monitoring Tools (but do not select or clear its check box), and then click Details.
- Select the Simple Network Management Protocol check box, and click OK.
- Click Next.
- You will be asked for the original installation CD
- Provide this and continue.
- When Finished Click on Finished.
- Close Add Remove Programes
SNMP starts automatically after installation.
This was all I needed to do to be able to have SNMP working. I have a Linux Server running Cacti, getting the snmp data from a Windows
To get around the Windows defalt firewall I ran this at a command line.... netsh firewall add portopening all 161:162 snmp enable custom xxx.xxx.xxx.xxx/32 Where xxx.xxx.xxx.xxx/32 is the ip address of my Linux Server doing the Cacti/SNMP monitoring
Windows Server 2003 & 2008
Setting up a win 2003 server is the sam as XP except you many need to also do the following.... Control Panel -> Turn WIndows features on or off -> Configuration -> Services -> SNMP Service (Double Click) Then the Security TAB
- Add a Community called public with Rights of READ ONLY.
- Set up the IP address of the Linux box running Cacti that is going to query this win 2003/2008 server.
Plugins
http://docs.cacti.net/plugin:thold http://docs.cacti.net/plugin:monitor http://docs.cacti.net/plugin:docs Down load and install the Plugin Architecture (PIA) from here http://www.cacti.net/downloads/pia/
wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz
then
tar -zvxf cacti-plugin-0.8.7h-PA-v3.0.tar.gz
Now install using the the pre-patched full files. http://docs.cacti.net/manual:087:1_installation.9_pia
Download the settings plugin first
wget http://docs.cacti.net/_media/plugin:settings-v0.71-1.tgz
Extract
tar -zvxf cacti-plugin-arch.tar.gz
Down load the plug ins desired.
Setting up Cacti Thresholds
Customising Cacti
Trango
Setting up Custom Graphs using SMNP
For a device to be queried for MIB information via SNMP we need a .xml file in <path_cacti>/resource/snmp_queries/ Data Queries
- This file is referenced in Data Queries under XML Path
- You may need to create a new Data Queries.
This Data Queries will need to be set up with a Data Input Method of Get SNMP Data (Indexed) Once you have a Data Queries, you need Associated Graph Templates. Once for each section of the .XML file that is querying MIBs area.
- The Associated Graph/Data Templates has a Name and a Graph Template.
- Make sure the Graph Template is set to the correct Graph.
- The correct Graph may not yet be created. You may do this later and need to come back here to set this correctly.
- In an Associated Graph Templates there will be fields automatically inserted from the .XML file for the Data Source, you will need to insure that the right DropDown is being setup and to place a Tick in the right hand tick box.
- Data Templates
- We now need a Data Templates to correctly receive the devices data for a RRD file.
The easiest way I have found to create a Data Template is to use an existing one of a similar type. IE use an Ethernet Traffic one to build a Radio Traffic Data Template. I have found that the Data Source - Step needs to be 300 and each Data Source Item - Heartbeat to be twice that, 600. At this point the Data Template does not know what .XML file is sending the data.
Graph Templates
We now need a Graph Templates to make use of this collected data in a Graph.
Again the easiest way I have found to create a Graph Template is to use an existing one of a similar type. Two areas need to be edited.
- Each Graph Template Item needs to be opened and edited to make sure the Data Source is pointed at the correct Data Template, Data Source, Data Source Item (set up in the previous section)
- Once all of these have Graph Template Items have been setup, you will most like have extra Graph Item Inputs we only what the Data Sources that relate to the # # Graph Template Items.
- Go in to each Data Source, the ones we want to keep are the ones with a tick in the Associated Graph Items.
- We now have a Graph Templates with an associated Data Template, but no link to the .XML that knows how to get the data from the device.
New Graphs
Now we create a Graph for a Device.
- The Device we want to graph should have already been created under Devices.
- Under New Graphs choose this device.
- Under Data Query choose the Select a graph type: and CREATE.
- Graph Management
- Under Graph Management choose this new Graph, and Turn On Graph Debug Mode.
You will most likely get an error because the associated .rrd files does not yet exist. We need to note this file and make sure it is the same file as refrenced in the Data Sources. Check that the Supplemental Graph Template Data, Graph Item Fields Data Sources are constant with the type of Graph Template and type of Data Template as we would expect.
Data Sources
Under Data Sources choose this new Data Source for this Graph, and Turn On Data Source Debug Mode.
- Check that the step, 300 and Heartbeat, 600 are correct.
- Check that the Data Source Fields, Data Source Path is the same as in the Graph Management RRDTool Command readout.
- Check that the Custom Data, Index Type - Index Value - Output Type ID are correct.
- This is where the link is back to the original .XML file in the Data Queries
- This will take some understanding of how the .XML file at the very beginning of this page has been constructed.
- Working with .XML files, Data Queries, Graph Templates and Data Templates that already work you can backtrack to see if and why your new Custom Cacti are or are not working.
Setting Up Graphs
Cacti & aiContact
Mail Scanner
Step 1
- Gain SSH access
- Login
- su
- Go To = pico /etc/snmp/snmpd.conf
- Scroll Down Till You Find = #Executables/scripts
Step 2
- Open "cacti server"
- Gain SSH access
- Login
- su
- Go To = pico /etc/snmp/snmpd.conf
- Scroll Down Till You Find = # Executables/scripts
Step 3
Look at the "Executables/scripts" information from the "cacti server" and make sure it is equal to the new site If this is not the case then add the information from the "cacti server" to the new intended site.
Then type the following code = /etc/init.d/snmpd restart Test The Following Code /var/www/html/iserver/snmp/mailscanner-inq.sh /bin/sh /var/www/html/iserver/snmp/mailscanner-outq.sh The result should be 0
Step 4
In Cacti = mail.ai.net.nz/cacti/
- Console go to "Newgraph"
- Make a Graph For = Mail Scanner & CPU Usage
- Create Each One Individually
(LEAVE EVERYTHING AS DEFAULTS)
Step 5
How To Add To Mailing List
- Graph Trees
- @ Processes
- ADD (Right Hand Side)
- Parent Item = Emails
- Tree Item Type = Graph
- Graph = CPU Usage & Mail Scanner Individually
Cacti Monitoring Backups
Steps for setting up Cacti to graph backups.
Cacti Prerequisites
- Create a new User under **User Management**
- The quickest way is to copy an existing one with the desired permissions and edit as needed.
- **New Username** no spaces and no capitals
- **New Full Name** FQDN that links later to the **Devices**
- **New Realm** local
- The quickest way is to copy an existing one with the desired permissions and edit as needed.
- Edit the new user:
- **Realm Permissions** just **View Graphs**
- **Graph Permissions (By Device)** Add the host for this customer
Cacti Graph Settings
- Log on to the server needing the graphs, i.e. mail.ai.net.nz
- emacs /var/www/inet/configure/python.cfg
- In the **[rsync]** section
- In the **directories = ** area
- Add **var/log/rsync* ** to the end of the area
- Save and run **python /var/www/inet/python/rsync_inet_backup.py delete**
- Log on to the weekly backup server
- Check that the files for rsync exist
- These are at **ll /backup.server/daily/mail.ai.net.nz/var/log/rsync.***
- And should be something like:
- -rw-r--r-- 1 root root 2050 Dec 18 02:05 /backup.server/daily/mail.ai.net.nz/var/log/rsync.mail.ai.net.nz.var_spool_mail
- -rw-r--r-- 1 root root 228401 Dec 18 02:05 /backup.server/daily/mail.ai.net.nz/var/log/rsync.mail.ai.net.nz.var_www
- Now create the needed graphs
- Log on to http://cacti.ai.net.nz/cacti/
- Go to **console**
- Go to **New Graphs**
- Choose the Host, i.e. mail.ai.net.nz
- Under **Graph Templates**, under **Create: (Select a graph type to create)** choose **BkUp Bytes Hr**
- Tick **Graph Template Name**
- Press Enter
- Under **Title** add the Directory being graphed i.e. **(Home)**
- Under **Backup Site** add this site, mail.ai.net.nz
- Under **Dir being Backed** add the dir being monitored **home**
- Click on **create**
- Do this for **home, boot, etc, var/lib, var/www** and may be some **zone** areas.
- Do this again for **BkUp Files Hr**
- Place these graphs in the **Must Monitor** Graph tree under **Backups**
- To do this go to the left hand **Graph Management**
- Choose the Host you have just created for.
- Search on **(**, this is the best way to get to all the back up graphs
- Select all
- Under **Choose an action:** chose **Place on a Tree (Must Monitor)**
- Under **Destination Branch:** choose **Backups**
- Choose **yes**
- In a couple of hours these graphs will begin to appear with a line.