Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcdonell committed Nov 29, 2023
2 parents 8eb9e33 + 1983b13 commit 1c3c6ea
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
if: github.repository == 'performancecopilot/pcp'
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
Expand Down Expand Up @@ -43,6 +44,7 @@ jobs:
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: ./build/containers/pcp/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
4 changes: 2 additions & 2 deletions build/containers/pcp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Build
FROM registry.fedoraproject.org/fedora:36 AS build
FROM registry.fedoraproject.org/fedora:38 AS build
COPY . /usr/src/pcp

WORKDIR /usr/src/pcp
Expand All @@ -25,7 +25,7 @@ RUN mkdir /build && \
/build

## Deploy
FROM registry.fedoraproject.org/fedora:36
FROM registry.fedoraproject.org/fedora:38
COPY --from=build /build /build

ENV SUMMARY="Performance Co-Pilot" \
Expand Down
82 changes: 82 additions & 0 deletions qa/1921
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions qa/1921.out
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions qa/group
Original file line number Diff line number Diff line change
Expand Up @@ -2091,6 +2091,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
Expand Down
3 changes: 3 additions & 0 deletions src/pcp/atop/showlinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -2564,6 +2564,7 @@ compusr(const void *a, const void *b)
register int uida;
register int uidb;

if (ta == tb) return 0;
if (ta == NULL) return 1;
if (tb == NULL) return -1;

Expand All @@ -2588,6 +2589,7 @@ compnam(const void *a, const void *b)
register char *nama;
register char *namb;

if (ta == tb) return 0;
if (ta == NULL) return 1;
if (tb == NULL) return -1;

Expand All @@ -2606,6 +2608,7 @@ compcon(const void *a, const void *b)
register char *containera;
register char *containerb;

if (ta == tb) return 0;
if (ta == NULL) return 1;
if (tb == NULL) return -1;

Expand Down
4 changes: 2 additions & 2 deletions src/pcp/ss/pcp-ss.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 6 additions & 9 deletions src/pcp/ss/pcp-ss.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
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"

Expand Down Expand Up @@ -57,8 +54,8 @@ def options(self):
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')
Expand Down Expand Up @@ -92,9 +89,6 @@ def options(self):
# 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")

Expand Down Expand Up @@ -283,13 +277,16 @@ def filter_ipv46(self, inst):
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):
Expand Down
2 changes: 1 addition & 1 deletion src/pmlogsize/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static metric_t *metric_tab; /* metric entries */
static int
metric_compar(const void *a, const void *b)
{
return ((metric_t *)a)->bytes < ((metric_t *)b)->bytes;
return ((metric_t *)b)->bytes - ((metric_t *)a)->bytes;
}

static int
Expand Down
2 changes: 1 addition & 1 deletion src/pmlogsize/meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ typedef struct {
static int
indom_compar(const void *a, const void *b)
{
return ((indom_t *)a)->bytes < ((indom_t *)b)->bytes;
return ((indom_t *)b)->bytes - ((indom_t *)a)->bytes;
}

void
Expand Down

0 comments on commit 1c3c6ea

Please sign in to comment.