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,6 +578,20 @@ sub nginx_cgi {
undef(@warning); undef(@warning);
my $pnum; my $pnum;
if($config->{os} eq "Linux") { if($config->{os} eq "Linux") {
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 |"); open(IN, "netstat -nl --tcp |");
while(<IN>) { while(<IN>) {
(undef, undef, undef, $pnum) = split(' ', $_); (undef, undef, undef, $pnum) = split(' ', $_);
@ -589,6 +603,7 @@ sub nginx_cgi {
} }
close(IN); close(IN);
} }
}
if(grep {$_ eq $config->{os}} ("FreeBSD", "OpenBSD", "NetBSD")) { if(grep {$_ eq $config->{os}} ("FreeBSD", "OpenBSD", "NetBSD")) {
open(IN, "netstat -anl -p tcp |"); open(IN, "netstat -anl -p tcp |");
my $stat; my $stat;

View File

@ -538,6 +538,20 @@ sub port_cgi {
undef(@warning); undef(@warning);
if(uc($plis || "") eq "L") { if(uc($plis || "") eq "L") {
if($config->{os} eq "Linux") { if($config->{os} eq "Linux") {
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 |"); open(IN, "netstat -nl --$pp |");
while(<IN>) { while(<IN>) {
(undef, undef, undef, $pnum) = split(' ', $_); (undef, undef, undef, $pnum) = split(' ', $_);
@ -549,6 +563,7 @@ sub port_cgi {
} }
close(IN); close(IN);
} }
}
if(grep {$_ eq $config->{os}} ("FreeBSD", "OpenBSD")) { if(grep {$_ eq $config->{os}} ("FreeBSD", "OpenBSD")) {
open(IN, "netstat -anl -p $pp |"); open(IN, "netstat -anl -p $pp |");
while(<IN>) { while(<IN>) {

View File

@ -2132,6 +2132,18 @@ This is the size of the graphs of the ports. It currently accepts up to 8 differ
.P .P
Default value: \fImini\fP Default value: \fImini\fP
.RE .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) .SS Users using the system (user.pm)
Only the limit and rigid values can be set here. Only the limit and rigid values can be set here.
.SS FTP statistics (ftp.pm) .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 .P
Default value: \fI24100\fP Default value: \fI24100\fP
.RE .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) .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. This graph requires that \fImod_status\fP is loaded in order to collect status information from the Lighttpd web server.
.P .P