#include "ext/powerblog/h2o-pp.hh" #include "minicurl.hh" #include #include "navmon.hh" #include "fmt/format.h" #include "fmt/printf.h" using namespace std; /* 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 dbname("galileo"); string url="http://127.0.0.1:8086/query?db="+dbname+"&epoch=s&q="; string period="time > now() - 1w"; int sigid=1; if(argc == 2) period = "time > now() - "+string(argv[1]); if(argc == 3) { period = "time > '"+string(argv[1]) +"' and time <= '" + string(argv[2])+"'"; } auto res = mc.getURL(url + mc.urlEncode("select distinct(value) from sisa where "+period+" and sigid='"+to_string(sigid)+"' group by gnssid,sv,sigid,time(10m)")); auto j = nlohmann::json::parse(res); // cout<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 "<