forked from crucially/timesplicedb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ngr_info.c
52 lines (41 loc) · 1.23 KB
/
ngr_info.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "NGR.h"
#include <sys/time.h>
#include <stdio.h>;
#include <time.h>;
#include <assert.h>;
#include <string.h>
#include <stdlib.h>;
extern char *optarg;
int main(int argc, char * const *argv) {
int o;
char *collection, *metric_s;
while ((o = getopt(argc, argv,
"c:m:")) != -1) {
switch(o) {
case 'c':
collection = malloc(strlen(optarg)+1);
memcpy(collection, optarg, strlen(optarg)+1);
break;
case 'm':
metric_s = malloc(strlen(optarg)+1);
memcpy(metric_s, optarg, strlen(optarg)+1);
break;
}
}
assert(collection);
assert(metric_s);
struct NGR_metric_t *metric = NGR_open(collection, metric_s);
time_t last_entry = (metric->created + (NGR_last_entry_idx(metric) * metric->resolution));
printf("Starting time: %s", ctime(&(metric->created)));
printf("Last entry: %s", ctime(&last_entry));
printf("Items: %d\n", NGR_last_entry_idx(metric));
printf("Resolution: %d seconds\n", metric->resolution);
printf("Verison: %d\n", metric->version);
if (metric->width == 8) {
printf("Format: 64bit\n");
} else if (metric->width == 4) {
printf("Format: 32bit\n");
} else {
printf("Format: unknown!\n");
}
}