Wednesday, July 20, 2016

Telegraf, InfluxDB and Grafana on Armbian (OrangePi )

InfluxDB and Grafana

Here we will describe how to install Telegraf, InfluxDB, and Grafana on an Orange Pi computer running Armbian.

InfluxData  provides a suite of applications supporting Data collection (Telegraf), Time series Data storage, (InfluxDB) Data processing and alerting (Kapacitor), and Visualization (Chronograf)

Armbian supports installation of Debian and Ubuntu images for installation on a number of ARM based computers. For example Orange Pi, Banana Pi and a number of other similar devices.
The installation procedure below

Grafana is a Dashboard that can receive data from InfluxDB as well as other sources as Graphite and present it as graphs.

Typically Telegraf, Grafana and InfluxDB are installed on one computer. For other computers that are to be monitored only, only Telegraf installation is needed.

InfluxDB from Debian Repo

InfluxDB suppports a Debian repository including an armhf  package. A slightly modified procedure is shown below.


curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/os-release
test $VERSION_ID = "7" && sudo echo "deb https://repos.influxdata.com/debian wheezy stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
test $VERSION_ID = "8" && sudo echo "deb https://repos.influxdata.com/debian jessie stable" | sudo  tee  /etc/apt/sources.list.d/influxdb.list

sudo apt-get update && sudo apt-get install influxdb telegraf

Grafana

It seems there is no Debian repository of  Grafana in Wheezy or Jessie. There is however support in 'stretch', the new Debian version.

sudo echo "deb https://repos.influxdata.com/debian stretch main  contrib non-free" | sudo  tee  /etc/apt/sources.list.d/grafana.list

sudo apt-get install grafana


Verification

Check that these are "active running":

sudo systemctl status influxdb.service
sudo systemctl status telegraf.service
sudo systemctl status grafana.service

These are my installed versions

anders@orangepi1:~$ dpkg -l | egrep -e "influx|telegraf|grafana"
ii  grafana             2.6.0+dfsg-3   armhf   feature rich metrics dashboard and graph editor
ii  grafana-data    2.6.0+dfsg-3    all       feature rich metrics dashboard and graph editor - data files
ii  influxdb           0.13.0-1      armhf     Distributed time-series database.

ii  telegraf            0.13.1-1       armhf   Plugin-driven server agent for reporting metrics into InfluxDB.


Configuration

Configuration is mostly left as an exercise for the reader. There ares several guides out there. 

Telegraf should be sufficiently configured by using the default configuration. When connfiguring on the monitored computer, change InfluxDB configuration from localhost to the remote IP or name of the computer on which InfluxDB is installed.

 vi /etc/telegraf/telegraf.conf 


InfluxDB configuration should be satisfactory wirh the default for many cases

vi /etc/influxdb/influxdb.conf

Grafana is available using a browser at port 3000:
e.g http://orangepi1:3000/

Add InfluxDB as Datasource

Sunday, April 26, 2015

Installing the Cacti Flowview plugin for Debian 7 Wheezy

Preparing for plugin installation

 # According to the file, /usr/share/cacti/site/plugins/README.Plugins , the directory structure shall be moved into a new location

