wiki:administration/cacti
close Warning: Can't synchronize with repository "(default)" (/usr/svn/silverfile does not appear to be a Subversion repository.). Look in the Trac log for more information.

Version 6 (modified by greg, 13 years ago) (diff)

--

monitor.silverfilecorp.com:2240 (no login yet, need to get into sudoers)

Cacti Server and Remote Host Setup

Initial Cacti Server Setup

This part needs to be done only once

Create a new user on the Cacti server named 'cacti' to run the ssh tunnels

###create the user and home directory. -m = make home directory
pw useradd cacti -m
###set the password for cacti and keep a safe copy.
passwd cacti

Create the private/public key for authentication

###This should be run from the cacti server logged in as the cacti user
###Press enter twice to accept the defaults. Use no pass phrase.
ssh-keygen -t rsa

Create a bash script to open up the ssh tunnels. We need to figure out the best way to close the tunnels before this script runs once we have many SilverFile? boxes to monitor. If the script is run while the existing tunnels are open, additional tunnels will be opened up which will get messy. Perhaps a perl or python script would be better for this.

###Create the file from the cacti user's home directory
vim tunnels.sh
###Add the following to the file

-----
###This should be run from the cacti server logged in as the cacti user.
#!/bin/sh
rm /home/cacti/tunnel.log
###Server1.remotesilverfilebox.com
### Each additional SilverFile box will get an entry like this one. The tunnel port number will
###increase by one and the box address will be unique. 
ssh -N -L 16000:127.0.0.1:161 snmp@server1.remotesilverfilebox.com >> /home/cacti/tunnel.log &
###Example of next remote host
###ssh -N -L 16001:127.0.0.1:161 snmp@server2.remotesilverfilebox.com >> /home/cacti/tunnel.log &

Make the file executable

chmod +x tunnels.sh

That's it until we have a remote host to monitor.

Remote Host setup

Setup snmp and a no-login user to tranfer the data to the Cacti server

Install snmp and some snmp utilities

###Install snmp and run it as a daemon
apt-get install snmpd
###Optional, intall some tools to use for testing if you want
apt-get install snmp

Create a backup of the conf file and add our settings

###Make a copy of the original
cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
###Edit snmpd.conf
vim /etc/snmp/snmpd.conf

Change (or comment out and add a new line) the line starting with com2sec so it reads:

com2sec readonly default public (where public is the name of our community string)

And add the following line to switch the port from upd to tcp

agentaddress tcp:161

Restart the snmpd daemon

/etc/init.d/snmpd restart

Optional: Test that snmp is producing data

snmpwalk -v 1 -c public tcp:localhost:161

Make a new user for the ssh tunnel to connect to.

###add a regular user w/login for now. We'll remove login-ability later
adduser snmp
###Give snmp a password for now. write it down for later.
passwd snmp

That's all on the remote client for now.

Setup access to remote hosts from the cacti server

Login as the ssh tunnel user and copy the public rsa key to the remote host.

###While logged in as ssh tunnel user.
###This will connect to the remote host, create the ~/.ssh directory on the remote host and create then write
###the public rsa key to the file ~/.ssh/authorized_keys. If the authorized_keys file already exists the key will 
###be appended to the file.
cat ~/.ssh/id_rsa.pub | ssh snmp@krs.bit-box.com 'mkdir .ssh && cat >>.ssh/authorized_keys'

Edit the tunnels.ssh file by adding the new host in a line similar to the others. Increase the 16000 range port by one and use the new host's url. Save the file. make the file executable

chmod +x tunnels.sh

At this point it might be best to just initiate the tunnel from the command line. Once we get a script that will kill all the existing tunnels and then re-establish them all we'll be able to just run the script. For now Just copy the line you added to the script and run it from the command line.

Now just log into the Cacti web-admin and configure the new client. Click on Devices and add a new device. The settings should be: Description: server1.silverfilecorp.com Hostname: tcp:127.0.0.1 Host Template: ucd/net SNMP Host SNMP Community: public SNMP Version: Version 2 SNMP Port: 16000

Make sure you put in the specific Description, Community and the SNMP Port for that host.

Next configure the graphs you want. Seperate wiki