8 #include "flowpusher.h"
13 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 pqxx::connection conn("dbname=nms host=localhost user=nms password=seesahS4");
25 std::vector<flow_element> flow, total_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);
42 for (unsigned i = 0; i < res.size(); ++i) {
43 int port = res[i][0].as<int>();
44 double x = res[i][1].as<double>();
45 unsigned long long y1 = res[i][2].as<long long>(), y2 = res[i][3].as<long long>();
47 if (port != last_port) {
48 if (last_port != -1) {
49 total_flow = sum_flows(total_flow, flow);
50 fprintf(stderr, "%u (%u)\n", last_port, ++num_total);
63 unsigned long long min_y = 0;
64 unsigned long long max_y = 10000000;
66 for (unsigned i = 0; i < total_flow.size(); ++i) {
67 flow_element fe = total_flow[i];
69 min_y = std::min(min_y, fe.y1);
70 max_y = std::max(max_y, fe.y1);
72 min_y = std::min(min_y, fe.y2);
73 max_y = std::max(max_y, fe.y2);
76 make_graph(65535, width, height, total_flow[0].x, total_flow[total_flow.size() - 1].x, min_y, max_y, total_flow);