bloopletech-webstats 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 10
4
- :patch: 1
4
+ :patch: 2
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + '/../clients/email_notifier/email_notifier'
@@ -63,128 +63,4 @@ END_OF_MESSAGE
63
63
  end
64
64
 
65
65
  s = EmailNotifier.new()
66
- s.start
67
-
68
- =begin
69
-
70
-
71
-
72
-
73
-
74
-
75
- require File.dirname(__FILE__) + '/../common'
76
- prepare_client
77
-
78
- load_settings('email_notifier', { 'email_addresses' => ['example@example.com'] }] }, "Please edit ~/.webstats_clients and add some email addresss to send to")
79
-
80
- urls = $settings[:urls]
81
- emails = $settings[:emails]
82
-
83
- failed_url = lambda do |url, password, exception|
84
- g.notify "Webstats Notification", "Cannot load Webstats data", "Could not load #{url}#{!password.nil? ? " with password #{password}" : ""}, error was #{exception.message}. Will try again in 60 seconds."
85
- sleep(60)
86
- true
87
- end
88
-
89
- urls.each do |url|
90
- url.merge!({ :meta_info => make_request(URI.join(url[:url], "information"), url[:password], failed_url), :last_warnings_text => nil, :last_danger_text => nil, :last_time => 0 })
91
- end
92
-
93
- while(true)
94
- urls.each do |url|
95
- data = make_request(URI.join(url[:url], "update"), url[:password], failed_url)
96
-
97
- bad = data.sort { |a, b| b[1]['importance'].to_f <=> a[1]['importance'].to_f }.select { |(k, v)| !v['status'].nil? && v['status'] != '' }
98
-
99
- has_warnings = bad.detect { |(k, v)| v['status'] == 'warning' }
100
- has_dangers = bad.detect { |(k, v)| v['status'] == 'danger' }
101
-
102
- title = []
103
- title << "Danger" if has_dangers
104
- title << "Warnings" if has_warnings
105
- title = title.join(" & ") + " for host #{URI.parse(url[:url]).host}"
106
-
107
- warnings_text = has_warnings ? "Warnings for #{bad.select { |(k, v)| v['status'] == 'warning' }.map { |(k, v)| url[:meta_info][k]['in_sentence'] }.join(", ")}." : nil
108
- danger_text = has_dangers ? "Dangerous situation for #{bad.select { |(k, v)| v['status'] == 'danger' }.map { |(k, v)| url[:meta_info][k]['in_sentence'] }.join(", ")}." : nil
109
-
110
- if url[:last_warnings_text] != warnings_text or url[:last_danger_text] != danger_text or (url[:last_time] != 0 and (Time.now - url[:last_time]) > 60)
111
- url[:last_warnings_text] = warnings_text
112
- url[:last_danger_text] = danger_text
113
- url[:last_time] = Time.now
114
-
115
- unless bad.empty?
116
- g.notify "Webstats Notification", title, [danger_text, warnings_text].compact.join(" "), nil, nil, true, (has_dangers ? 2 : 1)
117
- end
118
- end
119
- end
120
-
121
- sleep(10)
122
- end
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
- require 'rubygems'
162
- require 'net/smtp'
163
- require 'net/dns/resolver'
164
- require 'net/dns/rr'
165
- require 'time'
166
-
167
- def send_mail_hardcore(recipient, recipient_name, from, from_name, subject, message)
168
- username, domain = recipient.split('@', 2) #yeah yeah, username can contain @ sign, will fix later
169
-
170
- mxrs = Net::DNS::Resolver.new.mx(domain)
171
- if mxrs.empty?
172
- puts "No MX records on domain; bad domain name"
173
- return
174
- end
175
-
176
- msg = <<END_OF_MESSAGE
177
- From: #{from_name || recipient_name} <#{from || recipient}>
178
- To: #{recipient_name} <#{recipient}>
179
- Subject: #{subject}
180
- Date: #{Time.now.rfc2822}
181
- Message-Id: <#{Time.now.to_i}.#{rand(10000000)}@#{domain}>
182
-
183
- #{message}
184
- END_OF_MESSAGE
185
-
186
- Net::SMTP.start(mxrs.first.exchange, 25, domain) { |smtp| smtp.send_message msg, recipient, recipient }
187
- end
188
-
189
- send_mail_hardcore(*ARGV)
190
- =end
66
+ s.start
data/webstats.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{webstats}
5
- s.version = "0.10.1"
5
+ s.version = "0.10.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Brenton Fletcher"]
9
- s.date = %q{2009-05-14}
9
+ s.date = %q{2009-05-15}
10
10
  s.description = %q{Monitor server CPU/Memory/Disk Usage/URL Loading, so that you can view those statistics on a web page, as well as providing an interface to client prorams to read those statistics.}
11
11
  s.email = %q{i@bloople.net}
12
12
  s.executables = ["webstats", "webstats_growl_notifier"]
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  "Rakefile",
22
22
  "VERSION.yml",
23
23
  "bin/webstats",
24
+ "bin/webstats_email_notifier",
24
25
  "bin/webstats_growl_notifier",
25
26
  "clients/email_notifier/README.textile",
26
27
  "clients/email_notifier/email_notifier.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bloopletech-webstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brenton Fletcher
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-14 00:00:00 -07:00
12
+ date: 2009-05-15 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -29,6 +29,7 @@ files:
29
29
  - Rakefile
30
30
  - VERSION.yml
31
31
  - bin/webstats
32
+ - bin/webstats_email_notifier
32
33
  - bin/webstats_growl_notifier
33
34
  - clients/email_notifier/README.textile
34
35
  - clients/email_notifier/email_notifier.rb