Cacti monitoring
This is solution to monitor Internet access within UK and continental routes to US using continious ICMP message generated by Cacti. The setup varies but relays on SOHO customer grade routers connected over 3G mobile network, ADSL or radio point-to-point link. None these devices are SNMP enabled therefore having a little options we use continuous ping to certain POP and analyzing a ping latency it should provide us with reliability of the link. The Cacti package http://www.cacti.net/index.php will be used to draw graphs and coupled with Nectar plugin http://docs.cacti.net/plugin:nectar to email reports on a regular basis.
Tested environment
Hardware: Dell Laptop D620 / D630
OS: Ubuntu 13.04 and 13.10 Server 64 bit
Even if your setup may be different the steps below should still apply to any Debian based distro. Advised working steps are:
- Install Ubuntu Server 13.10 64 bit text version, with OpenSSH package only
- do packages updates
- install packages: smtp, exim4, cacti, download and extract cacti's plugins
- Optional: install desktop environment xubuntu (sudo apt-get install xubuntu-*) with XFCE
- Configure syslog-ng
Install wireless connection on Dell 620/630
sudo apt-get update sudo apt-get install firmware-b43-installer sudo apt-get remove bcmwl-kernel-source sudo reboot
Full guide is here Linux Broadcom BCM43xx drivers
Install email system and dependency packages
sudo apt-get install apache2 snmp snmpd #install Cacti required packages sudo apt-get install exim4 #installing email system to allow send emails MTA sudo dpkg-reconfigure exim4-config #configure exim4
Set the following (Google smtp services: smtp.gmail.com:465 or smtp.gmail.com:587)
General type of mail configuration: mail sent by smarthost; no local mail System mail name: (default) IP-addresses to listen on for incoming SMTP connections: 127.0.0.1 Other destinations for which mail is accepted: (default) Visible domain name for local users: localhost IP address or host name of the outgoing smarthost: smtp.gmail.com::587 Keep number of DNS-queries minimal (Dial-on-Demand)? No Split configuration into small files? No
Note: Visible domain name for local users its is advised every where to use real domain name but if you do not have one Gmail will be returnig:
Subject: Delivery Status Notification (Failure)
Delivery to the following recipient failed permanently:username@your.fooled.domainname.com
Technical details of permanent failure:
DNS Error: Domain name not found
- INFO from Debian site and link to forum forums.debian.net
2.1.1.10. Visible domain name for local users If you ask Exim to hide the local mail name in outgoing mail, it will next ask you for the domain name that should be visible for your local users. These information is then used to establish the appropriate rewriting rules.
The exim4 SMTP server is now set to route emails through Gmail. Now all we need to do is to tell exim4 the username and password we are going to use. To accomplish this create a text file if it is not already created called /etc/exim4/passwd.client. Add 3x lines as you see below to allow connecting to Gmail:
# password file used when the local exim is authenticating to a remote # host as a client. # # see exim4_passwd_client(5) for more documentation # # Example: ### target.mail.server.example:login:password gmail-smtp.l.google.com:you@gmail.com:password *.google.com:you@gmail.com:password smtp.gmail.com:you@gmail.com:password
Replace you@gmail.com:password with your login information.
Reload the exim4 server:
sudo /etc/init.d/exim4 reload
To test the configuration launch a terminal and type:
echo 'ok' | mail -s 'Gmail SMTP Relay Test' youremail@domain.com
Email system Exim/Mutt troubleshooting
To preview exim4 logs
cat /var/log/exim4/mainlog tail -1000f /var/log/exim4/mainlog
To check connection to smtp.gmail.com:587, you should receive these 3 lines:
telnet smtp.gmail.com 587 Trying 173.194.67.108... Connected to gmail-smtp-msa.l.google.com. Escape character is '^]'. 220 mx.google.com ESMTP w4sm36472599wia.9 - gsmtp
Flush frozen messages
exiqgrep -z -i | xargs exim -Mrm # list messages, require root exim -bpu | grep frozen | awk {'print $3'} | xargs exim -Mrm # flush messages, require root
Install Cacti
Please issue the command below to install cacti, it will download ~127Mb
sudo apt-get install cacti
You will be prompt for MySql "root" user password Please accept information about changed path Select 'apache2' as webserver, installation script will start configuring all necessary
You will be prompted:
Configure database for cacti with dbconfig-common? Yes Please provide the password for the administrative account with which this package should create its MySQL database and user. Password of the database's administrative user: ****
Please provide a password for cacti to register with the database server. If left blank, a random password will be generated. MySQL application password for cacti: ****
Now your Cacti is configured. Please go to http://localhost/cacti/ to finish configuration.
Select 'New Install', and details should be as follow, press next
The following information has been determined from Cacti's configuration file. If it is not correct, please edit 'include/config.php' before continuing. Database User: cacti Database Hostname: localhost Database: cacti Server Operating System Type: unix
Check for dependency programs, if every path is green, then press next
Default username: admin
Default password: admin
Then you will be forced to change admin password.
Nectar plugin installation
- PIA preparation
The Plugin Architecture (PIA) is a set of code changes to core cacti. The Plugin Architecture for Cacti was designed to be both simple in nature and robust enough to allow freedom to do almost anything in Cacti. - http://docs.cacti.net/manual:087:1_installation.9_pia
Note: Cacti ver 0.8.8a has PIA 3.1 built-in however symbolic links are still required by Debian based distros (not sure about other distributions), therefore please proceed as follow
- Navigate to Cacti install path: /usr/share/cacti/site/ and preview README.Plugins file
piotr@ubuntu:/usr/share/cacti/site/plugins$ cat README.Plugins If you read this and care about keeping your system maintainable, please change the layout of the plugins structure of cacti. Due to the way a lot of plug-ins are written (details in bug #681558) in combination with Debian policy, I can not fix this in the package. * Create a directory /usr/local/share/cacti/plugins: mkdir /usr/local/share/cacti/plugins * Move all content of /usr/share/cacti/site/plugins to /usr/local/share/cacti/plugins mv /usr/share/cacti/site/plugins/* /usr/local/share/cacti/plugins/ * Remove the empty /usr/share/cacti/site/plugins directory rmdir /usr/share/cacti/site/plugins * Create the following symlinks: ln -s /usr/local/share/cacti/plugins /usr/share/cacti/site/plugins ln -s /usr/share/cacti/site/include /usr/local/share/cacti/include ln -s /usr/share/cacti/site/lib /usr/local/share/cacti/lib -- Paul Gevers <elbrus@debian.org> Wed, 01 Aug 2012 22:32:32 +0200
- Issue all commands from above, or from combined here below with sudo added
sudo mkdir /usr/local/share/cacti/plugins sudo mv /usr/share/cacti/site/plugins/* /usr/local/share/cacti/plugins/ sudo rmdir /usr/share/cacti/site/plugins sudo ln -s /usr/local/share/cacti/plugins /usr/share/cacti/site/plugins sudo ln -s /usr/share/cacti/site/include /usr/local/share/cacti/include sudo ln -s /usr/share/cacti/site/lib /usr/local/share/cacti/lib
The latest plugins can be downloaded from http://docs.cacti.net/plugins we are going to install Nectar plugin to email graphs on a regular basis.
- Download Nectar plugin to a user home folder al line 1. Then in order to install the plugin, extract the plugin to the default Cacti's plugins directory: /usr/local/share/cacti/plugins/
wget http://docs.cacti.net/_media/plugin:nectar-v0.35a.tgz -O ~/nectar-v0.35a.tgz sudo tar -xvf nectar-v0.35a.tgz -C /usr/local/share/cacti/plugins/
The newly installed plugin should now be showing up in the cacti menu Console --> Plugin Management. To activate go to Console/Utilities/User Management and enable the 'Plugin Management' realm for your admin user, then go to Console/Configuration/Plugin Management and click the 'Enable Plugin' icon
Settings plugin installation
On the top of Nectar plugin the 'Settings' plugin is required to properly sent emails. It provides additional API features like: DNS Lookup API and a Mailer API. Please follow to install the plugin. Nectar plugin link http://docs.cacti.net/plugin:settings
- Download and extract to default Cacti's plugin directory
wget http://docs.cacti.net/_media/plugin:settings-v0.71-1.tgz -O ~/settings-v0.71-1.tgz sudo tar -xvf settings-v0.71-1.tgz -C /usr/local/share/cacti/plugins/
The newly installed plugin should now be showing up in the cacti menu Console --> Plugin Management. To activate go to Console/Utilities/User Management and enable the 'Plugin Management' realm for your admin user, then go to Console/Configuration/Plugin Management and click the 'Enable Plugin' icon
Then go to Settings and you find a new Mail/DNS tab. Having mail system setup already, press 'Save'. I was successful to email graphs generated by Nectar plugin. As far I do understand the Settings plugin it sends the Nectar generated email to localhost on port 25, and the email is relayed on by the mail system to the destination email address specified in the report. In my configuration exim4 is configured to relay the mail to Gmail server. Then Gmail server is sending to destination email address.
How to configure Cacti
- Update Localhost device
Go to Devices > click on Localhost > in SNMP Option section choose SNMP Version 2 from drop down menu > press save. If snmp and snmpd packages are installed you will see SNMP Information at top left corner.
- Add new devices
Go to Devices > press Add (right top corner) > set to as below and leave other settings with defaults > press Create
Description: Ping Google-8.8.8.8 Hostname: 8.8.8.8 Downed Device Detection: Ping Ping Method: ICMP Ping SNMP Version: Not In Use
-Then at Associated Graph Templates section choose from drop down menu: Unix - Ping Latency, then press Add in the same line. This adds graph template to the device
- Add graphs to the device
- Then at the top of screen click link '*Create Graphs for this Host', Host field will be already populated with the host name Google-8.8.8.8
- Tick next to Create: Unix - Ping Latency and press create
- Add Legend Text: Ping Latency, press Create to finish creating a graph for the device
- Add Data Sources to the device
- Press at the Device menu '*Data Source List', host will be populated, tick next to Unix - Ping Host and Choose an action: Enable, then press Go.
Configure new Nectar (email) report
- Go to Nectar tab, click Add new at top right corner, then fill in as follows:
- Report name: your report name
- Subject: it will be the email subject
- From Name: input superhost email address you configured with exim4
- From Email Address: input superhost email address you configured with exim4
- To Email Address(es) Please seperate multiple adresses by comma (,): it can be any email adders/addresses that superhost (email server) will forward the report to
- Navigate to Items press Add to add graphs. The easiest is to add all tree graphs so:
Type : Tree Graph Tree : <select tree to be added> Graph Tree Branch <all>
Howtos
Change Graph Title
- Go to Console>Graph Templates in my case: Interface - Traffic (bits/sec) template
- In Graph Template section, tick: Use Per-Graph Value (Ignore this Value)
- Go to Console>Graph Management>pick a graph you want to change the name. Make sure that in 3rd column: Template Name editing graph is using the template you edited in step #1
- You will find new field in section Supplemental Graph Template Data\subsection Graph Fields called: Title (--title)
The name that is printed on the graph. that you can now change
Resolved problems
- With the settings above I was unsucessfuly to send the report being on Vodafone network (their 10.x.x.x private ip). It may also requires full details in DNS/Mail tab. Similar like on photo from this link
- Answer: adding superhost email address to 'From Name This Name will be used as the default E-mail Sender' resolved the problem, http://forums.cacti.net/download/file.php?id=23717&sid=edef763bb9941907e2b860570c066447
- Extracted plugins to the default plugin path are not visible under Plugin Management tab.
- Answer: stop apache2 service, then purge cacti, apache2, apache2-utils. When reinstaling install apache2 first then cacti. Please re download, extract plugins into the default plugin directory /usr/local/share/cacti/plugins/
SNMP
- Simple Network Management Protocol Cisco wiki