hq-log-monitor-server 0.3.0 → 0.4.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.
@@ -16,7 +16,7 @@ Feature: View and manipulate a single event
16
16
  </log-monitor-server-config>
17
17
  """
18
18
 
19
- And the time is 100
19
+ And the time is 10
20
20
 
21
21
  And I submit the following event:
22
22
  """
@@ -37,6 +37,9 @@ Feature: View and manipulate a single event
37
37
  When I visit /event/${event-id}
38
38
 
39
39
  Then I should see the event
40
+ And I should see a button "mark as seen"
41
+ And I should not see a button "mark as unseen"
42
+
40
43
  And the event status should be "unseen"
41
44
 
42
45
  And the summary new should be 1
@@ -46,12 +49,15 @@ Feature: View and manipulate a single event
46
49
 
47
50
  Scenario: Mark as seen
48
51
 
49
- Given the time is 200
52
+ Given the time is 20
50
53
 
51
54
  When I visit /event/${event-id}
52
55
  And I click "mark as seen"
53
56
 
54
57
  Then I should see the event
58
+ And I should see a button "mark as unseen"
59
+ And I should not see a button "mark as seen"
60
+
55
61
  And the event status should be "seen"
56
62
 
57
63
  And the summary new should be 0
@@ -61,7 +67,34 @@ Scenario: Mark as seen
61
67
 
62
68
  And icinga should receive:
63
69
  """
64
- [100] PROCESS_SERVICE_CHECK_RESULT;host;service;0;OK no new events
65
- [100] PROCESS_SERVICE_CHECK_RESULT;host;service;1;WARNING 1 warning
66
- [200] PROCESS_SERVICE_CHECK_RESULT;host;service;0;OK no new events
70
+ [10] PROCESS_SERVICE_CHECK_RESULT;host;service;0;OK no new events
71
+ [10] PROCESS_SERVICE_CHECK_RESULT;host;service;1;WARNING 1 warning
72
+ [20] PROCESS_SERVICE_CHECK_RESULT;host;service;0;OK no new events
73
+ """
74
+
75
+ Scenario: Mark as unseen
76
+
77
+ Given the time is 20
78
+
79
+ When I visit /event/${event-id}
80
+ And I click "mark as seen"
81
+ And I click "mark as unseen"
82
+
83
+ Then I should see the event
84
+ And I should see a button "mark as seen"
85
+ And I should not see a button "mark as unseen"
86
+
87
+ And the event status should be "unseen"
88
+
89
+ And the summary new should be 1
90
+ And the summary total should be 1
91
+ And the summary new for type "warning" should be 1
92
+ And the summary total for type "warning" should be 1
93
+
94
+ And icinga should receive:
95
+ """
96
+ [10] PROCESS_SERVICE_CHECK_RESULT;host;service;0;OK no new events
97
+ [10] PROCESS_SERVICE_CHECK_RESULT;host;service;1;WARNING 1 warning
98
+ [20] PROCESS_SERVICE_CHECK_RESULT;host;service;0;OK no new events
99
+ [20] PROCESS_SERVICE_CHECK_RESULT;host;service;1;WARNING 1 warning
67
100
  """
@@ -48,3 +48,19 @@ Then /^I should see the event$/ do
48
48
  find("#event #id td").text.should == @event_id.to_s
49
49
 
50
50
  end
51
+
52
+ Then /^I should see a button "(.*?)"$/ do
53
+ |label|
54
+
55
+ find_button(label).should_not be_nil
56
+
57
+ end
58
+
59
+ Then /^I should not see a button "(.*?)"$/ do
60
+ |label|
61
+
62
+ expect {
63
+ find_button(label)
64
+ }.to raise_error Capybara::ElementNotFound
65
+
66
+ end
@@ -16,6 +16,13 @@ class Script
16
16
 
17
17
  end
18
18
 
19
+ if req.request_method == "POST" \
20
+ && req.params["mark-as-unseen"]
21
+
22
+ mark_event_as_unseen context[:event_id]
23
+
24
+ end
25
+
19
26
  # read from database
20
27
 
21
28
  event =
@@ -77,6 +84,13 @@ class Script
77
84
  ]
78
85
  html << "</tr>\n"
79
86
 
87
+ html << "<tr>\n"
88
+ html << "<th>Status</th>\n"
89
+ html << "<td>%s</td>\n" % [
90
+ esc_ht(event["status"].to_s),
91
+ ]
92
+ html << "</tr>\n"
93
+
80
94
  html << "<tr>\n"
81
95
  html << "<th>Service</th>\n"
82
96
  html << "<td>%s</td>\n" % [
@@ -108,7 +122,7 @@ class Script
108
122
  html << "<tr>\n"
109
123
  html << "<th>Line number</th>\n"
110
124
  html << "<td>%s</td>\n" % [
111
- esc_ht((event["location"]["line"] + 1).to_s),
125
+ esc_ht((event["location"]["line"].to_i + 1).to_s),
112
126
  ]
113
127
  html << "</tr>\n"
114
128
 
@@ -149,13 +163,29 @@ class Script
149
163
 
150
164
  html << "<form method=\"post\">\n"
151
165
 
152
- html <<
153
- "<p>" +
154
- "<input " +
155
- "type=\"submit\" " +
156
- "name=\"mark-as-seen\" " +
157
- "value=\"mark as seen\">" +
158
- "</p>\n"
166
+ html << "<p>\n"
167
+
168
+ if event["status"] != "seen"
169
+
170
+ html <<
171
+ "<input " +
172
+ "type=\"submit\" " +
173
+ "name=\"mark-as-seen\" " +
174
+ "value=\"mark as seen\">\n"
175
+
176
+ end
177
+
178
+ if event["status"] != "unseen"
179
+
180
+ html <<
181
+ "<input " +
182
+ "type=\"submit\" " +
183
+ "name=\"mark-as-unseen\" " +
184
+ "value=\"mark as unseen\">\n"
185
+
186
+ end
187
+
188
+ html << "</p>\n"
159
189
 
160
190
  html << "</form>\n"
161
191
 
@@ -37,6 +37,32 @@ class Script
37
37
 
38
38
  end
39
39
 
40
+ def mark_event_as_unseen event_id
41
+
42
+ event = get_event event_id
43
+
44
+ return if event["status"] == "unseen"
45
+
46
+ event["status"] = "unseen"
47
+
48
+ @db["events"].save event
49
+
50
+ # update summary
51
+
52
+ @db["summaries"].update(
53
+ { "_id" => event["source"] },
54
+ { "$inc" => {
55
+ "combined.new" => 1,
56
+ "types.#{event["type"]}.new" => 1,
57
+ } }
58
+ )
59
+
60
+ # notify icinga checks
61
+
62
+ do_checks
63
+
64
+ end
65
+
40
66
  def get_summaries_by_service
41
67
 
42
68
  summaries_by_service = {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hq-log-monitor-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -139,6 +139,22 @@ dependencies:
139
139
  - - ! '>='
140
140
  - !ruby/object:Gem::Version
141
141
  version: 1.2.1
142
+ - !ruby/object:Gem::Dependency
143
+ name: json
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: 1.7.7
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: 1.7.7
142
158
  - !ruby/object:Gem::Dependency
143
159
  name: rake
144
160
  requirement: !ruby/object:Gem::Requirement