Skip to content

Instantly share code, notes, and snippets.

@LKLG
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LKLG/8376c547888fe8dacb00 to your computer and use it in GitHub Desktop.
Save LKLG/8376c547888fe8dacb00 to your computer and use it in GitHub Desktop.
Creates a list of all available dashboards in dashing

Dashboardlist

Description / Beschreibung

en: Presents all available dashboards as widgets.

de: Zeigt alle verfügbaren Dashboards als Widget an.

Usage / Benutzung

en:

  1. Save the "monitor.rb"-file in the dashing job path.
  2. Restart dashing.
  3. (optional - default dashboard) edit the config.ru and add following option: "set :default_dashboard, 'monitor'"

de:

  1. Speicher die Datei "monitor.rb" in das Dashing-Job-Verzeichnis.
  2. Dashing neustarten.
  3. (Optional - Standard dashboard) Bearbeite config.ru und füge folgendes hinzu: "set :default_dashboard, 'monitor'"
Datenlizenz Deutschland – Namensnennung – Version 1.0
Jede Nutzung mit Quellenvermerk ist zulässig.
Veränderungen, Bearbeitungen, neue Gestaltungen oder sonstige Abwandlungen sind mit einem Veränderungshinweis im Quellenvermerk zu versehen oder der Quellenvermerk ist zu löschen, sofern die datenhaltende Stelle dies verlangt.
Der Bereitsteller stellt die Daten, Inhalte und Dienste mit der zur Erfüllung seiner öffentlichen Aufgaben erforderlichen Sorgfalt zur Verfügung. Für die Daten, Inhalte und Dienste gelten in Bezug auf deren Verfügbarkeit und deren Qualität die durch den Bereitsteller in den Metadaten oder sonstigen Beschreibungen zugewiesenen Spezifikationen und Qualitätsmerkmale. Der Bereitsteller übernimmt jedoch keine Gewähr für die Richtigkeit und Vollständigkeit der Daten und Inhalte sowie die dauerhafte Verfügbarkeit der Dienste. Davon ausgenommen sind Schadensersatzansprüche aufgrund einer Verletzung des Lebens, körperliche Unversehrtheit oder Gesundheit. Ebenfalls ausgenommen sind Schäden, die auf Vorsatz oder grober Fahrlässigkeit beruhen.
Data licence Germany – attribution – Version 1.0
Any use shall be permitted provided the source is mentioned.
Changes, editing, new designs or other amendments shall be marked with information in the source note about relevant changes, or the source note must be deleted if the entity keeping the data requires so.
The provider makes available the data, contents and services with the diligence necessary for the discharge of its public tasks. With reference to their availability and quality, the specifications and quality features assigned by the provider in the meta-data or other descriptions apply to the data, contents and services. However, the provider does not assume any liability for the accuracy and completeness of data and contents and for permanent availability of services. Exempt from this are any claims for damage due to an injury to life, limb or health. Also exempt is damage based on wilfulness or gross negligence.
# Create/Update every hour a dashboard with all available dashboards.
# The dasboard is called "monitor"
#
# to change the default dashboard edit the config.ru:
# add "set :default_dashboard, 'monitor'" under "configure do"
#
#
SCHEDULER.every '1h', allow_overlapping: false do |job|
dir = "/opt/dashing/dashboards"
file = "monitor.erb"
dircontent = Dir.entries(dir)
length = dircontent.length
i = 0
dashboards = []
while i < length do
if dircontent[i] != "layout.erb" and dircontent[i] != "." and dircontent[i] != ".." and dircontent[i] != file
dashboards << dircontent[i].split(/(.*?).erb/)[1]
end
i += 1
end
if File.exist?(dir + "/" + file)
File.delete(dir + "/" + file)
else
File.new(dir + "/" + file, "w+")
end
File.open(dir + "/" + file, 'w') do |f|
f << "<script type='text/javascript'>\n$(function() {\n $('li').live('click', function(e){\n var widget = $(this).find('.widget');\n var url = widget.data('url');\n window.location = url;\n });\n});\nDashing.widget_base_dimensions = [444,408];\nDashing.numColumns = 3;\n</script>\n\n<% content_for :title do %>Systemstatus<% end %>\n<div class='gridster'>\n <ul>\n"
dashboards.each do |i|
f << "<li data-row='1' data-col='1' data-sizex='1' data-sizey='1'>\n <div data-view='Text' data-title='" + i + "' data-url='http://icinga01.lklg.net:3030/" + i + "'></div>\n </li>\n"
end
f << " </ul>\n</div>"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment