Zabbix modern dashboard using DASHING
This page explains how to setup Ruby on Rails + Dashing + Zabbix monitoring dashboard.
This is an alternative to the ugly Zabbix default dashboard.
Contents
Sources
- Dashing official website: http://shopify.github.io/dashing/
- Zabbix dashboards:
- Nice looking dashboard: https://github.com/tolleiv/dashing-zabbix
- Simple dashboard: https://gist.github.com/chojayr/7401426
Requirements
Firewall
Dashing is running on the port TCP 3030.
IPTABLES=`which iptables`
$IPTABLES -A OUTPUT -p tcp --dport 3030 -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport 3030 -j ACCEPT
Ruby
Before starting you need to install some packages:
# Install Ruby
sudo apt-get install ruby
sudo apt-get install rbenv
# Ruby dependencies manager
sudo apt-get install bundler
# Javascript library for Ruby
sudo apt-get install ruby-execjs
# Ensure version is >= 1.9.0
sudo ruby --version
To work with Dashing & Zabbix you need some libraries as well:
# Common Ruby libraries
sudo gem install activesupport
sudo gem install execjs
sudo gem install thin
sudo gem install daemon
sudo gem install bundler
# Zabbix required libraries to work with Dashing
sudo gem install zabby
# Dashing library
sudo gem install dashing
Zabbix dashboard
Create a new dashboard
cd ~
dashing new zabbix_dashboard
cd ~/zabbix_dashboard
Remove the Twitter board (if you're not using it)
rm jobs/twitter.rb
[!] If you want to use Twitter dashboard you must adjust the Gemfile.
Get Zabbix dashboard sources
# Get Zabbix dashboard files
cd /tmp
wget https://github.com/tolleiv/dashing-zabbix/archive/master.zip
unzip master.zip
cd dashing-zabbix-master
# Backup default files
mv ~/zabbix_dashboard/Gemfile ~/zabbix_dashboard/Gemfile.backup
mv ~/zabbix_dashboard/README.md ~/zabbix_dashboard/README_dashing.md
# Copy files to your local installation
cp -r * ~/zabbix_dashboard/
Configure dashboard
Set your zabbix credentials
cd ~/zabbix_dashboard/
cp zabbix_credentials.example.rb zabbix_credentials.rb
vim zabbix_credentials.rb
>> You need to set your server URL + credentials. The user must have admin rights.
Dashboard generation
You have to build the dashboard before using it!
cd ~/zabbix_dashboard/
bundle install
[!] NOTE: If you change some files then you need to update instead of install == bundle update
Start dashboard
To start the dashboard you need to launch dashing:
cd ~/zabbix_dashboard/
dashing start
Point your browser at http://localhost:3030 or http://myServer:3030 and have fun!
To see the zabbix dashboard => http://localhost:3030/zabbix_status
Hints
Start dashboard on boot
If you want to start your dashboard on boot you must create a new init.d script.
cd /etc/init.d/
sudo vim dashboard
Put the following content:
#!/bin/bash
### BEGIN INIT INFO
# Provides: dashboard
# Required-Start: $all
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Zabbix dashing dashboard
### END INIT INFO
# This script is based upon: https://gist.github.com/gregology/5313326
set -e
. /lib/lsb/init-functions
# Must be a valid filename
NAME=dashing
DASHING_DIR=/home/vadmin/zabbix_dashboard
PIDFILE="$DASHING_DIR/$NAME.pid"
DAEMON=/usr/local/bin/$NAME
GEM_HOME=/var/lib/gems/1.9.1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$GEM_HOME
DASHING_PORT=3030
DAEMON_OPTS="start -d -p $DASHING_PORT -P $PIDFILE --tag $NAME -D"
### Ensure DASHING is installed
test -x $DAEMON || { log_failure_msg "$NAME not installed";exit 1; }
### This script must be executed as root
function checkuser() {
if [[ $UID != 0 ]]; then
if [[ `whoami` != "$RUNUSER" ]]; then
log_failure_msg "$1 must be run as root or $RUNUSER"
exit 1
fi
fi
}
function start_dashing() {
log_action_msg "Starting daemon: $NAME" || true
sleep 5
start-stop-daemon --verbose --quiet --start --chdir $DASHING_DIR --exec $DAEMON -- $DAEMON_OPTS
log_end_msg 0
}
function stop_dashing() {
log_action_msg "Stopping daemon: $NAME" || true
start-stop-daemon --quiet --stop --pidfile $PIDFILE --retry 30 --oknodo
log_end_msg 0
}
case "$1" in
start)
checkuser start
start_dashing
;;
stop)
checkuser stop
stop_dashing
;;
restart)
checkuser restart
log_action_msg "Restarting daemon: $NAME"
stop_dashing
start_dashing
;;
status)
status_of_proc -p $DAEMON $NAME
;;
logs)
tail -F $DASHING_DIR/log/thin.log
;;
*)
echo "Usage: "$1" {start|stop|restart|status}"
exit 1
esac
exit 0
Set the rights and register the script
sudo chmod 755 dashboard
sudo update-rc.d dashboard defaults
Create symlink
sudo ln -s /etc/init.d/dashboard /usr/bin/zabbix_dashboard
Restart your server to ensure it works!
sudo update-rc.d -f dashboard defaults