check-age 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +42 -0
- data/bin/check_age +9 -0
- data/lib/check/age.rb +35 -0
- data/lib/check/version.rb +3 -0
- metadata +84 -0
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/package_task'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'rdoc/task'
|
5
|
+
|
6
|
+
task :default => :spec
|
7
|
+
|
8
|
+
desc "Run specs"
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
10
|
+
spec.pattern = 'specs/**/*_spec.rb'
|
11
|
+
end
|
12
|
+
|
13
|
+
gem_spec = eval(File.read("check-age.gemspec"))
|
14
|
+
|
15
|
+
Gem::PackageTask.new(gem_spec) do |pkg|
|
16
|
+
pkg.gem_spec = gem_spec
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "install the gem locally"
|
20
|
+
task :install => [:package] do
|
21
|
+
sh %{gem install pkg/#{gem_spec.name}-#{gem_spec.version}}
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "create a gemspec file"
|
25
|
+
task :make_spec do
|
26
|
+
File.open("#{gem_spec.name}.gemspec", "w") do |file|
|
27
|
+
file.puts spec.to_ruby
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "remove build files"
|
32
|
+
task :clean do
|
33
|
+
sh %Q{ rm -f pkg/*.gem }
|
34
|
+
end
|
35
|
+
|
36
|
+
RDoc::Task.new do |rdoc|
|
37
|
+
rdoc.rdoc_dir = 'rdoc'
|
38
|
+
rdoc.title = "check-age #{gem_spec.version}"
|
39
|
+
rdoc.rdoc_files.include('README*')
|
40
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
41
|
+
end
|
42
|
+
|
data/bin/check_age
ADDED
data/lib/check/age.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/bin/env ruby
|
2
|
+
|
3
|
+
require 'sys/uptime'
|
4
|
+
require 'mixlib/cli'
|
5
|
+
|
6
|
+
class Age
|
7
|
+
include Sys
|
8
|
+
def self.check
|
9
|
+
return_value = nil
|
10
|
+
perf_string = "age_in_days=#{uptime.days}"
|
11
|
+
message = nil
|
12
|
+
if uptime.days == 20
|
13
|
+
message = "CRITICAL:I should die today, remember i'll shout only today"
|
14
|
+
return_value = 2
|
15
|
+
elsif uptime.days > 20
|
16
|
+
message = "WARNING: I'm dead man fucker"
|
17
|
+
return_value = 1
|
18
|
+
elsif uptime.days > 15
|
19
|
+
message = "WARNING: I'm too old to serve, kill me please!"
|
20
|
+
return_value = 1
|
21
|
+
else
|
22
|
+
message = "OK : I'm young are you?"
|
23
|
+
return_value = 0
|
24
|
+
end
|
25
|
+
return({ :return_value =>return_value,
|
26
|
+
:message => message,
|
27
|
+
:perf_string=> perf_string })
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def self.uptime
|
32
|
+
Uptime
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: check-age
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ranjib Dey
|
9
|
+
- Nilesh Bairagi
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-09-17 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sys-uptime
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: mixlib-cli
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: Nagios plugin that checks uptime of a server
|
48
|
+
email:
|
49
|
+
- dey.ranjib@gmail.com
|
50
|
+
- nileshb@thoughtworks.com
|
51
|
+
executables:
|
52
|
+
- check_age
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- Rakefile
|
57
|
+
- lib/check/age.rb
|
58
|
+
- lib/check/version.rb
|
59
|
+
- bin/check_age
|
60
|
+
homepage: https://github.com/ranjibd/check-age
|
61
|
+
licenses: []
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.8.23
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: Nagios plugin that checks uptime of a server
|
84
|
+
test_files: []
|