Skip to content

Commit

Permalink
Merge pull request #53 from Icinga/fix/problem-list-ordering
Browse files Browse the repository at this point in the history
Fix problem list ordering: Crit -> Warn -> Unknown
  • Loading branch information
Michael Friedrich committed Jan 22, 2018
2 parents 2ae0f15 + 77720b0 commit e465440
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions jobs/icinga2.rb
Expand Up @@ -91,14 +91,19 @@
severity_stats.push({
"label" => icinga.formatService(name),
"color" => icinga.stateToColor(state.to_int, false),
"state" => icinga.stateToString(state)
"state" => state.to_int
})
end
severity_stats = severity_stats.sort_by{|stat| stat["state"]}
puts "Severity: " + severity_stats.to_s

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

puts "Severity: " + result.to_s

send_event('icinga-severity', {
items: severity_stats,
items: result,
color: 'blue' })

# down, critical, warning, unknown
Expand Down

0 comments on commit e465440

Please sign in to comment.