sms-logparser 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 038037b20ed15c61e41f16b8dbdaf98ccce4df63
4
- data.tar.gz: d2717600032260e584b99d6467176ba2a4301d55
3
+ metadata.gz: bbfc8b0c75a4548ae8c9f15f2a79aeeb54066e9e
4
+ data.tar.gz: 7ab7890fcb50d47710d476e1de9078b8ebac901e
5
5
  SHA512:
6
- metadata.gz: 77f4e55d44aa15408cd9b89ea105128dc184ebfda13cbb041c52d4d2980251de3699414280879636851ef6237918ec200217cca5bee6c83abfb7572fd52c16bf
7
- data.tar.gz: e7869987d1c8fb3baffef551c2e7a0b14ac86fe391434cd3db89bed7134e4f232cab038091c0fb5a623abdb37aa260640890640a503426a227cbaa519c07c6bb
6
+ metadata.gz: 4f17dbe07a0804b3a47a09855c8a3c9873dd8e0ff1453ff688752e3c67d77c407ece48a069ab192f9e5abb42ad59e7c566c8eedeab1a7eca8914abe30885371f
7
+ data.tar.gz: c97f560d1f4ade101f0277b9f7d660f7218b933b00308274483f4610dde49692df6c2c7ac4735634ffc2cd9958c98cb22c597d6b4bb28824a9120a8e38310e87
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SmsLogparser
2
2
 
3
- sms-logparser for DB-Logparser for Simplex Media Server
3
+ sms-logparser - DB-Logparser for Simplex Media Server (SMS). Reads access logs stored in a MySQL database (coming from the SWISS TXT CDN) and pushes them to the SMS API.
4
4
 
5
5
  ## Installation
6
6
 
@@ -22,13 +22,13 @@ Create the database table to track which logs have been parsed:
22
22
 
23
23
  $ sms-logparser create_parser_table
24
24
 
25
- Make a testrun:
25
+ Make a test run:
26
26
 
27
27
  $ sms-logparser parse --simulate
28
28
 
29
29
  ## Usage
30
30
 
31
- See available commamds:
31
+ See available commands:
32
32
 
33
33
  $ sms-logparser help
34
34
 
@@ -36,6 +36,10 @@ Parse logs from database and send them to the API
36
36
 
37
37
  $ sms-logparser parse
38
38
 
39
+ Show the last parser runs:
40
+
41
+ $ sms-logparser last_runs
42
+
39
43
  ## Contributing
40
44
 
41
45
  1. Fork it
@@ -13,6 +13,12 @@ module SmsLogparser
13
13
  class_option :mysql_user, :default => 'root'
14
14
  class_option :mysql_db, :default => 'Syslog'
15
15
 
16
+ desc "version", "print cloudstack-cli version number"
17
+ def version
18
+ say "sms-logparser version #{SmsLogparser::VERSION}"
19
+ end
20
+ map %w(-v --version) => :version
21
+
16
22
  desc "parse", "Check the database for pcache logs and send them to SMS"
17
23
  option :api_base_path, :default => 'http://dev.simplex.tv/creator/rest'
18
24
  option :simulate, :type => :boolean, :default => false
@@ -49,7 +55,7 @@ module SmsLogparser
49
55
  rescue
50
56
  say "Error: Can't send log to #{url}", :red
51
57
  say "Aborting.", :red
52
- exit 1
58
+ break
53
59
  end
54
60
  end
55
61
  count += 1
@@ -60,13 +66,38 @@ module SmsLogparser
60
66
  puts "Number of valid messages found: #{count}"
61
67
  end
62
68
 
69
+ desc "last_runs", "List the last paser runs"
70
+ def last_runs
71
+ begin
72
+ runs = client.query(
73
+ "SELECT * FROM SmsParserRuns ORDER BY ID ASC LIMIT 10"
74
+ )
75
+ rescue Mysql2::Error
76
+ say "parser_table not found please create it with 'create_parser_table'", :red
77
+ exit 1
78
+ end
79
+ if runs.size > 0
80
+ table = [%w(RunAt #Events LastEventID)]
81
+ runs.each do |run|
82
+ table << [
83
+ run['RunAt'],
84
+ run['EventsFound'],
85
+ run['LastEventID']
86
+ ]
87
+ end
88
+ print_table table
89
+ else
90
+ say "No parser runs found in the database."
91
+ end
92
+ end
93
+
63
94
  desc "create_parser_table", "Create the parser table to track the last logs parsed"
64
95
  def create_parser_table
65
96
  client.query(
66
97
  "CREATE TABLE IF NOT EXISTS\
67
98
  SmsParserRuns(\
68
99
  ID INT PRIMARY KEY AUTO_INCREMENT,\
69
- LastRunAt datetime DEFAULT NULL,\
100
+ RunAt datetime DEFAULT NULL,\
70
101
  LastEventID INT DEFAULT NULL,\
71
102
  EventsFound INT DEFAULT 0,\
72
103
  INDEX `LastEventID_I1` (`LastEventID`)
@@ -87,7 +118,7 @@ module SmsLogparser
87
118
  end
88
119
 
89
120
  def write_parse_result(id, count)
90
- client.query("INSERT INTO SmsParserRuns(LastRunAt, LastEventID, EventsFound)\
121
+ client.query("INSERT INTO SmsParserRuns(RunAt, LastEventID, EventsFound)\
91
122
  VALUES(\
92
123
  '#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}',\
93
124
  #{id},\
@@ -1,3 +1,3 @@
1
1
  module SmsLogparser
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["nik.wolfgramm@gmail.com"]
11
11
  spec.description = %q{SMS Logparser}
12
12
  spec.summary = %q{SMS Logparser}
13
- spec.homepage = "https://github.com/niwo/sms-logparser"
13
+ spec.homepage = "https://github.com/swisstxt/sms-logparser"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms-logparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - niwo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-27 00:00:00.000000000 Z
11
+ date: 2014-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,7 +98,7 @@ files:
98
98
  - lib/sms-logparser/cli.rb
99
99
  - lib/sms-logparser/version.rb
100
100
  - sms-logparser.gemspec
101
- homepage: https://github.com/niwo/sms-logparser
101
+ homepage: https://github.com/swisstxt/sms-logparser
102
102
  licenses:
103
103
  - MIT
104
104
  metadata: {}