Skip to content

Commit

Permalink
Fix up reporter for new influxdb schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ahupowerdns committed Feb 3, 2020
1 parent 237d5e3 commit 6deb3ff
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,21 @@ int main(int argc, char **argv)
{
MiniCurl mc;
MiniCurl::MiniCurlHeaders mch;
string dbname("galileo");
string influxDBName("galileo");


string url="http://127.0.0.1:8086/query?db="+dbname+"&epoch=s&q=";
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("--influxdb", influxDBName, "Name of influxdb database");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
Expand All @@ -68,15 +72,20 @@ int main(int argc, char **argv)
showVersion(program, g_gitHash);
exit(0);
}

period = "time > now() - "+periodarg;
/* if(argc == 3) {
period = "time > '"+string(argv[1]) +"' and time <= '" + string(argv[2])+"'";

if(beginarg.empty() && endarg.empty())
period = "time > now() - "+periodarg;
else {
period = "time > '"+ beginarg +"' and time <= '" + endarg +"'";
cout<<"Period: "<<period<<endl;
}
*/

string url="http://127.0.0.1:8086/query?db="+influxDBName+"&epoch=s&q=";

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<<j<<endl;

Expand All @@ -92,7 +101,7 @@ int main(int argc, char **argv)
}


res = mc.getURL(url + mc.urlEncode("select distinct(value) from e1bhs where "+period+" and sigid='"+to_string(sigid)+"' group by gnssid,sv,sigid,time(10m)"));
res = mc.getURL(url + mc.urlEncode("select distinct(e1bhs) from galhealth where "+period+" and sigid='"+to_string(sigid)+"' group by gnssid,sv,sigid,time(10m)"));
j = nlohmann::json::parse(res);

for(const auto& sv : j["results"][0]["series"]) {
Expand Down

0 comments on commit 6deb3ff

Please sign in to comment.