sms-logparser 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/sms-logparser/cli.rb +12 -6
- data/lib/sms-logparser/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 038037b20ed15c61e41f16b8dbdaf98ccce4df63
|
4
|
+
data.tar.gz: d2717600032260e584b99d6467176ba2a4301d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77f4e55d44aa15408cd9b89ea105128dc184ebfda13cbb041c52d4d2980251de3699414280879636851ef6237918ec200217cca5bee6c83abfb7572fd52c16bf
|
7
|
+
data.tar.gz: e7869987d1c8fb3baffef551c2e7a0b14ac86fe391434cd3db89bed7134e4f232cab038091c0fb5a623abdb37aa260640890640a503426a227cbaa519c07c6bb
|
data/README.md
CHANGED
@@ -18,10 +18,22 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Setup
|
20
20
|
|
21
|
+
Create the database table to track which logs have been parsed:
|
22
|
+
|
21
23
|
$ sms-logparser create_parser_table
|
22
24
|
|
25
|
+
Make a testrun:
|
26
|
+
|
27
|
+
$ sms-logparser parse --simulate
|
28
|
+
|
23
29
|
## Usage
|
24
30
|
|
31
|
+
See available commamds:
|
32
|
+
|
33
|
+
$ sms-logparser help
|
34
|
+
|
35
|
+
Parse logs from database and send them to the API
|
36
|
+
|
25
37
|
$ sms-logparser parse
|
26
38
|
|
27
39
|
## Contributing
|
data/lib/sms-logparser/cli.rb
CHANGED
@@ -13,9 +13,9 @@ module SmsLogparser
|
|
13
13
|
class_option :mysql_user, :default => 'root'
|
14
14
|
class_option :mysql_db, :default => 'Syslog'
|
15
15
|
|
16
|
-
desc "
|
16
|
+
desc "parse", "Check the database for pcache logs and send them to SMS"
|
17
17
|
option :api_base_path, :default => 'http://dev.simplex.tv/creator/rest'
|
18
|
-
option :
|
18
|
+
option :simulate, :type => :boolean, :default => false
|
19
19
|
def parse
|
20
20
|
count = 0
|
21
21
|
last_id = get_last_parse_id
|
@@ -38,19 +38,25 @@ module SmsLogparser
|
|
38
38
|
url += "#{data[:project_id]}/"
|
39
39
|
url += "#{data[:traffic_type]}/"
|
40
40
|
url += "#{data[:bytes]}"
|
41
|
-
if options[:
|
42
|
-
puts result['ID']
|
41
|
+
if options[:simulate]
|
42
|
+
puts "Message ID: #{result['ID']}"
|
43
43
|
puts "URL: #{url}"
|
44
44
|
puts "Data: #{data}"
|
45
45
|
puts "-----------------------"
|
46
46
|
else
|
47
|
-
|
47
|
+
begin
|
48
|
+
RestClient.get(url)
|
49
|
+
rescue
|
50
|
+
say "Error: Can't send log to #{url}", :red
|
51
|
+
say "Aborting.", :red
|
52
|
+
exit 1
|
53
|
+
end
|
48
54
|
end
|
49
55
|
count += 1
|
50
56
|
end
|
51
57
|
last_id = result['ID']
|
52
58
|
end
|
53
|
-
write_parse_result(last_id, count) unless options[:
|
59
|
+
write_parse_result(last_id, count) unless options[:simulate]
|
54
60
|
puts "Number of valid messages found: #{count}"
|
55
61
|
end
|
56
62
|
|