Skip to content

Commit 2e84909

Browse files
authored
Merge pull request #72 from redhat-performance/pcp_initial_support
Initial support of PCP metrics gathering capability
2 parents 92251f0 + 00d12fe commit 2e84909

10 files changed

+588
-0
lines changed

general_setup

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ gs_usage_info()
6868
echo " --tuned_setting: used in naming the tar file, default for RHEL is the current active tuned. For non"
6969
echo " RHEL systems, default is none."
7070
echo " --usage: this usage message."
71+
echo " --use_pcp: Enables use of Performance Co-Pilot in wrappers, defaults to 0."
7172
exit 1
7273
}
7374

@@ -92,6 +93,7 @@ to_pstats="default"
9293
to_no_pkg_install=0
9394

9495
to_tuned_setting=""
96+
to_use_pcp=0
9597

9698
i=1
9799
j=$#
@@ -195,6 +197,10 @@ do
195197
--usage)
196198
gs_usage_info
197199
;;
200+
--use_pcp)
201+
i=$((i + 1))
202+
to_use_pcp=1
203+
shift 1
198204
--)
199205
break;
200206
;;

pcp/LICENSE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Copyright (C) 2025 Matt Lucius <[email protected]> & John Harrigan <[email protected]>
3+
#
4+
# This program is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU General Public License
6+
# as published by the Free Software Foundation; either version 2
7+
# of the License, or (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program; if not, write to the Free Software
16+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
#

pcp/PCPrecord.service

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=PCP Recorder
3+
4+
[Service]
5+
Type=notify
6+
WorkingDirectory=/usr/local/src/PCPrecord
7+
ExecStart=/usr/local/src/PCPrecord/PCPrecord_actions.sh
8+
9+
[Install]
10+
WantedBy=multi-user.target

pcp/PCPrecord_actions.sh

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (C) 2025 John Harrigan <[email protected]> & Matt Lucius <[email protected]>
4+
#
5+
# This program is free software; you can redistribute it and/or
6+
# modify it under the terms of the GNU General Public License
7+
# as published by the Free Software Foundation; either version 2
8+
# of the License, or (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program; if not, write to the Free Software
17+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18+
#
19+
# Executed by systemd service 'PCPrecord.service'
20+
# See: /etc/systemd/system/PCPrecord.service
21+
################################################################
22+
23+
# GLOBALS ###################
24+
# Include the PCP Functions file
25+
source $PWD/pcp_functions.inc
26+
27+
FIFO="/tmp/pcpFIFO" # get from cmdline
28+
sample_rate=5 # hardcode DEFAULT for now
29+
pmlogger_running="false" # Initialize service as OFF
30+
om_workload_file="/tmp/openmetrics_workload.txt"
31+
om_workload_file_reset="/tmp/openmetrics_workload_reset.txt"
32+
33+
#############################
34+
# Functions #################
35+
36+
reset_om_metrics()
37+
{
38+
echo "Reset OpenMetrics values"
39+
cp ${om_workload_file_reset} ${om_workload_file}
40+
}
41+
42+
error_exit()
43+
{
44+
if [[ "$?" != "0" ]]; then
45+
systemd-notify --status="ERROR: $1"
46+
# Additional error handling logic can be added here
47+
rm -f "$FIFO"
48+
# Reset openmetric.workload metric values prior to leaving
49+
reset_om_metrics
50+
## if pmlogger_running = True then attempt forcible STOP?
51+
exit 1
52+
fi
53+
}
54+
# END Functions #################
55+
56+
# Main #################
57+
# Initialize openmetric.workload metric values
58+
reset_om_metrics
59+
60+
# Verify required files and Packages are available
61+
#----------------------------------
62+
test -f "${om_workload_file}"
63+
error_exit "Initialization: ${om_workload_file} not found!"
64+
65+
# Remove and recreate FIFO on every service 'start'
66+
rm -f "$FIFO"
67+
mkfifo "$FIFO"
68+
error_exit "Initialization: mkfifo $FIFO failed"
69+
70+
## DEBUG - measure processing interval: $postaction-$preaction
71+
action='NONE'
72+
interval=0.0
73+
74+
# Infinite Loop #################
75+
# Read FIFO and perform requested ACTION (start, stop, ...)
76+
# Access each word in $action string for parsing 'actions' & 'metric'
77+
# NOTE: 'Start, Stop, Reset' actions have no metrics
78+
while : ; do
79+
# Required or we get TIMEOUT on 'read action < "$FIFO" '
80+
# Signal readiness for next $action. SYNC point w/client Workload
81+
# Report timing interval for most recent ACTION
82+
systemd-notify --ready --status="READY: last-action - $action = ${interval}ms"
83+
# Read the Request/'$action' and then process it
84+
read action < "$FIFO" # Blocks until data is available
85+
# Signal busy Processing this $action
86+
systemd-notify --status="$action PMLOGGER Request"
87+
action_arr=($action) # Array of 'words' in Request read from FIFO
88+
## DEBUG - measure processing interval for ACTION: $postaction-$preaction
89+
preaction=$(mark_ms)
90+
case "${action_arr[0]}" in
91+
Start) # 'Start $archive_dir $test_name $conf_file'
92+
archive_dir="${action_arr[1]}"
93+
archive_name="${action_arr[2]}"
94+
conf_file="${action_arr[3]}"
95+
# Start PMLOGGER to create ARCHIVE
96+
if [[ "$pmlogger_running" = "false" ]]; then
97+
# Signal Processing this $action
98+
systemd-notify --status="DEBUG: $action PMLOGGER Request"
99+
# These functions attempt to catch errors and verify success
100+
pcp_verify $conf_file
101+
error_exit "pcp_verify: Unable to start PMLOGGER"
102+
pcp_start $conf_file $sample_rate $archive_dir $archive_name
103+
error_exit "pcp_start: Unable to start PMLOGGER"
104+
pmlogger_running="true" # Record this STATE info
105+
fi
106+
;;
107+
Stop) # artifacts_dir="${action_arr[1]}"
108+
# Terminate PMLOGGER
109+
if [[ "$pmlogger_running" = "true" ]]; then
110+
# Will ZATHRAS Store PCP Archive related artifacts ?
111+
# - Currently Missing from PCPSTOP logic
112+
##pcp_stop "${artifacts_dir}"
113+
pcp_stop
114+
error_exit "pcp_stop: Unable to stop PMLOGGER"
115+
pmlogger_running="false"
116+
fi
117+
;;
118+
Reset) # om_workload_file="${action_arr[1]}"
119+
# RESET the Workload Metrics
120+
# the only Request that doesn't require $pmlogger_running
121+
reset_om_metrics
122+
error_exit "reset_om_metrics: Unable to RESET Workload Metrics"
123+
;;
124+
throughput|latency|numthreads|runtime) # Workload Metrics
125+
# metric="${action_arr[1]}" om_workload_file=$2
126+
if [[ "$pmlogger_running" = "true" ]]; then
127+
# Forward workload metric to openmetrics_workload.txt
128+
# Change only one metric line at a time
129+
# Replaces the entire line using sed
130+
# Should I only print 'action_arr[0] & action_arr[1]'
131+
sed -i "s/^.*${action_arr[0]}.*$/${action}/" "$om_workload_file"
132+
fi
133+
;;
134+
running|iteration) # Workload States
135+
# state="${action_arr[1]}" om_workload_file=$2
136+
if [[ "$pmlogger_running" = "true" ]]; then
137+
sed -i "s/^.*${action_arr[0]}.*$/${action}/" "$om_workload_file"
138+
fi
139+
;;
140+
*)
141+
systemd-notify --status="Unrecognized action - IGNORED"
142+
;;
143+
esac
144+
## DEBUG - measure time interval for processing ACTION
145+
postaction=$(mark_ms)
146+
interval=$(( 10*(postaction - preaction) ))
147+
done
148+
149+
# Cleanup
150+
echo "Cleaning up"
151+
152+
# Reset openmetric.workload metric values prior to leaving
153+
reset_om_metrics
154+
155+
exit 0

