Skip to content
Snippets Groups Projects
Commit 0a153c53 authored by Robin Obůrka's avatar Robin Obůrka
Browse files

[nethist] Print history to separate file.

parent 483bcac7
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@
#define SNAPSHOT_COUNT 100
#define SLEEP_TIME_USEC 3000000
#define SNIFF_FILE_NET "/proc/net/dev"
#define OUTPUT_FILE "/tmp/nethist.tmp"
#define FINAL_FILE "/tmp/nethist"
#define MAX_LEN_INTERFACE_NAME 20
#define MAX_LEN_INTERFACE_LIST 20
......@@ -161,7 +163,13 @@ int main(int argc, char **argv) {
take_snapshot(&(snapshots[write_to]));
print_history(stdout, snapshots, write_to);
FILE *fout = fopen(OUTPUT_FILE, "w+");
if (fout == NULL) {
return 1;
}
print_history(fout, snapshots, write_to);
fclose(fout);
rename(OUTPUT_FILE, FINAL_FILE);
write_to++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment