Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
2b00385d
"vscode:/vscode.git/clone" did not exist on "b5c6a5b1c6a5734832a95a458874aac7fb8c41da"
Commit
2b00385d
authored
Sep 16, 2010
by
antirez
Browse files
Added used CPU statistics in INFO output, obtained via getrusage()
parent
4c2e506a
Changes
1
Show whitespace changes
Inline
Side-by-side
src/redis.c
View file @
2b00385d
...
...
@@ -51,6 +51,7 @@
#include <float.h>
#include <math.h>
#include <pthread.h>
#include <sys/resource.h>
/* Our shared "common" objects */
...
...
@@ -1147,6 +1148,10 @@ sds genRedisInfoString(void) {
time_t
uptime
=
time
(
NULL
)
-
server
.
stat_starttime
;
int
j
;
char
hmem
[
64
];
struct
rusage
self_ru
,
c_ru
;
getrusage
(
RUSAGE_SELF
,
&
self_ru
);
getrusage
(
RUSAGE_CHILDREN
,
&
c_ru
);
bytesToHuman
(
hmem
,
zmalloc_used_memory
());
info
=
sdscatprintf
(
sdsempty
(),
...
...
@@ -1158,6 +1163,10 @@ sds genRedisInfoString(void) {
"process_id:%ld
\r\n
"
"uptime_in_seconds:%ld
\r\n
"
"uptime_in_days:%ld
\r\n
"
"used_cpu_sys:%.2f
\r\n
"
"used_cpu_user:%.2f
\r\n
"
"used_cpu_sys_childrens:%.2f
\r\n
"
"used_cpu_user_childrens:%.2f
\r\n
"
"connected_clients:%d
\r\n
"
"connected_slaves:%d
\r\n
"
"blocked_clients:%d
\r\n
"
...
...
@@ -1185,6 +1194,10 @@ sds genRedisInfoString(void) {
(
long
)
getpid
(),
uptime
,
uptime
/
(
3600
*
24
),
(
float
)
self_ru
.
ru_utime
.
tv_sec
+
(
float
)
self_ru
.
ru_utime
.
tv_usec
/
1000000
,
(
float
)
self_ru
.
ru_stime
.
tv_sec
+
(
float
)
self_ru
.
ru_stime
.
tv_usec
/
1000000
,
(
float
)
c_ru
.
ru_utime
.
tv_sec
+
(
float
)
c_ru
.
ru_utime
.
tv_usec
/
1000000
,
(
float
)
c_ru
.
ru_stime
.
tv_sec
+
(
float
)
c_ru
.
ru_stime
.
tv_usec
/
1000000
,
listLength
(
server
.
clients
)
-
listLength
(
server
.
slaves
),
listLength
(
server
.
slaves
),
server
.
blpop_blocked_clients
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment