#include "ext/powerblog/h2o-pp.hh" #include "minicurl.hh" #include #include "navmon.hh" #include "fmt/format.h" #include "fmt/printf.h" #include "CLI/CLI.hpp" #include "version.hh" static char program[]="reporter"; using namespace std; extern const char* g_gitHash; /* Goal: generate statistics from influxdb. Method: per x minute interval, determine status for all SVs. We only count minutes in which we have data We do only positive measurements, and report absence of data in neutral terms - either there was no reception or no transmission, we don't know. If an interval has no data: unobserved If interval has any data, it counts as observed If interval has a single unhealthy status, it is entirely unhealthy If interval is NAPA, but otherwise healthy, status is NAPA If observed and nothing else, status is healthy Input: time range, width if interval Internal: per SV, interval, bitfield Output: per SV, number of intervals healthy, number of intervals NAPA, number of intervals unhealthy, number of intervals unobserved */ struct IntervalStat { std::optional unhealthy; std::optional sisa; }; map> g_stats; int main(int argc, char **argv) { MiniCurl mc; MiniCurl::MiniCurlHeaders mch; string influxDBName("galileo"); string period="time > now() - 1w"; int sigid=1; bool doVERSION{false}; CLI::App app(program); string periodarg("1d"); string beginarg, endarg; app.add_flag("--version", doVERSION, "show program version and copyright"); app.add_option("--period,-p", periodarg, "period over which to report (1h, 1w)"); app.add_option("--begin,-b", beginarg, "Beginning"); app.add_option("--end,-e", endarg, "End"); app.add_option("--sigid,-s", sigid, "Signal identifier. 1 or 5 for Galileo."); app.add_option("--influxdb", influxDBName, "Name of influxdb database"); try { app.parse(argc, argv); } catch(const CLI::Error &e) { return app.exit(e); } if(doVERSION) { showVersion(program, g_gitHash); exit(0); } if(beginarg.empty() && endarg.empty()) period = "time > now() - "+periodarg; else { period = "time > '"+ beginarg +"' and time <= '" + endarg +"'"; cout<<"Period: "<first < start) start = sv.second.begin()->first; if(sv.second.rbegin()->first > stop) stop = sv.second.rbegin()->first; } if(sv.second.size() > maxintervals) maxintervals = sv.second.size(); } cout<<"Report on "<