performancecopilot / pcp

Performance Co-Pilot
https://pcp.io
Other
972 stars 236 forks source link

pmlogctl create using default class generates relative path to config file #1226

Open goodwinos opened 3 years ago

goodwinos commented 3 years ago

pmlogctl using the default class creates a control file with the pmlogger config file named ./somehost, which ends up in the pmlogger log directory rather than /var/lib/pcp/config/pmloggersomehost.config. E.g.

# pmlogctl status
pmcd Host            Archive           Class        PID State   
shack                20210312.00.10    primary  3638082 running 

create a new pmlogger instance:

# 
# pmlogctl create rhel84
# 
# pmlogctl status
pmcd Host            Archive           Class        PID State   
rhel84               20210312.15.59    default  3989452 running 
shack                20210312.00.10    primary  3638082 running 
# 
# cat /etc/pcp/pmlogger/control.d/rhel84 
# created by pmlogctl on Fri 12 Mar 2021 15:59:55 AEDT
$class=default
#DO NOT REMOVE OR EDIT THE FOLLOWING LINE
$version=1.1
rhel84 n n PCP_ARCHIVE_DIR/rhel84 -c ./rhel84.config

pmlogconf created the new config thusly:

# ls -l /var/log/pcp/pmlogger/rhel84/*.config
-rw-r--r--. 1 pcp pcp 39350 Mar 12 15:59 /var/log/pcp/pmlogger/rhel84/rhel84.config

If I create a class file named 'default' as follows, it seems to do the expected:

# pmlogctl destroy rhel84
# rm -rf /var/log/pcp/pmlogger/rhel84
# 
# cp ~mgoodwin/default /etc/pcp/pmlogger/class.d/default
# 
# 
# 
# cat /etc/pcp/pmlogger/class.d/default
# policy file for the "default" class
[class]
default
[ident]
%h

[control]
$version=1.1
%h n n PCP_ARCHIVE_DIR/%i -c %h.config

[create]
# matches all hosts
hostname(.*)
# 
# pmlogctl create rhel84
# 
# pmlogctl status
pmcd Host            Archive           Class        PID State   
rhel84               20210312.16.03    default  3990701 running 
shack                20210312.00.10    primary  3638082 running 
# ls -l /var/lib/pcp/config/pmlogger/rhel84.config 
-rw-r--r--. 1 pcp pcp 39350 Mar 12 15:22 /var/lib/pcp/config/pmlogger/rhel84.config
# 
# ls -l /var/log/pcp/pmlogger/rhel84
total 504
-rw-r--r--. 1 pcp pcp  43128 Mar 12 16:03 20210312.16.03.0
-rw-r--r--. 1 pcp pcp    212 Mar 12 16:03 20210312.16.03.index
-rw-r--r--. 1 pcp pcp 239661 Mar 12 16:03 20210312.16.03.meta
-rw-r--r--. 1 pcp pcp    239 Mar 12 16:03 Latest
-rw-r--r--. 1 pcp pcp    278 Mar 12 16:03 pmlogger.log

So the simple fix is probably just to ship a 'default' class file, unless I've missed something??

kmcdonell commented 3 years ago

@goodwinos I don't think there is a problem here. A relative pathname for the config file in /var/log/pcp/pmlogger/somehost is perfectly normal (. is where pmlogger looks first to find the -c configfile), and is probably more natural than populating /var/lib/pcp/config/pmlogger with a bunch of config files that need to have the hostname as part of the name to avoid collisions. pmlogctl already has a hard-wired policy file for the default class, it is

[class]
default

[ident]
%h

[destroy]
condition(1)

[create]
hostname(.*)

[control]
#DO NOT REMOVE OR EDIT THE FOLLOWING LINE
$version=1.1
%h n n PCP_ARCHIVE_DIR/%i -c ./%i.config