ipcad2squid 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/ipcad2squid CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'rubygems'
3
4
  require 'ipcad2squid'
4
5
  require 'optparse'
5
6
 
data/ipcad2squid.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ipcad2squid'
3
- s.version = '1.1.1'
3
+ s.version = '1.1.2'
4
4
  s.date = '2013-01-03'
5
5
  s.summary = "Convert ipcad logs to squid logs"
6
6
  s.description = "Simple gem for converting and appending output from ipcad to squid logs formats"
@@ -15,4 +15,4 @@ Gem::Specification.new do |s|
15
15
  s.homepage = 'https://github.com/drakmail/ipcad2squid'
16
16
 
17
17
  s.add_development_dependency 'rspec'
18
- end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipcad2squid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -33,7 +33,6 @@ description: Simple gem for converting and appending output from ipcad to squid
33
33
  email: drakmail@delta.pm
34
34
  executables:
35
35
  - ipcad2squid
36
- - ipcad2squid.rb
37
36
  extensions: []
38
37
  extra_rdoc_files: []
39
38
  files:
@@ -41,7 +40,6 @@ files:
41
40
  - Gemfile
42
41
  - Gemfile.lock
43
42
  - bin/ipcad2squid
44
- - bin/ipcad2squid.rb
45
43
  - ipcad2squid.gemspec
46
44
  - lib/ipcad2squid.rb
47
45
  - spec/input1.txt
data/bin/ipcad2squid.rb DELETED
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- class Ipcad2squid
4
- attr_reader :cmd1, :cmd2, :net, :ttime, :filename
5
-
6
- def initialize(options={})
7
- @cmd1 = options[:cmd1] || 'netkit-rsh localhost sh ip accounting'
8
- @cmd2 = options[:cmd2] || 'netkit-rsh localhost show ip accounting checkpoint'
9
- @net = options[:net] || '192.168.0'
10
- @filename = options[:filename] || '/var/log/squid/access.log'
11
- @ttime = `#{@cmd1}`.split("\n").grep(/saved/) { |saved| saved.split.last }.first rescue '0'
12
- end
13
-
14
- def output
15
- # get all data for subnet
16
- accounting_data = `#{@cmd2}`.split("\n").grep(/#{@net}/)
17
-
18
- # parse and output data
19
- accounting_data.map do |raw_data|
20
- data = raw_data.split
21
- "#{@ttime}.000 1 #{data[1]} TCP_MISS/200 #{data[3]} CONNECT #{data[0]}:#{data[4]} - DIRECT/#{data[1]} -"
22
- end.join("\n")
23
- end
24
-
25
- def write_to_file
26
- File.open(@filename, "w") { |file| file.write(output) }
27
- end
28
- end