Jump to content
Offsite

Dashing your labtech server with an Ubuntu VM

Recommended Posts

Hey everyone!

 

Big thanks to Martyn for allowing me to update his guide.

I've recently started a project using dashing & it's worked well so far. So I thought I'd update his guide as it's been a bit fiddly recently & I've had to go through a lot of troubleshooting, so I've placed this guide here for anyone who wants to get started with dashing & are fed up with the standard LT HUD's.

 

I was advised there were resource issues with the dashing plugin for Labtech, so I've used this method intead & it works great.

 

Here's one of our dashboards for example:

 

ubPen02l.jpg

 

_______________________________________________________

Pre-Requisites

 

This guide requires a PLAIN BUILD of Ubuntu 14.04 LTS 64 bit Server. The only software dependency you need on it is openssh so that you can 'Putty' in to it! It might also be a good idea, before the dashing installation to update/upgrade all current components of your Ubuntu VM.

Quote

sudo apt-get update && sudo apt-get -y upgrade

 

Quote
sudo apt-get -y install openssh-server

 

_______________________________________________________

 

INSTALLATION

 

**Considerations:

 

- Due to the way in which the dashboard works (mainly 'send event' based), it will NOT WORK in Internet Explorer. (So, use a REAL browser like Chrome or Firefox!)

 

- All development takes place on Ubuntu 14.04 LTS, and there may be issues with other platforms. No assistance will be given for installations not using Ubuntu 14.04 LTS.

 

- I am going to install dashing with an instance name of rmm_hud. Please feel free to name your name whatever you want, but just be sure to change all instances of rmm_hud to your own preference

 

- All command lines are in green!

 

- The guide assumes that you already have 'some' experience in a linux environment!

- You will need an SSH client to access your linux environment with ease.

 

First off... let's install Ruby and obtain the necessary gems, and a couple of extra bits we will need:

 

Quote
sudo apt-get update
Quote

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs

 

Quote

cd

wget http://ftp.ruby-lang.org/pub/ruby/2.2/ruby-2.2.5.tar.gz

tar -xzvf ruby-2.2.5.tar.gz

cd ruby-2.2.5/

./configure

make

sudo make install

ruby –v

 

Tip: Make yourself a cup of coffee whilst this is performing its configuration.

 

Quote
gem install bundler

Tip: If you have problems with this, try running as “sudo”. Sometimes it can throw up a warning.

 

Quote
sudo gem install roo

NOTE: Be patient with the roo gem install, it can take a few minutes to install. Do NOT cancel this.

 

Quote
sudo gem install mysql2 bundle dashing htmlentities rdf-rdfxml xml-simple simple-rss httparty json google-api-client puma passenger

Tip: Make another coffee or four, this takes a while.

 

Quote
sudo apt-get -y install unzip nodejs make libmysqlclient-dev

 

Next up, we will change directories and Install Dashing:

 

Quote
cd /opt

 

Quote

 

Quote
sudo mv master dashing.zip

 

Quote
sudo unzip dashing.zip

 

Quote
sudo mv Shopify-dashing-***** dashing

 

NOTE: **** denote random characters. Be sure to replace the *****'s in the guide with what is on your system! To find out what 'the characters are' then do a ls -l command while in the /opt directory.

 

 

Quote
cd dashing

 

Quote
sudo dashing new rmm_hud

 

Quote
cd rmm_hud

 

 

Quote
sudo dashing install 6246149

 

NOTE: This installs the 'Hotness Widget'.

 

Quote
sudo dashing install 4990174

 

NOTE: This installs the 'Weather Widget'. (Optional Step!)

 

Quote
sudo dashing install 5422482

 

NOTE: This installs the 'RSS/News Widget'. (Optional Step!)

 

Quote
sudo dashing install 9588819

 

NOTE: This installs the 'Server Status Widget'. (Optional Step!)

 

Quote
sudo nano Gemfile

 

Edit your Gem file needs to look like this:


source 'https://rubygems.org'

gem 'dashing'
gem 'mysql2'
gem 'twitter'
gem 'thin'
gem 'htmlentities'
gem 'rdf-rdfxml'
gem 'simple-rss'
gem 'httparty'
gem 'json'
gem 'passenger'
gem 'roo'
gem 'nokogiri'
gem 'google-api-client'
gem 'xml-simple'
gem 'puma'
 

 

Quote

sudo bundle install

NOTE: This actually compiles the dashing install and creates the dashboard.

 

Quote

sudo dashing start

Use CTRL + C to stop dashing.

 

 

OK... So at this point, you should be able to navigate to http://ip.of.ubuntu.vm:3030 and see a dashboard! If you don't then carefully go over steps one more time, making sure you have not missed anything out. If you DO see your dashboard, let’s set dashing up as a service first, then we will start on getting your data in there!

 

 

Now that we have the base dashboard set up, next step is to make sure that it will run as a Service, so the process won’t end when you exit your putty session. To do this, we need to create a service file, and a folder so that it store its logs. One of Dashing's dependencies is 'thin'. This is a really lightweight web-service that the dashboard will run on. We can get this setup in just a few steps.

 

 

Quote
sudo mkdir /opt/dashing/rmm_hud/logs

 

Quote
sudo touch /opt/dashing/rmm_hud/logs/thin.log

 

Quote
sudo nano /etc/init/thin.conf

 

Your thin.conf file needs to look like this:

 


description "thin"
version "1.0"
author "Travis Reeder"

env LANG=en_US.UTF-8
env APP_HOME=/opt/dashing/rmm_hud

