%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PCP Cheat Sheet, 
% Christian Horn <chorn@fluxcoil.net>
%
% based on:
% HTML Cheat Sheet by Michelle Cristina de Sousa Baltazar
% from http://www.LaTeXTemplates.com
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------

\documentclass[landscape,a0paper,fontscale=0.285]{baposter} % Adjust the font scale/size here
\title{Performance Co-Pilot Cheat Sheet}
% \usepackage[english]{babel}
\usepackage[utf8]{inputenc}

\usepackage{graphicx} % Required for including images
\graphicspath{{figures/}} % Directory in which figures are stored

\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{tabu}

\usepackage[pdftex]{hyperref}
\usepackage{verbatim}

\usepackage{mathtools}
%\usepackage{amsmath} % For typesetting math
\usepackage{amssymb} % Adds new symbols to be used in math mode

\usepackage{booktabs} % Top and bottom rules for tables
\usepackage{enumitem} % Used to reduce itemize/enumerate spacing
\usepackage{palatino} % Use the Palatino font
\usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures

\usepackage{multicol} % Required for multiple columns
\setlength{\columnsep}{1.5em} % Slightly increase the space between columns
\setlength{\columnseprule}{0mm} % No horizontal rule between columns

\usepackage{tikz} % Required for flow chart
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{shapes,arrows} % Tikz libraries required for the flow chart in the template

\newcommand{\compresslist}{ % Define a command to reduce spacing within itemize/enumerate environments, this is used right after \begin{itemize} or \begin{enumerate}
\setlength{\itemsep}{1pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}
\definecolor{orange}{RGB}{255,127,0}% Defines the color used for content box headers
\definecolor{lightblue}{rgb}{0.145,0.6666,1} 

\begin{document}

\begin{poster}
{
headerborder=closed, % Adds a border around the header of content boxes
colspacing=0.8em, % Column spacing
bgColorOne=white, % Background color for the gradient on the left side of the poster
bgColorTwo=white, % Background color for the gradient on the right side of the poster
borderColor=orange, % Border color
headerColorOne=black, % Background color for the header in the content boxes (left side)
headerColorTwo=orange, % Background color for the header in the content boxes (right side)
headerFontColor=white, % Text color for the header text in the content boxes
boxColorOne=white, % Background color of the content boxes
textborder=roundedleft, % Format of the border around content boxes, can be: none, bars, coils, triangles, rectangle, rounded, roundedsmall, roundedright or faded
eyecatcher=true, % Set to false for ignoring the left logo in the title and move the title left
headerheight=0.1\textheight, % Height of the header
headershape=roundedright, % Specify the rounded corner in the content box headers, can be: rectangle, small-rounded, roundedright, roundedleft or rounded
headerfont=\Large\bf\textsc, % Large, bold and sans serif font in the headers of content boxes
%textfont={\setlength{\parindent}{1.5em}}, % Uncomment for paragraph indentation
linewidth=2pt % Width of the border lines around content boxes
}
%----------------------------------------------------------------
% Title
%----------------------------------------------------------------
{\bf\textsc{Performance Co-Pilot Cheat Sheet}\vspace{0.5em}} % Poster title
{\textsc{\{ Performance \ \ \ \ \ Co-Pilot \ \ \ \ \ C h e a t \ \ \ \ \ S h e e t\} \hspace{12pt}}}
{\textsc{Christian Horn \hspace{12pt}}} 

%------------------------------------------------
% Basics
%------------------------------------------------
\headerbox{PCP Basics}{name=basics,column=0,row=0}{

\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf Installation}}
Package \textbf{zero-conf} pulls in dependencies, starts daemons, starts
archiving of a default set of metrics.  On RPM based distros (RHEL, 
Fedora, CentOS etc.): \\
	% \textit{ \hspace*{0.5cm}\# dnf -y install pcp-zeroconf \\ } \\
	\hspace*{0.5cm}\# dnf -y install pcp-zeroconf \\
Installation via Ansible playbook: \\
	\hspace*{0.5cm}\# linux-system-roles.metrics \\ 
Verify pcp installation: \\
	\hspace*{0.5cm}\# pcp \\
	\hspace*{0.5cm}\# systemctl status pmcd pmlogger \\

\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf Important tools}}
Package 'pcp-system-tools' contains following tools, which work towards live
running pmcd, and towards archive files: 
\begin{itemize}\compresslist
	\item pcp atop
	\item pcp collectcl
	\item pcp free
	\item pcp iostat
	\item pcp dstat
