1
0
mirror of https://github.com/pavel-odintsov/fastnetmon synced 2024-11-23 17:32:59 +01:00
fastnetmon-rewritten/fastnetmon_client.cpp

46 lines
911 B
C++
Raw Normal View History

#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
// 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();
}