Coder Social home page Coder Social logo

Guidance modifying dashlet about dashing-icinga2 HOT 7 OPEN

bensig avatar bensig commented on June 30, 2024
Guidance modifying dashlet

from dashing-icinga2.

Comments (7)

bensig avatar bensig commented on June 30, 2024

I have also tried to use a host group, but it returns no result even though it works on the curl

puts "Host listing: " + host_stats.to_s

hostFilter = "host.groups==\"API\""

from dashing-icinga2.

bensig avatar bensig commented on June 30, 2024

I have also tried this

serviceFilter = [ "service.state==state && match(pattern,service.name)", "filter_vars": { "state": 2, "pattern": "*API*" } ]

from dashing-icinga2.

mocdaniel avatar mocdaniel commented on June 30, 2024

Hey Ben,

from what I gathered, you want a widget showing a list of all host problems, is that right? You could do something like this:

./dashboards/icinga2.erb

[...]
<li data-row="3" data-col="1" data-sizex="2" data-sizey="2">
      <div data-id="icinga-host-severity" data-view="List" data-unordered="true" data-title="Problems"></div>
    </li>

This goes within the huge SCHEDULER loop, basically wherever you want:

./jobs/icinga2.rb

[...]
# host problems
  host_severity_stats = []
  icinga.getHostObjects().each do |host|
    if host['attrs']['groups'].include? 'dummy-hosts'
      name = host['attrs']['__name']
      state = host['attrs']['state']
      host_severity_stats.push({
        "label" => name,
        "color" => icinga.stateToColor(state.to_int, false),
        "state" => state.to_int
      })
    end
  end

  order = [ 2,1,3 ]
  host_result = host_severity_stats.sort do |a, b|
    order.index(a['state'].to_int) <=> order.index(b['state'].to_int)
  end

  send_event('icinga-host-severity', {
    items: host_result,
    color: 'blue'
  })
[...]

This example will display all non-OK host states of hosts within the group dummy-hosts.

Does this help?

from dashing-icinga2.

bensig avatar bensig commented on June 30, 2024

Thank you for the response. Very helpful to see how you did this... However, I have tried using this to substitute my own HostGroup instead of 'dummy-hosts' and it does not seem to limit to just that group.

It's still displaying service issues from all hosts. The actual hostgroup is defined in groups.conf and it loads correctly in Icinga2web with this filter:

/monitoring/list/hosts?hostgroup_name=mainnet-hosts&sort=host_severity&limit=50

from dashing-icinga2.

mocdaniel avatar mocdaniel commented on June 30, 2024

Sorry for the long delay, would you mind sharing your edited jobs/icinga2.rb and dashboards/icinga2.erb?

from dashing-icinga2.

bensig avatar bensig commented on June 30, 2024

Not a problem, thanks for the reply. Here are the files:
jobs/icinga2.rb
dashboards/icinga2.erb

from dashing-icinga2.

mocdaniel avatar mocdaniel commented on June 30, 2024

Seems like you never actually use the data you prepare in your jobs/icinga2.rb - for this you'd need to rename the data-id property of one of the widgets of type List to point to icinga-host-severity (as you named the data being pushed by the backend job like this) in your dashboards/icinga2.erb.

You might have to rearrange/uncomment some of the widgets, too. Let me know if I can be of further help.

from dashing-icinga2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.