summaryrefslogtreecommitdiffstats
path: root/src/pcp/openlmi-pcp-generate
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@redhat.com>2013-06-14 23:38:56 -0400
committerJan Safranek <jsafrane@redhat.com>2013-07-18 13:39:48 +0200
commit30d91d80793392adb4c5b3890555662caa0031da (patch)
treeafc3980d82b12eb646c3a6e5d05a7a55203e0d04 /src/pcp/openlmi-pcp-generate
parentf3cee6b1ca62752134c6c3520c3739a193753768 (diff)
downloadopenlmi-providers-30d91d80793392adb4c5b3890555662caa0031da.tar.gz
openlmi-providers-30d91d80793392adb4c5b3890555662caa0031da.tar.xz
openlmi-providers-30d91d80793392adb4c5b3890555662caa0031da.zip
PCP<->CIM bridge prototype v3
- contents properly built/packaged into openlmi-pcp subrpm - a cron.daily job conditionally (rarely) rebuilds the MOF/REG files based upon current PCP state - /usr/bin/openlmi-pcp-generate able to be run by hand, cron.daily job minimal - more run-time PCP error tolerance
Diffstat (limited to 'src/pcp/openlmi-pcp-generate')
-rw-r--r--src/pcp/openlmi-pcp-generate68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/pcp/openlmi-pcp-generate b/src/pcp/openlmi-pcp-generate
new file mode 100644
index 0000000..8c53512
--- /dev/null
+++ b/src/pcp/openlmi-pcp-generate
@@ -0,0 +1,68 @@
+#! /bin/sh
+
+# 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
+
+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 $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 $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