pcp/redhat-issues-RHEL-17335-ss-listen.patch
2023-11-29 14:26:12 +11:00

187 lines
6.4 KiB
Diff

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):