9 #include "flowpusher.h"
14 void from_string<long long>(const char *from, long long &to)
20 int main(int argc, char **argv)
22 int width = 1000, height = 500;
23 unsigned long long traffic = 0ULL;
24 pqxx::connection conn("dbname=nms host=localhost user=nms password=seesahS4");
26 std::vector<flow_element> flow;
29 mallopt(M_TRIM_THRESHOLD, -1);
32 pqxx::work t(conn, "fetch_all");
33 // pqxx::icursorstream::icursorstream cstream(t, "select port,extract(epoch from time) as time,bytes_in,bytes_out from polls natural join switches where ((switchtype='es3024' and port < 25) or (switchtype='summit400' and port > 1)) order by switch,port,time", "fetch_all", 500);
34 pqxx::icursorstream::icursorstream cstream(t, "select port,extract(epoch from time) as time,bytes_in,bytes_out from polls natural join switches where switch=1447 order by switch,port,time", "fetch_all", 500);
37 unsigned long long prev_y1, prev_y2;
46 for (unsigned i = 0; i < res.size(); ++i) {
47 int port = res[i][0].as<int>();
48 double x = res[i][1].as<double>();
49 unsigned long long y1 = res[i][2].as<long long>(), y2 = res[i][3].as<long long>();
51 if (port != last_port) {
52 if (last_port != -1) {
53 fprintf(stderr, "%.2f TB (%u)\n", traffic / double(1024.0 * 1024.0 * 1024.0 * 1024.0), ++num_total);
64 unsigned long long yf1, yf2;
65 FlowPusher::find_diff(x, prev_x, y1, prev_y1, y2, prev_y2, yf1, yf2);
66 traffic += 0.5 * (yf1 + yf2);
73 fprintf(stderr, "%.2f TB\n", traffic / double(1024.0 * 1024.0 * 1024.0 * 1024.0));