Back-port fix from upstream PCP for pcp-ss listen state handling

Resolves: RHEL-17335
This commit is contained in:
Nathan Scott 2023-11-29 14:26:12 +11:00
parent 77865a4afb
commit a6150af35b
2 changed files with 197 additions and 2 deletions

View File

@ -1,11 +1,14 @@
Name: pcp
Version: 6.1.1
Release: 1%{?dist}
Release: 2%{?dist}
Summary: System-level performance monitoring and performance management
License: GPL-2.0-or-later AND LGPL-2.1-or-later AND CC-BY-3.0
URL: https://pcp.io
Source0: https://github.com/performancecopilot/pcp/releases/pcp-%{version}.src.tar.gz
Patch1: redhat-issues-RHEL-17335-ss-listen.patch
%if 0%{?fedora} >= 40 || 0%{?rhel} >= 10
ExcludeArch: %{ix86}
%endif
@ -301,7 +304,9 @@ BuildRequires: qt5-qtsvg-devel
%endif
%endif
Requires: bash xz gawk sed grep findutils which %{_hostname_executable}
# Utilities used indirectly e.g. by scripts we install
Requires: bash xz gawk sed grep coreutils diffutils findutils
Requires: which %{_hostname_executable}
Requires: pcp-libs = %{version}-%{release}
%if !%{disable_selinux}
@ -3446,6 +3451,10 @@ fi
%files zeroconf -f pcp-zeroconf-files.rpm
%changelog
* Wed Nov 29 2023 Nathan Scott <nathans@redhat.com> - 6.1.1-2
- Fix pcp-ss(1) default handling of listen state (RHEL-17335)
- Added pcp package dependency on diffutils for diffstat(1)
* Mon Nov 20 2023 Nathan Scott <nathans@redhat.com> - 6.1.1-1
- Improve pmlogcheck performance with compressed archives (RHEL-3930)
- Fix pcp-ss(1) utility handling of duplicate sources (RHEL-7498)

View File

