Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
iproute2
Commits
f4e75c6f
Commit
f4e75c6f
authored
Sep 24, 2013
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Plain Diff
Merge /tmp/iproute2
parents
af60cf40
d48ed3f4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
6 deletions
+40
-6
misc/nstat.c
misc/nstat.c
+40
-6
No files found.
misc/nstat.c
View file @
f4e75c6f
...
@@ -33,6 +33,7 @@ int dump_zeros = 0;
...
@@ -33,6 +33,7 @@ int dump_zeros = 0;
int
reset_history
=
0
;
int
reset_history
=
0
;
int
ignore_history
=
0
;
int
ignore_history
=
0
;
int
no_output
=
0
;
int
no_output
=
0
;
int
json_output
=
0
;
int
no_update
=
0
;
int
no_update
=
0
;
int
scan_interval
=
0
;
int
scan_interval
=
0
;
int
time_constant
=
0
;
int
time_constant
=
0
;
...
@@ -255,10 +256,16 @@ static void load_netstat(void)
...
@@ -255,10 +256,16 @@ static void load_netstat(void)
}
}
}
}
static
void
dump_kern_db
(
FILE
*
fp
,
int
to_hist
)
static
void
dump_kern_db
(
FILE
*
fp
,
int
to_hist
)
{
{
struct
nstat_ent
*
n
,
*
h
;
struct
nstat_ent
*
n
,
*
h
;
const
char
*
eol
=
"
\n
"
;
h
=
hist_db
;
h
=
hist_db
;
if
(
json_output
)
fprintf
(
fp
,
"{
\"
%s
\"
: ["
,
info_source
);
else
fprintf
(
fp
,
"#%s
\n
"
,
info_source
);
fprintf
(
fp
,
"#%s
\n
"
,
info_source
);
for
(
n
=
kern_db
;
n
;
n
=
n
->
next
)
{
for
(
n
=
kern_db
;
n
;
n
=
n
->
next
)
{
unsigned
long
long
val
=
n
->
val
;
unsigned
long
long
val
=
n
->
val
;
...
@@ -276,15 +283,30 @@ static void dump_kern_db(FILE *fp, int to_hist)
...
@@ -276,15 +283,30 @@ static void dump_kern_db(FILE *fp, int to_hist)
}
}
}
}
}
}
if
(
json_output
)
{
fprintf
(
fp
,
"%s {
\"
id
\"
:
\"
%s
\"
,
\"
val
\"
:%llu,"
"
\"
rate
\"
:%.1f }"
,
eol
,
n
->
id
,
val
,
n
->
rate
);
eol
=
",
\n
"
;
}
else
fprintf
(
fp
,
"%-32s%-16llu%6.1f
\n
"
,
n
->
id
,
val
,
n
->
rate
);
fprintf
(
fp
,
"%-32s%-16llu%6.1f
\n
"
,
n
->
id
,
val
,
n
->
rate
);
}
}
if
(
json_output
)
fprintf
(
fp
,
"
\n
] }
\n
"
);
}
}
static
void
dump_incr_db
(
FILE
*
fp
)
static
void
dump_incr_db
(
FILE
*
fp
)
{
{
struct
nstat_ent
*
n
,
*
h
;
struct
nstat_ent
*
n
,
*
h
;
const
char
*
eol
=
"
\n
"
;
h
=
hist_db
;
h
=
hist_db
;
if
(
json_output
)
fprintf
(
fp
,
"{
\"
%s
\"
: ["
,
info_source
);
else
fprintf
(
fp
,
"#%s
\n
"
,
info_source
);
fprintf
(
fp
,
"#%s
\n
"
,
info_source
);
for
(
n
=
kern_db
;
n
;
n
=
n
->
next
)
{
for
(
n
=
kern_db
;
n
;
n
=
n
->
next
)
{
int
ovfl
=
0
;
int
ovfl
=
0
;
unsigned
long
long
val
=
n
->
val
;
unsigned
long
long
val
=
n
->
val
;
...
@@ -304,9 +326,18 @@ static void dump_incr_db(FILE *fp)
...
@@ -304,9 +326,18 @@ static void dump_incr_db(FILE *fp)
continue
;
continue
;
if
(
!
match
(
n
->
id
))
if
(
!
match
(
n
->
id
))
continue
;
continue
;
if
(
json_output
)
{
fprintf
(
fp
,
"%s {
\"
id
\"
:
\"
%s
\"
,
\"
val
\"
:%llu,"
"
\"
rate
\"
:%.1f,
\"
overflow
\"
:%d }"
,
eol
,
n
->
id
,
val
,
n
->
rate
,
ovfl
);
eol
=
",
\n
"
;
}
else
fprintf
(
fp
,
"%-32s%-16llu%6.1f%s
\n
"
,
n
->
id
,
val
,
fprintf
(
fp
,
"%-32s%-16llu%6.1f%s
\n
"
,
n
->
id
,
val
,
n
->
rate
,
ovfl
?
" (overflow)"
:
""
);
n
->
rate
,
ovfl
?
" (overflow)"
:
""
);
}
}
if
(
json_output
)
fprintf
(
fp
,
"
\n
] }
\n
"
);
}
}
static
int
children
;
static
int
children
;
...
@@ -451,7 +482,7 @@ int main(int argc, char *argv[])
...
@@ -451,7 +482,7 @@ int main(int argc, char *argv[])
int
ch
;
int
ch
;
int
fd
;
int
fd
;
while
((
ch
=
getopt
(
argc
,
argv
,
"h?vVzrnasd:t:"
))
!=
EOF
)
{
while
((
ch
=
getopt
(
argc
,
argv
,
"h?vVzrnasd:t:
j
"
))
!=
EOF
)
{
switch
(
ch
)
{
switch
(
ch
)
{
case
'z'
:
case
'z'
:
dump_zeros
=
1
;
dump_zeros
=
1
;
...
@@ -478,6 +509,9 @@ int main(int argc, char *argv[])
...
@@ -478,6 +509,9 @@ int main(int argc, char *argv[])
exit
(
-
1
);
exit
(
-
1
);
}
}
break
;
break
;
case
'j'
:
json_output
=
1
;
break
;
case
'v'
:
case
'v'
:
case
'V'
:
case
'V'
:
printf
(
"nstat utility, iproute2-ss%s
\n
"
,
SNAPSHOT
);
printf
(
"nstat utility, iproute2-ss%s
\n
"
,
SNAPSHOT
);
...
...
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