rec 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/lib/rec/correlator.rb +1 -1
- data/lib/rec/notify.rb +14 -13
- metadata +4 -4
data/CHANGELOG
CHANGED
data/lib/rec/correlator.rb
CHANGED
@@ -57,7 +57,7 @@ class Correlator
|
|
57
57
|
# and checks the message against the ruleset. Continuously loops until
|
58
58
|
# the log input stream is closed, or interrupted by a signal
|
59
59
|
def run()
|
60
|
-
while @running and !$stdin.
|
60
|
+
while @running and !$stdin.closed? do
|
61
61
|
logLine = gets()
|
62
62
|
next if logLine.nil?
|
63
63
|
logLine.strip!()
|
data/lib/rec/notify.rb
CHANGED
@@ -45,12 +45,19 @@ module REC # :nodoc:
|
|
45
45
|
# While we're on the topic of security, just a reminder that Notify::mail requires no credentials.
|
46
46
|
module Notify
|
47
47
|
|
48
|
+
@@workHours = 7...21
|
49
|
+
@@defaultSubject = "Alert"
|
50
|
+
|
51
|
+
# define the working hours during which instant messages are allowed
|
52
|
+
# Note that Notify.work_hours(7,21) means "7am-9pm" as you would assume, so from 07:00 to 20:59
|
53
|
+
def self.work_hours(start, finish)
|
54
|
+
@@workHours = start..finish
|
55
|
+
end
|
56
|
+
|
48
57
|
# Sets the default subject for alerts, overriding the system default of "Alert"
|
49
58
|
def self.default_subject(subject)
|
50
59
|
@@defaultSubject = subject
|
51
60
|
end
|
52
|
-
@@defaultSubject = "Alert"
|
53
|
-
|
54
61
|
|
55
62
|
# provides the credentials needed for sending email
|
56
63
|
def self.smtp_credentials(user, password, domain, server="smtp.gmail.com", port=587)
|
@@ -87,29 +94,23 @@ module Notify
|
|
87
94
|
def self.email(alert, recipient=@@emailTo, subject=@@defaultSubject)
|
88
95
|
smtp = Net::SMTP.new(@@emailServer, @@emailPort)
|
89
96
|
smtp.enable_starttls()
|
90
|
-
smtp.start(@@emailDomain, @@
|
91
|
-
smtp.send_message(alert, @@
|
97
|
+
smtp.start(@@emailDomain, @@emailUser, @@emailPassword, :plain)
|
98
|
+
smtp.send_message(alert, @@emailUser, recipient)
|
99
|
+
smtp.finish()
|
92
100
|
end
|
93
101
|
|
94
102
|
# Send the alert via google talk (or any other XMPP service)
|
95
103
|
def self.jabber(alert, recipient=@@jabberTo, subject=@@defaultSubject)
|
96
|
-
client = Jabber::Client::new(Jabber::JID.new(@@
|
104
|
+
client = Jabber::Client::new(Jabber::JID.new(@@jabberUser))
|
97
105
|
client.connect(@@jabberServer)
|
98
106
|
client.auth(@@jabberPassword)
|
99
107
|
message = Jabber::Message::new(recipient, alert).set_type(:normal).set_id('1').set_subject(subject)
|
100
108
|
client.send(message)
|
101
109
|
end
|
102
110
|
|
103
|
-
# define the working hours during which instant messages are allowed
|
104
|
-
# Note that Notify.work_hours(7,21) means "7am-9pm" as you would assume, so from 07:00 to 20:59
|
105
|
-
def self.work_hours(start, finish)
|
106
|
-
@@workHours = start..finish
|
107
|
-
end
|
108
|
-
@@workHours = 7...21
|
109
|
-
|
110
111
|
# Send an instant message during work hours, else send an email
|
111
112
|
def self.urgent(alert)
|
112
|
-
if @@
|
113
|
+
if @@workHours.include?(Time.now.hour)
|
113
114
|
self.jabber(alert)
|
114
115
|
else
|
115
116
|
self.email(alert)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 5
|
10
|
+
version: 1.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Richard Kernahan
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-10-01 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: xmpp4r
|