xinuc-sermont 0.2.5
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/.document +5 -0
- data/.gitignore +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +62 -0
- data/Rakefile +61 -0
- data/VERSION.yml +4 -0
- data/bin/sermont +55 -0
- data/lib/config/sermont.yaml +18 -0
- data/lib/handler/ftp.rb +7 -0
- data/lib/handler/http.rb +7 -0
- data/lib/handler/mysql.rb +7 -0
- data/lib/handler/open_port.rb +13 -0
- data/lib/handler/ping.rb +9 -0
- data/lib/sermont.rb +156 -0
- data/sermont.gemspec +64 -0
- data/spec/sermont.yaml +18 -0
- data/spec/sermont_spec.rb +70 -0
- data/spec/spec_helper.rb +9 -0
- metadata +91 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Nugroho Herucahyono
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
= sermont
|
2
|
+
|
3
|
+
* http://github.com/xinuc/sermont
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Sermont is a command line based script to monitor your servers.
|
8
|
+
|
9
|
+
== SYNOPSIS:
|
10
|
+
|
11
|
+
type the command in your terminal.
|
12
|
+
|
13
|
+
sermont [options]
|
14
|
+
|
15
|
+
=== Options:
|
16
|
+
|
17
|
+
--setup : copy example config file to your home directory
|
18
|
+
-r, --raw : print the report without colors
|
19
|
+
-t TIME, --time TIME : checking every TIME seconds
|
20
|
+
-o FILE, --output FILE: write the report to the FILE
|
21
|
+
-d, --daemon : running as a daemon
|
22
|
+
-h, --help : print this help
|
23
|
+
-v, --version : print sermont version
|
24
|
+
|
25
|
+
=== Example:
|
26
|
+
|
27
|
+
sermont -r -o /var/log/sermont.log -d -t 1800
|
28
|
+
|
29
|
+
== REQUIREMENTS:
|
30
|
+
|
31
|
+
* term-ansicolor
|
32
|
+
* daemons
|
33
|
+
|
34
|
+
== INSTALL:
|
35
|
+
|
36
|
+
install term-ansicolor & daemons gem if you haven't
|
37
|
+
|
38
|
+
sudo gem install term-ansicolor
|
39
|
+
sudo gem install daemons
|
40
|
+
|
41
|
+
install xinuc-sermont from github.com
|
42
|
+
|
43
|
+
sudo gem install xinuc-sermont --source=http://gems.github.com
|
44
|
+
|
45
|
+
== Add Your Own Handler
|
46
|
+
|
47
|
+
If you have any services that can't be checked by simply open the port, you can
|
48
|
+
add you own service handler. As an example, if you want to check 'weird' service by
|
49
|
+
your own method, you can create a file name "weird.rb" under YOUR_HOME_DIR/.sermont/
|
50
|
+
Then, the file should be like :
|
51
|
+
|
52
|
+
# file: weird.rb
|
53
|
+
|
54
|
+
def weird(host, port)
|
55
|
+
# your own checking algorithm
|
56
|
+
# this method should return true if the service is running
|
57
|
+
# and false if the service is stopped.
|
58
|
+
end
|
59
|
+
|
60
|
+
== Copyright
|
61
|
+
|
62
|
+
Copyright (c) 2009 Nugroho Herucahyono. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "sermont"
|
8
|
+
gem.summary = "Server Monitor"
|
9
|
+
gem.description = "Sermont is a command line based script to monitor your servers."
|
10
|
+
gem.email = "xinuc@xinuc.org"
|
11
|
+
gem.homepage = "http://github.com/xinuc/sermont"
|
12
|
+
gem.authors = ["Nugroho Herucahyono"]
|
13
|
+
gem.add_dependency("daemons", ">= 1.0.10")
|
14
|
+
gem.add_dependency("term-ansicolor", ">= 1.0.3")
|
15
|
+
gem.executables = ["sermont"]
|
16
|
+
gem.default_executable = "sermont"
|
17
|
+
gem.rubyforge_project = "indofaker"
|
18
|
+
end
|
19
|
+
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
Rake::TestTask.new(:test) do |test|
|
26
|
+
test.libs << 'lib' << 'test'
|
27
|
+
test.pattern = 'test/**/*_test.rb'
|
28
|
+
test.verbose = true
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
require 'rcov/rcovtask'
|
33
|
+
Rcov::RcovTask.new do |test|
|
34
|
+
test.libs << 'test'
|
35
|
+
test.pattern = 'test/**/*_test.rb'
|
36
|
+
test.verbose = true
|
37
|
+
end
|
38
|
+
rescue LoadError
|
39
|
+
task :rcov do
|
40
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
task :default => :test
|
46
|
+
|
47
|
+
require 'rake/rdoctask'
|
48
|
+
Rake::RDocTask.new do |rdoc|
|
49
|
+
if File.exist?('VERSION.yml')
|
50
|
+
config = YAML.load(File.read('VERSION.yml'))
|
51
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
52
|
+
else
|
53
|
+
version = ""
|
54
|
+
end
|
55
|
+
|
56
|
+
rdoc.rdoc_dir = 'rdoc'
|
57
|
+
rdoc.title = "sermont #{version}"
|
58
|
+
rdoc.rdoc_files.include('README*')
|
59
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
60
|
+
end
|
61
|
+
|
data/VERSION.yml
ADDED
data/bin/sermont
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'sermont'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
if ARGV.empty?
|
9
|
+
Sermont.new.run
|
10
|
+
elsif ARGV.include?("--help") || ARGV.include?("-h")
|
11
|
+
help = <<-HELP
|
12
|
+
Usage: sermont [options]
|
13
|
+
Options:
|
14
|
+
|
15
|
+
--setup : copy example config file to your home directory
|
16
|
+
-r, --raw : print the report without colors
|
17
|
+
-t TIME, --time TIME : checking every TIME seconds
|
18
|
+
-o FILE, --output FILE: write the report to the FILE
|
19
|
+
-d, --daemon : running as a daemon
|
20
|
+
-h, --help : print this help
|
21
|
+
-v, --version : print sermont version
|
22
|
+
|
23
|
+
Example:
|
24
|
+
|
25
|
+
sermont -r -o /var/log/sermont.log -d -t 1800
|
26
|
+
|
27
|
+
Sermont by xinuc, http://github.com/xinuc/sermont
|
28
|
+
HELP
|
29
|
+
|
30
|
+
puts(help)
|
31
|
+
elsif ARGV.include?("--version") || ARGV.include?("-v")
|
32
|
+
config = YAML.load(File.read(File.dirname(__FILE__) + '/../' + 'VERSION.yml'))
|
33
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
34
|
+
puts "Sermont : version #{version}"
|
35
|
+
puts "Sermont by xinuc, http://github.com/xinuc/sermont"
|
36
|
+
elsif ARGV.include?("--setup")
|
37
|
+
FileUtils.cp(File.expand_path(File.dirname(__FILE__) + "/../lib/config/sermont.yaml"), File.expand_path("~/.sermont.yml"))
|
38
|
+
FileUtils.mkdir(File.expand_path("~/.sermont")) unless File.exists?(File.expand_path("~/.sermont"))
|
39
|
+
puts "Creating #{File.expand_path("~/.sermont")} directory."
|
40
|
+
puts "Copying .sermont.yml to your home directory."
|
41
|
+
puts "Please edit this file according to your servers."
|
42
|
+
else
|
43
|
+
raw, time, out, daemon = nil
|
44
|
+
raw = ARGV.include?("--raw") || ARGV.include?("-r")
|
45
|
+
if ARGV.include?("-t") || ARGV.include?("--time")
|
46
|
+
t_index = ARGV.index("-t") || ARGV.index("--time")
|
47
|
+
time = ARGV[t_index + 1]
|
48
|
+
end
|
49
|
+
if ARGV.include?("-o") || ARGV.include?("--output")
|
50
|
+
o_index = ARGV.index("-o") || ARGV.index("--output")
|
51
|
+
out = ARGV[o_index + 1]
|
52
|
+
end
|
53
|
+
daemon = ARGV.include?("--daemon") || ARGV.include?("-d")
|
54
|
+
Sermont.new.run(raw, time, out, daemon)
|
55
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Add your servers informations here
|
2
|
+
# the informations consist of :
|
3
|
+
# - servername: the name of the server
|
4
|
+
# - ip: ip address of your server
|
5
|
+
# - services: all the services of your server, consists of the name and the port
|
6
|
+
# see the examples below.
|
7
|
+
---
|
8
|
+
- servername: My Server
|
9
|
+
ip: 127.0.0.1
|
10
|
+
services:
|
11
|
+
ftp: 21
|
12
|
+
http: 80
|
13
|
+
- servername: Yet Another Server
|
14
|
+
ip: 127.0.0.2
|
15
|
+
services:
|
16
|
+
ftp: 21
|
17
|
+
http: 80
|
18
|
+
ssh: 22
|
data/lib/handler/ftp.rb
ADDED
data/lib/handler/http.rb
ADDED
data/lib/handler/ping.rb
ADDED
data/lib/sermont.rb
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "yaml"
|
3
|
+
require "fileutils"
|
4
|
+
begin
|
5
|
+
require "term/ansicolor"
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
require "daemons"
|
11
|
+
rescue LoadError
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir[File.dirname(__FILE__) + '/handler/*.rb'].each{|h| require h}
|
15
|
+
|
16
|
+
class Sermont
|
17
|
+
|
18
|
+
include Handler
|
19
|
+
begin
|
20
|
+
include Daemonize
|
21
|
+
rescue NameError
|
22
|
+
end
|
23
|
+
begin
|
24
|
+
include Term::ANSIColor
|
25
|
+
rescue NameError
|
26
|
+
end
|
27
|
+
|
28
|
+
W = 80
|
29
|
+
|
30
|
+
req_dir = File.expand_path("~/.sermont")
|
31
|
+
Dir[req_dir + '/*.rb'].each{|h| require h} if File.exists? req_dir
|
32
|
+
|
33
|
+
def initialize
|
34
|
+
@raw = !(defined?(Term::ANSIColor) && self.is_a?(Term::ANSIColor))
|
35
|
+
@can_daemon = defined?(Daemonize) && self.is_a?(Daemonize)
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_setup
|
39
|
+
config_file = File.expand_path("~/.sermont.yml")
|
40
|
+
unless File.exists?(config_file) && @servers = YAML.load(IO.read(config_file))
|
41
|
+
puts "Config file .sermont.yml doesn't exists or invalid."
|
42
|
+
puts "Run 'sermont --setup' to create example config file in your home directory"
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def run(raw = nil, time = nil, output = nil, daemon = nil)
|
48
|
+
load_setup
|
49
|
+
@raw = @raw || raw
|
50
|
+
unless time
|
51
|
+
output ? add_to_output(report, output) : print(report)
|
52
|
+
else
|
53
|
+
if daemon && @can_daemon && output
|
54
|
+
pwd = Dir.pwd
|
55
|
+
daemonize
|
56
|
+
Dir.chdir pwd
|
57
|
+
end
|
58
|
+
loop do
|
59
|
+
output ? add_to_output(report, output) : print(report)
|
60
|
+
begin
|
61
|
+
sleep time.to_i
|
62
|
+
rescue Exception
|
63
|
+
exit
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def add_to_output(out, file)
|
70
|
+
File.open(file, "ab") do |f|
|
71
|
+
f << out
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def report
|
76
|
+
report = notification(Time.now.to_s)
|
77
|
+
@servers.each do |server|
|
78
|
+
servername = server["servername"]
|
79
|
+
ip = server["ip"]
|
80
|
+
report << handle_host(servername, ip)
|
81
|
+
services = server["services"]
|
82
|
+
services.each do |k, v|
|
83
|
+
report << handle_service(k, ip, v)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
report
|
87
|
+
end
|
88
|
+
|
89
|
+
def notification(notif)
|
90
|
+
if @raw
|
91
|
+
notif + whitespace(notif) + "\n"
|
92
|
+
else
|
93
|
+
on_black + dark + notif + whitespace(notif) + clear + "\n"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def whitespace(str)
|
98
|
+
spaces = W - str.size
|
99
|
+
w = ""
|
100
|
+
spaces.times {w << " "}
|
101
|
+
w
|
102
|
+
end
|
103
|
+
|
104
|
+
def dotspace(str, f_indent, b_indent)
|
105
|
+
spaces = W - 4 - str.size - f_indent - b_indent
|
106
|
+
w = ""
|
107
|
+
spaces.times {w << "."}
|
108
|
+
w
|
109
|
+
end
|
110
|
+
|
111
|
+
def host_str(hostname)
|
112
|
+
if @raw
|
113
|
+
"#{hostname} is " + dotspace(hostname, 0, 10)
|
114
|
+
else
|
115
|
+
on_yellow + black + bold + "#{hostname} is " + dotspace(hostname, 0, 10) + clear
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def host_status(alive)
|
120
|
+
if alive
|
121
|
+
@raw ? "Alive \n" : bold + on_green + white + "Alive " + clear + "\n"
|
122
|
+
else
|
123
|
+
@raw ? "In Trouble\n" : bold + on_red + white + "In Trouble" + clear + "\n"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def handle_host(servername, ip)
|
128
|
+
host_str(servername) + host_status(self.ping ip)
|
129
|
+
end
|
130
|
+
|
131
|
+
def service_str(service)
|
132
|
+
if @raw
|
133
|
+
" #{service} is " + dotspace(service, 5, 10)
|
134
|
+
else
|
135
|
+
on_blue + yellow + bold + " #{service} is " + dotspace(service, 5, 10) + clear
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def service_status(running)
|
140
|
+
if running
|
141
|
+
@raw ? "Running \n" : bold + on_green + white + "Running " + clear + "\n"
|
142
|
+
else
|
143
|
+
@raw ? "Stopped \n" : bold + on_red + white + "Stopped " + clear + "\n"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def handle_service(handler, ip, port)
|
148
|
+
running = begin
|
149
|
+
self.send(handler, ip, port)
|
150
|
+
rescue NoMethodError
|
151
|
+
self.open_port(ip, port)
|
152
|
+
end
|
153
|
+
service_str(handler) + service_status(running)
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
data/sermont.gemspec
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{sermont}
|
5
|
+
s.version = "0.2.5"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Nugroho Herucahyono"]
|
9
|
+
s.date = %q{2009-06-09}
|
10
|
+
s.default_executable = %q{sermont}
|
11
|
+
s.description = %q{Sermont is a command line based script to monitor your servers.}
|
12
|
+
s.email = %q{xinuc@xinuc.org}
|
13
|
+
s.executables = ["sermont"]
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION.yml",
|
25
|
+
"bin/sermont",
|
26
|
+
"lib/config/sermont.yaml",
|
27
|
+
"lib/handler/ftp.rb",
|
28
|
+
"lib/handler/http.rb",
|
29
|
+
"lib/handler/mysql.rb",
|
30
|
+
"lib/handler/open_port.rb",
|
31
|
+
"lib/handler/ping.rb",
|
32
|
+
"lib/sermont.rb",
|
33
|
+
"sermont.gemspec",
|
34
|
+
"spec/sermont.yaml",
|
35
|
+
"spec/sermont_spec.rb",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/xinuc/sermont}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubyforge_project = %q{indofaker}
|
42
|
+
s.rubygems_version = %q{1.3.4}
|
43
|
+
s.summary = %q{Server Monitor}
|
44
|
+
s.test_files = [
|
45
|
+
"spec/sermont_spec.rb",
|
46
|
+
"spec/spec_helper.rb"
|
47
|
+
]
|
48
|
+
|
49
|
+
if s.respond_to? :specification_version then
|
50
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
51
|
+
s.specification_version = 3
|
52
|
+
|
53
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<daemons>, [">= 1.0.10"])
|
55
|
+
s.add_runtime_dependency(%q<term-ansicolor>, [">= 1.0.3"])
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<daemons>, [">= 1.0.10"])
|
58
|
+
s.add_dependency(%q<term-ansicolor>, [">= 1.0.3"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<daemons>, [">= 1.0.10"])
|
62
|
+
s.add_dependency(%q<term-ansicolor>, [">= 1.0.3"])
|
63
|
+
end
|
64
|
+
end
|
data/spec/sermont.yaml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Add your servers informations here
|
2
|
+
# the informations consist of :
|
3
|
+
# - servername: the name of the server
|
4
|
+
# - ip: ip address of your server
|
5
|
+
# - services: all the services of your server, consists of the name and the port
|
6
|
+
# see the examples below.
|
7
|
+
---
|
8
|
+
- servername: My Server
|
9
|
+
ip: 127.0.0.1
|
10
|
+
services:
|
11
|
+
ftp: 21
|
12
|
+
http: 80
|
13
|
+
- servername: Yet Another Server
|
14
|
+
ip: 127.0.0.2
|
15
|
+
services:
|
16
|
+
ftp: 21
|
17
|
+
http: 80
|
18
|
+
ssh: 22
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Sermont do
|
4
|
+
include Term::ANSIColor
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@sermont = Sermont.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should include some modules" do
|
11
|
+
Sermont.should include(Handler)
|
12
|
+
Sermont.should include(Daemonize)
|
13
|
+
Sermont.should include(Term::ANSIColor)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should set raw to true if can include ansicolor" do
|
17
|
+
@sermont.instance_variable_get("@raw").should == false
|
18
|
+
@sermont.instance_variable_get("@can_daemon").should == true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should load servers correctly" do
|
22
|
+
File.stubs(:expand_path).with("~/.sermont.yml").returns(File.dirname(__FILE__) + "/sermont.yaml")
|
23
|
+
@sermont.load_setup
|
24
|
+
servers = @sermont.instance_variable_get("@servers")
|
25
|
+
servers.should_not be_nil
|
26
|
+
servers.should == [{"servername"=>"My Server", "ip"=>"127.0.0.1", "services"=>{"ftp"=>21, "http"=>80}}, {"servername"=>"Yet Another Server", "ip"=>"127.0.0.2", "services"=>{"ftp"=>21, "ssh"=>22, "http"=>80}}]
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should exit if config not found" do
|
30
|
+
File.stubs(:exists?).with(File.expand_path("~/.sermont.yml")).returns false
|
31
|
+
@sermont.stubs(:exit).returns("EXIT")
|
32
|
+
@sermont.load_setup.should == "EXIT"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should has notification of 81 chars in raw" do
|
36
|
+
@sermont.instance_variable_set("@raw", true)
|
37
|
+
@sermont.notification("some notif").size.should == 81
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should has host str of 70 chars in raw" do
|
41
|
+
@sermont.instance_variable_set("@raw", true)
|
42
|
+
@sermont.host_str("some host").size.should == 70
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should has service str of 70 chars in raw" do
|
46
|
+
@sermont.instance_variable_set("@raw", true)
|
47
|
+
@sermont.service_str("some service").size.should == 70
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should has status of 11 chars in raw" do
|
51
|
+
@sermont.instance_variable_set("@raw", true)
|
52
|
+
@sermont.service_status(true).size.should == 11
|
53
|
+
@sermont.service_status(false).size.should == 11
|
54
|
+
@sermont.host_status(true).size.should == 11
|
55
|
+
@sermont.host_status(false).size.should == 11
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should has handle host of 81 chars in raw" do
|
59
|
+
@sermont.instance_variable_set("@raw", true)
|
60
|
+
@sermont.handle_host("this localhost", "127.0.0.1").size.should == 81
|
61
|
+
@sermont.handle_host("some weird host", "167.0.0.1").size.should == 81
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should has handle service of 81 chars in raw" do
|
65
|
+
@sermont.instance_variable_set("@raw", true)
|
66
|
+
@sermont.handle_service("http", "127.0.0.1", 80).size.should == 81
|
67
|
+
@sermont.handle_service("ldap", "127.0.0.1", 2000).size.should == 81
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xinuc-sermont
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nugroho Herucahyono
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-09 00:00:00 -07:00
|
13
|
+
default_executable: sermont
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: daemons
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.10
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: term-ansicolor
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.3
|
34
|
+
version:
|
35
|
+
description: Sermont is a command line based script to monitor your servers.
|
36
|
+
email: xinuc@xinuc.org
|
37
|
+
executables:
|
38
|
+
- sermont
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION.yml
|
51
|
+
- bin/sermont
|
52
|
+
- lib/config/sermont.yaml
|
53
|
+
- lib/handler/ftp.rb
|
54
|
+
- lib/handler/http.rb
|
55
|
+
- lib/handler/mysql.rb
|
56
|
+
- lib/handler/open_port.rb
|
57
|
+
- lib/handler/ping.rb
|
58
|
+
- lib/sermont.rb
|
59
|
+
- sermont.gemspec
|
60
|
+
- spec/sermont.yaml
|
61
|
+
- spec/sermont_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
has_rdoc: false
|
64
|
+
homepage: http://github.com/xinuc/sermont
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options:
|
67
|
+
- --charset=UTF-8
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
version:
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project: indofaker
|
85
|
+
rubygems_version: 1.2.0
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Server Monitor
|
89
|
+
test_files:
|
90
|
+
- spec/sermont_spec.rb
|
91
|
+
- spec/spec_helper.rb
|