Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MojitOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sepia-pub
MojitOS
Commits
aa9ebc1b
Commit
aa9ebc1b
authored
5 years ago
by
Georges Da Costa
Browse files
Options
Downloads
Patches
Plain Diff
Adds the capability to detect the network device automatically
parent
426c7e23
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mojitos.c
+1
-1
1 addition, 1 deletion
mojitos.c
network.c
+12
-0
12 additions, 0 deletions
network.c
with
13 additions
and
1 deletion
mojitos.c
+
1
−
1
View file @
aa9ebc1b
...
...
@@ -95,7 +95,7 @@ void usage(char** argv) {
printf
(
"-p activates performance counters
\n
"
);
printf
(
" perf_list is coma separated list of performance counters without space. Ex: instructions,cache_misses
\n
"
);
printf
(
"-l lists the possible performance counters and quits
\n
"
);
printf
(
"-d activates network monitoring
\n
"
);
printf
(
"-d activates network monitoring
(if network_device is X tries to detect it automatically)
\n
"
);
printf
(
"-s activates statistics of overhead in nanoseconds
\n
"
);
printf
(
"-u activates report of system load
\n
"
);
exit
(
EXIT_SUCCESS
);
...
...
This diff is collapsed.
Click to expand it.
network.c
+
12
−
0
View file @
aa9ebc1b
...
...
@@ -20,10 +20,22 @@
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
char
**
init_network
(
char
*
dev
)
{
if
(
dev
==
NULL
)
return
NULL
;
if
(
strcmp
(
dev
,
"X"
)
==
0
)
{
FILE
*
f
=
fopen
(
"/proc/net/route"
,
"r"
);
char
buffer
[
1000
];
fgets
(
buffer
,
999
,
f
);
fgets
(
buffer
,
999
,
f
);
char
*
end_of_dev
=
index
(
buffer
,
'\t'
);
*
end_of_dev
=
'\0'
;
dev
=
buffer
;
}
char
*
filenames
[]
=
{
"/sys/class/net/%s/statistics/rx_packets"
,
"/sys/class/net/%s/statistics/rx_bytes"
,
"/sys/class/net/%s/statistics/tx_packets"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment