nagios_webbed_log 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/nagios_logger.rb +25 -0
- data/lib/views/index.haml +25 -22
- data/nagios_webbed_log.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/nagios_logger.rb
CHANGED
@@ -1,4 +1,27 @@
|
|
1
|
+
#coding: UTF-8
|
1
2
|
module NagiosLogger
|
3
|
+
=begin
|
4
|
+
CPU on remaccess Рабочий сервер
|
5
|
+
CPU on ra Тестовый сервер
|
6
|
+
HTTP УРМ
|
7
|
+
HTTP-work СОД
|
8
|
+
HTTP-lesson Тестовый СОД
|
9
|
+
Соответствие уровней оповещений в логе выводимым в таблице:
|
10
|
+
|
11
|
+
CRITICAL Ошибка
|
12
|
+
WARNING Предупреждение
|
13
|
+
=end
|
14
|
+
SERVICE_LUT = {
|
15
|
+
"CPU on ra" => "Тестовый сервер",
|
16
|
+
"CPU on remaccess" => "Рабочий сервер",
|
17
|
+
"HTTP" => "УРМ",
|
18
|
+
"HTTP-work" => "СОД",
|
19
|
+
"HTTP-lesson" => "Тестовый СОД"
|
20
|
+
}
|
21
|
+
LEVEL_LUT = {
|
22
|
+
"CRITICAL" => "Ошибка",
|
23
|
+
"WARNING" => "Предупреждение"
|
24
|
+
}
|
2
25
|
def load_file_list(pref)
|
3
26
|
Dir[File.join(pref, "*")].map{|n| File.basename(n) }
|
4
27
|
end
|
@@ -57,7 +80,9 @@ module NagiosLogger
|
|
57
80
|
data[:count] = n[4]
|
58
81
|
data[:message] = n[5]
|
59
82
|
end
|
83
|
+
return nil unless SERVICE_LUT.has_key?(data[:service])
|
60
84
|
end
|
85
|
+
data[:service] = SERVICE_LUT[data[:service]]
|
61
86
|
data
|
62
87
|
end
|
63
88
|
|
data/lib/views/index.haml
CHANGED
@@ -7,40 +7,43 @@
|
|
7
7
|
%label{:for => :year} Year
|
8
8
|
%select#year{:name => "year"}
|
9
9
|
%option{:value => '0'} ---
|
10
|
-
- @years.each do |year|
|
10
|
+
- @years.sort.each do |year|
|
11
11
|
%option{:value => year, :selected => (year == @year)}= year
|
12
12
|
|
13
13
|
%label{:for => :month} Month
|
14
14
|
%select#year{:name => "month"}
|
15
15
|
%option{:value => '0'} ---
|
16
|
-
- @months.each do |month|
|
16
|
+
- @months.sort.each do |month|
|
17
17
|
%option{:value => month, :selected => (month == @month)}= month
|
18
18
|
|
19
19
|
%label{:for => :day} Day
|
20
20
|
%select#day{:name => "day"}
|
21
21
|
%option{:value => '0'} ---
|
22
|
-
- @days.each do |day|
|
22
|
+
- @days.sort.each do |day|
|
23
23
|
%option{:value => day, :selected => (day == @day)}= day
|
24
24
|
%button{:name => "submit"} find
|
25
25
|
|
26
|
-
|
27
|
-
%
|
28
|
-
|
29
|
-
%th Start-time
|
30
|
-
%th Stop-time
|
31
|
-
%th Service
|
32
|
-
%th Reason
|
33
|
-
%th Comments
|
34
|
-
- @events.each do |evt|
|
35
|
-
-# lvl = evt.map{|it| levs.index(it[:level]) || 3 }.max
|
36
|
-
-# ll = evt.detect{|it| not levs.include?(it[:level]) }
|
37
|
-
-# len = evt.last[:stamp] - evt.first[:stamp]
|
38
|
-
-# puts "#{its.first[:host]}\t#{its.first[:service]}\t#{its.first[:stamp].to_i}\t#{its.first[:stamp].strftime("%Y-%m-%d %H:%M:%S")}\t#{levs[lvl]}\t#{len}\t#{its.first[:message]}"
|
26
|
+
- unless @events.empty?
|
27
|
+
%a{:href => "/#{@year == '0' ? 0 : @year}/#{@month == '0' ? 0 : @month}/#{@day == '0' ? 0 : @day}.csv"} Save to CSV
|
28
|
+
%table
|
39
29
|
%tr
|
40
|
-
%
|
41
|
-
%
|
42
|
-
%
|
43
|
-
%
|
44
|
-
%
|
45
|
-
%
|
30
|
+
%th Date
|
31
|
+
%th Start-time
|
32
|
+
%th Lattency
|
33
|
+
%th Service
|
34
|
+
%th Level
|
35
|
+
%th{:style => "display:none;"} Reason
|
36
|
+
- levs = %w(OK WARNING CRITICAL UNKNOWN)
|
37
|
+
- @events.each do |evt|
|
38
|
+
- lvl = evt.map{|it| levs.index(it[:level]) || 3 }.max
|
39
|
+
- ll = evt.detect{|it| not levs.include?(it[:level]) }
|
40
|
+
-# len = evt.last[:stamp] - evt.first[:stamp]
|
41
|
+
-# puts "#{its.first[:host]}\t#{its.first[:service]}\t#{its.first[:stamp].to_i}\t#{its.first[:stamp].strftime("%Y-%m-%d %H:%M:%S")}\t#{levs[lvl]}\t#{len}\t#{its.first[:message]}"
|
42
|
+
%tr
|
43
|
+
%td= evt.first[:stamp].strftime("%Y-%m-%d")
|
44
|
+
%td= evt.first[:stamp].strftime("%H:%M:%S")
|
45
|
+
%td= evt.last[:stamp] - evt.first[:stamp]
|
46
|
+
%td #{evt.first[:service]}
|
47
|
+
%td= NagiosLogger::LEVEL_LUT[lvl] || "---"
|
48
|
+
%td{:style => "display:none;"} #{evt.first[:message]}
|
46
49
|
|
data/nagios_webbed_log.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "nagios_webbed_log"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["afa"]
|
12
|
-
s.date = "2012-10-
|
12
|
+
s.date = "2012-10-09"
|
13
13
|
s.description = "simple nagios log publisher"
|
14
14
|
s.email = "afa.alone@gmail.com"
|
15
15
|
s.executables = ["nagios_webbed_log"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nagios_webbed_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -341,7 +341,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
341
341
|
version: '0'
|
342
342
|
segments:
|
343
343
|
- 0
|
344
|
-
hash: -
|
344
|
+
hash: -497093201
|
345
345
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
346
346
|
none: false
|
347
347
|
requirements:
|