Introduction: Install and Setup Shinken Network Monitor on Raspberry Pi
NOTE: shinken was last updated in MAR2016 to a stable release of 2.4.3. So, several years ago I moved on to other ways of doing home network monitoring. In addition, php5 doesn't seem to be available.
So, please do not use this instructable!
Install and setup the latest version of shinken Network Monitor for a home or small business.
At work, my team develops the software for more than 75 server classes, with over 300 instances in multiple data centers and points of presence. There is an experienced operational team that monitors and keeps these servers running 24x7. I don't have anything close to their knowledge or expertise. Besides myself, I have no one supporting my home network. And, I want to spend zero time monitoring and maintaining my home network.
My home LAN has more than 40 connected devices, which is much bigger than I ever expected. Many homes, perhaps even yours, have a large number of connected devices. Examples of networked devices are:
- laptops and tablets
- eBook readers
- cell phones
- nest thermostats, ring doorbells
- security system, irrigation system
- smart TVs, U-verse receivers and DVR
- streaming media servers (Apple TV, Roku, ChromeCast FireStick)
- raspberry pi home automation projects
As more home devices become connected, I expect my network to grow.
Why should a home have a network monitor? There are critical servers and services on a home network. Examples of critical servers include: ISP gateway, wireless access point, security system, and irrigation system. Examples of critical services include: backing up PCs or MACs, ensuring Wi-Fi or internet is operating at required speed. To ensure critical services/servers are running, they should be manually checked at regular intervals, which requires a lot of time. Alternatively, the servers should be automatically checked using a network monitor, which attempts to correct the issue and sends an alert if it is unable to correct.
Shinken is a Network Monitor that runs on any computer. In this instructable, I will get it to run a Raspberry Pi (2 or 3) running Diet-Pi or raspbian.
Many excellent network monitoring applications exist. Examples are: SolarWinds, NetCool, and nagios. These applications are capable of monitoring, identifying issues, self-correcting and sending alerts.
In general, I have been trying to keep my network low-cost and simple to maintain and update. I have narrowed my focus to open source applications written in a small number of languages. My languages of choice are: python, bash, html and css.
Shinken is an open source rewrite of nagios in python. So, shinken fits within my limitations and meets my needs.
The instructable provides step-by-step instructions if you want to do it by hand. But, I want a repeatable process, so I also include an unattended install script in the appendix, which does everything with a couple of commands.If something goes wrong, just run the unattended install and it should fix most issues.
Step 1: Gather Parts
Overtime, I have found the parts below perform best in my applications. These parts are more expensive than those contained in the usual starter kit.
Get parts and tools (prices in USD):
- Raspberry Pi 2 model B (Pi 3) Element14 $35 ($39)
- Panda 300n WiFi Adapter Amazon $16.99 (not needed if Pi 3 is used)
- 5.2V 2.1A USB Power Adapter from Amazon $5.99
- Micro USB to USB cable 3ft from Amazon $4.69
- CAT5e/6 Ethernet cable $x.xx, depends on the length
- Case from Amazon $6.99
- SanDisk Ultra 16 GB microSDHC Class 10 with Adapter (SDSQUAN-016G-G4A) from Amazon $8.99
- Common or reusable items:
- MacBook Pro (I use a MAC because it runs linux as its base OS. However, a Windows PC can be used)
- FTDI TTL-232R-RPI Serial to USB cable from Mouser $15
- TV with HDMI port
- USB keyboard
- USB mouse
- HDMI Cable (only needed on first pass)
Notes:
- Text enclosed in spades, such as, ♣replace-this♣, should be replaced with an actual value. Of course, remove the spades.
- Commands are indicated by a $. If cut-and-pasting commands, do not copy the $.
Step 2: Setup Raspberry Pi
Use this instructable to setup the Raspberry Pi running DietPi. If you prefer, Raspbian can be used with this instructable.
I changed the hostname to ♣monitor-hostname♣. Replace items in ♣'s with actual values.
Step 3: Open Terminal Window and Login
Before each of the following steps:
- Open a terminal window on a MacBook or PC, and then
- Login into Raspberry Pi
$ ssh pi@♣raspberry-pi-ip-address♣
If you installed avahi-daemon on your Raspberry Pi, then you can login this way (I am lazy and I don't want to remember IP addresses):
$ ssh pi♣hostname♣.local
Step 4: Always Upgrade and Update
Before installing new packages on a server, always update and upgrade.
- Update downloads latest package lists from appropriate repositories.
- Upgrade updates the packages
- Autoremove deletes packages that are no longer needed
- Reboot is optional. Some services need to be restarted after an upgrade. Rebooting is the lazy way of ensuring all required services are properly restarted
$ sudo apt-get update -y $ sudo apt-get upgrade -y $ sudo apt-get autoremove $ sudo reboot
Or you can skip all the remaining steps and use the unattended install in one of the appendices.
Step 5: Install Shinken Dependencies
Often shinken runs on a very large server and is installed on a virtual machine (VMs). A large server is capable of running multiple VMs. VMs have many benefits when administering multiple servers, or multiple instances of the same server. VMs make efficient use of expensive server resources.
A virtual machine can run on Raspberry Pi. However, many of the advantages of running a VM on a $35 Raspberry Pi are lost. Shinken does NOT require a VM. This instructable doesn't use a virtual machine.
Install shinken dependencies: sqlite3, php5, python3, and some python libraries:
$ sudo apt-get install sqlite3 -y $ sudo apt-get install php5 -y $ sudo apt-get install python3 -y $ sudo apt-get install python-pip python-pycurl python-cherrypy3 python-setuptools -y
Step 6: Install Shinken
Add shinken user and install shaken using pip.
$ sudo adduser shinken $ sudo pip install shinken $ sudo adduser shinken sudo
The above installs shinken and some daemons in /etc/init.d:
- shinken-poller
- shinken-reactionner
- shinken-receiver
- shinken-scheduler
- shinken-broker
Step 7: Initialize and Start Shinken
Just in case shinken is running, stop it. Also, create a log directory and set the permissions.
$ sudo mkdir /var/log/shinken $ sudo chmod 777 /var/log/shinken $ sudo service shinken stop
Run the following to initialize and start shinken:
$ sudo shinken --init $ sudo /etc/init.d/shinken start
Verify shinken is configured properly:
$ /usr/bin/shinken-arbiter -v -c /etc/shinken/shinken.cfg
Make shinken start on boot
$ sudo update-rc.d shinken defaults
Attachments
Step 8: Setup and Configure Sqlite3
$ sudo shinken install sqlitedb
Create a configuration file to add sqlite:
$ sudo nano /etc/shinken/modules/sqlitedb.cfg
I am using sqlite3. It is unclear how this maps into sqlite3 or into a particular sqlite DB file.
define module { module_name sqlitedb module_type sqlitedb uri /var/lib/shinken/webui.db }
Change permissions on the file
$ sudo chmod 777 /etc/shinken/modules/sqlitedb.cfg
Step 9: Install Shinken Web UI
Install Shinken's Web UI:
$ sudo /usr/bin/shinken search webui $ sudo /usr/bin/shinken install webui Grabbing : webui OK webui
Edit Web UI configuration and change the entry: CHANGE_ME. I am not sure what it is supposed to be change to. I changed to a random word.
$ sudo nano /etc/shinken/modules/webui.cfg
Edit the master broker to include the Web UI modules
$ sudo nano /etc/shinken/brokers/broker-master.cfg
Change the line:
modules
to
modules webui
Restart shinken
$ sudo /etc/init.d/shinken restart
Step 10: Add Users and Passwords
Ensure there is method installed to authorize shinken users
$ sudo shinken install auth-cfg-passwordEdit shinken's Web UI configuration:
$ sudo nano /etc/shinken/modules/webui.cfg
Change to look like:
modules auth-cfg-password
Vince35 suggests a restart is needed at this point:
$ sudo /etc/init.d/shinken restart
Open a browser window and login using password and username: admin, admin. Enter the following in the browser's URL (remove the spaces around the colon):
http : //♣hostname♣.local:7767
login using admin, raspberry-pi-password
And it should work!
Step 11: Appendix: References
Network Monitoring
Network Monitors
- fing: https://www.fingbox.com/features
- HowToGeek.com - excellent source
- MRTG: http://resources.intenseschool.com/network-monito...
- Netbeez: https://netbeez.net/2014/08/19/raspberry-pi-and-di...
- Raspberry Pi Geek: http://www.raspberry-pi-geek.com/Archive/2013/01/...
- Shinken: rewrite of Nagios in python: http://www.shinken-monitoring.org/index.php
- Shinken Install: http://www.roblayton.com/2015/07/manually-setting...
- Shinken Web UI Setup: http://shinkenlab.io/online-course-2-webui/
- GitHub systemd: https://github.com/naparuba/shinken/tree/master/fo...
- Rob Layton: Manually Setting Up a Shinken Monitoring Server
Step 12: Appendix: Updates
15OCT2016: Updated cover image to include Shinken and Raspberry Pi logos
16OCT2016: Rephrased some passages. No technical changes.
19OCT2016: Updated instructable and UAI to start shinken on reboot
Future Enhancements:
- Add systems to be monitored, either in the instructable or as an appendix with example scripts
Step 13: Appendix: Troubleshooting
Change permissions on Directories
/usr/bin /etc/init.d /etc/shinken /var/lib/shinken/modules/webui/ /etc/shinken/modules/
I restarted the Raspberry Pi, but shinken wouldn't start. I couldn't write to the log directories. So, I made the following changes:
sudo mkdir /var/log/shinken sudo chmod 777 /var/log/shinken
shinken localhost down
If localhost shows as down.
$ sudo nano /etc/network/interfaces
For whatever reason, my /etc/network/interfaces file is usually messed up. Change this one line:
auto lo iface lo inet loopback
to these two lines:
auto lo iface lo inet loopback
And reboot
$ sudo reboot
The init.d should start shinken automatically, but I had to do this:
$ sudo /etc/init.d/shinken restart
Step 14: Appendix: Unattended Install
Make shinken installation and configuration very easy by automating the instructable steps using a bash unattended install script. The script assumes a raspberry pi running raspbian or dietpi, which was setup using one of the embedded links.
I finished the script on github and
- tested the source on dietpi
- tested unattended install script on dietpi
- ran one time
- ran multiple times, with CTRL-c interrupts
- tested unattended install script on raspbian and diet-pi
The script assumes the username = pi, and the password = raspberry, and the script is trying to install shinken. If these aren't correct, then edit the file accordingly.
Open terminal window on a MacBook or PC and run the following commands:
$ ssh pi@♣ip-address♣ $ sudo wget "https://raw.githubusercontent.com/dumbo25/uai_install_shinken_rpi/master/shinken_uai.sh $ sudo chmod o+x shinken_uai.sh $ sudo bash shinken_uai.sh $ sudo reboot $ sudo /etc/init.d/shinken restart
The script takes a few minutes to run on diet-pi.
Be sure to reboot the Raspberry Pi and wait until shinken starts
Open a browser and in the URL window enter:
<a>http://♣ip-address♣:7767</a>
Login in using admin and ♣raspberry-pi-password♣
And it should work!