NetAlertX icon indicating copy to clipboard operation
NetAlertX copied to clipboard

Plugin for Mikrotik DHCP Leases

Open elraro opened this issue 1 year ago β€’ 6 comments

Is there an existing issue for this?

  • [X] I have searched the existing open and closed issues

Is your feature request related to a problem? Please describe

I was looking for the possibility to import directly from Mikrotik DHCP Leases, but I couldn't find a plugin to do it.

Describe the solution you'd like

The idea is to be able to import the DHCP Leases from the Mikrotik, just like the leiweibau fork: https://github.com/leiweibau/Pi.Alert/blob/24730e9269254a3ffcc06865feff7799e9fe7744/back/pialert.py#L729

Describe alternatives you've considered

I've been looking at how to create a plugin, and I think I might be able to do it, but I'm wondering how to install a library I need for Python, in order to make the plugin.

@jokob-sk could you confirm me if the python library needed for the plugin can be added here, or should I do it another way?

https://github.com/jokob-sk/Pi.Alert/blob/9f5884c4e769b026135be484dce38a36d6deadf8/install/install_python.sh#L16

Anything else?

More information about the Mikrotik DHCP Leases: https://wiki.mikrotik.com/wiki/Manual:IP/DHCP_Server#Leases

elraro avatar Jan 06 '24 23:01 elraro

Hi @elraro,

Thanks for helping out!

Please extend the existing dhcp_leases plugin and add an option to import microtik-formatted dhcp.leases files. It should be pretty straightforward (e.g. let's say the mapped path needs to have microtik in it, same as with pihole):

https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/dhcp_leases/script.py#L59

Yes, additional python packages can be installed via the file you referenced: https://github.com/jokob-sk/Pi.Alert/blob/9f5884c4e769b026135be484dce38a36d6deadf8/install/install_python.sh#L16

Looking forward to the PR!

Please also update relevant documentation and settings descriptions.

Thanks, j

jokob-sk avatar Jan 07 '24 00:01 jokob-sk

Hi @jokob-sk

The problem I see with extending the existing dhcp_leases plugin is this plugin reads the dhcp leases from files on disk. And in this case, I would connect to the mikrotik to read the console output. I had thought about making a new plugin, as the operation was completely different, but I can study it.

Thank you!

elraro avatar Jan 07 '24 20:01 elraro

Oh, in that case, sure thing. Go ahead and create a new plugin. I thought there was a file to read from.

jokob-sk avatar Jan 07 '24 20:01 jokob-sk

Hi @jokob-sk

I'm not dead hehe but very busy due to my girlfriend's surgery. Hope I can start with this in a few weeks.

Thank you!

elraro avatar Feb 09 '24 20:02 elraro

@elraro glad to hear that you are still alive πŸ˜…

I hope the surgery goes well! πŸ€ And of course no rush.

Thank you in advance for helping out!

jokob-sk avatar Feb 09 '24 22:02 jokob-sk

Hi @elraro ,

If you have some time, I've created a walkthrough of creating a custom plugin: Watch the video

πŸŽ₯Watch the video πŸ™‚

jokob-sk avatar Jun 30 '24 22:06 jokob-sk

Thank you jokob!

I was really busy this months preparing my wedding. Now that I am a married men, I will see your video and I make the plugin.

elraro avatar Aug 04 '24 14:08 elraro

Congratulations @elraro πŸŽ‰πŸΎ welcome to the club πŸ˜„

jokob-sk avatar Aug 04 '24 22:08 jokob-sk

Just FYI @elraro , @lookflying submitted a PR for this - but you are more than welcome to improve other things :) https://github.com/jokob-sk/NetAlertX/issues?q=is%3Aissue++label%3A%22help+wanted+%F0%9F%86%98%22+

jokob-sk avatar Aug 08 '24 22:08 jokob-sk

Its great! Thank you @lookflying . Im learning how to create a plugin. I will take a look!

elraro avatar Aug 08 '24 22:08 elraro