pcp
[Top] [All Lists]

Fwd: Fwd: Re: [pcp] Additional substitutions in pmlogger control file

To: Martins Innus <minnus@xxxxxxxxxxx>
Subject: Fwd: Fwd: Re: [pcp] Additional substitutions in pmlogger control file
From: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date: Fri, 16 Oct 2015 08:45:47 +1100
Cc: PCP <pcp@xxxxxxxxxxx>
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <56201E52.90009@xxxxxxxxxxxxxxxx>
References: <56201E52.90009@xxxxxxxxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
The mail handler at oss.sgi.com did not like my attachment, so here it
is again with the example inlined ...

-------- Forwarded Message --------
Subject: Re: [pcp] Additional substitutions in pmlogger control file
Date: Fri, 16 Oct 2015 07:27:22 +1100
From: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
To: Martins Innus <minnus@xxxxxxxxxxx>, pcp@xxxxxxxxxxx

Thanks for this Martins.

On 15/10/15 03:22, Martins Innus wrote:
Hi,
     Is there any interest in supporting other substitutions in the path
component of the pmlogger control file?  Something like the following,
or any other suggestions on how to achieve the same goal? (Obviously the
same change in pmlogger_daily)



--- pmlogger_check.sh    2015-09-18 15:31:31.000000000 +0000
+++ /usr/libexec/pcp/bin/pmlogger_check    2015-10-14 15:57:21.159413586
+0000
@@ -460,6 +460,12 @@
      dir=`echo $dir | sed -e "s;LOCALHOSTNAME;$dir_hostname;"`
      [ "x$host" = "xLOCALHOSTNAME" ] && host=local:

+    dir_date_day=`date "+%Y%m%d"`
+    dir=`echo $dir | sed -e "s;LOCALDAY;$dir_date_day;"`
+
+    dir_date_month=`date "+%Y%m"`
+    dir=`echo $dir | sed -e "s;LOCALMONTH;$dir_date_month;"`
+
      $VERY_VERBOSE && echo "[$controlfile:$line] host=\"$host\"
primary=\"$primary\" socks=\"$socks\" dir=\"$dir\" args=\"$args\""

      case "$host"

Can you please clarify a couple of things for me?

1. this is needed in pmlogger_check _and_ pmlogger_daily?  And for
consisitency I think we'd want to do the pmie_check and pmie_daily
scripts as well (they contain similar logic and semantics).

2. In your control lines you are using LOCALDAY for some of the "dir"
field entries and LOCALMONTH for some of the others?

Apropos 2, if this is the case, then I wonder if we'd not be better to
generalize your suggestion to allow the "dir" field to contain embedded
bash(1) syntax of the forms:
- $variable (from the environment, one presumes)
- `cmd`
- $(cmd)
- ...

Then a one line change to the daily and check scripts, along the lines of

        dir=`eval echo $dir`

would not only satisfy your needs but accommodate arbitrary policies for
the naming of the directories to hold the archive files ... and
importantly move those policies out of the scripts and into the
user-managed control files.

The attached [inlined] script demonstrates this idea.


-------------#!/bin/sh

_check()
{
     echo before dir=\"$dir\"
     dir=`eval echo $dir`
     echo after dir=\"$dir\"
}

echo no subst
dir='PCP_LOG_DIR/pmlogger/LOCALHOST'
_check

echo
echo '`cmd` subst'
dir='PCP_LOG_DIR/pmlogger/some_name/`date "+%Y%m%d"`'
_check

echo
echo '$(cmd) subst'
dir='PCP_LOG_DIR/pmlogger/some_name/$(date "+%Y%m")'
_check

echo
echo '$var subst'
export foo=myspecialpath
dir='PCP_LOG_DIR/pmlogger/some_name/$foo'
_check





<Prev in Thread] Current Thread [Next in Thread>
  • Fwd: Fwd: Re: [pcp] Additional substitutions in pmlogger control file, Ken McDonell <=