\end{itemize}

\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf Important Pathes}}
	\hspace*{0.5cm}/var/lib/pcp/config/ \\
	\hspace*{0.5cm}/var/log/pcp/ \\
	\hspace*{0.5cm}/etc/pcp/ \\

\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf Working with metrics}}
Which metrics are offered by the running pmcd? \\
	\hspace*{0.5cm}\# pminfo \\ 

Which metrics related to cpu are available? \\ 
	\hspace*{0.5cm}\# pminfo | grep cpu \\ 

\vspace{0.0em} % When there are two boxes, some whitespace may need to be added if the one on the right has more content
}

%------------------------------------------------
% Links
%------------------------------------------------
\headerbox{links}{name=linkbox,column=0,below=basics}{
Most essential links:
\begin{itemize}\compresslist
	% https://access.redhat.com/articles/1145953      : Index of Performance Co-Pilot (PCP) articles, solutions, tutorials and white papers
	\item https://access.redhat.com/articles/1145953 
	\item https://github.com/linux-system-roles/metrics 
	\item https://github.com/performancecopilot/ansible-pcp 
	\item https://pcp.io
% https://www.redhat.com/en/blog/how-solve-performance-mysteries-performance-co-pilot-red-hat-enterprise-linux
% https://www.redhat.com/en/blog/examining-container-performance-rhel-8-pcp-and-pdma-podman
% https://www.redhat.com/en/blog/implementing-dstat-performance-co-pilot
\end{itemize}
}

%------------------------------------------------
% Archive files
%------------------------------------------------

\headerbox{Archive files}{name=archivefiles,column=1,row=0}{

\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf Basics}}
Which archive is pmlogger logging into? \\
	\hspace*{0.5cm}\# pcp \\

Set a variable to current archive, and evaluate how many metrics
are logged in the archive: \\
	\hspace*{0.5cm}\# cd /var/log/pcp/pmlogger/<hostname> \\ 
	\hspace*{0.5cm}\# pminfo -a <archivename> | wc -l \\ 

% TODO: more verbose syntax here
Have pmdiff point out 'significant peaks' in archives: \\
	\hspace*{0.5cm}\# pmdiff -a <archivename> \\ 

\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf Accessing metrics}}
Most basic access to metrics: \\
	\hspace*{0.5cm}\# pmstat -t 1 \\
	\hspace*{0.5cm}\# pmrep -a <archivename> <metric> \\
	\hspace*{0.5cm}\# pcp -a 20180831.11.31 --origin @1pm \ \\
	\hspace*{1.0cm}   dstat --time --disk --mem 60sec 10 \\
	\hspace*{0.5cm}\# pmrep -a 20220128 kernel.cpu -p -t 300 \ \\
	\hspace*{1.0cm}   --hostzone -S @19:30 \\
\\
Graphical access: \\
	\hspace*{0.5cm}\# pmchart \\
	\hspace*{0.5cm}\# dnf -y install pcp2pdf; pcp2pdf -a <arch>\\
}


%------------------------------------------------
% pmdas/pmie
%------------------------------------------------

\headerbox{pmda's}{name=pmdabox,column=1,below=archivefiles,bottomaligned=linkbox}{
\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf PMDA installation}} \\
Most PMDS's can be searched and installed following this pattern: \\ 
	\hspace*{0.5cm}\# dnf search pcp-pmda \\
	\hspace*{0.5cm}\# dnf install -y pcp-pmda-lmsensors \\
	\hspace*{0.5cm}\# cd /var/lib/pcp/pmdas/lmsensors \\
	\hspace*{0.5cm}\# ./Install \\

\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf PMIE}} \\
pmie, performance metrics interference engine, can react on defined
metric states: send email on high load, and so on. \\ 

