diff options
author | Tomas Smetana <tsmetana@redhat.com> | 2013-11-12 15:35:30 +0100 |
---|---|---|
committer | Tomas Smetana <tsmetana@redhat.com> | 2013-11-12 15:35:30 +0100 |
commit | aa0ce80be89faa1fd3e4cb51b1b4f0b9edb8d94f (patch) | |
tree | bd5e516614bbb9f22e537d9e82d210c70ffe493d /src/pcp/openlmi-pcp-generate.in | |
parent | eae4cca7eb126191b38fe138c1419f190d030000 (diff) | |
download | openlmi-providers-aa0ce80be89faa1fd3e4cb51b1b4f0b9edb8d94f.tar.gz openlmi-providers-aa0ce80be89faa1fd3e4cb51b1b4f0b9edb8d94f.tar.xz openlmi-providers-aa0ce80be89faa1fd3e4cb51b1b4f0b9edb8d94f.zip |
PCP: fix failed post-install registration
Diffstat (limited to 'src/pcp/openlmi-pcp-generate.in')
-rw-r--r-- | src/pcp/openlmi-pcp-generate.in | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/pcp/openlmi-pcp-generate.in b/src/pcp/openlmi-pcp-generate.in new file mode 100644 index 0000000..088242e --- /dev/null +++ b/src/pcp/openlmi-pcp-generate.in @@ -0,0 +1,90 @@ +#! /bin/sh +# PCP bridge Providers +# +# Copyright (C) 2013 Red Hat, Inc. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Authors: Frank Ch. Eigler <fche@redhat.com> +# + +# +# This script refreshes WBEM/CIM MOF & REG files from the current PCP PMNS, +# if necessary, and reloads the new MOF/REGs into the CIMMON. +# +# The PCP PMNS changes infrequently (when the sysadmin manuall installs or +# removes pcp PMDA (agent) modules in /var/lib/pcp/pmdas/*). +# +# This script encodes the PCP->CIM metric name-mapping convention of replacing +# dots with double-underscores, which lmi/pcp/metric.py will dutifully undo. + +_LOCALSTATEDIR=/var +_DATADIR=/usr/share +NAME=openlmi-providers +PYTHON2_SITELIB=/usr/lib/python2.7/site-packages + +PCP_PMNS=$_LOCALSTATEDIR/lib/pcp/pmns/root +PCP_HOST=${1-localhost} # or local:// for pcp 3.9+ +BASEMOFFILE=$_DATADIR/$NAME/60_LMI_PCP.mof +MOFREGDIR=$_LOCALSTATEDIR/lib/$NAME +STAMPFILE=$MOFREGDIR/stamp +MOFFILE=$MOFREGDIR/60_LMI_PCP_PMNS.mof +REGFILE=$MOFREGDIR/60_LMI_PCP_PMNS.reg +PROVIDER=$PYTHON2_SITELIB/lmi/pcp/metric.py +VERSION=@OPENLMI_VERSION@ + +if [ ! -f $PROVIDER ]; then + echo "Cannot find $PROVIDER" 1>&2 + exit 1 +fi + +set -e + +echo Refreshing PCP_Metric CIMMON classes from current PCP PMNS + +# quick liveness test +pcp -h $PCP_HOST + +if [ -s $PCP_PMNS -a $PCP_PMNS -nt $STAMPFILE ]; then + if [ -f $MOFFILE -a -f $REGFILE ]; then + echo Unregistering $BASEMOFFILE + echo Unregistering previous $MOFFILE + echo Unregistering previous $REGFILE + openlmi-mof-register unregister -v $VERSION $BASEMOFFILE $MOFFILE $REGFILE || : + fi + + echo Generating $MOFFILE + pminfo -h $PCP_HOST | sed -e 's,\.,__,g' | + awk '{print "class PCP_Metric_" $1 " : PCP_MetricValue { } ;" }' > $MOFFILE + + echo Generating $REGFILE + pminfo -h $PCP_HOST | sed -e 's,\.,__,g' | + awk '{print "[PCP_Metric_" $1 "]" + print " provider: '$PROVIDER'" + print " location: pyCmpiProvider" + print " type: instance" + print " namespace: root/cimv2" + print " group: pcp" + print ""}' > $REGFILE + + echo Registering $BASEMOFFILE + echo Registering new $MOFFILE + echo Registering new $REGFILE + openlmi-mof-register register -v $VERSION $BASEMOFFILE $MOFFILE $REGFILE 2>&1 | # filter out two noise diagnostics + egrep -v 'Warning: the instance already exists.|In this implementation, that means it cannot be changed.' || : + touch $STAMPFILE +else + echo Doing nothing, $PCP_PMNS older than $STAMPFILE +fi |