log2json 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/redis2disk +7 -3
- data/bin/tail +0 -0
- data/log2json.gemspec +1 -1
- data/src/coreutils-8.13_tail.patch +25 -24
- data/src/tail.c +2 -1
- metadata +2 -2
data/bin/redis2disk
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
# another script at a slower rate when the queue is empty most of times.
|
9
9
|
#
|
10
10
|
#
|
11
|
-
set -e
|
12
11
|
|
13
12
|
# name of the queue in Redis. Must be a list in Redis.
|
14
13
|
QUEUE=${QUEUE:-jsonlogs}
|
@@ -60,11 +59,16 @@ do
|
|
60
59
|
log "New period begins---"
|
61
60
|
fi
|
62
61
|
s2=$(redis-cli llen $QUEUE) # current queue size
|
62
|
+
if [ $? -ne 0 -o ! "$s2" ]; then
|
63
|
+
sleep 1; continue
|
64
|
+
fi
|
63
65
|
log "queue size=$s2"
|
64
66
|
|
65
67
|
if [ "$s1" ]; then
|
66
68
|
delta=$(( s2 - s1 ))
|
67
69
|
rate=$(( delta / INTERVAL ))
|
70
|
+
#FIXME: ideally, this should be the time elapsed rather than the fixed INTERVAL.
|
71
|
+
|
68
72
|
log "delta=$delta rate=$rate"
|
69
73
|
|
70
74
|
# if within the period, we have crossed MAX_RATE CROSS_COUNT times
|
@@ -78,7 +82,7 @@ do
|
|
78
82
|
n_records=$((delta * count))
|
79
83
|
log "CROSS_COUNT($CROSS_COUNT) reached! Off loading $n_records log records to $batch_file ..."
|
80
84
|
|
81
|
-
redis-cli --eval <(echo "$LUA_LPOP_KEY_N") $QUEUE , $n_records > $batch_file
|
85
|
+
redis-cli --eval <(echo "$LUA_LPOP_KEY_N") $QUEUE , $n_records > $batch_file
|
82
86
|
count=0
|
83
87
|
off_loaded=1
|
84
88
|
fi
|
@@ -86,7 +90,7 @@ do
|
|
86
90
|
fi
|
87
91
|
|
88
92
|
if [ "$off_loaded" ]; then
|
89
|
-
s1=$(redis-cli llen $QUEUE)
|
93
|
+
s1=$(redis-cli llen $QUEUE) || s1=
|
90
94
|
off_loaded=
|
91
95
|
else
|
92
96
|
s1=$s2
|
data/bin/tail
CHANGED
Binary file
|
data/log2json.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'log2json'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.13'
|
4
4
|
s.summary = "Read, filter and ship logs. ie, poor man's roll-your-own, light-weight logstash replacement."
|
5
5
|
s.description = IO.read(File.join(File.dirname(__FILE__), 'README'))
|
6
6
|
s.authors = ['Jack Kuan']
|
@@ -1,25 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
82a83,85
|
2
|
+
> /* Size of the array that stores the -n option values. */
|
3
|
+
> #define MAX_FILE_SKIP_LINES 256
|
4
|
+
>
|
5
|
+
183a187,189
|
6
|
+
> /* Stores the number of lines to skip from the start for each file. */
|
7
|
+
> static int n_units_argv[MAX_FILE_SKIP_LINES];
|
8
|
+
>
|
9
|
+
1049a1056,1057
|
10
|
+
> if (print_headers)
|
11
|
+
> printf ("==> %s <== [new_file]\n", pretty_name (f));
|
12
|
+
1171a1180,1181
|
13
|
+
> if (print_headers)
|
14
|
+
> printf ("==> %s <== [truncated]\n", name);
|
15
|
+
1286a1297,1298
|
16
|
+
> if (print_headers)
|
17
|
+
> printf ("==> %s <== [truncated]\n", name);
|
18
|
+
1917a1930
|
19
|
+
> int n_units_argc = 0;
|
20
|
+
1948a1962,1963
|
21
|
+
> if (n_units_argc < MAX_FILE_SKIP_LINES)
|
22
|
+
> n_units_argv[n_units_argc++] = *n_units;
|
23
|
+
2163c2178
|
24
|
+
< ok &= tail_file (&F[i], n_units);
|
24
25
|
---
|
25
|
-
> ok &= tail_file (&F[i], n_units);
|
26
|
+
> ok &= tail_file (&F[i], i < MAX_FILE_SKIP_LINES ? n_units_argv[i] : n_units);
|
data/src/tail.c
CHANGED
@@ -1959,7 +1959,8 @@ parse_options (int argc, char **argv,
|
|
1959
1959
|
? _("invalid number of lines")
|
1960
1960
|
: _("invalid number of bytes")));
|
1961
1961
|
}
|
1962
|
-
|
1962
|
+
if (n_units_argc < MAX_FILE_SKIP_LINES)
|
1963
|
+
n_units_argv[n_units_argc++] = *n_units;
|
1963
1964
|
}
|
1964
1965
|
break;
|
1965
1966
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log2json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jls-grok
|