Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[help] nslookup plugin #543

Closed
jokob-sk opened this issue Jan 25, 2024 · 18 comments
Closed

[help] nslookup plugin #543

jokob-sk opened this issue Jan 25, 2024 · 18 comments
Labels
Feature request➕ New feature or request next release/in dev image🚀 This is coming in the next release or was already released if the issue is Closed.

Comments

@jokob-sk
Copy link
Owner

          Simply input: nslookup 192.168.8.12

output:
image

This is one of the devices it didn't find.

Originally posted by @uldtot in https://github.com/jokob-sk/Pi.Alert/issues/534#issuecomment-1904853124

@jokob-sk jokob-sk added help wanted 🆘 Extra attention is needed help-testing🧪 Looking for someone to help test this to make sure I don't break your setups. labels Jan 25, 2024
@jokob-sk
Copy link
Owner Author

Hi @uldtot ,

I implemented a NSLOOKUP plugin but I can't get any valid results on my network. It would be great if you could help testing it:

image

It's available in the pi.alert_dev image in ~20 min form now. Here is the output in the log file that I'm getting on my end:

image

The nslookup command I execute for every device is:

nslookup <device IP>

@jokob-sk jokob-sk added the Feature request➕ New feature or request label Jan 25, 2024
@uldtot
Copy link

uldtot commented Jan 26, 2024

I tried the dev and now no devices are shown and the nslookup settings are empty.
image

Console error:
image

@jokob-sk
Copy link
Owner Author

Thanks @uldtot for checking! Can you please try a different browser or refresh your browser cache? The function seems to be deployed, but it sounds like the old files are cached by the browser: https://github.com/jokob-sk/Pi.Alert/blob/d18a59944bba1e64b810b89e19734fc702cab105/front/js/pialert_common.js#L352

@uldtot
Copy link

uldtot commented Jan 26, 2024

That worked. didnt think if cache.

Here is what it said in logs ():

`19:47:20 [Plugin utils] display_name: NSLOOKUP (Name discovery)
19:47:20 [Plugins] CMD: python3 /home/pi/pialert/front/plugins/nslookup_scan/nslookup.py
19:47:20 [Plugin utils] Flattening the below array
19:47:20 ['0.0.0.0']['192.168.8.16']['192.168.8.8']['192.168.8.104']['192.168.8.13']['192.168.8.12']['192.168.8.1']['192.168.8.14']['192.168.8.15']['192.168.8.9']
19:47:20 [Plugin utils] isinstance(arr, list) : True | isinstance(arr, str) : False
19:47:20 [Plugin utils] Flattened array: 0.0.0.0,192.168.8.16,192.168.8.8,192.168.8.104,192.168.8.13,192.168.8.12,192.168.8.1,192.168.8.14,192.168.8.15,192.168.8.9
19:47:20 [Plugins] Resolved value: 0.0.0.0,192.168.8.16,192.168.8.8,192.168.8.104,192.168.8.13,192.168.8.12,192.168.8.1,192.168.8.14,192.168.8.15,192.168.8.9
19:47:20 [Plugins] Convert to Base64: False
19:47:20 [Plugins] The parameter "name":"ips" will multiply the timeout 10 times. Total timeout: 100s
19:47:20 [Plugins] Timeout: 100
19:47:20 [Plugin utils] Pre-Resolved CMD: python3/home/pi/pialert/front/plugins/nslookup_scan/nslookup.py
19:47:20 [Plugins] Executing: python3 /home/pi/pialert/front/plugins/nslookup_scan/nslookup.py
19:47:20 [Plugins] Resolved : ['python3', '/home/pi/pialert/front/plugins/nslookup_scan/nslookup.py']
19:47:20 [NSLOOKUP] In script
19:47:20 [Database] Opening DB
19:47:20 [plugin_helper] reading config file
19:47:20 [NSLOOKUP] In script
19:47:20 [Database] Opening DB
Traceback (most recent call last):
File "/home/pi/pialert/front/plugins/nslookup_scan/nslookup.py", line 134, in
main()
File "/home/pi/pialert/front/plugins/nslookup_scan/nslookup.py", line 55, in main
domain_name, dns_server = execute_nslookup(device['dev_LastIP'], timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/pialert/front/plugins/nslookup_scan/nslookup.py", line 100, in execute_nslookup
domain_match = domain_pattern.search(output.stdout)
^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'stdout'

19:47:20 [Plugins] ⚠ ERROR - enable LOG_LEVEL=debug and check logs
19:47:20 [Plugins] The file /home/pi/pialert/front/plugins/nslookup_scan/last_result.log does not exist
19:47:20 [Plugins] No output received from the plugin NSLOOKUP - enable LOG_LEVEL=debug and check logs
19:47:20 [Plugin utils] ---------------------------------------------`

