mrtg2xy 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +15 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/exe/mrtg2xy +77 -0
- data/lib/mrtg2xy/version.rb +3 -0
- data/lib/mrtg2xy.rb +1 -0
- data/mrtg2xy.gemspec +26 -0
- metadata +15 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe955a00e4d5ff6c55aa79d6d7c8fb52c48b7ee6
|
4
|
+
data.tar.gz: b65f5b6e58d3cc85967a2a936d1ed2bd011eab93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f9b1c820d9aa3737a2d4c37d9e051084114e2e3e6509bf2e2c2dd2c90aede4c75d7a632560bafda90f9cb72536a6644ddfa9fd2a967098aa32bc414fee3b167
|
7
|
+
data.tar.gz: de6b5397d491a0721b65efde530e5692889a1b3f01a3fddff3f52e07f43c6300886ac1ce8a33539eb51c8414e2b72b91bed1b22ebbe77357658d04972b983f62
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jeff McFadden
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mrtg2xy"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/mrtg2xy
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
options = {}
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: mrtg2xy [options] file"
|
8
|
+
|
9
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
10
|
+
options[:verbose] = v
|
11
|
+
end
|
12
|
+
|
13
|
+
opts.on("-t", "--time-frame [day|week|month|year]", "Time Frame") do |tf|
|
14
|
+
options[:timeframe] = tf
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("-f", "--factor [factor]", "Factor") do |factor|
|
18
|
+
options[:factor] = factor
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end.parse!
|
23
|
+
|
24
|
+
# p options
|
25
|
+
# p ARGV
|
26
|
+
|
27
|
+
# puts "Aliases:"
|
28
|
+
# puts zway.aliases
|
29
|
+
|
30
|
+
file = ARGV.last
|
31
|
+
|
32
|
+
if file.nil?
|
33
|
+
puts "No file specified."
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
|
37
|
+
puts options
|
38
|
+
|
39
|
+
mrtg_data = File.open( file ).read
|
40
|
+
|
41
|
+
lines = mrtg_data.split( "\n" )
|
42
|
+
lines.shift #Get rid of the useless first line
|
43
|
+
|
44
|
+
if options[:timeframe] == "day"
|
45
|
+
data = lines[0..604]
|
46
|
+
elsif options[:timeframe] == "week"
|
47
|
+
data = lines[605..1204]
|
48
|
+
elsif options[:timeframe] == "month"
|
49
|
+
data = lines[1205..1804]
|
50
|
+
elsif options[:timeframe] == "year"
|
51
|
+
data = lines[1804..2535]
|
52
|
+
end
|
53
|
+
|
54
|
+
data.each do |line|
|
55
|
+
vals = line.split( " " )
|
56
|
+
|
57
|
+
x = vals[0].to_f
|
58
|
+
y = vals[1].to_f
|
59
|
+
|
60
|
+
unless options[:factor].nil?
|
61
|
+
y = y * options[:factor].to_f
|
62
|
+
end
|
63
|
+
|
64
|
+
puts "#{x}:#{y}"
|
65
|
+
end
|
66
|
+
|
67
|
+
# day: 0, 604
|
68
|
+
# week: 605, 1204
|
69
|
+
# month: 1205, 1804
|
70
|
+
# year: 1804, 2535
|
71
|
+
|
72
|
+
# ts = 0
|
73
|
+
# mrtg_data.split( "\n" ).each_with_index do |line, index|
|
74
|
+
# new_ts = line.split( " " ).first.to_i
|
75
|
+
# puts "#{index} : #{ts - new_ts}"
|
76
|
+
# ts = new_ts
|
77
|
+
# end
|
data/lib/mrtg2xy.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'zway/cli.rb'
|
data/mrtg2xy.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8 #
|
2
|
+
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'mrtg2xy/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "mrtg2xy"
|
10
|
+
spec.version = Mrtg2xy::VERSION
|
11
|
+
spec.authors = ["jeffmcfadden"]
|
12
|
+
spec.email = ["jeff@forgeapps.com"]
|
13
|
+
|
14
|
+
spec.summary = %q{Convert MRTG data files to an X:Y data format.}
|
15
|
+
spec.description = %q{Convert MRTG data files to an X:Y data format.}
|
16
|
+
spec.homepage = "https://github.com/jeffmcfadden/mrtg2xy"
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mrtg2xy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jeffmcfadden
|
@@ -41,10 +41,22 @@ dependencies:
|
|
41
41
|
description: Convert MRTG data files to an X:Y data format.
|
42
42
|
email:
|
43
43
|
- jeff@forgeapps.com
|
44
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- mrtg2xy
|
45
46
|
extensions: []
|
46
47
|
extra_rdoc_files: []
|
47
|
-
files:
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- exe/mrtg2xy
|
57
|
+
- lib/mrtg2xy.rb
|
58
|
+
- lib/mrtg2xy/version.rb
|
59
|
+
- mrtg2xy.gemspec
|
48
60
|
homepage: https://github.com/jeffmcfadden/mrtg2xy
|
49
61
|
licenses:
|
50
62
|
- MIT
|