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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 649c5121fe848bcd51650fc4633b8039d66b1ae3
4
- data.tar.gz: 4b2c9619e6c9262b843b1968e8e2af5a2cea4fa5
3
+ metadata.gz: fe955a00e4d5ff6c55aa79d6d7c8fb52c48b7ee6
4
+ data.tar.gz: b65f5b6e58d3cc85967a2a936d1ed2bd011eab93
5
5
  SHA512:
6
- metadata.gz: 0104935a7d16914ad9737a4ba77ea07b2d4c22c569ad8a5ff2f8cd42f3c6b1c134dbac25e188955844324678adbdebb97e7baa75c901e3039c662de48aba0f92
7
- data.tar.gz: 914ee1b9c347155b1e7e45c414e0ffb433ff8f66f8844ebf7d1f1b73ad220196abfbead200f989081bcb7b27c9c0433c9594ce86790b8847be0d33fcad14c08a
6
+ metadata.gz: 2f9b1c820d9aa3737a2d4c37d9e051084114e2e3e6509bf2e2c2dd2c90aede4c75d7a632560bafda90f9cb72536a6644ddfa9fd2a967098aa32bc414fee3b167
7
+ data.tar.gz: de6b5397d491a0721b65efde530e5692889a1b3f01a3fddff3f52e07f43c6300886ac1ce8a33539eb51c8414e2b72b91bed1b22ebbe77357658d04972b983f62
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zway-cli.gemspec
4
+ gemspec
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
@@ -0,0 +1,15 @@
1
+ # MRTG2XY
2
+
3
+ A very simple utility to convert data from mrtg log files to a simple x:y format.
4
+
5
+ I use this to send data to a graph utility.
6
+
7
+ ## Installation
8
+
9
+ Install it yourself:
10
+
11
+ $ gem install mrtg2xy
12
+
13
+ ## Usage
14
+
15
+ $ mrtg2xy
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
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
@@ -0,0 +1,3 @@
1
+ module Mrtg2xy
2
+ VERSION = "1.0.1"
3
+ 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.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