@jokob-sk
Copy link
Owner Author

Thanks a lot! Can you try again to download the image once this run finishes (in ~17 min form now)? I hope I fixed the error above:

https://github.com/jokob-sk/Pi.Alert/actions/runs/7674821635

@uldtot
Copy link

uldtot commented Jan 27, 2024

`14:06:20 [Plugins] Executing: python3 /home/pi/pialert/front/plugins/nslookup_scan/nslookup.py
14:06:20 [Plugins] Resolved : ['python3', '/home/pi/pialert/front/plugins/nslookup_scan/nslookup.py']
14:06:21 [NSLOOKUP] In script
14:06:21 [Database] Opening DB
14:06:21 [NSLOOKUP]** server can't find 0.0.0.0.in-addr.arpa: NXDOMAIN

14:06:21 [NSLOOKUP] ⚠ ERROR - check logs
14:06:21 [NSLOOKUP] Scan: FAIL - check logs
14:06:21 [NSLOOKUP] Script finished
14:06:21 [Plugins] No output received from the plugin NSLOOKUP - enable LOG_LEVEL=debug and check logs
14:06:21 [2024-01-27 14:06:21+01:00] END Run: NSLOOKUP
14:06:21 [API] Update API starting
14:06:21 [MAIN] waiting to start next loop
14:06:26 [Config] No old setting names found in the file. No changes made.
14:06:26 [Import Config] checking config file
14:06:26 [Import Config] lastImportedConfFile :1706360641.9622402
14:06:26 [Import Config] fileModifiedTime :1706360641.9622402
14:06:26 [Import Config] skipping config file import
14:06:26 [API] Update API starting
14:06:26 [MAIN] waiting to start next loop
14:06:31 [Config] No old setting names found in the file. No changes made.
14:06:31 [Import Config] checking config file
14:06:31 [Import Config] lastImportedConfFile :1706360641.9622402
14:06:31 [Import Config] fileModifiedTime :1706360641.9622402
14:06:31 [Import Config] skipping config file import
14:06:31 [API] Update API starting
14:06:31 [MAIN] waiting to start next loop
14:06:36 [Config] No old setting names found in the file. No changes made.
14:06:36 [Import Config] checking config file
14:06:36 [Import Config] lastImportedConfFile :1706360641.9622402
14:06:36 [Import Config] fileModifiedTime :1706360641.9622402
14:06:36 [Import Config] skipping config file import
14:06:36 [API] Update API starting
14:06:36 [MAIN] waiting to start next loop
14:06:41 [Config] No old setting names found in the file. No changes made.
14:06:41 [Import Config] checking config file
14:06:41 [Import Config] lastImportedConfFile :1706360641.9622402
14:06:41 [Import Config] fileModifiedTime :1706360641.9622402
14:06:41 [Import Config] skipping config file import
14:06:41 [API] Update API starting
14:06:42 [Plugins] Check if any plugins need to be executed on run type: schedule
14:06:42 [Scheduler] - Scheduler run for VNDRPDT: NO
14:06:42 [Scheduler] - Scheduler run for INTRSPD: NO
14:06:42 [Scheduler] - Scheduler run for ARPSCAN: NO
14:06:42 [Scheduler] - Scheduler run for NSLOOKUP: NO
14:06:42 [Scheduler] - Scheduler run for CSVBCKP: NO
14:06:42 [Scheduler] - Scheduler run for MAINT: NO
14:06:42 [Scheduler] - Scheduler run for DBCLNP: NO
14:06:42 [Plugins] Check if any plugins need to be executed on run type: always_after_scan
14:06:42 [MAIN] processScan: False
14:06:42 [Notification] Check if something to report
14:06:42 [Notification] Included sections: ['new_devices']
14:06:42 [Notification] new_devices SQL query: SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
WHERE eve_PendingAlertEmail = 1
AND eve_EventType = 'New Device'

                    ORDER BY eve_DateTime

14:06:42 [Notification] No changes to report
14:06:42 [MAIN] Process: Wait
14:06:47 [Config] No old setting names found in the file. No changes made.
14:06:47 [Import Config] checking config file
14:06:47 [Import Config] lastImportedConfFile :1706360641.9622402
14:06:47 [Import Config] fileModifiedTime :1706360641.9622402
14:06:47 [Import Config] skipping config file import
14:06:47 [API] Update API starting
14:06:47 [MAIN] waiting to start next loop
14:06:52 [Config] No old setting names found in the file. No changes made.
14:06:52 [Import Config] checking config file
14:06:52 [Import Config] lastImportedConfFile :1706360641.9622402
14:06:52 [Import Config] fileModifiedTime :1706360641.9622402
14:06:52 [Import Config] skipping config file import
14:06:52 [API] Update API starting
14:06:52 [MAIN] waiting to start next loop`