sudo mkdir /usr/local/share/cacti/plugins
sudo mv /usr/share/cacti/site/plugins/* /usr/local/share/cacti/plugins/

# Remove the empty /usr/share/cacti/site/plugins directory

sudo rmdir /usr/share/cacti/site/plugins


# Create the following symlinks:

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


Installing the Flowview plugin

# The current plugin version is fetched from this URL:
http://docs.cacti.net/plugin:flowview

cd /usr/local/share/cacti/plugins/
sudo wget http://docs.cacti.net/_media/plugin:flowview-v1.1-1.tgz
sudo mv plugin\:flowview-v1.1-1.tgz flowview-v1.1-1.tgz
sudo tar xvf flowview-v1.1-1.tgz

# Now proceed to  'Plugin Management' in the Cacti web.
Flowview should be listed among the available plugins.
Install and then enable the plugin by clicking in 'Actions' column.
A 'Flows' tab should now be available at the top of the page

Configure PHP timezone

# Set your local  timezone
 sudo nano /etc/php5/apache2/php.ini 
     date.timezone =Europe/Stockholm

sudo service apache2 restart

Install and configure flow-tools


sudo apt-get install flow-tools

# Prepare a storage directory for your different netflows. Here I will configure my WAN router.
sudo mkdir -p /var/flow/wanrouter

# In Cacti->Console->Settings->Tab:Misc
# Set 'Flows Directory' to /var/flow
# Add your local DNS caching server or Googles 8.8.8.8

# Replace the native flow-capture init script with the Flowview specific replacement
sudo service flow-capture stop
sudo cp /etc/init.d/flow-capture /etc/init.d/flow-capture.org
sudo cp /usr/local/share/cacti/plugins/flowview/flow-capture /etc/init.d/flow-capture

Add a flow-capture listener

# Edit flow-capture configuration. Comment out the existing examples
# flow-capture is not configured by this file. It is configured in the Cacti Listener Tab.

sudo nano /etc/flow-tools/flow-capture.conf
 

# In Cacti add the a listener for the wanrouter
Tab:Flows ->Tab: Listeners -> Add

# Restart flow-view service when a new listener has been added
sudo service flow-capture start

# NOTE, deleteing listeners does not work in flowview 1.1-1
# For a solution apply the patch here:
# http://bugs.cacti.net/view.php?id=2463



Configure your device to send netflow information

# My router is an Ubiquity Edgerouter POE with the WAN interface connected to eth0

configure
set system flow-accounting interface eth0

# Needs version 9 or 10;  set system flow-accounting netflow enable-egress

set system flow-accounting netflow server 192.168.1.56 port 2055
set system flow-accounting netflow version 5
commit

# The commit messages says that egress accounting is registered, even though I did not configure the enable-egress command above. Maybe some kind of misunderstanding from by side.


Verify netflow sent from the router

Verfify that netflow is sent from your device by sending the file contents to the flow-print command
flow-print < /var/flow/wanrouter/<Date>/<filename>

Additional Netflow software

Here is an extensive list of open source and closed source software



Saturday, April 25, 2015

Installing Cacti on Debian

# Here are some notes taken during installation of Cacti on Debian 7, on a Cubieboard 2.

#  Install PHP, apache2 and mysql-server first and then install Cacti.

sudo apt-get update
sudo apt-get install apache2
sudo apt-get install mysql-server

# Configure mysql server with root password. For the rest of the questions answer Yes.
sudo mysql_secure_installation

# PHP installation (Before Debian 7 Wheezy add php5-suhosin )
 sudo apt-get install php5 php-pear php5-mysql

# Configure PHP installation info from the server by adding the following lines into info.php:

sudo nano /var/www/info.php

<?php
phpinfo();
?>

# Restart Apache to apply the new configuration

sudo service apache2 restart

# Verify that Apache and PHP was installed successfully by entering the following URL
# http://<Ip address of your server>/info.php
# Information regarding the PHP installation is shown in the browser.

# Now it is  time  to install Cacti

sudo apt-get install cacti


# Remove comment ('//') before $url_path and $cacti_session_name last in debian.php file

sudo vi /etc/cacti/debian.php

# Link Cacti Web server configuration to the apache2 config directory. My Apache version is 2.2

sudo ln -s /etc/cacti/apache.conf /etc/apache2/conf.d/cacti.conf

# Restart Apache to apply the new configuration

sudo service apache2 restart

# Enter the following URL in your browser  http://<Ip address of your server>/cacti
# Follow the instructions. The user /password is admin/admin
# After having logged in, the web console is ready for configuration of devices and graphs for your devices.






Wednesday, December 11, 2013

Build and install telldus-core on Debian

 Build and install telldus-core from Telldus' Debian source

Building Telldus core from source on Debian Linux.
 Thanks to Itslav

Preparing build environment


sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install cmake libconfuse-dev libftdi-dev help2man

Building telldus-core

# set up debian source to use use the stable version of the Telldus software. This is the source code repository. (There are precompiled sources as well)

sudo nano /etc/apt/sources.list.d/telldus.list
# Enter row below into the file:
deb-src http://download.telldus.com/debian/ stable main

# Fetch and configure public key
wget http://download.telldus.se/debian/telldus-public.key
sudo apt-key add telldus-public.key

sudo apt-get update

sudo apt-get build-dep telldus-core

mkdir -p ~/telldus-temp
cd ~/telldus-temp

sudo apt-get --compile source telldus-core

sudo dpkg --install *.deb

Optionally remove code directory:
cd ; rm ~/telldus-temp

Now there is a tellldus daemon started. (It is here /etc/init.d/telldusd)