Dashboard widget for open tickets (showing number rather than graph)

Question:
What is the best way to add a dashboard widget that shows the latest measurement as a number? (not a graph)

Here’s an example of the type of widgets I’m trying to add to our Dashboard:

Context:

  • We have TVs that display the LibreNMS dashboard in our office
  • I would like to display info from our ticketing system (current number of tickets, etc)
  • We’re using a Nagios plugin to collect the current number of open tickets as a number
  • My issue is that I haven’t been able to find any method to create a dashboard widget that lets me just show the latest result
  • The issue isn’t specific to Nagios plugins. We’d also like to display the most recent value of a temperature sensor, rather than display a graph
  • My suspicion is that it’s not currently possible to do this in LibreNMS. Please correct me if I’m wrong
  • Would doing this require adding new dashboard widgets? I had a look in the /opt/librenms/resources/views/widgets directory, but I don’t know how to write PHP. Is there an obvious technical limitation preventing this type of widget from being created? I’m debating whether to try implementing a new widget to get this functionality

Relevant KB: Customizing the Web UI - LibreNMS Docs

I know a couple people with Laravel experience. Will ask them what they think.

1 Like

Probably could make a new widget to just show the current value of something like a sensor, nagios check, or similar.

Here is a PR adding a widget. I’m not sure if it is a current example or not, but probably a good place to start.

Bumping thread to keep alive. I’ll update thread with progress, but nothing yet.

Bumping to keep alive. Haven’t learned PHP yet, still chipping away at this though

Bump to keep alive. Still chipping away at this

Bumping for keepalive. I’ve roped in some friends that are familiar with laravel, but we weren’t able to figure out how to do this yet. But haven’t given up.

I wasn’t able to figure out how to implement this in LibreNMS, so we’ve been using this crude solution as a workaround.

I added an extra step to the nagios service check - it now uses imagemagick to create /opt/librenms/html/images/helpdesk_queue.png

The image can then be added to LibreNMS dashboard using the “External Images” widget (http://librenms.example.com/images/helpdesk_queue.png).

#!/bin/bash
# /usr/lib64/nagios/plugins/check_zammadhelpdeskqueue.sh
# https://gist.github.com/maxcnunes/9f77afdc32df354883df
# https://www.howtoforge.com/tutorial/write-a-custom-nagios-check-plugin/
URL="https://helpdesk.example.com/api/v1/tickets/search?query=owner.id%3A1%20AND%20group.id%3A1%20AND%20state.name%3A(%22new%22%20OR%20%22open%22%20OR%20%22pending%20reminder%22)"
BEARER="blablabla"

# store the whole response with the status at the and
HTTP_RESPONSE=$(curl --url $URL --header "Authorization: Bearer $BEARER" --silent --write-out "HTTPSTATUS:%{http_code}")

# extract the body, then extract ticket_count value from the JSON
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g' | jq '.tickets_count')

# extract the status
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')

# if HTTP status is 200 OK, then return ticket_count
if [ $HTTP_STATUS -eq 200 ]; then
  convert -size 550x275 -background none -fill white -gravity center -font Courier-Bold label:$HTTP_BODY /opt/librenms/html/images/helpdesk_queue.png
  convert -size 550x275 -gravity center -font Courier-Bold label:$HTTP_BODY /opt/librenms/html/images/helpdesk_queue.svg
  echo "$HTTP_BODY tickets in Helpdesk queue with no Owner | 'tickets'=$HTTP_BODY"
  exit 0
fi

# if HTTP status is not 200 OK, exit  with warning state
if [ ! $HTTP_STATUS -eq 200  ]; then
  echo "Error [HTTP status: $HTTP_STATUS]"
  exit 2
fi

Here’s how it looks:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.