Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
e9055880
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e9055880
编写于
7月 02, 2014
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
LATENCY GRAPH implemented.
上级
b38996aa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
66 addition
and
6 deletion
+66
-6
src/latency.c
src/latency.c
+61
-1
src/redis-cli.c
src/redis-cli.c
+3
-2
src/sparkline.c
src/sparkline.c
+1
-2
src/sparkline.h
src/sparkline.h
+1
-1
未找到文件。
src/latency.c
浏览文件 @
e9055880
...
...
@@ -140,6 +140,53 @@ void latencyCommandReplyWithLatestEvents(redisClient *c) {
dictReleaseIterator
(
di
);
}
#define LATENCY_GRAPH_COLS 80
sds
latencyCommandGenSparkeline
(
char
*
event
,
struct
latencyTimeSeries
*
ts
)
{
int
j
;
struct
sequence
*
seq
=
createSparklineSequence
();
sds
graph
=
sdsempty
();
uint32_t
min
,
max
;
for
(
j
=
0
;
j
<
LATENCY_TS_LEN
;
j
++
)
{
int
i
=
(
ts
->
idx
+
j
)
%
LATENCY_TS_LEN
;
int
elapsed
;
char
*
label
;
char
buf
[
64
];
if
(
ts
->
samples
[
i
].
time
==
0
)
continue
;
/* Update min and max. */
if
(
seq
->
length
==
0
)
{
min
=
max
=
ts
->
samples
[
i
].
latency
;
}
else
{
if
(
ts
->
samples
[
i
].
latency
>
max
)
max
=
ts
->
samples
[
i
].
latency
;
if
(
ts
->
samples
[
i
].
latency
<
min
)
min
=
ts
->
samples
[
i
].
latency
;
}
/* Use as label the number of seconds / minutes / hours / days
* ago the event happened. */
elapsed
=
time
(
NULL
)
-
ts
->
samples
[
i
].
time
;
if
(
elapsed
<
60
)
snprintf
(
buf
,
sizeof
(
buf
),
"%ds"
,
elapsed
);
else
if
(
elapsed
<
3600
)
snprintf
(
buf
,
sizeof
(
buf
),
"%dm"
,
elapsed
/
60
);
else
if
(
elapsed
<
3600
*
24
)
snprintf
(
buf
,
sizeof
(
buf
),
"%dh"
,
elapsed
/
3600
);
else
snprintf
(
buf
,
sizeof
(
buf
),
"%dd"
,
elapsed
/
(
3600
*
24
));
label
=
zstrdup
(
buf
);
sparklineSequenceAddSample
(
seq
,
ts
->
samples
[
i
].
latency
,
label
);
}
graph
=
sdscatprintf
(
graph
,
"%s - high %lu ms, low %lu ms (all time high %lu ms)
\n
"
,
event
,
(
unsigned
long
)
max
,
(
unsigned
long
)
min
,
(
unsigned
long
)
ts
->
max
);
for
(
j
=
0
;
j
<
LATENCY_GRAPH_COLS
;
j
++
)
graph
=
sdscatlen
(
graph
,
"-"
,
1
);
graph
=
sdscatlen
(
graph
,
"
\n
"
,
1
);
graph
=
sparklineRender
(
graph
,
seq
,
LATENCY_GRAPH_COLS
,
4
,
SPARKLINE_NO_FLAGS
);
freeSparklineSequence
(
seq
);
return
graph
;
}
/* LATENCY command implementations.
*
* LATENCY SAMPLES: return time-latency samples for the specified event.
...
...
@@ -155,12 +202,25 @@ void latencyCommand(redisClient *c) {
ts
=
dictFetchValue
(
server
.
latency_events
,
c
->
argv
[
2
]
->
ptr
);
if
(
ts
==
NULL
)
goto
nodataerr
;
latencyCommandReplyWithSamples
(
c
,
ts
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"graph"
)
&&
c
->
argc
==
3
)
{
/* LATENCY GRAPH <event> */
sds
graph
;
dictEntry
*
de
;
char
*
event
;
de
=
dictFind
(
server
.
latency_events
,
c
->
argv
[
2
]
->
ptr
);
if
(
de
==
NULL
)
goto
nodataerr
;
ts
=
dictGetVal
(
de
);
event
=
dictGetKey
(
de
);
graph
=
latencyCommandGenSparkeline
(
event
,
ts
);
addReplyBulkCString
(
c
,
graph
);
sdsfree
(
graph
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"latest"
)
&&
c
->
argc
==
2
)
{
/* LATENCY LATEST */
latencyCommandReplyWithLatestEvents
(
c
);
}
else
{
addReply
(
c
,
shared
.
syntaxerr
);
return
;
}
return
;
...
...
src/redis-cli.c
浏览文件 @
e9055880
...
...
@@ -598,8 +598,9 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
(
!
strcasecmp
(
argv
[
1
],
"nodes"
)
||
!
strcasecmp
(
argv
[
1
],
"info"
)))
||
(
argc
==
2
&&
!
strcasecmp
(
command
,
"client"
)
&&
!
strcasecmp
(
argv
[
1
],
"list"
)))
!
strcasecmp
(
argv
[
1
],
"list"
))
||
(
argc
==
3
&&
!
strcasecmp
(
command
,
"latency"
)
&&
!
strcasecmp
(
argv
[
1
],
"graph"
)))
{
output_raw
=
1
;
}
...
...
src/sparkline.c
浏览文件 @
e9055880
...
...
@@ -161,9 +161,8 @@ sds sparklineRenderRange(sds output, struct sequence *seq, int rows, int offset,
}
/* Turn a sequence into its ASCII representation */
sds
sparklineRender
(
struct
sequence
*
seq
,
int
columns
,
int
rows
,
int
flags
)
{
sds
sparklineRender
(
s
ds
output
,
s
truct
sequence
*
seq
,
int
columns
,
int
rows
,
int
flags
)
{
int
j
;
sds
output
=
sdsempty
();
for
(
j
=
0
;
j
<
seq
->
length
;
j
+=
columns
)
{
int
sublen
=
(
seq
->
length
-
j
)
<
columns
?
(
seq
->
length
-
j
)
:
columns
;
...
...
src/sparkline.h
浏览文件 @
e9055880
...
...
@@ -51,6 +51,6 @@ struct sequence *createSparklineSequence(void);
void
sparklineSequenceAddSample
(
struct
sequence
*
seq
,
double
value
,
char
*
label
);
void
freeSparklineSequence
(
struct
sequence
*
seq
);
sds
sparklineRenderRange
(
sds
output
,
struct
sequence
*
seq
,
int
rows
,
int
offset
,
int
len
,
int
flags
);
sds
sparklineRender
(
struct
sequence
*
seq
,
int
columns
,
int
rows
,
int
flags
);
sds
sparklineRender
(
s
ds
output
,
s
truct
sequence
*
seq
,
int
columns
,
int
rows
,
int
flags
);
#endif
/* __SPARKLINE_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录