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

[pcp] collect 12 newest pmlogger files regardless of size #1496

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 21 additions & 7 deletions sos/plugins/pcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class Pcp(Plugin, RedHatPlugin, DebianPlugin):

# size-limit of PCP logger and manager data collected by default (MB)
option_list = [
("pcplogs", "size-limit in MB of pmlogger and pmmgr logs", "", 100),
("pmmgrlogs", "size-limit in MB of pmmgr logs", "", 100),
("pmloggerfiles", "number of newest pmlogger files to grab", "", 12),
]

pcp_sysconf_dir = None
Expand Down Expand Up @@ -71,8 +72,10 @@ def pcp_parse_conffile(self):
return True

def setup(self):
self.limit = (None if self.get_option("all_logs")
else self.get_option("pcplogs"))
self.sizelimit = (None if self.get_option("all_logs")
else self.get_option("pmmgrlogs"))
self.countlimit = (None if self.get_option("all_logs")
else self.get_option("pmloggerfiles"))

if not self.pcp_parse_conffile():
self._log_warn("could not parse %s" % self.pcp_conffile)
Expand Down Expand Up @@ -116,10 +119,21 @@ def setup(self):
# Make sure we only add the two dirs if hostname is set, otherwise
# we would collect everything
if self.pcp_hostname != '':
for pmdir in ('pmlogger', 'pmmgr'):
path = os.path.join(self.pcp_log_dir, pmdir,
self.pcp_hostname, '*')
self.add_copy_spec(path, sizelimit=self.limit)
# collect pmmgr logs up to 'pmmgrlogs' size limit
path = os.path.join(self.pcp_log_dir, 'pmmgr', self.pcp_hostname,
'*')
self.add_copy_spec(path, sizelimit=self.sizelimit, tailit=False)
# collect newest pmlogger logs up to 'pmloggerfiles' count
files_collected = 0
path = os.path.join(self.pcp_log_dir, 'pmlogger',
self.pcp_hostname, '*')
pmlogger_ls = self.get_cmd_output_now("ls -t1 %s" % path)
if pmlogger_ls:
for line in open(pmlogger_ls).read().splitlines():
self.add_copy_spec(line, sizelimit=None)
files_collected = files_collected + 1
if self.countlimit and files_collected == self.countlimit:
break

self.add_copy_spec([
# Collect PCP_LOG_DIR/pmcd and PCP_LOG_DIR/NOTICES
Expand Down