@jokob-sk
Copy link
Owner Author

Thanks! That looks better, can you send me a screenshot from Plugins -> NSLOOKUP if there are any valid names I can use?

image

@uldtot
Copy link

uldtot commented Jan 28, 2024

its empty:

image

@jokob-sk
Copy link
Owner Author

Hummm.. .thanks....

I've added some debug output, can you re-test and check the logs once you have a minute after downloading the latest build after the below finishes?

https://github.com/jokob-sk/Pi.Alert/actions/runs/7685768406

mylog('verbose', [f'[{pluginName}] DEBUG OUTPUT : {output}'])

@uldtot
Copy link

uldtot commented Jan 28, 2024

`14:12:42 [Import Config] checking config file
14:12:42 [Import Config] lastImportedConfFile :1706446962.822595
14:12:42 [Import Config] fileModifiedTime :1706446962.822595
14:12:42 [Import Config] skipping config file import
14:12:42 [API] Update API starting
14:12:42 [MAIN] waiting to start next loop
14:12:47 [Config] No old setting names found in the file. No changes made.
14:12:47 [Import Config] checking config file
14:12:47 [Import Config] lastImportedConfFile :1706446962.822595
14:12:47 [Import Config] fileModifiedTime :1706446962.822595
14:12:47 [Import Config] skipping config file import
14:12:47 [2024-01-28 14:12:47+01:00] START Run: NSLOOKUP
14:12:47 [Plugin utils] Flattening the below array
14:12:47 ['0.0.0.0']['192.168.8.16']['192.168.8.8']['192.168.8.17']['192.168.8.104']['192.168.8.13']['192.168.8.12']['192.168.8.1']['192.168.8.14']['192.168.8.15']['192.168.8.9']
14:12:47 [Plugin utils] isinstance(arr, list) : True | isinstance(arr, str) : False
14:12:47 [Plugin utils] Flattened array: 0.0.0.0,192.168.8.16,192.168.8.8,192.168.8.17,192.168.8.104,192.168.8.13,192.168.8.12,192.168.8.1,192.168.8.14,192.168.8.15,192.168.8.9
14:12:47 [Plugins] Resolved value: 0.0.0.0,192.168.8.16,192.168.8.8,192.168.8.17,192.168.8.104,192.168.8.13,192.168.8.12,192.168.8.1,192.168.8.14,192.168.8.15,192.168.8.9
14:12:47 [Plugins] Convert to Base64: False
14:12:47 [Plugins] The parameter "name":"ips" will multiply the timeout 11 times. Total timeout: 110s
14:12:47 [Plugins] Timeout: 110
14:12:47 [Plugin utils] Pre-Resolved CMD: python3/home/pi/pialert/front/plugins/nslookup_scan/nslookup.py
14:12:47 [Plugins] Executing: python3 /home/pi/pialert/front/plugins/nslookup_scan/nslookup.py
14:12:47 [Plugins] Resolved : ['python3', '/home/pi/pialert/front/plugins/nslookup_scan/nslookup.py']
14:12:48 [NSLOOKUP] In script
14:12:48 [Database] Opening DB
14:12:48 [NSLOOKUP] DEBUG OUTPUT : ;; Got recursion not available from 192.168.8.1, trying next server
13.8.168.192.in-addr.arpa name = Kims-A54.

Authoritative answers can be found from:

14:12:48 [NSLOOKUP]** server can't find 0.0.0.0.in-addr.arpa: NXDOMAIN

14:12:48 [NSLOOKUP] ⚠ ERROR - check logs
14:12:48 [NSLOOKUP] Scan: FAIL - check logs
14:12:48 [NSLOOKUP] DEBUG OUTPUT : ;; Got recursion not available from 192.168.8.1, trying next server
17.8.168.192.in-addr.arpa name = Kims-A54.

Authoritative answers can be found from:

14:12:48 [NSLOOKUP] Script finished`

@jokob-sk
Copy link
Owner Author

Hey @uldtot ,

Thanks a lot for the help! I finally got NSLOOKUP running on my local LAN and I was able to test this on my end.

If you want to test it also on your setup, you can try after this build finishes: https://github.com/jokob-sk/Pi.Alert/actions/runs/7710412087

Thanks for all the help!
j

