So one of the big questions I was asked at the London Apple Admins Meetup was around the Dashboard that I mentioned during my talk, so I thought I’d knock up a quick guide to show you all how we at Just Eat went about making this.

Creating your Dashboard Environment

So the dashboard which I mentioned runs on an open source framework called Smashing (fork of Dashing.io), which can be found here.

Although Dashing is no longer maintained you can still use it and it still works, however there is a fork of Dashing now called Smashing which works just as well.

You can run Dashing/Smashing on virtually all platforms that support Ruby, for this example I built it on a Windows Server, and followed this guide to get it configured.

Setting up your Dashing Framework

So for the purposes of this demo I’m using a Windows Server 2012 Base, which is a free tier available on Amazon EC2 and will install the Ruby Framework on the Server.

Configuring a new Security Group

  • Now we’ll need to create a security group in EC2 that will let HTTP and HTTPS traffic from the web to your dashboard. You also want to configure RDP Access to the box from your IP Address only. To do this click, Security and Groups under the Network & Security section.
  • Click, Create Security Group
  • Give the Security Group a name and a Description, i.e. DashingFramework and configure your Inbound Rules for HTTP, HTTPS from Anywhere (Note: If you’d like to lock this down then be specific with the IP Address at this stage) and configure RDP access from “My IP” only.
  • Click, Create
  • Head back to your instance and assign your newly created Security Group to your Dashboard Instance, do this by clicking, Actions > Networking > Change Security Group and Selecting your new Security group from the list, make sure you uncheck the default security group also.

Generating your Windows Administrator Password

Installing and Configuring Ruby on Windows Server

  • Now that you’ve got your server up and running, I highly recommend getting another browser like Chrome so you don’t run into the crazy amount of security dialogs that IE has to offer.
  • Navigate to, https://rubyinstaller.org/downloads/ , download and install the 32-bit version of Ruby 2.3.3, I found this works better with Dashing, selecting all options during the installation.
  • Next, you want to create a folder called Ruby_DevKit on the root of the C: drive of the server and download the relevant 32-bit DevKit from https://rubyinstaller.org/downloads/ and place the downloaded file in the C:\Ruby_DevKit folder, run the self-extracting program and it should automatically extract the files within this location.
  • Now you’ll need to download and install NodeJS with all the defaults from, https://nodejs.org/en/
  • Once installed, open programs and launch Start Command Prompt with Ruby
  • Check Ruby is installed by typing:
    ruby -v
  •  Next, we need to configure and install the Ruby Dev Kit use these following commands:
    cd C:\Ruby_DevKit

    then

    ruby dk.rb init
    ruby dk.rb review
    ruby dk.rb install
  • Now that the Ruby Dev Kit is installed, change your directory back to the Ruby directory folder:
    cd C:\Ruby23

Installing and Configuring Smashing Framework

Configuring a Load Balancer to point to your Dashboard

Now we have the dashboard up and running we need to configure web access to the dashboard to do this we need to use  load balancer, it’s a good idea to have a Static IP at this point set for your dashboard.

  • Head back into your Amazon EC2 and navigate to Load Balancers and Create a Load Balancer
  • Create a Classic Load Balancer
  • Give your Load Balancer a Name, i.e. Smashing
  • Change your Load Balancer Instance Port to 3030
  • Selcet your Security Group, select the default/Security Group we created earlier, click Next
  • As I’m not configuring HTTPS at this stage for this demo, I see a warning message about security, click Next
  • In the health check window insure your “ping port” is set to 3030 and click Next
  • Select your Dashboard instance and click Next
  • Add Tags and click Review and Create
  • Once reviewed, click Create
  • Now try navigating to http://IPAddressORUrl:3030/sample in a web browser and the dashboard will now appear.

Creating a JSS API User

  • Next head into your JSS and create an API User that has read-only access to the data you want to report on, i.e. my user only has access to read Smart Groups and and Advanced Smart Searches. Click, Settings > JSS User Accounts and Groups and create a new user called apiuser and password [yourpassword], again ensure you give access to what ever you want to report on the dashboard (or if it’s easier apply the Auditor permissions this gives read-only access to the JSS).

Diving into the JSS API

  • Next you want to dive into your JSS API, this will be located at the following, https://YOURJSSURL:8443/api this will then display a list of all the API’s in which you can interact with, so for example I have a smart group in my JSS which tells me all the machines on macOS Sierra so I want to report on that.
  • Find the ID of your smart group, by navigating to the smart group, but not clicking edit this then shows the ID of the smart group in the URL, in my instance this is 78
  • Head back to the API page and scroll down to /computergroups and expand the operations, select the /computergroups/id/{id} option.
  • This will now ask for authentication, enter the api user details created previously
  • Enter the ID of your smart group and hit Try It Out if all configured correctly this should return a 200 response code with the correct information in the XML Response body, the Size within the XML Response Body should match the figure of the Smart Group within your JSS.

Editing the Dashboard

  • So now you know how to interact with the API and find the information you actually need. You now need to get this onto the Dashboard, so I created a seperate dashboard file in C:\Ruby23\jamf_pro_dashboard\dashboards\yourdashboardname.erb, you can use my template below:
    <% content_for :title do %>Sachin Parmar Blog<% end %>
    <div class="gridster">
      <ul>
        <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
          <div data-id="macossierra" data-view="Number" data-title="macOS Sierra Machines"></div>
        </li>
      </ul>
    </div>
  • So now by navigating to http://mydashboardurl:3030/dashboardname, you’ll see the one box for “macOS Sierra Installed Machines” or whatever you have chosen:
  • You’ll need to keep building these up for the more boxes/queries/data you want to display on your dashboard. There are some great additional widgets available here, they’re worth checking out, especially Hotfloat is the one I use a lot.

JSS Data to Dashboard

  • Now you’ve got your dashboard running, you’ve queried the API for your data, all we have to do now is write a little bash script that will upload the data to your dashboard using the curl command, so a sample one for this demo is a script I put together below:
    #!/bin/bash
    total=$(curl -L -skfu apiuser:apiuser 'https://YOURJSSURLHERE/JSSResource/computergroups/id/78' | /usr/bin/awk -F '<size>|</size>' '{print $4}')
    curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "current":'"$total"' }' \http://YOURDASHBOARDURLHERE:3030/widgets/macossierra
  • You can take this a step further and set up a cron job which can automate your shell scripts at the interval you require so you can set it up once and it’ll refresh the data as often as you like, over at Just Eat we host our scripts within TeamCity which execute hourly.

Final Result

After some playing around you’ll get the idea of how it all works and you can end up with something like this. But efefctively all the data represented in the dashboard are a combination of smart computer groups, static computer groups, advance computer searches and more.

Let me know how you get on, it’s a bit of a long process but once it’s working it’s brilliant.

P.S: I’ve tried setting up a Ruby instance of the dashboard in Linux but I can’t get it working, so the actual working method i’ve got so far is the Windows Server 2012 R2 option, so if anyone out there can get it working please let me know in the comments below!

Sachin