This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

configexport - Filter Results beyond -edited

I'm attempting to write a script to extract a list of all rules currently configured on the server.

I can run:

Fglcmd.sh ... -cmd util:configexport
Returns EVERYTHING (7MB+ XML file)

or alternatively 

Fglcmd.sh ... -cmd util:configexport -edited
This appears to return only items added / changed since installation

Are there further arguments similar to -edited to allow someone to further target specific items within the configuration XML, possibly similar to the way util:topologyexport allows one to pass a query of sorts?

  • This is non-trivial, but there is a post processing way to do this (after you export it).

    In this example to get secondary ASPs, you use fglcmd to export the whole (or -edited) monitoring policy into export.xml.

     

    Then you run the groovy below (in Groovy interpreter - nothing Foglight specific to the env) to filter out the 2ndary ASPs into a new file sharedasps.xml.

     

    import javax.xml.transform.TransformerFactory

    import javax.xml.transform.stream.StreamResult

    import javax.xml.transform.stream.StreamSource                             

    // the file we're creating with 2ndary ASPs

    output = new File("sharedasps.xml"); 

     

    // assuming we have a monitoring policy exported already

    export = new File("C:\\Temp\\configexport101.xml"); 

     

    // transform/filter secondaries

    xslt = '''

      <xsl:stylesheet xmlns:xsl="www.w3.org/.../Transform" version="1.0">

      <xsl:output method="xml"/>

        <xsl:template match="foglight-config">   

          <xsl:copy><xsl:copy-of select="@*"/>

             <xsl:for-each select="persistable-config-model[config_type!='private']">

               <xsl:copy><xsl:copy-of select="@*"/>

                  <xsl:apply-templates/>

               </xsl:copy>

              </xsl:for-each>

             <xsl:text>&#10;</xsl:text>

             </xsl:copy>

            </xsl:template>

            <xsl:template match="* | @*">

              <xsl:copy><xsl:copy-of select="@*"/><xsl:apply-templates/></xsl:copy>

            </xsl:template>

         </xsl:stylesheet>

    '''; 

     

    def factory = TransformerFactory.newInstance()

    def transformer = factory.newTransformer(new StreamSource(new StringReader(xslt)));

    source = new FileInputStream(export);

    dest = new FileOutputStream(output); 

    transformer.transform(new StreamSource(source), new StreamResult(dest));

    source.close();

    dest.close(); 

     

    // report what to do with the output next

    "copy non private ASPs to target FMS via:\n"+ 

    "fglcmd ... -cmd util:configimport -f ${output.absolutePath}"

     

     

     

    Or for example, to extract all Rules, use:
    <xsl:for-each select="severity-family">

     

    Or you could be more specific for a particular rule.

     

    You will need to decide which subset you want.

     

    I hope this helps.

    -Jeff

  • Thanks for the reply. Currently, I have a Perl script running several export routines for a TopologyItem search for things like ESXHosts, Datastores, Clusters, VMs, etc. Then, it moves through the files, extracting the longName 'field' via RegEx. Next, the script exports the full config (~7-8mb XML) and performs a similar routine, looking for 'simple-rule' and 'severity-level' items. It's not pretty or efficient, but it's accomplishing the end result.