\# pmie --verbose --timestamp --interval 1 \\
\# /etc/pcp/pmie/config.default \\
\# pmie --archive 20200512 --config <rules> \\

}


%------------------------------------------------
% diff
%------------------------------------------------

\headerbox{Analysis}{name=pmdiff,column=2,span=2,row=0}{
\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf Automated Analysis}} \\
Analyze which metrics are remarkably different in a certain timeframe: \\
	\hspace*{0.5cm}\# cat cull \\
	\hspace*{1.2cm}     rsyslog. \\
	\hspace*{0.5cm}\# pmdiff -z -X ./cull -q 10 --start @10:00 --finish @10:30 \\
	\hspace*{1.2cm}   --begin @12:00 --end @12:30 ./archives/20120512 | less \\
What are the top 5 cpu and memory hogs? \\
	\hspace*{0.5cm}\# pmrep proc.hog.cpu, proc.memory.rss -J 5 -1 -g -b MB \\
What are the current PIDs, and how much rss uses process with pid 75? \\
	\hspace*{0.5cm}\# pmrep proc.smaps.rss -g|less \\
	\hspace*{0.5cm}\# pmrep proc.smaps.rss -g -i '.*75.*'
}

%------------------------------------------------
% Remote collection
%------------------------------------------------

\headerbox{Remote collection}{name=remotecol,column=2,span=2,below=pmdiff}{

%---------------------------------------------
\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf Install PCP on clients}} \\
Setup client systems to offer metrics via pmcd: install pcp, open packet based firewall,
enable remote access in pmcd: \\
	\hspace*{0.5cm} yum -y install pcp \\
	\hspace*{0.5cm} firewall-cmd --permanent --zone=public --add-port=44321/tcp \\
	\hspace*{0.5cm} firewall-cmd --reload \\
	\hspace*{0.5cm} if grep -q PMCD\_LOCAL /etc/sysconfig/pmcd; then \\
	\hspace*{1.1cm} sed -ie 's,PMCD\_LOCAL.*,PMCD\_LOCAL=0,' /etc/sysconfig/pmcd \\
	\hspace*{0.5cm} else \\
	\hspace*{1.1cm} echo 'PMCD\_LOCAL=0' >>/etc/sysconfig/pmcd \\
	\hspace*{0.5cm} fi \\
	\hspace*{0.5cm} grep PMCD\_LOCAL /etc/sysconfig/pmcd \\
	\hspace*{0.5cm} service pmcd restart \\
	\hspace*{0.5cm} chkconfig pmcd on \\
\\

\colorbox[HTML]{FFE4B5}{\makebox[\textwidth-2\fboxsep][l]{\bf Install PCP on collector system}} \\
On the collector, we install pcp-zeroconf which also sets up logging to archive files.
We then set variable CLIENT to the clients name, create a config- and controlfile,
and notify pmlogger of the changes.
	\hspace*{0.5cm} yum -y install pcp-zeroconf \\
	\hspace*{0.5cm} CLIENT=rhel7u8a \\
	\hspace*{0.5cm} /usr/libexec/pcp/bin/pmlogconf \textbackslash \\
	\hspace*{1.5cm} /var/lib/pcp/config/pmlogger/config.\$CLIENT \\
	\hspace*{0.5cm} \# optionally, execute the last command a second time \\
	\hspace*{0.5cm} echo "\$CLIENT.local n n PCP\_LOG\_DIR/pmlogger/\$CLIENT.local" \textbackslash \\
	\hspace*{1.5cm} " -r -T30d -c config.\$CLIENT" \textbackslash \\
	\hspace*{1.5cm} >/etc/pcp/pmlogger/control.d/\$CLIENT \\
	\hspace*{0.5cm} /usr/libexec/pcp/bin/pmlogger\_check 

% \includegraphics[width=10em,height=4em]{pics/s05_pcp-daemons-grafanaserver.png}
\center{
	\includegraphics[width=20em]{pics/s05_browsers_pcp_servers_overview_components.jpg}
}

% pmlogconf - configures configfile, including the pmdas you run on the system

}
\end{poster}
\end{document}

