This is an automated email from the ASF dual-hosted git repository.
dgelinas pushed a commit to branch 3.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/3.0.x by this push:
new 8d57131 backport: Handle port different than 80 for Traffic Ops
Checks (#3390)
8d57131 is described below
commit 8d57131f7efe1752bb3ec7a1206083541c0892ad
Author: Steve Malenfant <[email protected]>
AuthorDate: Thu Mar 7 14:50:19 2019 -0500
backport: Handle port different than 80 for Traffic Ops Checks (#3390)
* Fixing TO Checks related to tcpPorts
- CDU, CHR and DSCP were not working on port different than 80
- Division by zero on server with no hit/miss/errors, check would abort
* Fixing indentation
* Broken logic to calculate cache hit
---
traffic_ops/app/bin/checks/ToCDUCheck.pl | 5 +++--
traffic_ops/app/bin/checks/ToCHRCheck.pl | 16 +++++++++++-----
traffic_ops/app/bin/checks/ToDSCPCheck.pl | 10 ++++++----
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/traffic_ops/app/bin/checks/ToCDUCheck.pl
b/traffic_ops/app/bin/checks/ToCDUCheck.pl
index a7c9351..433c1f5 100755
--- a/traffic_ops/app/bin/checks/ToCDUCheck.pl
+++ b/traffic_ops/app/bin/checks/ToCDUCheck.pl
@@ -80,7 +80,8 @@ foreach my $server ( @{$jdataserver} ) {
my $ip = $server->{ipAddress};
my $host_name = $server->{hostName};
my $interface = $server->{interfaceName};
- my $url = 'http://' . $ip .
'/_astats?application=bytes_used;bytes_total&inf.name=' . $interface;
+ my $port = $server->{tcpPort};
+ my $url = 'http://' . $ip . ':' . $port .
'/_astats?application=bytes_used;bytes_total&inf.name=' . $interface;
TRACE "getting $url";
my $response = $ua->get($url);
if ( $response->is_success ) {
@@ -100,7 +101,7 @@ foreach my $server ( @{$jdataserver} ) {
my $size =
$stats_var->{ats}{'proxy.process.cache.bytes_total'};
my $used =
$stats_var->{ats}{'proxy.process.cache.bytes_used'};
- if ( $size == 0 ) {
+ if ( $size == 0 ) {
ERROR "$host_name: cache size is 0!";
next;
}
diff --git a/traffic_ops/app/bin/checks/ToCHRCheck.pl
b/traffic_ops/app/bin/checks/ToCHRCheck.pl
index 3f1add7..e17017d 100755
--- a/traffic_ops/app/bin/checks/ToCHRCheck.pl
+++ b/traffic_ops/app/bin/checks/ToCHRCheck.pl
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# CHR check extension. Populates the 'CHR' (Cache Hit Ratio) column.
+# CHR check extension. Populates the 'CHR' (Cache Hit Ratio) column.
#
use strict;
@@ -98,7 +98,8 @@ foreach my $server ( @{$jdataserver} ) {
my $ip = $server->{ipAddress};
my $host_name = $server->{hostName};
my $interface = $server->{interfaceName};
- my $url = 'http://' . $ip .
'/_astats?application=proxy.process.http.transaction_counts&inf.name=' .
$interface;
+ my $port = $server->{tcpPort};
+ my $url = 'http://' . $ip . ':' . $port .
'/_astats?application=proxy.process.http.transaction_counts&inf.name=' .
$interface;
TRACE "getting $url";
my $response = $ua->get($url);
if ( $response->is_success ) {
@@ -149,9 +150,14 @@ foreach my $server ( @{$jdataserver} ) {
my $h = $hits - $prev_hits;
my $m = $miss - $prev_miss;
my $e = $errors - $prev_errors;
- my $hr = sprintf( "%3d", $h / ( $h + $m
+ $e ) * 100 );
- TRACE "$host_name: \% hitratio: $hr\%
errors: $e period: $secs\n";
- $ext->post_result( $server->{id},
$check_name, $hr );
+ my $t = ( $h + $m + $e );
+ if ( $t != 0 ) {
+ my $hr = sprintf( "%d", ($h /
$t) * 100 );
+ TRACE "$host_name: hitratio:
$hr\%, errors: $e, period: $secs\n";
+ $ext->post_result(
$server->{id}, $check_name, $hr );
+ } else {
+ TRACE "$host_name: No
transaction_counts! Service enabled?"
+ }
}
}
else {
diff --git a/traffic_ops/app/bin/checks/ToDSCPCheck.pl
b/traffic_ops/app/bin/checks/ToDSCPCheck.pl
index a9f6a25..787b995 100755
--- a/traffic_ops/app/bin/checks/ToDSCPCheck.pl
+++ b/traffic_ops/app/bin/checks/ToDSCPCheck.pl
@@ -136,6 +136,8 @@ foreach my $server ( @{$jdataserver} ) {
my $host_name = trim($server->{hostName});
my $fqdn = $host_name.".".trim($server->{domainName});
my $interface = trim($server->{interfaceName});
+ my $http_port = $server->{tcpPort};
+ my $https_port = $server->{httpsPort};
my $status = $server->{status};
my $details = $ext->get( '/api/1.1/servers/hostname/' . $host_name .
'/details.json' );
my $successful = 1; # assume all is good
@@ -189,7 +191,7 @@ foreach my $server ( @{$jdataserver} ) {
## check ipv4
# TODO "http://" should be a var so that we can also check https
- my $url = "http://".$ip.$ds->{checkPath};
+ my $url = "http://".$ip.":".$tcpPort.$ds->{checkPath};
TRACE "About to check header: ".$header." url: ".$url;
@@ -234,7 +236,7 @@ foreach my $server ( @{$jdataserver} ) {
## check ipv6
# TODO "http://" should be a var so that we can also check https
# TODO "80" should be var when we add https
- $url = "http://".$ip6.":80".$ds->{checkPath};
+ $url = "http://".$ip.":".$tcpPort.$ds->{checkPath};
TRACE "About to check header: ".$header." url: ".$url;
@@ -324,7 +326,7 @@ sub get_dscp() {
if ( $ip_obj->{src_ip} eq $ip && $ip_obj->{len} > $max_len &&
$ip_obj->{proto} == 6 ) {
my $tcp_obj = NetPacket::TCP->decode( $ip_obj->{data} );
TRACE " TCP2 $ip_obj->{src_ip}:$tcp_obj->{src_port} ->
$ip_obj->{dest_ip}:$tcp_obj->{dest_port} $ip_obj->{proto} tos $ip_obj->{tos}
len $ip_obj->{len}\n";
- if ( ($tcp_obj->{src_port} == 80) && ($tcp_obj->{dest_port} ==
$src_port) ) {
+ if ( ($tcp_obj->{src_port} == $http_port) &&
($tcp_obj->{dest_port} == $src_port) ) {
TRACE " TCP3 $ip_obj->{src_ip}:$tcp_obj->{src_port} ->
$ip_obj->{dest_ip}:$tcp_obj->{dest_port} $ip_obj->{proto} tos $ip_obj->{tos}
len $ip_obj->{len}\n";
$max_len = $ip_obj->{len};
$tos = $ip_obj->{tos};
@@ -338,7 +340,7 @@ sub get_dscp() {
if ( $ip_obj->{src_ip} eq $ip && $ip_obj->{plen} > $max_len &&
$ip_obj->{nxt} == 6 ) {
my $tcp_obj = NetPacket::TCP->decode( $ip_obj->{data} );
TRACE " TCP2 $ip_obj->{src_ip}:$tcp_obj->{src_port} ->
$ip_obj->{dest_ip}:$tcp_obj->{dest_port} $ip_obj->{nxt} tos $ip_obj->{class}
len $ip_obj->{plen}\n";
- if ( $tcp_obj->{src_port} == 80 && $tcp_obj->{dest_port} ==
$src_port ) {
+ if ( $tcp_obj->{src_port} == $http_port &&
$tcp_obj->{dest_port} == $src_port ) {
TRACE " TCP3 $ip_obj->{src_ip}:$tcp_obj->{src_port} ->
$ip_obj->{dest_ip}:$tcp_obj->{dest_port} $ip_obj->{nxt} tos $ip_obj->{class}
len $ip_obj->{plen}\n";
$max_len = $ip_obj->{plen};
$tos = $ip_obj->{class};