Skip to content

Commit

Permalink
pihole #418 work
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Sep 11, 2023
1 parent af41eed commit 78a87c4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
31 changes: 29 additions & 2 deletions front/plugins/pihole_scan/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
},
{
"function": "CMD",
"type": "readonly",
"default_value":"SELECT hwaddr as Object_PrimaryID, cast('http://' || (SELECT ip FROM EXTERNAL_PIHOLE.network_addresses WHERE network_id = id ORDER BY lastseen DESC, ip LIMIT 1) as VARCHAR(100)) || ':' || cast( SUBSTR((SELECT name FROM EXTERNAL_PIHOLE.network_addresses WHERE network_id = id ORDER BY lastseen DESC, ip LIMIT 1), 0, INSTR((SELECT name FROM EXTERNAL_PIHOLE.network_addresses WHERE network_id = id ORDER BY lastseen DESC, ip LIMIT 1), '/')) as VARCHAR(100)) as Object_SecondaryID, datetime() as DateTime, macVendor as Watched_Value1, lastQuery as Watched_Value2, (SELECT name FROM EXTERNAL_PIHOLE.network_addresses WHERE network_id = id ORDER BY lastseen DESC, ip LIMIT 1) as Watched_Value3, 'null' as Watched_Value4, '' as Extra, hwaddr as ForeignKey FROM EXTERNAL_PIHOLE.network WHERE hwaddr NOT LIKE 'ip-%' AND hwaddr <> '00:00:00:00:00:00'; ",
"type": "text",
"default_value":"SELECT n.hwaddr AS Object_PrimaryID, 'null' AS Object_SecondaryID, datetime() AS DateTime, na.ip AS Watched_Value1, n.lastQuery AS Watched_Value2, na.name AS Watched_Value3, n.macVendor AS Watched_Value4, {s-quote}null{s-quote} AS Extra, n.hwaddr AS ForeignKey FROM EXTERNAL_PIHOLE.Network AS n LEFT JOIN EXTERNAL_PIHOLE.Network_Addresses AS na ON na.network_id = n.id WHERE n.hwaddr NOT LIKE {s-quote}ip-%{s-quote} AND n.hwaddr <> {s-quote}00:00:00:00:00:00{s-quote};",
"options": [],
"localized": ["name", "description"],
"name" : [{
Expand Down Expand Up @@ -219,6 +219,19 @@
"string" : "MAC"
}]
},
{
"column": "Object_SecondaryID",
"css_classes": "col-sm-2",
"show": false,
"type": "label",
"default_value":"",
"options": [],
"localized": ["name"],
"name":[{
"language_code":"en_us",
"string" : "N/A"
}]
},
{
"column": "Watched_Value1",
"mapped_to_column": "cur_IP",
Expand Down Expand Up @@ -265,6 +278,20 @@
"string" : "Name"
}]
},
{
"column": "Watched_Value4",
"mapped_to_column": "cur_Vendor",
"css_classes": "col-sm-2",
"show": true,
"type": "label",
"default_value":"",
"options": [],
"localized": ["name"],
"name":[{
"language_code":"en_us",
"string" : "Vendor"
}]
},
{
"column": "Dummy",
"mapped_to_column": "cur_ScanMethod",
Expand Down
3 changes: 2 additions & 1 deletion pialert/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,14 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ):
else:
mylog('none', ['[Plugins] Skipped invalid sql result'])


# check if the subprocess / SQL query failed / there was no valid output
if len(sqlParams) == 0:
mylog('none', ['[Plugins] No output received from the plugin ', plugin["unique_prefix"], ' - enable LOG_LEVEL=debug and check logs'])
return pluginsState
else:
mylog('verbose', ['[Plugins] SUCCESS, received ', len(sqlParams), ' entries'])
mylog('debug', ['[Plugins] sqlParam entries: ', sqlParams])

# process results if any
if len(sqlParams) > 0:
Expand Down

0 comments on commit 78a87c4

Please sign in to comment.