opnsense / plugins

OPNsense plugin collection
https://opnsense.org/
BSD 2-Clause "Simplified" License
849 stars 644 forks source link

Add OPNarplog #4322

Open mr-manuel opened 1 month ago

mr-manuel commented 1 month ago

Hello,

I wrote a new plugin that has similar features as arpwatch. I would like to share it with the community so that everyone can use it.

This is my first plugin and I still not fully understand how everything interacts with the OPNsense UI/API. Could you help me with a few questions?

  1. How to troubleshoot API errors? When the GUI tries to call https://192.168.133.1/api/opnarplog/service/stop then it returns {"response":"Error (127)"}. Before I renamed my plugin everything worked. Now I'm clueless where the error could be. Same for https://192.168.133.1/api/opnarplog/service/status where I get {"status":"unknown","widget":{"caption_stop":"stop service","caption_start":"start service","caption_restart":"restart service"}}. SOLVED: I made a call to /usr/local/bin/bash which does not exist on a plain installation. It was replaced with a service call.

  2. How does the logging work in OPNsense? Currently I'm writing to a logfile under /var/log/opnarplog.log and rotate it with my script. The logformat is not recognized, but somehow the logfile is recognized on the logpage.

To test the plugin :

  1. Copy the content of the repository folder net-mgmt/opnarplog/src to the firewall folder /usr/local
  2. Set the permission for two files:
    chmod 755 /usr/local/bin/openarplog.py
    chmod 755 /usr/local/etc/rc.d/opnarplog
  3. Restart configd
    service configd restart
mr-manuel commented 1 month ago

@Monviech @fichtner the PR is now ready for merge. Let me know, if I should change anything else.