How do I display custom information/graphics on the dashboard landing page?

Hello,

I would like to display some custom information, such as current utilization statistics, or data sourced from scripts, on the main dashboard page when users login. I have read the documentation on customization, but it seems like what I’m trying to do is not described in one of the use cases (or if it is, I missed it).

Can this be accomplished with Passenger Apps? If not, is there another way to do what I’m describing?

Thanks,
Nick

You could put these items in message of the day. That supports Ruby ERB templating, so in theory the MOTD could be something that is computed (we often do this to calculate when a message will expire and only show if it’s before that time).

Though if you’re aiming for something more complicated than simple message, you’re better off passenger app.

Still, for a few simple things, like disk or resource unit usage or how many current nodes available then this may be OK (though it’s not interactive, it would need a page refresh to show a new value). Hope that helps!

Thanks, Jeff. I will take a look at what I can accomplish with the ERB templates.

Can you configure passenger apps to display directly on the home page dashboard? Or do they have to be tied to a separate URL so that you have to follow a navbar link?

They’re a separate URL.

Here’s a quick example of a message that will expire, just so you get a sense of what it looks like to do some computation at the top and use the result in the message.

<%- expire = Time.new(2020, 4, 9, 9, 0, 0) -%>
<%- portal = ENV["OOD_PORTAL"] == "awesim" ? "AweSim" : "OnDemand" -%>
type: warning
msg: |
  <%- if Time.now < expire -%>
  **On Thursday, April 9 from 9am-915am there will
  be a short interruption of service for <%= portal %>
  when we deploy a new version of the portal.**

  During this interruption any active shell connections, and file transfers may be terminated.

  Contact oschelp@osc.edu if you have any questions.
  <%- end -%>
1 Like

Thanks, that’s helpful. Within ERB templates, do you have access to the entire Ruby language? For example, could you shell out and collect the output of a command? This is probably extending ERB a little bit beyond what it was made for, but I’m curious to know if it’s possible.

Either way, I would like to turn this into a feature request: Being able to have a passenger app be visible by default on the main dashboard page. I don’t know how complicated this would be for you to implement, but I think it would be useful to present users with system-generated information that’s richer than what a MotD can provide. It sounds like the passenger apps framework is suitable for this level of customization.

What are your thoughts?

Yes within ERB you have the entire language and probably a lot of rails utilities that are loaded in the dashboard. Tildes are a nice way to run a command easily like `ls -lrt` will run ls and return a string of the output (as an example).

As to what should be on the dashboard, I agree with you in spirit. We’re working on adding XDMOD panels, so there’s that. It’s a balance for us to provide things that are useful so everyone can use them, but then also places where folks can do something more site specific.

My thoughts are this: tell us what you’re trying to do, what you want or show us what you have done. Or make an image in MS PAINT and say ‘I want to show my users this’. I think if we understood the landscape of what folks want, then we could take action to provide panels or ways to add panels.

Sounds good. I can refine our use case(s) and submit a formal feature request on a different thread.

Thanks!
Nick

Thanks! There’s no need for formality, just verbosity. This is discourse after all, you can tell us your thinking as it stands as we can talk through it (and maybe another community user can jump in and yes-and us).

Ok, so for instance: When our users login via the terminal, they see a login banner that shows several pieces of information, such as

  • List of directories/project folders they have access to and how much storage they’re using in each, out of their total quota
  • Some help links
  • Links to tutorials

Obviously, the second and third items can be put in a static message. The quota/directory information, however, is sourced from some filesystem scripts. We could probably get ERB to do this by shelling out and capturing the output.

Then there are some other utilities that users can run to see which nodes are free, or what current utilization is in the cluster. Some of these can (and should) be passenger apps at a separate URL. But it would be great if the current utilization information could be available on the dashboard.

For example, visually, it might look like something like this (imagine this in HTML/CSS, which we would code):

Cores  ||||||||||||||-------| 67% ( 2528 / 3768 )
Memory ||||||||||-----------| 44% ( 6.7T / 15.3T )
GPUs   |||||----------------| 18% ( 4 / 22 )

We do have XDMoD deployed here, but we’re not interested in putting that information front and center. However, I can see the value of being able to pull in information from XDMoD in a separate page, like a passenger app. So that feature is also interesting.

Is that more helpful? I know it’s still a little light on the details, but in essence, we would like to be able to capture dynamic information from our system, using scripts we already have, and then display that information using the passenger app framework.

Nick

That’s super helpful, thanks!

Yea I think we’re trying to define what “current utilization information” is exactly. Or putting the problem a different way: what information could benefit the user in some meaningful way.

