added support to use the 'ss' command in 'port.pm' and 'nginx.pm'

This commit is contained in:
Jordi Sanfeliu 2020-06-22 15:43:44 +02:00
parent be3e6e8bcf
commit 3663c450fe
3 changed files with 70 additions and 16 deletions

View File

@ -578,16 +578,31 @@ sub nginx_cgi {
undef(@warning);
my $pnum;
if($config->{os} eq "Linux") {
open(IN, "netstat -nl --tcp |");
while(<IN>) {
(undef, undef, undef, $pnum) = split(' ', $_);
chomp($pnum);
$pnum =~ s/.*://;
if($pnum eq $nginx->{port}) {
last;
my $cmd = $nginx->{cmd} || "";
if(!$cmd || $cmd eq "ss") {
open(IN, "ss -nl --$pp |");
while(<IN>) {
(undef, undef, undef, $pnum) = split(' ', $_);
chomp($pnum);
$pnum =~ s/.*://;
if($pnum eq $nginx->{port}) {
last;
}
}
close(IN);
}
if($cmd eq "netstat") {
open(IN, "netstat -nl --tcp |");
while(<IN>) {
(undef, undef, undef, $pnum) = split(' ', $_);
chomp($pnum);
$pnum =~ s/.*://;
if($pnum eq $nginx->{port}) {
last;
}
}
close(IN);
}
close(IN);
}
if(grep {$_ eq $config->{os}} ("FreeBSD", "OpenBSD", "NetBSD")) {
open(IN, "netstat -anl -p tcp |");

View File

@ -538,16 +538,31 @@ sub port_cgi {
undef(@warning);
if(uc($plis || "") eq "L") {
if($config->{os} eq "Linux") {
open(IN, "netstat -nl --$pp |");
while(<IN>) {
(undef, undef, undef, $pnum) = split(' ', $_);
chomp($pnum);
$pnum =~ s/.*://;
if($pnum eq $num) {
last;
my $cmd = $port->{cmd} || "";
if(!$cmd || $cmd eq "ss") {
open(IN, "ss -nl --$pp |");
while(<IN>) {
(undef, undef, undef, $pnum) = split(' ', $_);
chomp($pnum);
$pnum =~ s/.*://;
if($pnum eq $num) {
last;
}
}
close(IN);
}
if($cmd eq "netstat") {
open(IN, "netstat -nl --$pp |");
while(<IN>) {
(undef, undef, undef, $pnum) = split(' ', $_);
chomp($pnum);
$pnum =~ s/.*://;
if($pnum eq $num) {
last;
}
}
close(IN);
}
close(IN);
}
if(grep {$_ eq $config->{os}} ("FreeBSD", "OpenBSD")) {
open(IN, "netstat -anl -p $pp |");

View File

@ -2132,6 +2132,18 @@ This is the size of the graphs of the ports. It currently accepts up to 8 differ
.P
Default value: \fImini\fP
.RE
.P
.BI cmd
.RS
This is the command that will be used to test if the network port is down (not listening). There are two possible values:
.P
.RS
\fIss\fP
.br
\fInetstat\fP
.RE
.P
Default value: \fIss\fP
.SS Users using the system (user.pm)
Only the limit and rigid values can be set here.
.SS FTP statistics (ftp.pm)
@ -2240,6 +2252,18 @@ This is the rule number that Monitorix will use when using the \fIipfw\fP comman
.P
Default value: \fI24100\fP
.RE
.P
.BI cmd
.RS
This is the command that will be used to test if the Nginx web server is down (not listening). There are two possible values:
.P
.RS
\fIss\fP
.br
\fInetstat\fP
.RE
.P
Default value: \fIss\fP
.SS Lighttpd statistics (lighttpd.pm)
This graph requires that \fImod_status\fP is loaded in order to collect status information from the Lighttpd web server.
.P