richardforth / apache2buddy

apache2buddy
Apache License 2.0
384 stars 72 forks source link

SS support along with netstat #400

Open sumitgarg44 opened 2 years ago

sumitgarg44 commented 2 years ago

As OS vendors are moving towards 'ss' than netstat in latest releases. I believe it will be worth to add ss support in apache2buddy script.

Regards Sumit Garg

richardforth commented 2 years ago

Hi Sumit,

This has been in my radar for several years but so far all the Jenkins Tests are passing so I'm loathe to change things at the moment as it may break backward compatibility.

I'll certainly keep this issue open for now but if you get an os where netstat is no longer available and SS is the only option then we can take a look at it.

Hope you are keeping well.

Kind Regards Richard

On Thu, 13 Oct 2022, 14:37 sumit garg, @.***> wrote:

As OS vendors are moving towards 'ss' than netstat in latest releases. I believe it will be worth to add ss support in apache2buddy script.

Regards Sumit Garg

— Reply to this email directly, view it on GitHub https://github.com/richardforth/apache2buddy/issues/400, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNFIVY2VJHVC3TKDGGWV5DWDAGA3ANCNFSM6AAAAAAREJIDEM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

sumitgarg44 commented 2 years ago

I had one device having only SS but then I end up installing netstat temporarily :)

richardforth commented 2 years ago

If you can remember what OS it was on I'll run some tests.

I know netstat has been a hard dependency for some time and I think the docker images I'm using I'm the Jenkins builds have it pre installed.

I could add another test without netstat and see if I can fall back on ss.

But as I said I'm petrified of breaking backwards compatibility.

On Thu, 13 Oct 2022, 17:41 sumit garg, @.***> wrote:

I had one device having only SS but then I end up installing netstat temporarily :)

— Reply to this email directly, view it on GitHub https://github.com/richardforth/apache2buddy/issues/400#issuecomment-1277895935, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNFIV3PGX7ERNIOGVWNDUTWDA3SVANCNFSM6AAAAAAREJIDEM . You are receiving this because you commented.Message ID: @.***>

sumitgarg44 commented 2 years ago

Unfortunately I don’t remember it exactly, I believe it was Ubuntu 20 or 22 LTS

richardforth commented 2 years ago
# yum whatprovides ss
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager

...

iproute-4.11.0-30.el7.x86_64 : Advanced IP routing and network device configuration tools
Repo        : base
Matched from:
Filename    : /usr/sbin/ss

iproute-4.11.0-25.el7_7.2.x86_64 : Advanced IP routing and network device configuration tools
Repo        : @base
Matched from:
Filename    : /sbin/ss

iproute-4.11.0-25.el7_7.2.x86_64 : Advanced IP routing and network device configuration tools
Repo        : @base
Matched from:
Filename    : /usr/sbin/ss
richardforth commented 2 years ago

I'm also in the process of adding an Ubuntu 22.04 Docker file and Jenkins stage in the pipeline

richardforth commented 2 years ago
  1671          # Check 2.1
  1672          # this script uses netstat to determine the port that apache is listening on
  1673          # process. make sure that netstat is available.
  1674          our $netstat = `which netstat`;
  1675          chomp($netstat);
  1676
  1677          # make sure that netstat is available within our path
  1678          if ( $netstat !~ m/.*\/netstat/ ) {
  1679                  show_crit_box();
  1680                  print "Unable to locate the netstat utility. This script requires netstat to determine the port that apache is listening on.\n";
  1681                  show_info_box(); print "${YELLOW}To fix this make sure the net-tools package is installed.${ENDC}\n";
  1682                  exit;
  1683          } else {
  1684                  if ( ! $NOOK ) { show_ok_box(); print "The utility 'netstat' exists and is available for use: ${CYAN}$netstat${ENDC}\n" }
  1685          }
richardforth commented 2 years ago

Thinking of setting some flags, and checking for netstat, and falling back to ss, then later in the script calling netstat or ss depending on what flag is set

richardforth commented 2 years ago

for ss

show_info_box(); print "${YELLOW}To fix this make sure the iproute package is installed.${ENDC}\n";
richardforth commented 2 years ago

or im also thinking of looking for ss first, and falling back to netstat, as this will likely future proof the logic for a few years, since ss is the new preferred command and netstat is being deprecated and probably eventually removed.