Hi Jeff,

Is there any trick to getting OOD to render ERB within the MOTD? Right now, I have the following in /etc/ood/config/apps/dashboard/env:

MOTD_PATH="/etc/motd.erb" # this supports both file and RSS feed URIs
MOTD_FORMAT="markdown" # markdown, txt, rss

And here’s what I have in /etc/motd.erb:

<%= `some_command` %>

But when I reload the dashboard, all I get is the literal text of the above expression. The command is not actually run.

Thanks,
Nick

Sorry about that! You’re completely right, what I looked at was announcements, which is not MOTD.

You can create this initializer /etc/ood/config/apps/dashboard/initializers/motd_md_erb.rb that’ll work. It supports both .md and .erb file formats, and if something breaks in your ERB, it’ll render the text as is (as you have it now).

class MotdFormatterMarkdown

  attr_reader :content, :title

  # @param [MotdFile] motd_file an MotdFile object that contains a URI path to a message of the day in OSC format
  def initialize(motd_file)
    motd_file = MotdFile.new unless motd_file
    @title = motd_file.title

    file_content = if File.extname(motd_file.motd_path).eql?(".erb")
                     begin
                       ERB.new(motd_file.content).result
                     rescue
                       motd_file.content
                     end
                   else
                     motd_file.content
                   end

    @content = OodAppkit.markdown.render(file_content)
  end

  def to_partial_path
    "dashboard/motd_markdown"
  end
end

Before you drop this file in /etc/ood, I would suggest enabling development and getting a copy of the dashboard code in ~/ondemand/dev/dashboard and dropping this file in ~/ondemand/dev/dashboard/config/initializers/motd_md_erb.rb. Then you can modify ~/ondemand/dev/dashboard/.env.local to point to your own copy of an erb file (like say ~/motd/test.erb). Then you’ll be able to go to the URL /pun/dev/dashboard and see all of this in action and make tweaks (and break stuff) without affecting anyone else.

Great, thanks Jeff. I have development enabled, so I will try it there first. If you have the dashboard code in your ~/ondemand/dev folder, then would you just access it via the sandbox apps, just like any other app you would develop? In other words, when you login to OOD, you are still taken to the prod dashboard, and accessing the dev dashboard requires going to sandbox apps?

Nick

Yep! You should be able to go directly to /pun/dev/dashboard (notice the -dev- in the middle). Just cd into ~/ondemand/dev/dashboard and run bin/bundle install before you get started (dev apps need to be setup manually like that).

1 Like

Hi Jeff,

I have the dashboard code from the github repo in ~/ondemand/dev/dashboard and the dashboard app is loading properly when I navigate to /pun/dev/dashboard. The problem is, I cannot get the dev app to render an MOTD file in any format.

As you recommended, I have a copy of my production dashboard env file in the dev dashboard root directory, named .env.local, modified to point to an MOTD file in the config subdirectory. But after restarting the NGINX web server several times, I am still not getting a MOTD in my dev dashboard.

Can you confirm that there isn’t anything else I need to be doing to get the dev dashboard to render a MOTD?

Thanks,
Nick

These are the two entries in your .env.local that you need to get this to work.

MOTD_PATH="/path/to/local/erb_message.md.erb"
MOTD_FORMAT="markdown"

MOTD_PATH has to be a real valid file. Check the log files at ~/ondemand/dev/dashboard/log/development.log for anything that looks amiss.

I just confirmed that misconfiguring MOTD_PATH will trigger errors like this, but nothing is shown in the UI.

So you’ll likely need a working combination of a valid file and that that file is in the format you’ve specified.

Started GET "/pun/dev/dashboard/" for ip at 2020-07-07 14:08:21 -0400
Processing by DashboardController#index as HTML
MOTD File is missing; it was expected at /some/location/motd/erb_message.md.erb2
  Rendering dashboard/index.html.erb within layouts/application
  Rendered shared/_welcome.html.erb (2999.4ms)
  Rendered dashboard/index.html.erb within layouts/application (3006.6ms)

Also this is just a reminder that you’ll drop that initializer ~/ondemand/dev/dashboard/config/initializers/motd_md_erb.rb while you’re working in your development environment.

1 Like

Thanks for the quick response! The log helped me debug the issue. I was defining my MOTD path starting with ~/ as shorthand for my home directory. Changing this to an absolute path name solved my problem.

Thanks!
Nick

This is interesting - did you ever get it done?

@datakid No, it ended up landing at the bottom of my to-do list. But I’ve had some success with a couple other concepts using the passenger apps framework, and I think this would be doable.

Nick

1 Like