Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
551105ff
Unverified
Commit
551105ff
authored
Oct 20, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools/lxc_top: do not hide global variable
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
f3c34858
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
29 deletions
+29
-29
lxc_top.c
src/lxc/tools/lxc_top.c
+29
-29
No files found.
src/lxc/tools/lxc_top.c
View file @
551105ff
...
@@ -73,7 +73,7 @@ struct stats {
...
@@ -73,7 +73,7 @@ struct stats {
struct
blkio_stats
io_serviced
;
struct
blkio_stats
io_serviced
;
};
};
struct
c
t
{
struct
c
ontainer_stats
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
stats
*
stats
;
struct
stats
*
stats
;
};
};
...
@@ -84,7 +84,7 @@ static int delay = 3;
...
@@ -84,7 +84,7 @@ static int delay = 3;
static
char
sort_by
=
'n'
;
static
char
sort_by
=
'n'
;
static
int
sort_reverse
=
0
;
static
int
sort_reverse
=
0
;
static
struct
termios
oldtios
;
static
struct
termios
oldtios
;
static
struct
c
t
*
ct
=
NULL
;
static
struct
c
ontainer_stats
*
container_stats
=
NULL
;
static
int
ct_alloc_cnt
=
0
;
static
int
ct_alloc_cnt
=
0
;
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
...
@@ -336,7 +336,7 @@ out:
...
@@ -336,7 +336,7 @@ out:
return
;
return
;
}
}
static
void
stats_get
(
struct
lxc_container
*
c
,
struct
c
t
*
ct
,
struct
stats
*
total
)
static
void
stats_get
(
struct
lxc_container
*
c
,
struct
c
ontainer_stats
*
ct
,
struct
stats
*
total
)
{
{
ct
->
c
=
c
;
ct
->
c
=
c
;
ct
->
stats
->
mem_used
=
stat_get_int
(
c
,
"memory.usage_in_bytes"
);
ct
->
stats
->
mem_used
=
stat_get_int
(
c
,
"memory.usage_in_bytes"
);
...
@@ -448,8 +448,8 @@ static void stats_print(const char *name, const struct stats *stats,
...
@@ -448,8 +448,8 @@ static void stats_print(const char *name, const struct stats *stats,
static
int
cmp_name
(
const
void
*
sct1
,
const
void
*
sct2
)
static
int
cmp_name
(
const
void
*
sct1
,
const
void
*
sct2
)
{
{
const
struct
c
t
*
ct1
=
sct1
;
const
struct
c
ontainer_stats
*
ct1
=
sct1
;
const
struct
c
t
*
ct2
=
sct2
;
const
struct
c
ontainer_stats
*
ct2
=
sct2
;
if
(
sort_reverse
)
if
(
sort_reverse
)
return
strncmp
(
ct2
->
c
->
name
,
ct1
->
c
->
name
,
strlen
(
ct2
->
c
->
name
));
return
strncmp
(
ct2
->
c
->
name
,
ct1
->
c
->
name
,
strlen
(
ct2
->
c
->
name
));
...
@@ -459,8 +459,8 @@ static int cmp_name(const void *sct1, const void *sct2)
...
@@ -459,8 +459,8 @@ static int cmp_name(const void *sct1, const void *sct2)
static
int
cmp_cpuuse
(
const
void
*
sct1
,
const
void
*
sct2
)
static
int
cmp_cpuuse
(
const
void
*
sct1
,
const
void
*
sct2
)
{
{
const
struct
c
t
*
ct1
=
sct1
;
const
struct
c
ontainer_stats
*
ct1
=
sct1
;
const
struct
c
t
*
ct2
=
sct2
;
const
struct
c
ontainer_stats
*
ct2
=
sct2
;
if
(
sort_reverse
)
if
(
sort_reverse
)
return
ct2
->
stats
->
cpu_use_nanos
<
ct1
->
stats
->
cpu_use_nanos
;
return
ct2
->
stats
->
cpu_use_nanos
<
ct1
->
stats
->
cpu_use_nanos
;
...
@@ -470,8 +470,8 @@ static int cmp_cpuuse(const void *sct1, const void *sct2)
...
@@ -470,8 +470,8 @@ static int cmp_cpuuse(const void *sct1, const void *sct2)
static
int
cmp_blkio
(
const
void
*
sct1
,
const
void
*
sct2
)
static
int
cmp_blkio
(
const
void
*
sct1
,
const
void
*
sct2
)
{
{
const
struct
c
t
*
ct1
=
sct1
;
const
struct
c
ontainer_stats
*
ct1
=
sct1
;
const
struct
c
t
*
ct2
=
sct2
;
const
struct
c
ontainer_stats
*
ct2
=
sct2
;
if
(
sort_reverse
)
if
(
sort_reverse
)
return
ct2
->
stats
->
io_service_bytes
.
total
<
ct1
->
stats
->
io_service_bytes
.
total
;
return
ct2
->
stats
->
io_service_bytes
.
total
<
ct1
->
stats
->
io_service_bytes
.
total
;
...
@@ -481,8 +481,8 @@ static int cmp_blkio(const void *sct1, const void *sct2)
...
@@ -481,8 +481,8 @@ static int cmp_blkio(const void *sct1, const void *sct2)
static
int
cmp_memory
(
const
void
*
sct1
,
const
void
*
sct2
)
static
int
cmp_memory
(
const
void
*
sct1
,
const
void
*
sct2
)
{
{
const
struct
c
t
*
ct1
=
sct1
;
const
struct
c
ontainer_stats
*
ct1
=
sct1
;
const
struct
c
t
*
ct2
=
sct2
;
const
struct
c
ontainer_stats
*
ct2
=
sct2
;
if
(
sort_reverse
)
if
(
sort_reverse
)
return
ct2
->
stats
->
mem_used
<
ct1
->
stats
->
mem_used
;
return
ct2
->
stats
->
mem_used
<
ct1
->
stats
->
mem_used
;
...
@@ -492,8 +492,8 @@ static int cmp_memory(const void *sct1, const void *sct2)
...
@@ -492,8 +492,8 @@ static int cmp_memory(const void *sct1, const void *sct2)
static
int
cmp_memorysw
(
const
void
*
sct1
,
const
void
*
sct2
)
static
int
cmp_memorysw
(
const
void
*
sct1
,
const
void
*
sct2
)
{
{
const
struct
c
t
*
ct1
=
sct1
;
const
struct
c
ontainer_stats
*
ct1
=
sct1
;
const
struct
c
t
*
ct2
=
sct2
;
const
struct
c
ontainer_stats
*
ct2
=
sct2
;
if
(
sort_reverse
)
if
(
sort_reverse
)
return
ct2
->
stats
->
memsw_used
<
ct1
->
stats
->
memsw_used
;
return
ct2
->
stats
->
memsw_used
<
ct1
->
stats
->
memsw_used
;
...
@@ -503,8 +503,8 @@ static int cmp_memorysw(const void *sct1, const void *sct2)
...
@@ -503,8 +503,8 @@ static int cmp_memorysw(const void *sct1, const void *sct2)
static
int
cmp_kmemory
(
const
void
*
sct1
,
const
void
*
sct2
)
static
int
cmp_kmemory
(
const
void
*
sct1
,
const
void
*
sct2
)
{
{
const
struct
c
t
*
ct1
=
sct1
;
const
struct
c
ontainer_stats
*
ct1
=
sct1
;
const
struct
c
t
*
ct2
=
sct2
;
const
struct
c
ontainer_stats
*
ct2
=
sct2
;
if
(
sort_reverse
)
if
(
sort_reverse
)
return
ct2
->
stats
->
kmem_used
<
ct1
->
stats
->
kmem_used
;
return
ct2
->
stats
->
kmem_used
<
ct1
->
stats
->
kmem_used
;
...
@@ -526,7 +526,7 @@ static void ct_sort(int active)
...
@@ -526,7 +526,7 @@ static void ct_sort(int active)
case
'k'
:
cmp_func
=
cmp_kmemory
;
break
;
case
'k'
:
cmp_func
=
cmp_kmemory
;
break
;
}
}
qsort
(
c
t
,
active
,
sizeof
(
*
ct
),
(
int
(
*
)(
const
void
*
,
const
void
*
))
cmp_func
);
qsort
(
c
ontainer_stats
,
active
,
sizeof
(
*
container_stats
),
(
int
(
*
)(
const
void
*
,
const
void
*
))
cmp_func
);
}
}
static
void
ct_free
(
void
)
static
void
ct_free
(
void
)
...
@@ -534,13 +534,13 @@ static void ct_free(void)
...
@@ -534,13 +534,13 @@ static void ct_free(void)
int
i
;
int
i
;
for
(
i
=
0
;
i
<
ct_alloc_cnt
;
i
++
)
{
for
(
i
=
0
;
i
<
ct_alloc_cnt
;
i
++
)
{
if
(
c
t
[
i
].
c
)
{
if
(
c
ontainer_stats
[
i
].
c
)
{
lxc_container_put
(
c
t
[
i
].
c
);
lxc_container_put
(
c
ontainer_stats
[
i
].
c
);
c
t
[
i
].
c
=
NULL
;
c
ontainer_stats
[
i
].
c
=
NULL
;
}
}
free
(
c
t
[
i
].
stats
);
free
(
c
ontainer_stats
[
i
].
stats
);
c
t
[
i
].
stats
=
NULL
;
c
ontainer_stats
[
i
].
stats
=
NULL
;
}
}
}
}
...
@@ -551,15 +551,15 @@ static void ct_realloc(int active_cnt)
...
@@ -551,15 +551,15 @@ static void ct_realloc(int active_cnt)
ct_free
();
ct_free
();
c
t
=
realloc
(
ct
,
sizeof
(
*
ct
)
*
active_cnt
);
c
ontainer_stats
=
realloc
(
container_stats
,
sizeof
(
*
container_stats
)
*
active_cnt
);
if
(
!
c
t
)
{
if
(
!
c
ontainer_stats
)
{
fprintf
(
stderr
,
"Cannot alloc mem
\n
"
);
fprintf
(
stderr
,
"Cannot alloc mem
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
for
(
i
=
0
;
i
<
active_cnt
;
i
++
)
{
for
(
i
=
0
;
i
<
active_cnt
;
i
++
)
{
c
t
[
i
].
stats
=
malloc
(
sizeof
(
*
ct
[
0
].
stats
));
c
ontainer_stats
[
i
].
stats
=
malloc
(
sizeof
(
*
container_stats
[
0
].
stats
));
if
(
!
c
t
[
i
].
stats
)
{
if
(
!
c
ontainer_stats
[
i
].
stats
)
{
fprintf
(
stderr
,
"Cannot alloc mem
\n
"
);
fprintf
(
stderr
,
"Cannot alloc mem
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -640,7 +640,7 @@ int main(int argc, char *argv[])
...
@@ -640,7 +640,7 @@ int main(int argc, char *argv[])
memset
(
&
total
,
0
,
sizeof
(
total
));
memset
(
&
total
,
0
,
sizeof
(
total
));
for
(
i
=
0
;
i
<
active_cnt
;
i
++
)
for
(
i
=
0
;
i
<
active_cnt
;
i
++
)
stats_get
(
active
[
i
],
&
c
t
[
i
],
&
total
);
stats_get
(
active
[
i
],
&
c
ontainer_stats
[
i
],
&
total
);
ct_sort
(
active_cnt
);
ct_sort
(
active_cnt
);
...
@@ -650,7 +650,7 @@ int main(int argc, char *argv[])
...
@@ -650,7 +650,7 @@ int main(int argc, char *argv[])
}
}
for
(
i
=
0
;
i
<
active_cnt
&&
i
<
ct_print_cnt
;
i
++
)
{
for
(
i
=
0
;
i
<
active_cnt
&&
i
<
ct_print_cnt
;
i
++
)
{
stats_print
(
c
t
[
i
].
c
->
name
,
ct
[
i
].
stats
,
&
total
);
stats_print
(
c
ontainer_stats
[
i
].
c
->
name
,
container_stats
[
i
].
stats
,
&
total
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -661,8 +661,8 @@ int main(int argc, char *argv[])
...
@@ -661,8 +661,8 @@ int main(int argc, char *argv[])
fflush
(
stdout
);
fflush
(
stdout
);
for
(
i
=
0
;
i
<
active_cnt
;
i
++
)
{
for
(
i
=
0
;
i
<
active_cnt
;
i
++
)
{
lxc_container_put
(
c
t
[
i
].
c
);
lxc_container_put
(
c
ontainer_stats
[
i
].
c
);
c
t
[
i
].
c
=
NULL
;
c
ontainer_stats
[
i
].
c
=
NULL
;
}
}
in_char
=
'\0'
;
in_char
=
'\0'
;
...
...
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