Skip to content

Commit 6deb3ff

Browse files
committed
Fix up reporter for new influxdb schema
1 parent 237d5e3 commit 6deb3ff

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

reporter.cc

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,21 @@ int main(int argc, char **argv)
4747
{
4848
MiniCurl mc;
4949
MiniCurl::MiniCurlHeaders mch;
50-
string dbname("galileo");
50+
string influxDBName("galileo");
51+
5152

52-
string url="http://127.0.0.1:8086/query?db="+dbname+"&epoch=s&q=";
5353
string period="time > now() - 1w";
5454
int sigid=1;
5555
bool doVERSION{false};
5656

5757
CLI::App app(program);
5858
string periodarg("1d");
59+
string beginarg, endarg;
5960
app.add_flag("--version", doVERSION, "show program version and copyright");
6061
app.add_option("--period,-p", periodarg, "period over which to report (1h, 1w)");
62+
app.add_option("--begin,-b", beginarg, "Beginning");
63+
app.add_option("--end,-e", endarg, "End");
64+
app.add_option("--influxdb", influxDBName, "Name of influxdb database");
6165
try {
6266
app.parse(argc, argv);
6367
} catch(const CLI::Error &e) {
@@ -68,15 +72,20 @@ int main(int argc, char **argv)
6872
showVersion(program, g_gitHash);
6973
exit(0);
7074
}
71-
72-
period = "time > now() - "+periodarg;
73-
/* if(argc == 3) {
74-
period = "time > '"+string(argv[1]) +"' and time <= '" + string(argv[2])+"'";
75+
76+
if(beginarg.empty() && endarg.empty())
77+
period = "time > now() - "+periodarg;
78+
else {
79+
period = "time > '"+ beginarg +"' and time <= '" + endarg +"'";
80+
cout<<"Period: "<<period<<endl;
7581
}
76-
*/
82+
83+
string url="http://127.0.0.1:8086/query?db="+influxDBName+"&epoch=s&q=";
84+
7785
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)"));
7886

7987

88+
8089
auto j = nlohmann::json::parse(res);
8190
// cout<<j<<endl;
8291

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

94103

95-
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)"));
104+
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)"));
96105
j = nlohmann::json::parse(res);
97106

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

0 commit comments

Comments
 (0)