npmGrafStats icon indicating copy to clipboard operation
npmGrafStats copied to clipboard

Ability to exclude subnets

Open pittbull opened this issue 1 year ago • 2 comments

Hi, just found your tool and must say I allready love it very much. Thank you for the effort.

One question on exclusions: is it much work to enable CIDR notation in the monitoringips.txt file? I am frequently accessing my services via proxy services (work enforced), and I would like to be able to exclude entire subnets.

pittbull avatar Aug 05 '24 11:08 pittbull

Hi, great to hear.

Currently, the monitoringips.txt gets the ips with https://github.com/smilebasti/npmGrafStats/blob/42e8a3661f07e97da167b903770b5cf1964d1f3b/sendips.sh#L58. This is just a simple comparison for the same IP. This would require a rewrite of that logic. Currently, i don't have the time for that. You are welcome to open am Pull request if you know how to implement such thing.

I will leave this issue open for the future and my todo list.

smilebasti avatar Aug 10 '24 09:08 smilebasti

Appreciate the lack of time on your part, so I've done some searching and there exists a command 'grepcidr' which will solve this problem.

Unfortunately the official package does not, but there exists a forked version 3 here which does. Any chance you could update the image with this command? (I downloaded the zip on my labserver and it was no efforts making and installing it)

If so I can create a PR which would add the possibility to use CIDR as well.

pittbull avatar Aug 10 '24 14:08 pittbull

Compiled the linked package on another machine and made it available to the image. Confirming that the following command will identify the ip both if specified as an ip and in cidr notation:

grepcidr -D ip monitoringips.txt

pittbull avatar Aug 15 '24 09:08 pittbull

Compiled the linked package on another machine and made it available to the image. Confirming that the following command will identify the ip both if specified as an ip and in cidr notation:

grepcidr -D ip monitoringips.txt

  • Cloned your reposity locally
  • Added grepcidr
  • Changed sendips.sh line 59 to: elif grepcidr -D $outsideip ./monitoringips.txt >> /dev/nul
  • Rebuild image

Success!

pittbull avatar Aug 15 '24 12:08 pittbull

Hi, great to hear. I would implement it. Would you mind sharing how you compiled grepcidr and made it available to the image? Never worked with make files. Thanks

smilebasti avatar Aug 21 '24 09:08 smilebasti

No worries - not an expert myself. Perhaps I got lucky, but I downloaded it to a temp folder on my server and entered into it and ran "build".

Copy the grepcidr file to the folder with your Dockerfile and add the following to it:

`COPY grepcidr /usr/local/bin/grepcidr

RUN chmod +x /usr/local/bin/grepcidr`

pittbull avatar Aug 21 '24 12:08 pittbull

No worries - not an expert myself. Perhaps I got lucky, but I downloaded it to a temp folder on my server and entered into it and ran "build".

Copy the grepcidr file to the folder with your Dockerfile and add the following to it:

`COPY grepcidr /usr/local/bin/grepcidr

RUN chmod +x /usr/local/bin/grepcidr`

Thanks. Got it to work. Will release it in the coming days.

smilebasti avatar Sep 02 '24 15:09 smilebasti