respawn
start on runlevel [23]

script
   cd $APP_HOME
   sudo thin start -e production -p 3030 > $APP_HOME/logs/thin.log 2>&1
end script
 

Reminder: If you chose not to use rmm_hud as your dashing instance name, be sure to change it on line 6!

 

 

Now that you have created the service that the dash will run on. Now we can start it!

 

Quote
sudo start thin

 

NOTE: To RESTART the 'thin' service (i.e.: your dashboard) at ANY time, then the command for that is: sudo stop thin && sudo start thin

 

 

Now, let’s get the SQL set up and get some data in your dashboard!

 

Next up, we are going to create an 'odbc connection' to our LabTech server, to port 3306. This is done by creating a my_db.rb file.

 

Quote
sudo nano jobs/my_db.rb

 

Your my_db.rb file needs to look like this:

 


require 'mysql2'

class MyDb
 def self.conn
   Mysql2::Client.new( :host => "IP.of.LT.Server", :username => "username", :password => "MyP@$$w0rd", :port => "3306", :database => "labtech" )
end
end
 

 

 

If you want to create a READ-ONLY account in your LT Database, to use (almost like a service account) for this, then that can be done by running the following query in SqlYog:

 

Quote
GRANT SELECT on labtech.* to 'dashing'@'*' IDENTIFIED by 'MyP@$$w0rd';

 

Now, we will create another '.rb' file for a SQL query. Each query needs to be in it's own '.rb' file, and overtime you will have lots of these, so be sure to name appropriately and try and avoid spaces in your filenames!! For the purposes of the How-To Guide, we will create an agentcount.rb file. This will return the number of agents installed in your LT system. Please also consider when writing your queries (in your '.rb' files, make sure that they bring back a valid result in SQLyog first!!

 

Quote
sudo nano jobs/agentcount.rb

Your agentcount.rb file needs to look like this:

 


require_relative 'my_db.rb'

SCHEDULER.every '30s', :first_in => 0 do |job|

       db = MyDb.conn

       sql = "SELECT computerid FROM computers"

       results = db.query(sql)

       current_agentcount = results.count


       send_event('agentcount', { value: current_agentcount } )
db.close
end
 

 

 

The last thing we need to do in order for this result to show on your dashboard is program a widget to present the data. We will first need to create our own dashboard, which we call 'home' (by copying one that is already included) and then replacing an existing widget (or 'tile') with one that will show your query result.

 

 

Quote
sudo cp dashboards/sampletv.erb dashboards/home.erb

 

Quote
sudo nano dashboards/home.erb

 

Find the following code:

 


	    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
	      <div data-id="synergy" data-view="Meter" data-moreinfo="In sync with my neighbour!" data-title="Synergy" data-min="0" data-max="100"></div>
    </li>
 

 

and replace it with this:

 


	    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
	      <div data-id="agentcount" data-view="Hotness" data-title="Total Agents Deployed" data-cool="20" data-warm="1000"></div>
    </li>
 

 

Now, if everything works correctly, you should see the below image on your dashboard:

 

rP3PWyy.jpg

 

NOTE 1: Ensure that 'data-warm' value represents YOUR Total LT License count.

NOTE 2: Feel free to give your dash 'page' a new name - on Line 11.

NOTE 3: Every time you make a change to the home.erb file, you will need to restart dashing for change to take effect. (sudo stop thin && sudo start thin).

 

 

TIP 1: Change the default image in /assets/images/logo.png for the image widget (I’ve found the easiest way to get the file on there is to rename the old file ‘sudo mv logo.png logo2.png’ then download the new logo.png using ‘sudo wget http://url-to-download-image.png’)

TIP 2: Favicon change, same method used above & favicon is located in the /public directory.

TIP 3: Want more than 5 colums or the formatting is messed up? Add the below script to the top of your home.erb file.

<script type='text/javascript'>
  $(function() {
    Dashing.widget_base_dimensions = [370, 340]
    Dashing.numColumns = 5
  });
</script>
 

TIP 4: Test things, use your SQL code to get what you want.

TIP 5: if the page doesn’t load, or you get a timeout, or none of the tiles appear, remove or change back to whatever you just made a change to

TIP 6: when making large changes, always ensure to ‘sudo cp’ to make a backup copy of the file you are editing.

Edited by Offsite

Share this post


Link to post
Share on other sites

I know this post is quite old but just getting started with this and using Smashing rather than Dashing - got the test dashboard working - only piece missing is the code to change in the home.erb file (sudo nano dashboards/home.erb), this also appears to be missing in the original post.

Can you give some pointers.

Thanks

 

Share this post


Link to post
Share on other sites

just trying to follow the example through to show number of LT agents deployed, if I can see how this one is done I should be able to work out how to do others, the part wher is says "find the following code" and "and replace it with this" doesn't show anything.  Just getting started with Linux so on a steep learning curve :)

 

Edited by G-Man

Share this post


Link to post
Share on other sites

Very sorry about that!

This is the below code that isn't showing for some reason

 

sudo cp dashboards/sampletv.erb dashboards/home.erb

 

sudo nano dashboards/home.erb

 

Find the following code: 

 

    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">

     <div data-id="synergy" data-view="Meter" data-moreinfo="In sync with my neighbour!" data-title="Synergy" data-min="0" data-max="100"></div>

    </li>

 

and replace it with this:

 

   

    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">

      <div data-id="agentcount" data-view="Hotness" data-title="Total Agents Deployed" data-cool="20" data-warm="1000"></div>

    </li>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...