@ -0,0 +1,186 @@
diff -Naurp pcp-6.1.1.orig/qa/1921 pcp-6.1.1/qa/1921
--- pcp-6.1.1.orig/qa/1921 1970-01-01 10:00:00.000000000 +1000
+++ pcp-6.1.1/qa/1921 2023-11-29 14:21:22.969455810 +1100
@@ -0,0 +1,82 @@
+#!/bin/sh
+# PCP QA Test No. 1921
+# Exercise default option handling for pcp-ss(1).
+#
+# Copyright (c) 2023 Red Hat. All Rights Reserved.
+#
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+# get standard environment, filters and checks
+. ./common.product
+. ./common.filter
+. ./common.check
+
+[ $PCP_PLATFORM = linux ] || _notrun "Linux-specific sockets testing"
+[ -f $PCP_BINADM_DIR/pcp-ss ] || _notrun "pcp-ss utility is not installed"
+[ -f $PCP_PMDAS_DIR/sockets/pmdasockets ] || _notrun "sockets PMDA not installed"
+
+_cleanup()
+{
+ cd $here
+ $sudo rm -rf $tmp $tmp.*
+}
+
+status=0 # success is the default!
+$sudo rm -rf $tmp $tmp.* $seq.full
+
+pmdasockets_install()
+{
+ # start from known starting points
+ cd $PCP_PMDAS_DIR/sockets
+ $sudo ./Remove >/dev/null 2>&1
+
+ echo
+ echo "=== sockets agent installation ==="
+ $sudo ./Install </dev/null >$tmp.out 2>&1
+ cat $tmp.out >>$here/$seq.full
+ # Check sockets metrics have appeared ... X metrics and Y values
+ _filter_pmda_install <$tmp.out \
+ | sed \
+ -e 's/[0-9][0-9]* warnings, //' \
+ | $PCP_AWK_PROG '
+/Check network.persocket metrics have appeared/ {
+ if ($7 >= 50 && $7 <= 99) $7 = "X"
+ if ($10 >= 0) $10 = "Y"
+ }
+ { print }'
+}
+
+pmdasockets_remove()
+{
+ echo
+ echo "=== remove sockets agent ==="
+ $sudo ./Remove >$tmp.out 2>&1
+ _filter_pmda_remove <$tmp.out
+}
+
+# real QA test starts here
+_prepare_pmda sockets
+trap "_cleanup_pmda sockets; exit \$status" 0 1 2 3 15
+_stop_auto_restart pmcd
+
+pmdasockets_install
+echo
+
+pcp ss > $tmp.out 2>&1
+if grep -q LISTEN $tmp.out # do not show LISTEN state by default
+then
+ echo Failed LISTEN check
+ cat $tmp.out
+ status=1
+ exit
+else
+ echo Passed LISTEN check
+ cat $tmp.out >> $here/$seq.full
+fi
+
+pmdasockets_remove
+
+# success, all done
+exit
diff -Naurp pcp-6.1.1.orig/qa/1921.out pcp-6.1.1/qa/1921.out
--- pcp-6.1.1.orig/qa/1921.out 1970-01-01 10:00:00.000000000 +1000
+++ pcp-6.1.1/qa/1921.out 2023-11-29 14:21:22.969455810 +1100
@@ -0,0 +1,17 @@
+QA output created by 1921
+
+=== sockets agent installation ===
+Updating the Performance Metrics Name Space (PMNS) ...
+Terminate PMDA if already installed ...
+[...install files, make output...]
+Updating the PMCD control file, and notifying PMCD ...
+Check network.persocket metrics have appeared ... X metrics and Y values
+
+Passed LISTEN check
+
+=== remove sockets agent ===
+Culling the Performance Metrics Name Space ...
+network.persocket ... done
+Updating the PMCD control file, and notifying PMCD ...
+[...removing files...]
+Check network.persocket metrics have gone away ... OK
diff -Naurp pcp-6.1.1.orig/qa/group pcp-6.1.1/qa/group
--- pcp-6.1.1.orig/qa/group 2023-11-29 14:21:04.266425958 +1100
+++ pcp-6.1.1/qa/group 2023-11-29 14:21:22.978455824 +1100
@@ -2090,6 +2090,7 @@ x11
1912 pmie local
1913 pmie local valgrind
1914 atop local
+1921 pmda.sockets local
1927 pmda.sockets local
1931 pmda.bpf local
1936 other local pmclient
diff -Naurp pcp-6.1.1.orig/src/pcp/ss/pcp-ss.1 pcp-6.1.1/src/pcp/ss/pcp-ss.1
--- pcp-6.1.1.orig/src/pcp/ss/pcp-ss.1 2023-11-29 14:21:04.266425958 +1100
+++ pcp-6.1.1/src/pcp/ss/pcp-ss.1 2023-11-29 14:21:22.978455824 +1100
@@ -168,10 +168,10 @@ show help message and exit
output version information
.TP 5
\fB\-n\fP, \fB\-\-numeric\fP
-don't resolve service names
+don't resolve service names (currently always set)
.TP 5
\fB\-r\fP, \fB\-\-resolve\fP
-resolve host names
+resolve host names (not yet implemented)
.TP 5
\fB\-a\fP, \fB\-\-all\fP
display all sockets
diff -Naurp pcp-6.1.1.orig/src/pcp/ss/pcp-ss.py pcp-6.1.1/src/pcp/ss/pcp-ss.py
--- pcp-6.1.1.orig/src/pcp/ss/pcp-ss.py 2023-11-29 14:21:04.267425959 +1100
+++ pcp-6.1.1/src/pcp/ss/pcp-ss.py 2023-11-29 14:21:22.979455826 +1100
@@ -25,9 +25,6 @@ from pcp import pmapi
from cpmapi import PM_CONTEXT_ARCHIVE, PM_CONTEXT_HOST
from cpmapi import PM_ERR_EOL, PM_MODE_INTERP
-if sys.version >= '3':
- long = int
-
# pmns prefix for pmdasockets(1) metrics
pmns = "network.persocket"
@@ -57,8 +54,8 @@ class SS(object):
p.add_argument('-V', '--version', action='store_true', help='output version information')
p.add_argument('-n', '--numeric', action='store_true', help='don\'t resolve service names or port names (currently always set)')
p.add_argument('-r', '--resolve', action='store_true', help='resolve host names (currently never set)')
- p.add_argument('-a', '--all', action='store_true', help='display sockets in any state, not just listening')
- p.add_argument('-l', '--listening', action='store_true', help='display only listening sockets')
+ p.add_argument('-a', '--all', action='store_true', help='display both listening and non-listening states')
+ p.add_argument('-l', '--listening', action='store_true', default=False, help='display only listening sockets')
p.add_argument('-o', '--options', action='store_true', help='show timer information')
p.add_argument('-e', '--extended', action='store_true', help='show detailed socket information')
p.add_argument('-m', '--memory', action='store_true', help='show socket memory usage')
@@ -92,9 +89,6 @@ class SS(object):
# default to both ipv4 and ipv6, subject to the prevailing filter
args.ipv4 = args.ipv6 = True
- if args.all:
- args.listening = True
-
if args.events or args.context or args.contexts or args.net or args.summary or args.processes:
print("Warning: --events, --context --net, --summary and --processes options are not implemented")
@@ -283,13 +277,16 @@ class SS(object):
return ret
def filter_listening(self, inst):
- """ filter on tcp state, return True if socket is listening """
+ """ filter on tcp socket listening state """
if self.args.all:
return True
state = self.valuesD["state"][inst]
if self.args.listening:
if state != "LISTEN":
return False
+ else:
+ if state == "LISTEN":
+ return False
return True
def report(self):