2014-12-23 19:07:50 +01:00
|
|
|
#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();
|
2015-01-26 09:07:21 +01:00
|
|
|
|
2014-12-23 19:07:50 +01:00
|
|
|
// hide cursor
|
|
|
|
curs_set(0);
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
sleep(1);
|
|
|
|
// clean up screen
|
|
|
|
clear();
|
|
|
|
|
2015-01-27 20:46:33 +01:00
|
|
|
std::ifstream reading_file;
|
2014-12-23 19:07:50 +01:00
|
|
|
reading_file.open("/tmp/fastnetmon.dat", std::ifstream::in);
|
|
|
|
|
|
|
|
if (!reading_file.is_open()) {
|
|
|
|
std::cout<<"Can't open fastnetmon stats file";
|
|
|
|
}
|
|
|
|
|
2015-01-27 20:46:33 +01:00
|
|
|
std::string line = "";
|
|
|
|
std::stringstream screen_buffer;
|
2014-12-23 19:07:50 +01:00
|
|
|
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();
|
|
|
|
}
|