mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
fixes
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
## Overview
|
||||
|
||||
A plugin allowing for importing devices from DHCP.leases files.
|
||||
|
||||
### Usage
|
||||
|
||||
- Specify full paths of all `dhcp.leases` files you want to import and watch in the `DHCPLSS_paths_to_check`setting.
|
||||
- Map the paths specified in the `DHCPLSS_paths_to_check`setting in your `docker-compose.yml` file.
|
||||
|
||||
#### Example:
|
||||
|
||||
|
||||
`docker-compose.yml` excerpt:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
...
|
||||
# mapping different dhcp.leases files
|
||||
- /first/location/dhcp.leases:/mnt/dhcp1.leases
|
||||
- /second/location/dhcp.leases:/mnt/dhcp2.leases
|
||||
...
|
||||
```
|
||||
|
||||
`DHCPLSS_paths_to_check` Setting:
|
||||
|
||||
```python
|
||||
DHCPLSS_paths_to_check = ['/mnt/dhcp1.leases','/mnt/dhcp2.leases']
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
- No specific configuration needed.
|
||||
|
||||
- This plugin expects the dhcp.leases file(s) to be in the format of **dhcpd.leases** that is different to the format that PiHole uses.
|
||||
[dhcpd.leases(5) - Linux man page]( https://linux.die.net/man/5/dhcpd.leases#:~:text=This%20database%20is%20a%20free,file%20is%20the%20current%20one.)
|
||||
|
||||
Example File Format: _(not all lines are required)_
|
||||
|
||||
```
|
||||
lease 192.168.79.15 {
|
||||
starts 0 2016/08/21 13:25:45;
|
||||
ends 0 2016/08/21 19:25:45;
|
||||
cltt 0 2016/08/21 13:25:45;
|
||||
binding state active;
|
||||
next binding state free;
|
||||
rewind binding state free;
|
||||
hardware ethernet 8c:1a:bf:11:00:ea;
|
||||
uid "\001\214\032\277\021\000\352";
|
||||
option agent.circuit-id 0:17;
|
||||
option agent.remote-id c0:a8:9:5;
|
||||
client-hostname "android-8182e21c852776e7";
|
||||
}
|
||||
```
|
||||
@@ -1,336 +0,0 @@
|
||||
{
|
||||
"code_name": "dhcp_leases",
|
||||
"unique_prefix": "DHCPLSS",
|
||||
"enabled": true,
|
||||
"data_source": "python-script",
|
||||
"data_filters": [
|
||||
{
|
||||
"compare_column" : "Object_PrimaryID",
|
||||
"compare_operator" : "==",
|
||||
"compare_field_id": "txtMacFilter",
|
||||
"compare_js_template": "'{value}'.toString()",
|
||||
"compare_use_quotes": true
|
||||
}
|
||||
],
|
||||
"localized": ["display_name", "description", "icon"],
|
||||
"mapped_to_table": "DHCP_Leases",
|
||||
"display_name" : [{
|
||||
"language_code":"en_us",
|
||||
"string" : "DHCP Leases"
|
||||
}],
|
||||
"icon":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "<i class=\"fa-solid fa-hourglass-half\"></i>"
|
||||
}],
|
||||
"description": [{
|
||||
"language_code":"en_us",
|
||||
"string" : "This plugin is to import devices from dhcp.leases files."
|
||||
}],
|
||||
"params" : [
|
||||
{
|
||||
"name" : "paths",
|
||||
"type" : "setting",
|
||||
"value" : "DHCPLSS_paths_to_check"
|
||||
}],
|
||||
"database_column_definitions":
|
||||
[
|
||||
{
|
||||
"column": "Index",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": false,
|
||||
"type": "label",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "N/A"
|
||||
}]
|
||||
} ,
|
||||
{
|
||||
"column": "Plugin",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": false,
|
||||
"type": "label",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "N/A"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "DHCP_MAC",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "devicemac",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "MAC address"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "DHCP_IP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "deviceip",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "IP"
|
||||
}]
|
||||
} ,
|
||||
{
|
||||
"column": "DateTimeCreated",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Created"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"column": "DateTimeChanged",
|
||||
"mapped_to_column": "DHCP_DateTime",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Changed"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Is active"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "DHCP_Name",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Hostname"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Hardware"
|
||||
}]
|
||||
} ,
|
||||
{
|
||||
"column": "Watched_Value4",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "State"
|
||||
}]
|
||||
} ,
|
||||
{
|
||||
"column": "UserData",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": false,
|
||||
"type": "textboxsave",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Comments"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"column": "Extra",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
"default_value":"",
|
||||
"options": [],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "DHCP leases file"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"column": "Status",
|
||||
"css_classes": "col-sm-1",
|
||||
"show": true,
|
||||
"type": "replace",
|
||||
"default_value":"",
|
||||
"options": [
|
||||
{
|
||||
"equals": "watched-not-changed",
|
||||
"replacement": "<div style='text-align:center'><i class='fa-solid fa-square-check'></i><div></div>"
|
||||
},
|
||||
{
|
||||
"equals": "watched-changed",
|
||||
"replacement": "<div style='text-align:center'><i class='fa-solid fa-triangle-exclamation'></i></div>"
|
||||
},
|
||||
{
|
||||
"equals": "new",
|
||||
"replacement": "<div style='text-align:center'><i class='fa-solid fa-circle-plus'></i></div>"
|
||||
}
|
||||
],
|
||||
"localized": ["name"],
|
||||
"name":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Status"
|
||||
}]
|
||||
}
|
||||
],
|
||||
"settings":[
|
||||
{
|
||||
"function": "RUN",
|
||||
"type": "text.select",
|
||||
"default_value":"disabled",
|
||||
"options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"],
|
||||
"localized": ["name", "description"],
|
||||
"name" :[{
|
||||
"language_code":"en_us",
|
||||
"string" : "When to run"
|
||||
}],
|
||||
"description": [{
|
||||
"language_code":"en_us",
|
||||
"string" : "Enable import of devices from <code>dhcp.leases</code> files. If you select <code>schedule</code> the scheduling settings from below are applied. If you select <code>once</code> the scan is run only once on start of the application (container) or after you update your settings."
|
||||
}]
|
||||
},
|
||||
{
|
||||
"function": "CMD",
|
||||
"type": "text",
|
||||
"default_value":"python3 /home/pi/pialert/front/plugins/dhcp_leases/script.py paths={paths}",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name" : [{
|
||||
"language_code":"en_us",
|
||||
"string" : "Command"
|
||||
}],
|
||||
"description": [{
|
||||
"language_code":"en_us",
|
||||
"string" : "Command to run"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"function": "paths_to_check",
|
||||
"type": "list",
|
||||
"default_value":["/mnt/dhcp1.leases", "/mnt/dhcp2.leases"],
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name" : [{
|
||||
"language_code":"en_us",
|
||||
"string" : "Files"
|
||||
}],
|
||||
"description": [{
|
||||
"language_code":"en_us",
|
||||
"string" : "Add all dhcp.leases mapped paths to watch. Enter full path within the container, e.g. <code>/mnt/dhcp2.leases</code>. You must map these files accordingly in your <code>docker-compose.yml</code> file."
|
||||
}]
|
||||
},
|
||||
{
|
||||
"function": "RUN_SCHD",
|
||||
"type": "text",
|
||||
"default_value":"0 2 * * *",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name" : [{
|
||||
"language_code":"en_us",
|
||||
"string" : "Schedule"
|
||||
}],
|
||||
"description": [{
|
||||
"language_code":"en_us",
|
||||
"string" : "Only enabled if you select <code>schedule</code> in the <a href=\"#DHCPLSS_RUN\"><code>DHCPLSS_RUN</code> setting</a>. Make sure you enter the schedule in the correct cron-like format (e.g. validate at <a href=\"https://crontab.guru/\" target=\"_blank\">crontab.guru</a>). For example entering <code>0 4 * * *</code> will run the scan after 4 am in the <a onclick=\"toggleAllSettings()\" href=\"#TIMEZONE\"><code>TIMEZONE</code> you set above</a>. Will be run NEXT time the time passes."
|
||||
}]
|
||||
},
|
||||
{
|
||||
"function": "RUN_TIMEOUT",
|
||||
"type": "integer",
|
||||
"default_value":5,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name" : [{
|
||||
"language_code":"en_us",
|
||||
"string" : "Run timeout"
|
||||
},
|
||||
{
|
||||
"language_code":"de_de",
|
||||
"string" : "Wartezeit"
|
||||
}],
|
||||
"description": [{
|
||||
"language_code":"en_us",
|
||||
"string" : "Maximum time in seconds to wait for the script to finish. If this time is exceeded the script is aborted."
|
||||
}]
|
||||
},
|
||||
{
|
||||
"function": "WATCH",
|
||||
"type": "text.multiselect",
|
||||
"default_value":["Watched_Value1", "Watched_Value4"],
|
||||
"options": ["Watched_Value1","Watched_Value2","Watched_Value3","Watched_Value4"],
|
||||
"localized": ["name", "description"],
|
||||
"name" :[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Watched"
|
||||
}] ,
|
||||
"description":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Send a notification if selected values change. Use <code>CTRL + Click</code> to select/deselect. <ul> <li><code>Watched_Value1</code> is Active </li><li><code>Watched_Value2</code> is Hostname </li><li><code>Watched_Value3</code> is hardware </li><li><code>Watched_Value4</code> is State </li></ul>"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"function": "REPORT_ON",
|
||||
"type": "text.multiselect",
|
||||
"default_value":["new","watched-changed"],
|
||||
"options": ["new","watched-changed","watched-not-changed"],
|
||||
"localized": ["name", "description"],
|
||||
"name" :[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Report on"
|
||||
}] ,
|
||||
"description":[{
|
||||
"language_code":"en_us",
|
||||
"string" : "Send a notification only on these statuses. <code>new</code> means a new unique (unique combination of PrimaryId and SecondaryId) object was discovered. <code>watched-changed</code> means that selected <code>Watched_ValueN</code> columns changed."
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
00:11:22:33:44:55|10.0.1.1|2023-04-12 19:32:57|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-04-12 19:32:57|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-04-12 19:32:57|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-04-12 19:32:57|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-04-12 19:32:57|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-04-12 19:32:57|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-04-12 19:32:57|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-04-12 19:32:57|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-04-12 19:43:21|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-04-12 19:43:21|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-04-12 19:43:21|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-04-12 19:43:21|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-04-12 19:43:21|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-04-12 19:43:21|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-04-12 19:43:21|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-04-12 19:43:21|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-04-12 19:50:43|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-04-12 19:50:43|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-04-12 19:50:43|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-04-12 19:50:43|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-04-12 19:50:43|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-04-12 19:50:43|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-04-12 19:50:43|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-04-12 19:50:43|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-04-12 19:58:19|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-04-12 19:58:19|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-04-12 19:58:19|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-04-12 19:58:19|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-04-12 19:58:19|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-04-12 19:58:19|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-04-12 19:58:19|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-04-12 19:58:19|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-05-05 21:54:53|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-05-05 21:54:53|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-05 21:54:53|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-05 21:54:53|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-05-05 21:54:53|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-05-05 21:54:53|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-05-05 21:54:53|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-05-05 21:54:53|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-05-05 21:57:39|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-05-05 21:57:39|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-05 21:57:39|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-05 21:57:39|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-05-05 21:57:39|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-05-05 21:57:39|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-05-05 21:57:39|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-05-05 21:57:39|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-05-05 22:32:47|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-05-05 22:32:47|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-05 22:32:47|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-05 22:32:47|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-05-05 22:32:47|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-05-05 22:32:47|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-05-05 22:32:47|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-05-05 22:32:47|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-05-07 10:46:31|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-05-07 10:46:31|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-07 10:46:31|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-07 10:46:31|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-05-07 10:46:31|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-05-07 10:46:31|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-05-07 10:46:31|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-05-07 10:46:31|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-05-14 14:03:19|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-05-14 14:03:19|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-14 14:03:19|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-14 14:03:19|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-05-14 14:03:19|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-05-14 14:03:19|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-05-14 14:03:19|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-05-14 14:03:19|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-05-14 14:07:44|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-05-14 14:07:44|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-14 14:07:44|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-05-14 14:07:44|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-05-14 14:07:44|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-05-14 14:07:44|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-05-14 14:07:44|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-05-14 14:07:44|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-06-10 08:26:10|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-06-10 08:26:10|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-06-10 08:26:10|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-06-10 08:26:10|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-06-10 08:26:10|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-06-10 08:26:10|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-06-10 08:26:10|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-06-10 08:26:10|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:55|10.0.1.1|2023-06-10 08:31:48|False|host1|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|10.0.1.2|2023-06-10 08:31:48|False|host2|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-06-10 08:31:48|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:57|10.0.1.3|2023-06-10 08:31:48|False|host3|ethernet|free|/mnt/dhcp1.leases|
|
||||
00:11:22:33:44:56|20.0.1.1|2023-06-10 08:31:48|False|b-host1|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:57|20.0.1.2|2023-06-10 08:31:48|False|b-host2|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:58|20.0.1.3|2023-06-10 08:31:48|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
00:11:22:33:44:59|20.0.1.3|2023-06-10 08:31:48|False|b-host3|ethernet|free|/mnt/dhcp2.leases|
|
||||
@@ -1,116 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Based on the work of https://github.com/leiweibau/Pi.Alert
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from time import sleep, time, strftime
|
||||
import requests
|
||||
import pathlib
|
||||
import threading
|
||||
import subprocess
|
||||
import socket
|
||||
import argparse
|
||||
import io
|
||||
import sys
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
import pwd
|
||||
import os
|
||||
from dhcp_leases import DhcpLeases
|
||||
|
||||
curPath = str(pathlib.Path(__file__).parent.resolve())
|
||||
log_file = curPath + '/script.log'
|
||||
last_run = curPath + '/last_result.log'
|
||||
|
||||
print(last_run)
|
||||
|
||||
# Workflow
|
||||
|
||||
def main():
|
||||
|
||||
last_run_logfile = open(last_run, 'a')
|
||||
|
||||
# empty file
|
||||
last_run_logfile.write("")
|
||||
|
||||
parser = argparse.ArgumentParser(description='Import devices from dhcp.leases files')
|
||||
parser.add_argument('paths', action="store", help="absolute dhcp.leases file paths to check separated by ','")
|
||||
values = parser.parse_args()
|
||||
|
||||
# parse output
|
||||
newEntries = []
|
||||
|
||||
if values.paths:
|
||||
for path in values.paths.split('=')[1].split(','):
|
||||
|
||||
|
||||
newEntries = get_entries(newEntries, path)
|
||||
|
||||
|
||||
for e in newEntries:
|
||||
# Insert list into the log
|
||||
service_monitoring_log(e.primaryId, e.secondaryId, e.created, e.watched1, e.watched2, e.watched3, e.watched4, e.extra, e.foreignKey )
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
def service_monitoring_log(primaryId, secondaryId, created, watched1, watched2 = '', watched3 = '', watched4 = '', extra ='', foreignKey ='' ):
|
||||
|
||||
if watched1 == '':
|
||||
watched1 = 'null'
|
||||
if watched2 == '':
|
||||
watched2 = 'null'
|
||||
if watched3 == '':
|
||||
watched3 = 'null'
|
||||
if watched4 == '':
|
||||
watched4 = 'null'
|
||||
|
||||
with open(last_run, 'a') as last_run_logfile:
|
||||
# https://www.duckduckgo.com|192.168.0.1|2023-01-02 15:56:30|200|0.9898|null|null|Best search engine|null
|
||||
last_run_logfile.write("{}|{}|{}|{}|{}|{}|{}|{}|{}\n".format(
|
||||
primaryId,
|
||||
secondaryId,
|
||||
created,
|
||||
watched1,
|
||||
watched2,
|
||||
watched3,
|
||||
watched4,
|
||||
extra,
|
||||
foreignKey
|
||||
)
|
||||
)
|
||||
# -----------------------------------------------------------------------------
|
||||
def get_entries(newEntries, path):
|
||||
|
||||
|
||||
leases = DhcpLeases(path)
|
||||
leasesList = leases.get()
|
||||
|
||||
for lease in leasesList:
|
||||
|
||||
tmpPlugObj = plugin_object_class(lease.ethernet, lease.ip, lease.active, lease.hostname, lease.hardware, lease.binding_state, path)
|
||||
|
||||
newEntries.append(tmpPlugObj)
|
||||
|
||||
return newEntries
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
class plugin_object_class:
|
||||
def __init__(self, primaryId = '',secondaryId = '', watched1 = '',watched2 = '',watched3 = '',watched4 = '',extra = '',foreignKey = ''):
|
||||
self.pluginPref = ''
|
||||
self.primaryId = primaryId
|
||||
self.secondaryId = secondaryId
|
||||
self.created = strftime("%Y-%m-%d %H:%M:%S")
|
||||
self.changed = ''
|
||||
self.watched1 = watched1
|
||||
self.watched2 = watched2
|
||||
self.watched3 = watched3
|
||||
self.watched4 = watched4
|
||||
self.status = ''
|
||||
self.extra = extra
|
||||
self.userData = ''
|
||||
self.foreignKey = foreignKey
|
||||
|
||||
#===============================================================================
|
||||
# BEGIN
|
||||
#===============================================================================
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user