Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Remove instperf" #5356

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions anaconda.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ rm -rf \
%license COPYING
%{_unitdir}/*
%{_prefix}/lib/systemd/system-generators/*
%{_bindir}/instperf
%{_bindir}/anaconda-disable-nm-ibft-plugin
%{_bindir}/anaconda-nm-disable-autocons
%{_sbindir}/anaconda
Expand Down
1 change: 1 addition & 0 deletions data/systemd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dist_systemd_DATA = anaconda.service \
anaconda.target \
[email protected] \
[email protected] \
instperf.service \
anaconda-sshd.service \
anaconda-nm-config.service \
anaconda-nm-disable-autocons.service \
Expand Down
4 changes: 2 additions & 2 deletions data/systemd/anaconda-direct.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
Description=the anaconda installation program
Wants=rsyslog.service systemd-udev-settle.service NetworkManager.service
After=rsyslog.service systemd-udev-settle.service NetworkManager.service anaconda-sshd.service
Wants=instperf.service rsyslog.service systemd-udev-settle.service NetworkManager.service
After=instperf.service rsyslog.service systemd-udev-settle.service NetworkManager.service anaconda-sshd.service
Requires=anaconda.service
ConditionPathIsDirectory=|/sys/hypervisor/s390
ConditionKernelCommandLine=|inst.notmux
Expand Down
1 change: 1 addition & 0 deletions data/systemd/anaconda-pre.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Description=pre-anaconda logging service
Requires=basic.target
After=basic.target
Before=anaconda.target
Wants=instperf.service
Wants=rsyslog.service
Wants=systemd-udev-settle.service
Wants=NetworkManager.service
Expand Down
1 change: 1 addition & 0 deletions data/systemd/anaconda.target
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Description=Anaconda System Services
Requires=basic.target
After=basic.target
AllowIsolate=yes
Wants=instperf.service
Wants=rsyslog.service
Wants=systemd-udev-settle.service
Wants=NetworkManager.service
Expand Down
8 changes: 8 additions & 0 deletions data/systemd/instperf.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
ConditionKernelCommandLine=debug
Description=anaconda performance monitor
Before=anaconda.service

[Service]
WorkingDirectory=/
ExecStart=/usr/bin/instperf
3 changes: 2 additions & 1 deletion scripts/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ dist_scripts_SCRIPTS = run-anaconda anaconda-pre-log-gen log-capture start-modul

dist_noinst_SCRIPTS = makeupdates makebumpver

dist_bin_SCRIPTS = anaconda-cleanup anaconda-disable-nm-ibft-plugin \
dist_bin_SCRIPTS = anaconda-cleanup instperf anaconda-disable-nm-ibft-plugin \
anaconda-nm-disable-autocons

miscdir = $(datadir)/$(PACKAGE_NAME)
dist_misc_DATA = instperf.p

MAINTAINERCLEANFILES = Makefile.in
55 changes: 55 additions & 0 deletions scripts/instperf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/python3

import logging
from subprocess import Popen, PIPE
import time

# grab the top five memory consuming processes, returning them in a string of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please extend the comment with information that we have about this script and its use cases?

# of the format:
#
# name1:kB1,name2:kB2,...,name5:kB5
def topProcesses():
output = Popen(["ps", "-eo", "comm,rss", "--sort", "-rss", "--no-headers"], stdout=PIPE, universal_newlines=True).communicate()[0]
top5 = output.split("\n")[:5]
return ",".join("%s:%s" % (proc[0], proc[1]) for proc in (s.split() for s in top5))

def logit():
buffers = 0
cached = 0
memTotal = 0
memFree = 0
swapTotal = 0
swapFree = 0

with open("/proc/meminfo") as f:
for line in f.readlines():
if line.startswith("Buffers:"):
buffers = line.split()[1]
elif line.startswith("Cached:"):
cached = line.split()[1]
elif line.startswith("MemTotal:"):
memTotal = line.split()[1]
elif line.startswith("MemFree:"):
memFree = line.split()[1]
elif line.startswith("SwapTotal:"):
swapTotal = line.split()[1]
elif line.startswith("SwapFree:"):
swapFree = line.split()[1]

d = {"memUsed": int(memTotal)-int(memFree)-int(cached)-int(buffers),
"swapUsed": int(swapTotal)-int(swapFree),
"procs": topProcesses()}

mem_logger.debug("%(memUsed)d %(swapUsed)d %(procs)s", d)

mem_logger = logging.getLogger("memLog")
mem_logger.setLevel(logging.DEBUG)

handler = logging.FileHandler("/tmp/memory.dat")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you write a simple kickstart test for this script, please? I think it might be enough to start an installation with the debug kernel option, check if the instperf service is running and make sure that /tmp/memory.dat is not empty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use mkstmp because using /tmp ended up causing problems #5375

handler.setLevel(logging.DEBUG)
handler.setFormatter(logging.Formatter("%(asctime)s %(message)s", "%H:%M:%S"))
mem_logger.addHandler(handler)

while True:
logit()
time.sleep(1)
15 changes: 15 additions & 0 deletions scripts/instperf.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This script processes a memory.dat file as generated by instperf during
# installation and writes out a graph to memusage.png.
set terminal png size 1024,768
set output "memusage.png"
set title "anaconda Memory Usage"
set xlabel "Time"
set xtics rotate
set xdata time
set timefmt "%H:%M:%S"
set ylabel "Memory Used (in KB)\n(Total-Free-Buffers-Cached)"
set format y "%.0f"
set grid

plot "memory.dat" using 1:2 title "Memory" with lines, \
"memory.dat" using 1:3 title "Swap" with lines
Loading