mirror of
https://github.com/pavel-odintsov/fastnetmon
synced 2024-11-23 13:22:36 +01:00
Add client for getting fastnetmon stats
This commit is contained in:
parent
1ecd808692
commit
8d041b2b8f
46
fastnetmon_client.cpp
Normal file
46
fastnetmon_client.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
// Init ncurses screen
|
||||
initscr();
|
||||
|
||||
// disable any character output
|
||||
noecho();
|
||||
// hide cursor
|
||||
curs_set(0);
|
||||
|
||||
while (true) {
|
||||
sleep(1);
|
||||
// clean up screen
|
||||
clear();
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
string line = "";
|
||||
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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user