Forum Discussion

The_Other_Josh's avatar
5 years ago

Groovy WMI documentation

Is there any documentation for the Groovy WMI implementation (com.santaba.agent.groovyapi.win32.WMI and com.santaba.agent.groovyapi.win32.WMISession)?  I wasn't able to find anything in a short search.

In particular, none of the examples that I found in LM check for WMI credential properties (wmi.user and wmi.pass).

  • Anonymous's avatar
    Anonymous

    "instanceProps.get()" only works on script because in batch mode, which instance's props would be fetched.

     

    That DS "cheats" a little to get the instance props by using this function to grab the props:

    /*******************************************************************************
     * © 2007-2020 - LogicMonitor, Inc. All rights reserved.
     ******************************************************************************/
    
    /**
     * Capture instance props for the interface.
     * @param hostName
     * @param dsName
     * @return instanceProps
     */
    static def getInstanceProps(hostName, dsName) {
        def instanceProps = [:]
        CollectorDb.getInstance().hostEntries.each { device ->
            if (device.getHostName() == hostName) {
                device.getDataSourceInstances().each { instance ->
                    if (instance.getName().startsWith(dsName + "-")) {
                        def props = [:]
                        instance.properties.each { k, v ->
                            props[k] = v
                        }
    
                        instanceProps[instance.wildValue] = props
                    }
                }
            }
        }
        return instanceProps
    }

     

  • 3 minutes ago, mnagel said:

    So you know what I am going to ask next, right?  What is CollectorDb and where is that documented?  Feels a bit unfair to us poor mortal developers :).

    heh, still looking for that key-value store huh? :)

  • Just now, Mike Moniz said:

    heh, still looking for that key-value store huh? :)/emoticons/smile@2x.png 2x" title=":)" width="20">

    I was not actually thinking that, but sure, I really would like one!  Seems like a way to possibly do some of the cross-device correlation I have been wishing I could do.  Just would not dream of touching without docs....

  • CollectorDB is an unpublished internal class/API. We are looking at building this functionality into a published API that you can use without fear.