Search in sources :

Example 1 with OnmsWbemPropertySet

use of org.opennms.protocols.wmi.wbem.OnmsWbemPropertySet in project opennms by OpenNMS.

the class TestingNewStructure method main.

/**
     * <p>main</p>
     *
     * @param args an array of {@link java.lang.String} objects.
     */
public static void main(final String[] args) {
    try {
        // Connect to the WMI server.
        final WmiClient wmiClient = new WmiClient("localhost");
        wmiClient.connect("CHILDRENSNT", "CE136452", "aj7162007", WmiParams.WMI_DEFAULT_NAMESPACE);
        final OnmsWbemObjectSet wos = wmiClient.performExecQuery("Select * From Win32_NTLogEvent");
        System.out.println("The number of objects retrieved: " + wos.count());
        for (int i = 0; i < wos.count(); i++) {
            final OnmsWbemObject obj = wos.get(i);
            if (obj == null)
                System.out.println("Received null object.");
            //System.out.println("+++++ Testing Object PropertySet +++++");
            final OnmsWbemPropertySet propSet = obj.getWmiProperties();
            //System.out.println("Object has " + propSet.count() + " properties available.");
            System.out.println("The service (" + propSet.getByName("EventIdentifier").getWmiValue() + ") is: " + propSet.getByName("Message").getWmiValue());
        //for(int b=0; b<propSet.count(); b++) {
        //    OnmsWbemProperty prop = propSet.get(b);
        //    System.out.println("Property named: " + prop.getWmiName());
        //    System.out.println("Property origin: " + prop.getWmiOrigin());
        //    System.out.println("Property is array: " + prop.getWmiIsArray());
        //    System.out.println("Property is local: " + prop.getWmiIsLocal());
        //    System.out.println("Property value: " + prop.getWmiValue());
        //    System.out.println("Property CIMType: " + OnmsWbemCimTypeEnum.get(prop.getWmiCIMType()).getCimName() );
        //}
        }
        // lets do some logic here....
        //            OnmsWbemObjectSet wos = wmiClient.performInstanceOf("Win32_Keyboard");
        //
        //            System.out.println("The number of objects retrieved: " + wos.count());
        //            for(int i=0; i<wos.count(); i++) {
        //                OnmsWbemObject obj = wos.get(0);
        //                if(obj == null)
        //                    System.out.println("Received null object.");
        //
        //                System.out.println("+++++ Testing OnmsWbemMethodSet and Mehod +++++");
        //                OnmsWbemMethodSet methodSet = obj.getWmiMethods();
        //                System.out.println("object has " + methodSet.getCount() + " methods available.");
        //                for(int a=0;a<methodSet.getCount(); a++) {
        //                    OnmsWbemMethod method = methodSet.get(a);
        //                    System.out.println("Object method Name: " + method.getWmiName());
        //                    System.out.println("Object method Origin: " + method.getWmiOrigin());
        //                }
        //
        //                System.out.println("+++++ Testing OnmsWbemObjectPath +++++");
        //                OnmsWbemObjectPath objPath = obj.getWmiPath();
        //                System.out.println("Object Path is: " + objPath.getWmiPath());
        //                System.out.println("Object ParentNamespace is: " + objPath.getWmiParentNamespace());
        //                System.out.println("Object Namespace is: " + objPath.getWmiNamespace());
        //                System.out.println("Object Locale is: " + objPath.getWmiLocale());
        //                System.out.println("Object DisplayName is: " + objPath.getWmiDisplayName());
        //                System.out.println("Object Class is: " + objPath.getWmiClass());
        //                System.out.println("Object Authority is: " + objPath.getWmiAuthority());
        //                System.out.println("Object RelPath is: " + objPath.getWmiRelPath());
        //                System.out.println("Object Server is: " + objPath.getWmiServer());
        //                System.out.println("Object IsClass is: " + objPath.getWmiIsClass());
        //                System.out.println("Object IsSingleton is: " + objPath.getWmiIsSingleton());
        //
        //                System.out.println("+++++ Testing Getting Object Text +++++");
        //                System.out.println(obj.getWmiObjectText());
        //
        //                System.out.println("+++++ Testing Object PropertySet +++++");
        //                OnmsWbemPropertySet propSet = obj.getWmiProperties();
        //                System.out.println("Object has " + propSet.count() + " properties available.");
        //                for(int b=0; b<propSet.count(); b++) {
        //                    OnmsWbemProperty prop = propSet.get(b);
        //                    System.out.println("Property named: " + prop.getWmiName());
        //                    System.out.println("Property origin: " + prop.getWmiOrigin());
        //                    System.out.println("Property is array: " + prop.getWmiIsArray());
        //                    System.out.println("Property is local: " + prop.getWmiIsLocal());
        //                    System.out.println("Property value: " + prop.getWmiValue());
        //                    System.out.println("Property CIMType: " + OnmsWbemCimTypeEnum.get(prop.getWmiCIMType()).getCimName() );
        //
        //
        //                }
        //
        //            }
        // Disconenct from the WMI server.
        wmiClient.disconnect();
    } catch (final WmiException e) {
        System.out.println("Caught exception: " + e.getMessage() + "\n");
        e.printStackTrace();
    }
}
Also used : OnmsWbemPropertySet(org.opennms.protocols.wmi.wbem.OnmsWbemPropertySet) OnmsWbemObjectSet(org.opennms.protocols.wmi.wbem.OnmsWbemObjectSet) OnmsWbemObject(org.opennms.protocols.wmi.wbem.OnmsWbemObject)

Aggregations

OnmsWbemObject (org.opennms.protocols.wmi.wbem.OnmsWbemObject)1 OnmsWbemObjectSet (org.opennms.protocols.wmi.wbem.OnmsWbemObjectSet)1 OnmsWbemPropertySet (org.opennms.protocols.wmi.wbem.OnmsWbemPropertySet)1