Advertisement
Guest User

painters patch

a guest
May 28th, 2015
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. 728a729,751
  2. > def paint_grafana_graph(host, service = "Check MK"):
  3. >     import ConfigParser as conf
  4. >     host_clean = host.replace('.', '_')
  5. >     svc_clean = service.replace(' ', '')
  6. >     config = conf.ConfigParser()
  7. >     config.read('/etc/check_mk/influxdb.config')
  8. >     section = 'GrafanaSettings'
  9. >     url = config.get(section, 'url')
  10. >     if svc_clean.lower() in config.options(section):
  11. >         url += config.get(section, svc_clean.lower())
  12. >     else:
  13. >         url += config.get(section, 'default')
  14. >     url += "&var-host=%s&var-service=%s" % (host_clean, svc_clean)
  15. >     return "grafanagraph", '<iframe src="%s" width="900" height="400" frameborder="0"></iframe>' % url
  16. >
  17. > multisite_painters["svc_grafanagraph"] = {
  18. >     "title"     : _("Grafana service graph"),
  19. >     "short"     : _("Grafana graph"),
  20. >     "columns"   : [ "host_name", "service_description" ],
  21. >     "paint"     : lambda row: paint_grafana_graph(row["host_name"], row["service_description"]),
  22. > }
  23. >
  24. >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement