opticon 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,22 +1 @@
1
- === 0.0.3 :: 2008-03-02
2
-
3
- * When a service doesn't respond, a ConnectionFailure is now correctly
4
- recorded. You can change how long Opticon will wait for a connection by
5
- setting the Opticon.default_timeout value. The timeout is 3 seconds by
6
- default.
7
- * Changed require paths to fix strange loading problems experienced
8
- by some people.
9
-
10
- === 0.0.2 :: 2007-11-15
11
-
12
- * A series of tests on a service can now be specified as a block to the
13
- Service#test method.
14
- * All failures generated inside a test block are all batched together
15
- into one notification.
16
- * Opticon test scripts can now be run with the "-v" switch to verbosely
17
- display what the script is doing.
18
- * Failure messages are now a bit more readable for non-techies.
19
-
20
- === 0.0.1 :: 2007-02-21
21
-
22
- * First public release.
1
+ See History.txt
@@ -0,0 +1,30 @@
1
+ === 0.0.4 :: 2008-10-09
2
+
3
+ * Added the SNMPTrap notifier to make it possible to send failure notifications
4
+ as SNMP traps.
5
+ * Added the IOStream notifier to print failures to an output stream. By default
6
+ the $stderr stream is used, but this can be configured to point to a file
7
+ or any other output stream.
8
+
9
+ === 0.0.3 :: 2008-04-02
10
+
11
+ * When a service doesn't respond, a ConnectionFailure is now correctly
12
+ recorded. You can change how long Opticon will wait for a connection by
13
+ setting the Opticon.default_timeout value. The timeout is 3 seconds by
14
+ default.
15
+ * Changed require paths to fix strange loading problems experienced
16
+ by some people.
17
+
18
+ === 0.0.2 :: 2007-11-15
19
+
20
+ * A series of tests on a service can now be specified as a block to the
21
+ Service#test method.
22
+ * All failures generated inside a test block are all batched together
23
+ into one notification.
24
+ * Opticon test scripts can now be run with the "-v" switch to verbosely
25
+ display what the script is doing.
26
+ * Failure messages are now a bit more readable for non-techies.
27
+
28
+ === 0.0.1 :: 2007-02-21
29
+
30
+ * First public release.
@@ -1,5 +1,3 @@
1
- .loadpath
2
- .project
3
1
  CHANGELOG.txt
4
2
  History.txt
5
3
  Manifest.txt
data/README.txt CHANGED
@@ -1,3 +1,10 @@
1
+ = Opticon
2
+
3
+ *Copyright*:: 2008 Urbacon Ltd.
4
+ *Authors*:: Matt Zukowski <matt at roughest dot net>
5
+ *Homepage*:: http://opticon.googlecode.com
6
+
7
+
1
8
  Opticon is a no-nonsense utility for monitoring HTTP-based services (i.e. websites).
2
9
 
3
10
  When triggered, opticon connects to a list of URIs and checks to make sure that
@@ -13,3 +20,23 @@ page at:
13
20
  http://code.google.com/p/opticon/
14
21
 
15
22
  (Have a look at the Wiki in particular)
23
+
24
+
25
+ == License
26
+
27
+ Opticon is free software; you can redistribute it and/or modify
28
+ it under the terms of the GNU Lesser General Public License as published
29
+ by the Free Software Foundation; either version 2 of the License, or
30
+ (at your option) any later version.
31
+
32
+ Opticon is distributed in the hope that it will be useful,
33
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
34
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35
+ GNU General Public License for more details.
36
+
37
+ You should have received a copy of the GNU Lesser General Public License
38
+ along with RubyCAS-Server; if not, write to the Free Software
39
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
40
+
41
+
42
+
@@ -33,7 +33,7 @@ FROM = "opticon@nowhere.foo"
33
33
  # default notification behaviour for Opticon, which is to email failures to the
34
34
  # addresses you configured above.
35
35
 
36
- Opticon.default_notifiers = Opticon::Notifier::Email.new(SEND_TO, :from => FROM)
36
+ Opticon.default_notifiers << Opticon::Notifier::Email.new(SEND_TO, :from => FROM)
37
37
 
38
38
  # You may need to configure the Mailer with your mail server info. Here's how to
39
39
  # use an SMTP mail server (unless you do this, local sendmail will be used used
@@ -3,7 +3,7 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
 
4
4
  module Opticon
5
5
 
6
- @@default_notifiers = nil
6
+ @@default_notifiers = []
7
7
  def default_notifiers
8
8
  @@default_notifiers
9
9
  end
@@ -3,7 +3,7 @@ require 'pstore'
3
3
 
4
4
  module Opticon
5
5
  module Notifier
6
- # Send failure notifications via email to the given list of recipients.
6
+ # Sends failure notifications via email to the given list of recipients.
7
7
  #
8
8
  # To set options, configure Opticon::Mailer the same way you
9
9
  # would any other ActionMailer. For example, to send via SMTP:
@@ -25,9 +25,9 @@ module Opticon
25
25
  # this is set to true.
26
26
  @@resend = false
27
27
 
28
- def initialize(recipients, options = {:from => "opticon@#{ENV['HOSTNAME']}"})
28
+ def initialize(recipients, options = {})
29
29
  @recipients = recipients
30
- @from = options[:from]
30
+ @from = options[:from] || "opticon@#{ENV['HOSTNAME']}"
31
31
  end
32
32
 
33
33
  def notify(failures)
@@ -54,8 +54,82 @@ module Opticon
54
54
  end
55
55
  end
