Issues with sql_influx types and statuses.
Closed this issue · 1 comments
xNinjaKittyx commented
Hello, I'm currently using latest master branch and using pi-hole version v5.2.1 (FTL 5.3.2)
I noticed that "type" now goes to index 14 (13, with the -1), and "statuses" now goes to index 12.
I added the following diff to sql_influx to debug
diff --git a/sql_influx/main.py b/sql_influx/main.py
index a1725b6..d0d1d3a 100644
--- a/sql_influx/main.py
+++ b/sql_influx/main.py
@@ -40,7 +40,7 @@ def get_last_id():
def add_new_results(last_id):
"""write new results from pihole-FTL.db"""
row = None
- print('filling data...')
+ print('filling data from {}'.format(PIHOLE_FTL_DB))
while True:
try:
con = connect(PIHOLE_FTL_DB)
@@ -59,24 +59,27 @@ def add_new_results(last_id):
if row and curr_id != last_id:
for item in rows:
- json_body = [
- {
- "measurement": "pihole-FTL",
- "tags": {
- "uniq": item[0] % 1000,
- "type": types[item[2] - 1],
- "status": statuses[item[3]],
- "domain": item[4],
- "client": item[5],
- "forward": item[6]
- },
- "time": time.strftime('%Y-%m-%dT%H:%M:%S', time.gmtime(item[1])),
- "fields": {
- "id": item[0]
+ try:
+ json_body = [
+ {
+ "measurement": "pihole-FTL",
+ "tags": {
+ "uniq": item[0] % 1000,
+ "type": types[item[2] - 1],
+ "status": statuses[item[3]],
+ "domain": item[4],
+ "client": item[5],
+ "forward": item[6]
+ },
+ "time": time.strftime('%Y-%m-%dT%H:%M:%S', time.gmtime(item[1])),
+ "fields": {
+ "id": item[0]
+ }
}
- }
- ]
- client.write_points(json_body)
+ ]
+ client.write_points(json_body)
+ except IndexError as e:
+ print(f"The following item was not parsable {e}. {item}")
else:
time.sleep(5)
except KeyboardInterrupt:
Then the following errors show - 9(some redacted)
sql_influx | The following item was not parsable list index out of range. (1479447, 1608060599, 14, 2, 'omitted', 'omitted', 'omitted', None)
sql_influx | The following item was not parsable list index out of range. (1479418, 1608060587, 1, 12, 'omitted', 'omitted', None, None)
Brandawg93 commented
Fixed in #24.