Configure Dashing


Last time I installed dashing to the raspberry pi, this time I want to fill it with meaningful data so that it can do meaningful things.

I will add a couple of jenkins build status monitors.

As said, last time I installed dashing directly to the pi. This was to show what’s needed to actually run it and show it in kiosk mode. To configure our board we probably wille have to write some code and add it to the project so it’s best to do this on a local machine first – simply because it’s more fluid and we usually have all the development tools around. So let’s start and jump to some dev space directory.

×
$ dashing new monitoring
$ cd monitoring
$ bundle
$ git init
$ git add .
$ git commit -m "Create monitoring project

Command: dashing new monitoring"

As you may see, I like to point out the actual command I’ve run to create or change things if it’s been done by a command like that – for reference and self learning. Having several shells open I choose one to run it as a daemon

×
bash
$ dashing start -d
$ 

In a seperate shell tail the log to see what’s going on

×
bash
$ tail -f log/thin.log
$ 

And open in your browser: http://localhost:3030/ To stop it simply type

×
bash
$ dashing stop
$ 

Taking a look at git status we see that log/ is unknown. Since we don’t want to store logs in the repo we should ignore it

×
bash
$ echo "log/" >> .gitignore
$ git commit -am "Ignore log/ path for git"
$ 

This step can be omitted once my pull request has been merged and published.

Now that we have seen a demo, let’s do something useful. For the sake of simplicity, we will reuse the existing sample.erb dashboard, but you can also rename it to something different. However you have to be careful at least a bit. Maybe you noticed that we just opened http://localhost:3030/ and it immediately redirected us to http://localhost:3030/sample. Why is that? You can search through the code but you won’t find it. That’s because dashing redirects on requests to / to the dashboard given as default*dashboard or if this is not set to the first one found – which is the first file found in dashboards in alphabetical order excluding the layout. So when you rename it, keep this in mind since there’s also a sampletv.erb file present.

For now we just empty our sample dashboard by just leaving the following code inside:

×
<% content_for :title do %>Monitoring<% end %>
<div class="gridster">
  <ul>
    <!-- widgets will go here -->
  </ul>
</div>

Now for the real fun. Let’s install a widget to watch jenkins status. Luckily someone already wrote such a plugin - unluckily I had to change some things to make it working.

×
$ dashing install 6334816
$ git add .
$ git commit -am "Install jenkins build widget

Command: dashing install 6334816"

This will install one new widget including html, scss and coffee files as well as one new job. You have to add one or more widgets to your dashboard .erb:

×
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-id="jenkins_www_kluks_de_master" data-view="JenkinsBuild" data-title="master"></div>
</li>

would for add a job for the master build. Repeat this step for all jenkins builds to monitor. Next configure the builds in jobs/jenkins_builds.rb near the top

×
JENKINS_URI = URI.parse("http://localhost:8080/")

job_mapping = {
  # id used in dashboard => { job: name of job }
  'jenkins_www_kluks_de_master' => { job: 'www_kluks_de_master' },
  # repeat for all jobs added to the dashboard
}

That’s for the simple configuration. You can add more tweaks to the job to e.g. get a release candidate number built by one job or that like. Just pass it inside send_event and use it in the widgets/jenkins_build/jenkins_build.html.


Es gibt noch keine Kommentare