pcp/default.cfg

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#pmlogconf 2.0
2+
#
3+
## Workload Metrics - hardcoded sampling rate
4+
log advisory on 1 second {
5+
openmetrics.workload
6+
openmetrics.control.fetch_time
7+
}
8+
9+
## Intel RAPL & RFchassis metrics
10+
log advisory on default {
11+
# denki.rapl
12+
openmetrics.RFchassis
13+
}
14+
15+
## platform, filesystem and hardware configuration
16+
log advisory on once {
17+
hinv
18+
kernel.uname
19+
filesys.mountdir
20+
filesys.uuid
21+
filesys.type
22+
filesys.blocksize
23+
filesys.capacity
24+
}
25+
26+
#+ tools/htop:y:default:
27+
## metrics used by the htop command
28+
log advisory on default {
29+
# disk.all.read_bytes
30+
# disk.all.write_bytes
31+
# disk.all.avactive
32+
# hinv.cpu.clock
33+
kernel.all.load
34+
kernel.all.uptime
35+
kernel.all.cpu.user
36+
kernel.all.cpu.nice
37+
kernel.all.cpu.sys
38+
kernel.all.cpu.idle
39+
kernel.all.cpu.wait.total
40+
kernel.all.cpu.intr
41+
kernel.all.cpu.irq.soft
42+
kernel.all.cpu.steal
43+
kernel.all.cpu.guest
44+
kernel.all.cpu.guest_nice
45+
# kernel.all.pressure.cpu.some.avg
46+
# kernel.all.pressure.io.some.avg
47+
# kernel.all.pressure.io.full.avg
48+
# kernel.all.pressure.memory.some.avg
49+
# kernel.all.pressure.memory.full.avg
50+
# kernel.percpu.cpu.user
51+
# kernel.percpu.cpu.nice
52+
# kernel.percpu.cpu.sys
53+
# kernel.percpu.cpu.idle
54+
# kernel.percpu.cpu.wait.total
55+
# kernel.percpu.cpu.intr
56+
# kernel.percpu.cpu.irq.soft
57+
# kernel.percpu.cpu.steal
58+
# kernel.percpu.cpu.guest
59+
# kernel.percpu.cpu.guest_nice
60+
mem.util.available
61+
mem.util.free
62+
mem.util.bufmem
63+
mem.util.cached
64+
mem.util.shmem
65+
mem.util.slabReclaimable
66+
mem.util.swapCached
67+
mem.util.swapTotal
68+
mem.util.swapFree
69+
network.all.in.bytes
70+
network.all.out.bytes
71+
network.all.in.packets
72+
network.all.out.packets
73+
# zram.capacity
74+
# zram.mm_stat.data_size.original
75+
# zram.mm_stat.data_size.compressed
76+
}

pcp/openmetrics_default_reset.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
iteration 0
2+
running 0
3+
numthreads 0
4+
runtime NaN
5+
throughput NaN
6+
latency NaN

0 commit comments

Comments
 (0)