fritz 0.0.1
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.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/Rakefile +1 -0
- data/bin/fritz +3 -0
- data/config/hosts.yaml +11 -0
- data/config/schedule.rb +25 -0
- data/fritz.gemspec +29 -0
- data/lib/fritz.rb +58 -0
- data/lib/fritz/ping.rb +31 -0
- data/lib/fritz/version.rb +3 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTcyZjVjZDA3NGUyYjQ4OGNiZDg2NjE5NjlmZDJiODE0Yjc4ZjEwNw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OGI2YTEwMDk0OTA2ZmRiZDg2N2ZjNzliMDI3ZmIyYzRlNTljYjYwNA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDgwN2VmN2E0MzI4MGFkYjYwN2QzZTE3YWUyMzUwYmM0MjhjYTc4YmUzODI1
|
10
|
+
YzIyZTBhNmZlNWRmNGJkMmIzNjY4MmYzOTA5YTAwODU5MDY2MTMwMDhkNGFj
|
11
|
+
NmUxMzFmMGEzNzI2NDEzMjk1OGU3NjhlNzliNzkwODNjZTE5MGU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZGU3ZTIxNDcwYjJhNDZlMDllNDYzNDUzY2EyNzg5ODRhZDk5YmVjZWJmMjUz
|
14
|
+
YzBiY2E1NjgwMzBlODM4ZDAwODc2ZTBjZjNmYWFmNDY1ZjY4YjMyYTdiZTk2
|
15
|
+
YmFiZWNhYWFlNDVmY2ExOTcxOWIxNDQxZmMxOWZlNDE0YTYzMGU=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Juan Romero Abelleira
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Fritz
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Install fritz from your command line:
|
6
|
+
|
7
|
+
$ gem install fritz
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
1. Run `fritz setup FOLDER` for a folder of your choosing.
|
12
|
+
2. Edit `FOLDER/config/hosts.yaml` and `FOLDER/config/schedule.rb`
|
13
|
+
3. Run `fritz schedule`.
|
14
|
+
|
15
|
+
## Contributing
|
16
|
+
|
17
|
+
1. Fork it
|
18
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
19
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
20
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
21
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/fritz
ADDED
data/config/hosts.yaml
ADDED
data/config/schedule.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Use this file to easily define all of your Fritz cron jobs.
|
2
|
+
#
|
3
|
+
# It's helpful, but not entirely necessary to understand cron before proceeding.
|
4
|
+
# http://en.wikipedia.org/wiki/Cron
|
5
|
+
|
6
|
+
# Example:
|
7
|
+
#
|
8
|
+
# every 5.minutes do
|
9
|
+
# command "fritz hosts "+File.expand_path(../hosts.yaml, __FILE__)
|
10
|
+
# end
|
11
|
+
|
12
|
+
# Redirecting the output to a logfile:
|
13
|
+
#
|
14
|
+
# every 2.minutes do
|
15
|
+
# command File.expand_path("~/Documents/Cedras/Fritz/fritz/bin/fritz")+" hosts "+File.expand_path("../hosts.yaml", __FILE__), output: File.expand_path("../../log/hosts.log", __FILE__)
|
16
|
+
# end
|
17
|
+
|
18
|
+
# Using fritz with rbenv:
|
19
|
+
#
|
20
|
+
# every 2.minutes do
|
21
|
+
# command "export PATH=\"/home/user/.rbenv/bin:$PATH\" ; eval \"$(rbenv init -)\"; rbenv shell 1.9.3-p392; "+"/home/user/fritz/bin/fritz ping hosts "+File.expand_path("../hosts.yaml", __FILE__), output: File.expand_path("../../log/hosts.log", __FILE__)
|
22
|
+
# end
|
23
|
+
|
24
|
+
# Fritz uses whenever for scheduling.
|
25
|
+
# Learn more: http://github.com/javan/whenever
|
data/fritz.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fritz/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fritz"
|
8
|
+
spec.version = Fritz::VERSION
|
9
|
+
spec.authors = ["Juan Romero Abelleira"]
|
10
|
+
spec.email = ["romero@cedras.ch"]
|
11
|
+
spec.description = "Pings a list of IPs and reports their status."
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
spec.add_runtime_dependency 'thor', '~> 0.18.1'
|
27
|
+
spec.add_runtime_dependency 'net-ping', '~> 1.6.0'
|
28
|
+
spec.add_runtime_dependency 'whenever', '~> 0.8.2'
|
29
|
+
end
|
data/lib/fritz.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path("#{File.dirname(__FILE__)}/fritz/version")
|
3
|
+
require "thor"
|
4
|
+
require File.expand_path("#{File.dirname(__FILE__)}/fritz/ping")
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
module Fritz
|
8
|
+
class Fritz < Thor
|
9
|
+
include FileUtils
|
10
|
+
include Thor::Shell
|
11
|
+
|
12
|
+
desc "setup FOLDER", "Sets up a Fritz example configuration and log in the specified folder."
|
13
|
+
def setup(folder)
|
14
|
+
destination_root=folder
|
15
|
+
invoke :setup_config
|
16
|
+
invoke :setup_log
|
17
|
+
invoke :copy_readme
|
18
|
+
invoke :copy_hosts
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "schedule", "Uses the config to schedule the monitoring tasks."
|
22
|
+
def schedule
|
23
|
+
%x{whenever -w}
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "setup_config FOLDER", "Sets up an example config folder and file."
|
27
|
+
def setup_config(folder)
|
28
|
+
destination_root=folder
|
29
|
+
mkdir "config"
|
30
|
+
cp File.expand_path("../../config/schedule.rb", __FILE__), "config/"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "setup_log FOLDER", "Sets up and empty file in the log folder."
|
34
|
+
def setup_log(folder)
|
35
|
+
destination_root=folder
|
36
|
+
mkdir "log"
|
37
|
+
touch "log/hosts.log"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "copy_readme FOLDER", "Copies Fritz's README to the current folder."
|
41
|
+
def copy_readme(folder)
|
42
|
+
destination_root=folder
|
43
|
+
cp File.expand_path("../../README.md", __FILE__), "#{destination_root}"
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "copy_hosts FOLDER", "Copies Fritz's example hosts list to the config folder."
|
47
|
+
def copy_hosts(folder)
|
48
|
+
destination_root=folder
|
49
|
+
cp File.expand_path("../../config/hosts.yaml", __FILE__), "config/"
|
50
|
+
end
|
51
|
+
|
52
|
+
# register(class_name, subcommand_alias, usage_list_string, description_string)
|
53
|
+
register(Ping, "ping", "ping host(s) ADDRESS/LIST", "Type fritz ping for more information.")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# TODO Use Dir.pwd and --output or --target throughout
|
58
|
+
# TODO Suppose location of hosts.yaml
|
data/lib/fritz/ping.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require "thor"
|
3
|
+
require "net/ping"
|
4
|
+
require "yaml"
|
5
|
+
require "logger"
|
6
|
+
|
7
|
+
module Fritz
|
8
|
+
class Ping < Thor
|
9
|
+
@@logger = Logger.new($stdout, shift_age = 'weekly')
|
10
|
+
|
11
|
+
desc "host ADDRESS","Uses external ping command to ping one single host."
|
12
|
+
method_option :out, aliases: "-o", default: false, desc: "Whether the hosts status should be printed to STDOUT."
|
13
|
+
def host(address)
|
14
|
+
p = Net::Ping::External.new(address)
|
15
|
+
puts "#{address} #{p.ping?}" if options.out?
|
16
|
+
p.ping?
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "hosts FILE", "Pings all addresses in a yaml file."
|
20
|
+
method_option :logfile, aliases: "-l", desc: "Location of the writable logfile."
|
21
|
+
def hosts(file)
|
22
|
+
@@logger = Logger.new(options[:logfile], shift_age = 'weekly') unless options[:logfile].nil?
|
23
|
+
hosts = YAML.load(File.open(file))
|
24
|
+
hosts.each do |label, addresses|
|
25
|
+
addresses.each do |address|
|
26
|
+
@@logger.add Logger::Severity::INFO, "#{label}\t#{address}\t#{self.host(address)}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fritz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juan Romero Abelleira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.18.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.18.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: net-ping
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.6.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.6.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: whenever
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.8.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.8.2
|
83
|
+
description: Pings a list of IPs and reports their status.
|
84
|
+
email:
|
85
|
+
- romero@cedras.ch
|
86
|
+
executables:
|
87
|
+
- fritz
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- .gitignore
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/fritz
|
97
|
+
- config/hosts.yaml
|
98
|
+
- config/schedule.rb
|
99
|
+
- fritz.gemspec
|
100
|
+
- lib/fritz.rb
|
101
|
+
- lib/fritz/ping.rb
|
102
|
+
- lib/fritz/version.rb
|
103
|
+
homepage: ''
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.0.3
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Pings a list of IPs and reports their status.
|
127
|
+
test_files: []
|
128
|
+
has_rdoc:
|