@jokob-sk jokob-sk added next release/in dev image🚀 This is coming in the next release or was already released if the issue is Closed. and removed help wanted 🆘 Extra attention is needed help-testing🧪 Looking for someone to help test this to make sure I don't break your setups. labels Jan 30, 2024
@uldtot
Copy link

uldtot commented Jan 30, 2024

Tried the latest one, but it just keep failing and restarting the container now.

Think this is relevant log:
pialert | 21:13:06 [Plugin utils] Pre-Resolved CMD: python3/home/pi/pialert/front/plugins/undiscoverables/script.pydevices={devices} pialert | 21:13:06 [Plugins] Executing: python3 /home/pi/pialert/front/plugins/undiscoverables/script.py devices={devices} pialert | 21:13:06 [Plugins] Resolved : ['python3', '/home/pi/pialert/front/plugins/undiscoverables/script.py', 'devices=(name not found)'] pialert | 21:13:06 [Plugins] SUCCESS, received 1 entries pialert | Traceback (most recent call last): pialert | File "", line 198, in _run_module_as_main pialert | File "", line 88, in _run_code pialert | File "/home/pi/pialert/pialert/__main__.py", line 195, in pialert | sys.exit(main()) pialert | ^^^^^^ pialert | File "/home/pi/pialert/pialert/__main__.py", line 136, in main pialert | process_scan(db) pialert | File "/home/pi/pialert/pialert/networkscan.py", line 45, in process_scan pialert | update_devices_names(db) pialert | File "/home/pi/pialert/pialert/device.py", line 324, in update_devices_names pialert | newName = get_device_name_nslookup(db, device['dev_MAC'], device['dev_LastIP']) pialert | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pialert | File "/home/pi/pialert/pialert/helper.py", line 386, in get_device_name_nslookup pialert | name = cleanDeviceName(nslookupEntry[0][0]) pialert | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pialert | TypeError: cleanDeviceName() missing 1 required positional argument: 'match_IP' pialert | 21:13:06 [Plugins] sqlParam entries: [(0, 'UNDIS', '(name not found)', '0.0.0.0', 'null', '2024-01-30 21:13:06', '(name not found)', '', '', '', 'not-processed', '', 'null', 'ed:2d:66:db:b4:4f')] pialert | 21:13:06 [Plugins] Processing : UNDIS

`21:13:07 [New Devices] New Devices end
21:13:07 [Process Scan] Updating Devices Info
21:13:07 [Update Devices] 1 Last Connection
21:13:07 [Update Devices] 2 Clean no active devices
21:13:07 [Update Devices] - 3 LastIP
21:13:07 [Update Devices] - 3 Vendor
21:13:07 [Update Devices] - 4 Unknown Name
21:13:07 [Update Devices] Update devices end
21:13:07 [Process Scan] Resolve devices names
21:13:07 [Update Device Name] Trying to resolve devices without name
21:13:07 [Update Device Name] Pholus entries from prev scans: 8
21:14:23 [MAIN] Setting up ...
21:14:23 [conf.tz] Setting up ...
21:14:23

21:14:23 The container restarted (started). If this is unexpected check https://bit.ly/PiAlertDebug for troubleshooting tips.
21:14:23

21:14:23 Permissions check (All should be True)
21:14:23 ------------------------------------------------
21:14:23 /config/pialert.conf | READ | True
21:14:23 /config/pialert.conf | WRITE | True
21:14:23 /db/pialert.db | READ | True
21:14:23 /db/pialert.db | WRITE | True
21:14:23 ------------------------------------------------
21:14:23 [Setup] Attempting to fix permissions.`

@jokob-sk
Copy link
Owner Author

Oh, my bad - fixed it now and the new image will be available after this action finishes: https://github.com/jokob-sk/Pi.Alert/actions/runs/7732279513

Thanks again for your help 🙏

@uldtot
Copy link

uldtot commented Jan 31, 2024

Look like it worked, will do more tests tomorrow. :)

@jokob-sk
Copy link
Owner Author

jokob-sk commented Feb 1, 2024

Yayyy - getting there :) thanks for the help. Let me know if you have feedback 👍

@uldtot
Copy link

uldtot commented Feb 5, 2024

It look like its working now. My chroembook got an odd name, but it found one (looks like something hashed value, but im sure that just how my chromebook work :D) and my phone are found now.

The email sent still show no name found, so maybe its sending email before nslookup part?

@jokob-sk
Copy link
Owner Author

jokob-sk commented Feb 5, 2024

Cool, thanks! Pushing hopefully a fix for that 👍

@jokob-sk
Copy link
Owner Author

released -> closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request➕ New feature or request next release/in dev image🚀 This is coming in the next release or was already released if the issue is Closed.
Projects
None yet
Development

No branches or pull requests

2 participants