forked from HostSuki/fastnetmon
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfastnetmon_client.cpp
More file actions
45 lines (35 loc) · 911 Bytes
/
fastnetmon_client.cpp
File metadata and controls
45 lines (35 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <unistd.h>
#include <ncurses.h>
int main() {
// Init ncurses screen
initscr();
// disable any character output
noecho();
// hide cursor
curs_set(0);
while (true) {
sleep(1);
// clean up screen
clear();
std::ifstream reading_file;
reading_file.open("/tmp/fastnetmon.dat", std::ifstream::in);
if (!reading_file.is_open()) {
std::cout<<"Can't open fastnetmon stats file";
}
std::string line = "";
std::stringstream screen_buffer;
while ( getline(reading_file, line) ) {
screen_buffer<<line<<"\n";
}
reading_file.close();
printw( screen_buffer.str().c_str() );
// update screen
refresh();
}
/* End ncurses mode */
endwin();
}