56
56
 
57
+ # Prints failures to an output stream. By default failures are sent to
58
+ # $stderr, but this can be changed using the :output_stream configuration
59
+ # option.
60
+ class IOStream
61
+ attr_accessor :output_stream
62
+
63
+ def initialize(output_stream = $stderr, options = {})
64
+ @output_stream = output_stream
65
+ end
66
+
67
+ def notify(failures)
68
+ if ARGV.include?("-v")
69
+ puts "Printing #{failures.size} failures to #{output_stream}:"
70
+ failures.each{|f| puts " #{f.failure_message}"}
71
+ end
72
+
73
+ failures.each do |f|
74
+ # TODO: make output format configurable
75
+ output_stream.puts "#{Time.now} :: #{f.uri} :: #{f.failure_message}"
76
+ end
77
+ end
78
+ end
79
+
80
+ # Sends failure notifications as SNMP traps.
81
+ #
82
+ # The notification is sent using the `snmptrap` command-line utility, part
83
+ # of the Net-SNMP perl package. You will have to install Net-SNMP prior
84
+ # to using this notifier. On Linux machines this is generally as easy as
85
+ # `apt-get install net-snmp` or `smart install net-snmp`. On Windows
86
+ # machines, you're on your own.
87
+ #
88
+ # In the future the net-snmp requirement may be swapped in favor of using
89
+ # the native Ruby SNMP library, but for now you need net-snmp.
90
+ class SNMPTrap
91
+ attr_accessor :to_host, :snmp_community, :enterprise_oid,
92
+ :snmp_persistent_dir
93
+
94
+ def initialize(to_host, snmp_community, options = {})
95
+ @to_host = to_host
96
+ @snmp_community = snmp_community
97
+ @enterprise_oid = options[:enterprise_oid] || '1.3.6.1.4.1.3.1.1'
98
+ @snmp_persistent_dir = options[:snmp_persistent_dir] || '/tmp'
99
+ end
100
+
101
+ def notify(failures)
102
+ failures = [failures] unless failures.kind_of? Array
103
+
104
+ if ARGV.include?("-v")
105
+ puts "Sending SNMP trap(s) to #{to_host} regarding #{failures.size} failures:"
106
+ failures.each{|f| puts " #{f.failure_message}"}
107
+ end
108
+
109
+ failures.each do |f|
110
+ oid = '1.3.1.2.1.1.0'
111
+ typ = 's'
112
+
113
+ # TODO: make msg format configurable
114
+ msg = ("Opticon Test Failure on URL #{f.uri} :: #{f.failure_message}").gsub(/"/, '\"')
115
+
116
+ debug = "-d" if ARGV.include?("-v")
117
+ cmd = %{snmptrap -v 1 #{debug} -c #{snmp_community} #{to_host} #{enterprise_oid} #{ENV['HOSTNAME']} 6 0 '' #{oid} #{typ} "#{msg}"}
118
+
119
+ puts ">> #{cmd}" if ARGV.include?("-v")
120
+
121
+ # Band-aid fix for bug in Net-SNMP.
122
+ # See http://sourceforge.net/tracker/index.php?func=detail&aid=1588455&group_id=12694&atid=112694
123
+ ENV['SNMP_PERSISTENT_DIR'] ||= snmp_persistent_dir
124
+
125
+ `#{cmd}`
126
+ end
127
+ end
128
+ end
129
+
57
130
  # Dummy notifier used in testing. It doesn't do anything other than store
58
- # the error_messages given to notify in the object's notifications attribute.
131
+ # the error_messages fed in to the notify method. These can later be
132
+ # be retrieved by looking at the object's notifications instance attribute.
59
133
  class Dummy
60
134
  attr_accessor :notifications
61
135
 
@@ -2,7 +2,7 @@ module Opticon #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opticon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zukowski
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-02 00:00:00 -04:00
12
+ date: 2008-10-09 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: actionmailer
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -21,6 +22,16 @@ dependencies:
21
22
  - !ruby/object:Gem::Version
22
23
  version: "0"
23
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.0
34
+ version:
24
35
  description: Peace of mind through automated monitoring of your HTTP services.
25
36
  email: matt [at] roughest.net
26
37
  executables: []
@@ -33,8 +44,6 @@ extra_rdoc_files:
33
44
  - Manifest.txt
34
45
  - README.txt
35
46
  files:
36
- - .loadpath
37
- - .project
38
47
  - CHANGELOG.txt
39
48
  - History.txt
40
49
  - Manifest.txt
@@ -82,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
91
  requirements: []
83
92
 
84
93
  rubyforge_project: opticon
85
- rubygems_version: 1.0.1
94
+ rubygems_version: 1.2.0
86
95
  signing_key:
87
96
  specification_version: 2
88
97
  summary: Peace of mind through automated monitoring of your HTTP services.
data/.loadpath DELETED
@@ -1,5 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <loadpath>
3
- <pathentry path="" type="src"/>
4
- <pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con"/>
5
- </loadpath>
data/.project DELETED
@@ -1,17 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <projectDescription>
3
- <name>opticon</name>
4
- <comment></comment>
5
- <projects>
6
- </projects>
7
- <buildSpec>
8
- <buildCommand>
9
- <name>org.rubypeople.rdt.core.rubybuilder</name>
10
- <arguments>
11
- </arguments>
12
- </buildCommand>
13
- </buildSpec>
14
- <natures>
15
- <nature>org.rubypeople.rdt.core.rubynature</nature>
16
- </natures>
17
- </projectDescription>