PMLOGGER_JANITOR(1)

πŸ’– PMLOGGER_JANITOR πŸ’–

okay bestie, welcome to the pmlogger_janitor page, part of the General Commands Manual section 1 🧹✨ β€” she's the lil cleanup crew for Performance Co-Pilot archive files and she does NOT get enough credit fr fr.


✨ SYNOPSIS ✨

$PCP_BINADM_DIR/pmlogger_janitor [-NV?]  [-c control] [-l logfile] [-X program] [-Y regex]

🧚 DESCRIPTION 🧚

so like, most of the time you're not calling pmlogger_janitor yourself, okay? πŸ’… usually it gets called from pmlogger_check(1) to go clean up all the residual processes and state files left behind by moribund instances of pmlogger(1). it's giving janitorial main character energy, and honestly? iconic. 🧽

if you do run pmlogger_janitor directly, bestie, it needs to be run as the user $PCP_USER β€” the one and only exception is when you're using the -N option. no cap. πŸ‘‘


πŸŽ€ OPTIONS πŸŽ€

  • -c control, --control=control β€” just like pmlogger_check (1) and pmlogger_daily(1), pmlogger_janitor is controlled by PCP logger control file(s) that spell out which pmlogger instances are being managed. the default control file is $PCP_PMLOGGERCONTROL_PATH, but you can point at an alternate one with -c. and get this 🌸 β€” if the directory $PCP_PMLOGGERCONTROL_PATH.d exists (or control.d if you used -c), then the contents of any additional control files in there get appended to the main control file (which has to exist, periodt).
  • -l file, --logfile=file β€” so that mail doesn't get sent by accident when this script runs from cron(8) or systemd(1), diagnostics always go to log files. by default that file is $PCP_LOG_DIR/pmlogger/pmlogger_janitor.log but you can switch it up with -l. 🫢 if that log file already exists when the script starts, it gets renamed with a .prev suffix first (which overwrites any log file saved earlier 😭) before diagnostics get written out.
  • -N, --showme β€” turns on a "show me" mode where the actions are echoed but not executed, in the style of make -n. using -N together with -V maximizes the diagnostic capabilities for debugging. lowkey the best combo for snooping. πŸ”
  • -V, --verbose β€” enables verbose tracing. by default pmlogger_janitor generates no output unless some error or warning condition pops up. a second -V increases the verbosity even more. and again β€” using -N in conjunction with -V maximizes the diagnostic capabilities for debugging. ✨
  • -X program, --compressor=program β€” specifies the program to use for compression. refer to pmlogger_daily(1) for details. πŸ—œοΈ
  • -Y regex, --regex=regex β€” lets you hand over a regular expression that causes files in the set of files matched for compression to be omitted. refer to pmlogger_daily(1) for details. 🎯
  • -?, --help β€” display usage message and exit. the classic. πŸ’–

🌈 OPERATION 🌈

pmlogger_janitor operates in a number of passes looking for things to cleanup. it's a whole multi-pass skincare routine, but for stale processes. πŸ§–

Pass 1 β€” scan the pmlogger port map files in the $PCP_TMP_DIR/pmlogger directory. use the process id (PID) from the name of the port map file and ps(1) to check, and if the process exists and it "looks like" an active pmlogger, append the PID and the directory where the archive is being written (extracted from the port map file) to a list of interest. otherwise the port map file is assumed to be associated with a pmlogger that has exited and the port map file is removed. bye boo πŸ‘‹

Pass 2 β€” use ps(1) to scan all processes and identify any pmlogger instances that were started by pmlogger_check(3) or pmlogger_daily(3). these will have a signature -m option in their arguments. append the PIDs and directories where the archive is being written (extracted from the command line arguments) to the list of interest. πŸ•΅οΈ

Pass 3 β€” parse all of the pmlogger.control(5) files from either the standard places, or control if the -c option is used. for each pmlogger instance, it should be in the list of interest, and if so remove it from that list.

if the list of interest is empty at the end of this Pass, we're done. slay, nothing to see here. πŸ’…

Pass 4 β€” each process remaining in the list of interest is a pmlogger that is running but should not be, probably as a result of a change to the pmlogger.control(5) files. send each process a SIGTERM. 🚨

Pass 5 β€” for each process remaining in the list of interest after Pass 3, compress any archives in the directory pmlogger was writing into. this is the only step where the -X and -Y options might be used. πŸ—œοΈβœ¨

Pass 6 β€” for each pmlogger sent a SIGTERM in Pass 4, check that it has exited and if not send it a SIGKILL. not me being the final boss πŸ˜­πŸ’€


πŸ“ FILES πŸ“

  • $PCP_LOG_DIR/pmlogger/pmlogger_janitor.log β€” if the previous execution of pmlogger_janitor produced any output it is saved here. the normal case is no output, in which case the file does not exist. 🫧
  • $PCP_ARCHIVE_DIR/SaveLogs β€” if this directory exists, then the log file from the -l argument for pmlogger_janitor will be saved in this directory with the name of the format <date>-pmlogger_janitor.log.<pid>. this allows the log file to be inspected at a later time, even if several pmlogger_janitor executions have been launched in the interim. $PCP_ARCHIVE_DIR/SaveLogs needs to be owned by the user $PCP_USER. πŸ‘‘
  • $PCP_TMP_DIR/pmlogger β€” pmlogger maintains the files in this directory as the port map between the PID of the pmlogger instance, the IPC port that may be used to control each pmlogger instance (as used by pmlc(1)), the name of the host where pmcd(1) is providing the metrics for pmlogger, the remote connection string for the remote HTTP server that is receiving the logged data or the full path to the archive base name for a local logger and any annotation from the -m or -x options. all of this information is also available via the pmcd.pmlogger.* metrics, e.g. $ pminfo -f pmcd.pmlogger πŸ¦‹

🌸 PCP ENVIRONMENT 🌸

environment variables with the prefix PCP_ are used to parameterize the file and directory names used by PCP. on each installation, the file /etc/pcp.conf contains the local values for these variables. the $PCP_CONF variable may be used to specify an alternative configuration file, as described in pcp.conf(5). 🌈


πŸ‘‘ SEE ALSO πŸ‘‘

PCPIntro(1), pmcd(1), pmlc(1), pmlogctl(1), pmlogger(1), pmlogger_check(1), pmlogger_daily(1), ps(1), systemd(1), pmlogger.control(5) and cron(8).


that's the whole page bestie, go forth and janitor responsibly πŸ§ΉπŸ’– this lil queen ships with Performance Co-Pilot (that's the PCP source, mwah 😘) β€” and remember, she's section PMLOGGER_JANITOR(1) of the General Commands Manual, so cite her correctly or it's not giving academic integrity πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from