/**
        Get DHCPEnabled status from the process list
    */
    bool NetworkInterfaceConfigurationEnumeration::GetDHCPEnabledFromProcessList(
            std::wstring& name,
            SCXCoreLib::SCXHandle<NetworkInstanceConfigurationEnumerationDeps> deps)
    {
        ProcessEnumeration procEnum;
        procEnum.SampleData();
        procEnum.Update(true);

        std::vector<SCXCoreLib::SCXHandle<ProcessInstance> > proc_v = deps->Find(L"dhcpcd", procEnum); 
        if(proc_v.size() == 0)
          return false; 
        
        for(std::vector<SCXCoreLib::SCXHandle<ProcessInstance> >::iterator i = proc_v.begin(); i != proc_v.end(); ++i)
        {
             SCXCoreLib::SCXHandle<ProcessInstance> process = (*i);
             std::vector<std::string> parms;  
             if(!process->GetParameters(parms))
                  continue; 
            
             for(std::vector<std::string>::iterator i_parms = parms.begin(); i_parms != parms.end(); i_parms++)
               if(name.compare(SCXCoreLib::StrFromMultibyte(*i_parms)) == 0)
                 return true;
        } 
        
        return false;
    }
Esempio n. 2
0
    /**
      Lookup the instance representation, given keys provided from CIMOM

      \param[in]    keys   SCXInstance with property keys set
      \returns             Pointer to located instance

      \throws              SCXInvalidArgumentException
      \throws              SCXInternalErrorException
      \throws              SCXCIMInstanceNotFound   The instance with given keys cannot be found

      This method knows which the key properties of the entity are and returns
      pointer to that item if found.

    */
    SCXCoreLib::SCXHandle<SCXSystemLib::CPUInstance> CPUProvider::FindInstance(const SCXInstance& keys) const // private
    {
        // Start by extracting all key properties
        const SCXProperty& nameprop = GetKeyRef(L"Name", keys);

        for(size_t i=0; i<m_cpus->Size(); i++)
        {
            SCXCoreLib::SCXHandle<SCXSystemLib::CPUInstance> testinst = m_cpus->GetInstance(i);

            // Compare key values of input args and the current instance
            if (testinst->GetProcName() == nameprop.GetStrValue())
            {
                // Match
                return testinst;
            }
        }

        // As last resort, check if we the request is for the _Total instance
        if (m_cpus->GetTotalInstance() != 0 )
        {
            SCXCoreLib::SCXHandle<SCXSystemLib::CPUInstance> testinst = m_cpus->GetTotalInstance();

            if (testinst->GetProcName() == nameprop.GetStrValue())
            {
                return testinst;
            }
        }

        throw SCXCIMInstanceNotFound(keys.DumpString(), SCXSRCLOCATION);
    }
    /**
       Add a SCXInstance with the name property set frmo the ProcessInstance to the collection

       \param[in]   processinst    Process instance to get data from
       \param[out]  inst           Instance to add keys to
       \param[in]   cimtype        Type of CIM Class to return

       \throws      SCXInvalidArgumentException - The instance can not be converted to a ProcessInstance

       This method contains knowledge on which are the key fields for the class.
       The key properties are defined in the MOF file.

    */
    void ProcessProvider::AddKeys(SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> processinst, SCXInstance &inst, SupportedCimClasses cimtype) // private
    {
        SCX_LOGTRACE(m_log, L"ProcessProvider AddKeys()");

        if (processinst == NULL)
        {
            throw SCXInvalidArgumentException(L"einst", L"Not a ProcessInstance", SCXSRCLOCATION);
        }

        scxulong pid;
        if (processinst->GetPID(pid))
        {
            SCXProperty pid_prop(L"Handle", StrFrom(pid));
            inst.AddKey(pid_prop);
        }

        AddScopingOperatingSystemKeys(inst);
        if (eSCX_UnixProcessStatisticalInformation == cimtype)
        {
            std::string name;
            if (processinst->GetName(name))
            {
                SCXProperty name_prop(L"Name", StrFromMultibyte(name));
                inst.AddKey(name_prop);
                SCXProperty creationClass_prop(L"ProcessCreationClassName", L"SCX_UnixProcessStatisticalInformation");
                inst.AddKey(creationClass_prop);
            }
        }
        else if (eSCX_UnixProcess == cimtype)
        {
            SCXProperty creationClass_prop(L"CreationClassName", L"SCX_UnixProcess");
            inst.AddKey(creationClass_prop);
        }

    }
Esempio n. 4
0
 void callDumpStringForCoverage()
 {
     SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
     CPPUNIT_ASSERT(thread->DumpString().find(L"SCXThread") != std::wstring::npos);
     thread->RequestTerminate();
     CPPUNIT_ASSERT(SCXCoreLib::SCXThreadParam().DumpString().find(L"SCXThreadParam") != std::wstring::npos);
 }
Esempio n. 5
0
 void TestStartTwiceFails()
 {
     SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
     SCXUNIT_ASSERT_THROWN_EXCEPTION(thread->Start(SCXThreadTest::SimpleThreadBodyTerminate), SCXCoreLib::SCXThreadStartException, L"started");
     thread->RequestTerminate();
     thread->Wait();
 }
MI_BEGIN_NAMESPACE

static void EnumerateOneInstance(Context& context,
                          SCX_LANEndpoint_Class& inst, bool keysOnly,
                          SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance> intf)
{
    // Add the key properperties first.
    inst.CreationClassName_value("SCX_LANEndpoint");
    inst.Name_value(StrToMultibyte(intf->GetName()).c_str());

    // Add the scoping systems keys.
    inst.SystemCreationClassName_value("SCX_ComputerSystem");
    SCXCoreLib::NameResolver mi;
    inst.SystemName_value(StrToMultibyte(mi.GetHostDomainname()).c_str());
    if (!keysOnly)
    {
        inst.InstanceID_value(StrToMultibyte(intf->GetName()).c_str());
        inst.Caption_value("LAN endpoint caption information");
        inst.Description_value("LAN Endpoint description information");
        
        inst.ElementName_value(StrToMultibyte(intf->GetName()).c_str());

        std::wstring text;
        if(intf->GetMACAddressRAW(text))
        {
            inst.MACAddress_value(StrToMultibyte(text).c_str());
            intf->GetMACAddress(text, '-', true);
            inst.FormattedMACAddress_value(StrToMultibyte(text).c_str());
        }
    }
    context.Post(inst);
}
Esempio n. 7
0
 void TestGetFileSuffix(void)
 {
     // Check for correct existing suffix.
     CPPUNIT_ASSERT(m_path->GetFilesuffix() == L"ext");
     // Check for correct non-existing suffix.
     CPPUNIT_ASSERT(m_file->GetFilesuffix() == L"");
     // Check for correct non-existing suffix when file name is missing.
     CPPUNIT_ASSERT(m_directory->GetFilesuffix() == L"");
 }
Esempio n. 8
0
 void TestThreadExceptionHaveCorrectThreadID()
 {
     SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
     try {
         thread->Start(SCXThreadTest::SimpleThreadBodyTerminate);
         CPPUNIT_FAIL("Expected exception not thrown: SCXThreadStartException");
     } catch (SCXCoreLib::SCXThreadStartException& e) {
         CPPUNIT_ASSERT_EQUAL(SCXCoreLib::SCXThread::GetCurrentThreadID(), e.GetThreadID());
     }
 }
Esempio n. 9
0
    void TestSetFilename(void)
    {
        // Check that only file name is changed.
        m_path->SetFilename(L"new.file");
#if defined(WIN32)
        CPPUNIT_ASSERT(m_path->Get() == L"some\\path\\new.file");
#else
        CPPUNIT_ASSERT(m_path->Get() == L"some/path/new.file");
#endif
        m_path->SetFilename(L"");
        // Check that empty filename removes filename...
        CPPUNIT_ASSERT(m_path->GetFilename() == L"");
        // ...but not directory
#if defined(WIN32)
        CPPUNIT_ASSERT(m_path->GetDirectory() == L"some\\path\\");
#else
        CPPUNIT_ASSERT(m_path->GetDirectory() == L"some/path/");
#endif

        // Check correct exception thrown when adding folder separators in file name.
        SCXUNIT_RESET_ASSERTION();
        CPPUNIT_ASSERT_THROW(m_path->SetFilename(L"not/valid"), SCXCoreLib::SCXInvalidArgumentException);
        SCXUNIT_ASSERTIONS_FAILED(2); // both in append function and in SCXInvalidArgumentException constructor
        CPPUNIT_ASSERT_THROW(m_path->SetFilename(L"not\\valid"), SCXCoreLib::SCXInvalidArgumentException);
        SCXUNIT_ASSERTIONS_FAILED(2); // both in append function and in SCXInvalidArgumentException constructor
    }
    /**
       Discover physical disks.

       Logical disks are identified by the /etc/mnttab file (by design). Physical
       disks discovered will be those "hosting" the logical disks found. If ever
       seen in that file, the disk will be discovered. If the disk is removed it
       will be marked as offline.

       How to identify physical disks from logical disks:

       Linux --

       Logical disks are named things like /dev/hda0, /dev/hda1 and so on.
       The numeric value in the end of the name is the partition/logical ID
       of the physical disk. In the example above both logical disks are on
       physical disk /dev/hda.

       For LVM partitions on Linux have two entries for the same device.  An LVM
       device entry is stored in the /dev/mapper directory with a name in the form
       <logical-volume-group>-<logical-volume>.  There is also a device mapper (dm)
       device entry stored in the /dev directory in the form dm-<id>.  This is a
       1-to-1 relationship and the <id> is equal to the device minor ID that both
       device entries have in common.  Discovery of the physical device(s) that
       contain the LVM partition is done by mapping the LVM device to the dm device,
       then looking at the dm devices slave entries in Sysfs, and then finally
       performing the same conversion from a logical Linux partition name to a
       physical drive name that is done for all other partitions.

       Solaris --

       Logical disks are named things like /dev/dsk/c1t0d0s0, /dev/dsk/c1t0d0s1
       and so on. The last letter/numeric pair is the partition/logical ID
       of the physical disk. In the example above both logical disks are on
       physical disk /dev/dsk/c1t0d0.

       HPUX --

       Logical disks are logical volumes with names like /dev/vg00/lvol3.
       /dev/vg00 in the example name is the volume group name. Using the /etc/lvmtab
       file the volume group can be translated to a partition named /dev/disk/disk3_p2
       (or /dev/dsk/c2t0d0s2 using a naming standard deprecated as of HPUX 11.3). The
       old naming standard works like the one for solaris while the new one identifies
       the physical disk as /dev/disk/disk3 in the example above.

       AIX --

       TODO: Document how disks are enumerated on AIX.
    */
    void StatisticalPhysicalDiskEnumeration::FindPhysicalDisks()
    {
        for (EntityIterator iter=Begin(); iter!=End(); iter++)
        {
            SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> disk = *iter;
            disk->m_online = false;
        }

        m_deps->RefreshMNTTab();
        for (std::vector<MntTabEntry>::const_iterator it = m_deps->GetMNTTab().begin();
             it != m_deps->GetMNTTab().end(); it++)
        {
            if ( ! m_deps->FileSystemIgnored(it->fileSystem) &&
                 ! m_deps->DeviceIgnored(it->device) &&
                 m_deps->LinkToPhysicalExists(it->fileSystem, it->device, it->mountPoint) )
            {
                std::map<std::wstring, std::wstring> devices = m_deps->GetPhysicalDevices(it->device);
                if (devices.size() == 0)
                {
                    static SCXCoreLib::LogSuppressor suppressor(SCXCoreLib::eError, SCXCoreLib::eTrace);
                    std::wstringstream               out;

                    out << L"Unable to locate physical devices for: " << it->device;
                    SCX_LOG(m_log, suppressor.GetSeverity(out.str()), out.str());
                    continue;
                }
                for (std::map<std::wstring, std::wstring>::const_iterator dev_it = devices.begin();
                     dev_it != devices.end(); dev_it++)
                {
                    SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> disk = AddDiskInstance(dev_it->first, dev_it->second);
#if defined(hpux)
                    if (0 != disk)
                    {
                        if (m_pathToRdev.end() == m_pathToRdev.find(disk->m_device))
                        {
                            SCXCoreLib::SCXFilePath fp(disk->m_device);
                            fp.SetFilename(L"");
                            UpdatePathToRdev(fp.Get());
                        }
                        SCXASSERT(m_pathToRdev.end() != m_pathToRdev.find(disk->m_device));

                        scxlong diskInfoIndex = disk->FindDiskInfoByID(m_pathToRdev.find(disk->m_device)->second);
                        m_deps->AddDeviceInstance(disk->m_device, L"", diskInfoIndex, m_pathToRdev.find(disk->m_device)->second);
                    }
#endif
                }
            }
        }

#if defined(sun)
        this->UpdateSolarisHelper();
#endif

    }
Esempio n. 11
0
    void TestThreadTerminate(void)
    {
        // Test terminating a thread
        SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
        CPPUNIT_ASSERT_NO_THROW(thread->RequestTerminate());
        time_t later = time(NULL) + 10;
        while (thread->IsAlive() && later > time(NULL))
            SCXCoreLib::SCXThread::Sleep(10);
        CPPUNIT_ASSERT_MESSAGE("Thread did not terminate", ! thread->IsAlive());

        // terminate again
        CPPUNIT_ASSERT_NO_THROW(thread->RequestTerminate());
    }
    /**
       Store sample data for all instances in collection.

    */
    void StatisticalPhysicalDiskEnumeration::SampleDisks()
    {
        SCXCoreLib::SCXThreadLock lock(m_lock);
#if defined(linux)
        m_deps->RefreshProcDiskStats();
#endif
        for (EntityIterator iter = Begin(); iter != End(); iter++)
        {
            SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> disk = *iter;

            disk->Sample();
        }
    }
    /**
      Lookup the instance representation, given keys provided from CIMOM

      \param[in]    keys   SCXInstance with property keys set
      \returns             Pointer to located instance

      \throws              SCXInvalidArgumentException
      \throws              SCXInternalErrorException
      \throws              SCXCIMInstanceNotFound   The instance with given keys cannot be found

      This method knows which the key properties of the entity are and returns
      pointer to that item if found.

    */
    SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> ProcessProvider::FindInstance(const SCXInstance& keys) const // private
    {
        // Start by extracting all key properties
        ValidateScopingOperatingSystemKeys(keys);
        SupportedCimClasses cimtype = static_cast<SupportedCimClasses>(m_ProviderCapabilities.GetCimClassId(keys));
        if (eSCX_UnixProcessStatisticalInformation == cimtype) {
            ValidateKeyValue(L"ProcessCreationClassName", keys, L"SCX_UnixProcessStatisticalInformation");
            GetKeyRef(L"Name", keys);
        } else if (eSCX_UnixProcess == cimtype) {
            ValidateKeyValue(L"CreationClassName", keys, L"SCX_UnixProcess");
        } else {
            throw SCXInvalidStateException(L"Unknown cimtype value", SCXSRCLOCATION);
        }

        const SCXProperty &pidprop = GetKeyRef(L"Handle", keys);
        scxulong pid;

        for(size_t i=0; i<m_processes->Size(); i++)
        {
            SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> testinst = m_processes->GetInstance(i);
            if (testinst == NULL)
            {
                throw SCXInternalErrorException(L"Instance from list not an ProcessInstance", SCXSRCLOCATION);
            }
            // Compare key values of input args and the current instance
            testinst->GetPID(pid);
            if (StrFrom(pid) == pidprop.GetStrValue())
            {
                // Match
                return testinst;
            }
        }

        // As last resort, check if we the request is for the _Total instance
        if (m_processes->GetTotalInstance() != 0)
        {
            SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> testinst = m_processes->GetTotalInstance();
            if (testinst == NULL)
            {
                throw SCXInternalErrorException(L"Total instance not a ProcessInstance", SCXSRCLOCATION);
            }
            testinst->GetPID(pid);
            if (StrFrom(pid) == pidprop.GetStrValue())
            {
                return testinst;
            }
        }


        throw SCXCIMInstanceNotFound(keys.DumpString(), SCXSRCLOCATION);
    }
    /**
        Get the value for the spcified resource from a specified instance

        \param[in]     resource      Name of resource to get
        \param[in]     processinst   Instance to get resource from

        \returns       Value for specifed resource

        \throws        SCXInternalErrorException    If given resource not handled
    */
    scxulong ProcessProvider::GetResource(const std::wstring &resource, SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> processinst)
    {
        scxulong res = 0;
        bool gotResource = false;

        if (StrCompare(resource, L"CPUTime", true) == 0)
        {
            unsigned int cputime;
            gotResource = processinst->GetCPUTime(cputime);
            res = static_cast<scxulong>(cputime);
        }
        else if (StrCompare(resource, L"BlockReadsPerSecond", true) == 0)
        {
            gotResource = processinst->GetBlockReadsPerSecond(res);
        }
        else if (StrCompare(resource, L"BlockWritesPerSecond", true) == 0)
        {
            gotResource = processinst->GetBlockWritesPerSecond(res);
        }
        else if (StrCompare(resource, L"BlockTransfersPerSecond", true) == 0)
        {
            gotResource = processinst->GetBlockTransfersPerSecond(res);
        }
        else if (StrCompare(resource, L"PercentUserTime", true) == 0)
        {
            gotResource = processinst->GetPercentUserTime(res);
        }
        else if (StrCompare(resource, L"PercentPrivilegedTime", true) == 0)
        {
            gotResource = processinst->GetPercentPrivilegedTime(res);
        }
        else if (StrCompare(resource, L"UsedMemory", true) == 0)
        {
            gotResource = processinst->GetUsedMemory(res);
        }
        else if (StrCompare(resource, L"PercentUsedMemory", true) == 0)
        {
            gotResource = processinst->GetPercentUsedMemory(res);
        }
        else if (StrCompare(resource, L"PagesReadPerSec", true) == 0)
        {
            gotResource = processinst->GetPagesReadPerSec(res);
        }
        else
        {
            throw UnknownResourceException(resource, SCXSRCLOCATION);
        }

        if ( ! gotResource)
        {
            throw SCXInternalErrorException(StrAppend(L"GetResource: Failed to get resouce: ", resource), SCXSRCLOCATION);
        }

        return res;
    }
MI_BEGIN_NAMESPACE

static void EnumerateOneInstance(Context& context,
                          SCX_EthernetPortStatistics_Class& inst, bool keysOnly,
                          SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance> intf)
{
    // Add the key properperties first.
    inst.InstanceID_value(StrToMultibyte(intf->GetName()).c_str());

    if (!keysOnly)
    {
        inst.Caption_value("Ethernet port information");
        inst.Description_value("Statistics on transfer performance for a port");

        scxulong ulong = 0;
        scxulong bytesReceived = intf->GetBytesReceived(ulong) ? ulong : 0;
        inst.BytesReceived_value(bytesReceived);

        scxulong bytesTransmitted = intf->GetBytesSent(ulong) ? ulong : 0;
        inst.BytesTransmitted_value(bytesTransmitted);

        inst.BytesTotal_value(bytesReceived + bytesTransmitted);

        inst.PacketsReceived_value(intf->GetPacketsReceived(ulong) ? ulong : 0);
        inst.PacketsTransmitted_value(intf->GetPacketsSent(ulong) ? ulong : 0);

        inst.TotalTxErrors_value(intf->GetErrorsSending(ulong) ? ulong : 0);

        inst.TotalRxErrors_value(intf->GetErrorsReceiving(ulong) ? ulong : 0);

        inst.TotalCollisions_value(intf->GetCollisions(ulong) ? ulong : 0);
    }
    context.Post(inst);
}
    /**
       Add a new disk instacne if it does not already exist.

       \param   name name of instance.
       \param   device device string (only used if new instance created).
       \returns NULL if a disk with the given name already exists - otherwise the new disk.

       \note The disk will be marked as online if found.
    */
    SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> StatisticalPhysicalDiskEnumeration::AddDiskInstance(const std::wstring& name, const std::wstring& device)
    {
        SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> disk = FindDiskByDevice(name);
        if (0 == disk)
        {
            disk = new StatisticalPhysicalDiskInstance(m_deps);
            disk->SetId(name);
            disk->m_device = device;
            disk->m_online = true;
            AddInstance(disk);
            return disk;
        }
        disk->m_online = true;
        return SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance>(0);
    }
//! Determine enabled state according to CIM
//! \param[in]   intf    Interface in question
static unsigned short GetEnabledState(SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance> intf) 
{
    enum {eUnknown = 0, eEnabled = 2, eDisabled = 3, eEnabledButOffline = 6} enabledState = eUnknown;
    bool up = false;
    bool running = false;
    bool knownIfUp = intf->GetUp(up);
    bool knownIfRunning = intf->GetRunning(running);
    if (knownIfUp && knownIfRunning) {
        if (up) {
            enabledState = eEnabled;
        } else {
            enabledState = running ? eEnabledButOffline : eDisabled;
        }
    }
    return enabledState;
}
Esempio n. 18
0
    void TestAssign(void)
    {
        SCXCoreLib::SCXFilePath fp = *m_path;

        // Check may assign to itself.
        CPPUNIT_ASSERT_NO_THROW(*m_path = *m_path);
        // Check content after assign operation is equal.
        CPPUNIT_ASSERT(fp.Get() == m_path->Get());
    }
    /**
       Enumeration Helper for the Solaris platform. Not all disks are available from
       MNTTAB on this platform, this it is necessary to perform some additional
       searching of the file system.
    */
    void StaticPhysicalDiskEnumeration::UpdateSolarisHelper()
    {
        // workaround for unknown FS/devices
        // try to get a list of disks from /dev/dsk
        std::vector<SCXCoreLib::SCXHandle<SCXCoreLib::SCXFileInfo> > disk_infos = m_deps->GetDevDskInfo();
        std::map< std::wstring, int > found_devices;

        // iterate through all devices 
        for ( unsigned int i = 0; i < disk_infos.size(); i++ ){
            std::wstring dev_name = disk_infos[i]->GetFullPath().GetFilename();

            dev_name = dev_name.substr(0,dev_name.find_last_not_of(L"0123456789"));

            if ( found_devices.find( dev_name ) != found_devices.end() )
                continue; // already considered

            found_devices[dev_name] = 0;

            try {
                SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk = GetInstance(dev_name);

                if ( disk == 0 ){
                    disk = new StaticPhysicalDiskInstance(m_deps);
                    disk->SetId(dev_name);
                    disk->m_device = disk_infos[i]->GetDirectoryPath().Get() + dev_name;
                    disk->m_online = true;
                    // NOTE: Update will throw in case if disk is removable media, so 
                    // we will skip it (no call to AddInstance)
                    disk->Update();
                    AddInstance(disk);
                   
                } else {
                    disk->Update(); // check if disk is still 'alive'
                    // if disk goes off-line, Update throws and status remains 'false'
                    disk->m_online = true;
                }
            } catch ( SCXCoreLib::SCXException& e )
            {
                //std::wcout << L"excp in dsk update: " << e.What() << endl << e.Where() << endl;
                // ignore errors, since disk may not be accessible and it's fine
            }
        }
    }
Esempio n. 20
0
    /**
       Add a SCXInstance with the name property set frmo the CPUInstance to the collection

       \param[in]   cpuinst  CPU instance to get data from
       \param[out]  inst     Instance to add keys to

       \throws      SCXInvalidArgumentException - The instance can not be converted to a CPUInstance

       This method contains knowledge on which are the key fields for the class.
       The key properties are defined in the MOF file.

    */
    void CPUProvider::AddKeys(SCXCoreLib::SCXHandle<SCXSystemLib::CPUInstance> cpuinst, SCXInstance &inst) // private
    {
        SCX_LOGTRACE(m_log, L"CPUProvider AddKeys()");

        if (cpuinst == NULL)
        {
            throw SCXInvalidArgumentException(L"einst", L"Not a CPUInstance", SCXSRCLOCATION);
        }

        SCXProperty name_prop(L"Name", cpuinst->GetProcName());
        inst.AddKey(name_prop);
    }
Esempio n. 21
0
    void TestAppendDirectory(void)
    {
        // Test appending to empty folder.
        m_file->AppendDirectory(L"/some\\append/");
        // Test appending folder without trailing folder separator.
        m_directory->AppendDirectory(L"some_append");
        // Test removing starting folder separators and adding trailing folder separator.
        m_path->AppendDirectory(L"/some/append");
#if defined(WIN32)
        CPPUNIT_ASSERT(m_file->Get() == L"\\some\\append\\file");
        CPPUNIT_ASSERT(m_directory->Get() == L"dir\\some_append\\");
        CPPUNIT_ASSERT(m_path->Get() == L"some\\path\\some\\append\\file.ext");
#else
        CPPUNIT_ASSERT(m_file->Get() == L"/some/append/file");
        CPPUNIT_ASSERT(m_directory->Get() == L"dir/some_append/");
        CPPUNIT_ASSERT(m_path->Get() == L"some/path/some/append/file.ext");
#endif
    }
MI_BEGIN_NAMESPACE

static void EnumerateOneInstance(Context& context,
                          SCX_IPProtocolEndpoint_Class& inst, bool keysOnly,
                          SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance> intf)
{
    // Add the key properperties first.
    inst.CreationClassName_value("SCX_IPProtocolEndpoint");
    inst.Name_value(StrToMultibyte(intf->GetName()).c_str());

    // Add the scoping systems keys.
    inst.SystemCreationClassName_value("SCX_ComputerSystem");
    SCXCoreLib::NameResolver mi;
    inst.SystemName_value(StrToMultibyte(mi.GetHostDomainname()).c_str());

    if (!keysOnly)
    {
        inst.Caption_value("IP protocol endpoint information");
        inst.Description_value("Properties of an IP protocol connection endpoint");

        inst.ElementName_value(StrToMultibyte(intf->GetName()).c_str());

        wstring text;
        if (intf->GetIPAddress(text))
        {
            inst.IPv4Address_value(StrToMultibyte(text).c_str());
        }
        if (intf->GetBroadcastAddress(text))
        {
            inst.IPv4BroadcastAddress_value(StrToMultibyte(text).c_str());
        }
        if (intf->GetNetmask(text))
        {
            inst.SubnetMask_value(StrToMultibyte(text).c_str());
        }
        inst.EnabledState_value(GetEnabledState(intf));
    }
    context.Post(inst);
}
    /**
       Store sample data for all instances in collection.

    */
    void StatisticalLogicalDiskEnumeration::SampleDisks()
    {
        SCXCoreLib::SCXThreadLock lock(m_lock);
#if defined(linux)
        m_deps->RefreshProcDiskStats();
#endif
        for (EntityIterator iter = Begin(); iter != End(); iter++)
        {
            SCXCoreLib::SCXHandle<StatisticalLogicalDiskInstance> disk = *iter;

            try {
                disk->Sample();
            }
            catch (const SCXCoreLib::SCXException& e)
            {
                SCX_LOGERROR(m_log,
                            std::wstring(L"StatisticalLogicalDiskEnumeration::SampleDisks() - Unexpected exception caught: ").append(
                            e.What()).append(L" - ").append(e.Where()).append(
                            L"; for logical disk ").append(disk->m_device) );
            }
        }
    }
    /**
       Add a new disk instance if it does not already exist.

       \param   name name of instance.
       \param   device device string (only used if new instance created).
       \param   cdDrive device is an optical drive.
       \returns NULL if a disk with the given name already exists - otherwise the new disk.

       \note The disk will be marked as online if found.
    */
    SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> StaticPhysicalDiskEnumeration::AddDiskInstance(
        const std::wstring& name, const std::wstring& device
#if defined(linux)
        , bool cdDrive
#endif
        )
    {
        SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk = GetInstance(name);
        if (0 == disk)
        {
            disk = new StaticPhysicalDiskInstance(m_deps);
            disk->SetId(name);
            disk->m_device = device;
            disk->m_online = true;
#if defined(linux)
            disk->m_cdDrive = cdDrive;
#endif
            AddInstance(disk);
            return disk;
        }
        disk->m_online = true;
        return SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance>(0);
    }
Esempio n. 25
0
    void TestCompare(void)
    {
        SCXCoreLib::SCXFilePath fp1 = *m_path;
        SCXCoreLib::SCXFilePath fp2 = m_path->Get();
        SCXCoreLib::SCXFilePath fp3 = *m_directory;
        SCXCoreLib::SCXFilePath fp4 = *m_file;

        // Check compare operators to match content.
        CPPUNIT_ASSERT(fp1 == fp2);
        CPPUNIT_ASSERT(fp3 == *m_directory);
        CPPUNIT_ASSERT(fp4 == *m_file);
        CPPUNIT_ASSERT(fp1 != fp3);
        CPPUNIT_ASSERT(fp1 != fp4);
        CPPUNIT_ASSERT(fp3 != fp4);
    }
Esempio n. 26
0
    /**
       Set all properties from the CPUInstance in the SCXInstance

       \param[in]  cpuinst - CPU instance to get data from
       \param[in]  inst    - Instance to populate

       \throws      SCXInvalidArgumentException - If the instance can not be converted to a CPUInstance

       This method knows how to map the values of the CPU PAL to the CMPI class
       definition.

    */
    void CPUProvider::AddProperties(SCXCoreLib::SCXHandle<SCXSystemLib::CPUInstance> cpuinst, SCXInstance &inst) // private
    {
        scxulong data;

        if (cpuinst == NULL)
        {
            throw SCXInvalidArgumentException(L"einst", L"Not a CPUInstance", SCXSRCLOCATION);
        }

        SCX_LOGTRACE(m_log, L"CPUProvider AddPropeties()");

        SCXProperty total_prop(L"IsAggregate", cpuinst->IsTotal());
        inst.AddProperty(total_prop);

        if (cpuinst->GetProcessorTime(data))
        {
            SCXProperty data_prop(L"PercentProcessorTime", static_cast<unsigned char> (data));
            inst.AddProperty(data_prop);
        }

        if (cpuinst->GetIdleTime(data))
        {
            SCXProperty data_prop(L"PercentIdleTime", static_cast<unsigned char> (data));
            inst.AddProperty(data_prop);
        }

        if (cpuinst->GetUserTime(data))
        {
            SCXProperty data_prop(L"PercentUserTime", static_cast<unsigned char> (data));
            inst.AddProperty(data_prop);
        }

        if (cpuinst->GetNiceTime(data))
        {
            SCXProperty data_prop(L"PercentNiceTime", static_cast<unsigned char> (data));
            inst.AddProperty(data_prop);
        }

        if (cpuinst->GetPrivilegedTime(data))
        {
            SCXProperty data_prop(L"PercentPrivilegedTime", static_cast<unsigned char> (data));
            inst.AddProperty(data_prop);
        }

        if (cpuinst->GetIowaitTime(data))
        {
            SCXProperty data_prop(L"PercentIOWaitTime", static_cast<unsigned char> (data));
            inst.AddProperty(data_prop);
        }

        if (cpuinst->GetInterruptTime(data))
        {
            SCXProperty data_prop(L"PercentInterruptTime", static_cast<unsigned char> (data));
            inst.AddProperty(data_prop);
        }

        if (cpuinst->GetDpcTime(data))
        {
            SCXProperty data_prop(L"PercentDPCTime", static_cast<unsigned char> (data));
            inst.AddProperty(data_prop);
        }

    }
    /**
       Discover logical disks.
    
       Logical disks are identified by the /etc/mnttab file (by design). If ever
       seen in that file, the disk will be discovered. If the disk is removed it 
       will be marked as offline.
    
    */
    void StatisticalLogicalDiskEnumeration::FindLogicalDisks()
    {
        for (EntityIterator iter=Begin(); iter!=End(); iter++)
        {
            SCXCoreLib::SCXHandle<StatisticalLogicalDiskInstance> disk = *iter;
            disk->m_online = false;
        }

        m_deps->RefreshMNTTab();
        for (std::vector<MntTabEntry>::const_iterator it = m_deps->GetMNTTab().begin(); 
             it != m_deps->GetMNTTab().end(); it++)
        {
            if ( ! m_deps->FileSystemIgnored(it->fileSystem) && ! m_deps->DeviceIgnored(it->device))
            {
                SCXCoreLib::SCXHandle<StatisticalLogicalDiskInstance> disk = FindDiskByDevice(it->device);
                if (0 == disk)
                {
                    disk = new StatisticalLogicalDiskInstance(m_deps);
                    disk->m_device = it->device;
                    disk->m_mountPoint = it->mountPoint;
                    disk->m_fsType = it->fileSystem;
                    disk->SetId(disk->m_mountPoint);

#if defined(linux)
                    static SCXLVMUtils lvmUtils;

                    if (lvmUtils.IsDMDevice(it->device))
                    {
                    try
                    {
                            // Try to convert the potential LVM device path into its matching
                            // device mapper (dm) device path.
                            std::wstring dmDevice = lvmUtils.GetDMDevice(it->device);

                            SCXASSERT(!dmDevice.empty());
                            disk->m_samplerDevices.push_back(dmDevice);
                    }
                        catch (SCXCoreLib::SCXException& e)
                    {
                            static SCXCoreLib::LogSuppressor suppressor(SCXCoreLib::eWarning, SCXCoreLib::eTrace);
                            std::wstringstream               out;

                            out << L"An exception occurred resolving the dm device that represents the LVM partition " << it->device
                                << L" : " << e.What();
                            SCX_LOG(m_log, suppressor.GetSeverity(out.str()), out.str());
                        }
                    }
                    // no else required; device was not an LVM device
#endif

                    AddInstance(disk);

#if defined(hpux)
                    if (m_pathToRdev.end() == m_pathToRdev.find(disk->m_device))
                    {
                        SCXCoreLib::SCXFilePath fp(disk->m_device);
                        fp.SetFilename(L"");
                        UpdatePathToRdev(fp.Get());
                    }
                    SCXASSERT(m_pathToRdev.end() != m_pathToRdev.find(disk->m_device));

                    m_deps->AddDeviceInstance(disk->m_device, L"", disk->FindLVInfoByID(m_pathToRdev.find(disk->m_device)->second), m_pathToRdev.find(disk->m_device)->second);
#endif
                }
                disk->m_online = true;
            }
        }
    }
MI_BEGIN_NAMESPACE

static void EnumerateOneInstance(Context& context,
        SCX_UnixProcessStatisticalInformation_Class& inst, bool keysOnly,
        SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> processinst)
{
    SCXLogHandle& log = SCXCore::g_ProcessProvider.GetLogHandle();

    // Add the key properties first.
    scxulong pid;
    if (processinst->GetPID(pid))
    {
        inst.Handle_value(StrToUTF8(StrFrom(pid)).c_str());
    }

    // Add keys of scoping operating system
    try {
        SCXCoreLib::NameResolver mi;
        inst.CSName_value(StrToMultibyte(mi.GetHostDomainname()).c_str());
    } catch (SCXException& e){
        SCX_LOGWARNING(log, StrAppend(
                    StrAppend(L"Can't read host/domainname because ", e.What()),
                    e.Where()));
    }

    try {
        SCXSystemLib::SCXOSTypeInfo osinfo;
        inst.OSName_value(StrToMultibyte(osinfo.GetOSName(true)).c_str());
    } catch (SCXException& e){
        SCX_LOGWARNING(log, StrAppend(
                    StrAppend(L"Can't read OS name because ", e.What()),
                    e.Where()));
    }

    inst.CSCreationClassName_value("SCX_ComputerSystem");
    inst.OSCreationClassName_value("SCX_OperatingSystem");
    inst.ProcessCreationClassName_value("SCX_UnixProcessStatisticalInformation");

    std::string name;
    if (processinst->GetName(name))
    {
        inst.Name_value(name.c_str());
    }

    if (!keysOnly)
    {
        unsigned int uint = 0;
        scxulong ulong = 0;

        inst.Description_value("A snapshot of a current process");
        inst.Caption_value("Unix process information");

        if (processinst->GetRealData(ulong))
        {
            inst.RealData_value(ulong);
        }

        if (processinst->GetRealStack(ulong))
        {
            inst.RealStack_value(ulong);
        }

        if (processinst->GetVirtualText(ulong))
        {
            inst.VirtualText_value(ulong);
        }

        if (processinst->GetVirtualData(ulong))
        {
            inst.VirtualData_value(ulong);
        }

        if (processinst->GetVirtualStack(ulong))
        {
            inst.VirtualStack_value(ulong);
        }

        if (processinst->GetVirtualMemoryMappedFileSize(ulong))
        {
            inst.VirtualMemoryMappedFileSize_value(ulong);
        }

        if (processinst->GetVirtualSharedMemory(ulong))
        {
            inst.VirtualSharedMemory_value(ulong);
        }

        if (processinst->GetCpuTimeDeadChildren(ulong))
        {
            inst.CpuTimeDeadChildren_value(ulong);
        }

        if (processinst->GetSystemTimeDeadChildren(ulong))
        {
            inst.SystemTimeDeadChildren_value(ulong);
        }

        if (processinst->GetRealText(ulong))
        {
            inst.RealText_value(ulong);
        }

        if (processinst->GetCPUTime(uint))
        {
            inst.CPUTime_value(uint);
        }

        if (processinst->GetBlockWritesPerSecond(ulong))
        {
            inst.BlockWritesPerSecond_value(ulong);
        }

        if (processinst->GetBlockReadsPerSecond(ulong))
        {
            inst.BlockReadsPerSecond_value(ulong);
        }

        if (processinst->GetBlockTransfersPerSecond(ulong))
        {
            inst.BlockTransfersPerSecond_value(ulong);
        }

        if (processinst->GetPercentUserTime(ulong))
        {
            inst.PercentUserTime_value((unsigned char) ulong);
        }

        if (processinst->GetPercentPrivilegedTime(ulong))
        {
            inst.PercentPrivilegedTime_value((unsigned char) ulong);
        }

        if (processinst->GetUsedMemory(ulong))
        {
            inst.UsedMemory_value(ulong);
        }

        if (processinst->GetPercentUsedMemory(ulong))
        {
            inst.PercentUsedMemory_value((unsigned char) ulong);
        }

        if (processinst->GetPagesReadPerSec(ulong))
        {
            inst.PagesReadPerSec_value(ulong);
        }
    }
    context.Post(inst);
}
MI_BEGIN_NAMESPACE

static void EnumerateOneInstance(
    Context& context,
    SCX_MemoryStatisticalInformation_Class& inst,
    bool keysOnly,
    SCXCoreLib::SCXHandle<SCXSystemLib::MemoryInstance> meminst)
{
    // Populate the key values
    inst.Name_value("Memory");

    if (!keysOnly)
    {
        scxulong physmem = 0;
        scxulong resmem = 0;
        scxulong usermem = 0;
        scxulong avail = 0;
        scxulong data = 0;
        scxulong data2 = 0;

        inst.Caption_value("Memory information");
        inst.Description_value("Memory usage and performance statistics");

        inst.IsAggregate_value(meminst->IsTotal());

        if (meminst->GetTotalPhysicalMemory(physmem))
        {
            // Adjust numbers from PAL to Megabytes
            physmem = BytesToMegaBytes(physmem);

            if (meminst->GetReservedMemory(resmem))
            {
                resmem = BytesToMegaBytes(resmem);
            }
            else
            {
                resmem = 0;
            }

            // If available, get memory unavailable for user processes and remove it from physical memory
            usermem = physmem - resmem;
        }

        if (meminst->GetAvailableMemory(avail))
        {
            // Adjust numbers from PAL to Megabytes
            avail = BytesToMegaBytes(avail);
            inst.AvailableMemory_value(avail);

            // If we have a number for physical memory use it to compute a percentage
            if (usermem > 0)
            {
                // Need an unsigned char since this is what is required by the MOF
                unsigned char percent = static_cast<unsigned char> (GetPercentage(0, avail, 0, usermem));
                inst.PercentAvailableMemory_value(percent);
            }
        }

        if (meminst->GetUsedMemory(data))
        {
            // Adjust numbers from PAL to Megabytes
            data = BytesToMegaBytes(data);
            inst.UsedMemory_value(data);

            // If we have a number for physical memory use it to compute a percentage
            if (usermem > 0)
            {
                unsigned char percent = static_cast<unsigned char> (GetPercentage(0, data, 0, usermem));
                inst.PercentUsedMemory_value(percent);
            }
        }

        {
            data = 0;
            unsigned char percent = static_cast<unsigned char> (0);

            if (meminst->GetCacheSize(data) && usermem > 0)
            {
                percent = static_cast<unsigned char> (GetPercentage(0, BytesToMegaBytes(data), 0, usermem));
            }
            inst.PercentUsedByCache_value(percent);
        }

        bool pageReadsAvailable = meminst->GetPageReads(data);
        bool pageWritesAvailable = meminst->GetPageWrites(data2);
        if (pageReadsAvailable && pageWritesAvailable)
        {
            inst.PagesPerSec_value(data + data2);
        }

        if (pageReadsAvailable)
        {
            inst.PagesReadPerSec_value(data);
        }

        if (pageWritesAvailable)
        {
            inst.PagesWrittenPerSec_value(data2);
        }

        if (meminst->GetAvailableSwap(data))
        {
            // Adjust numbers from PAL to Megabytes
            data = BytesToMegaBytes(data);
            inst.AvailableSwap_value(data);

            if (meminst->GetTotalSwap(data2))
            {
                // Adjust numbers from PAL to Megabytes
                data2 = BytesToMegaBytes(data2);

                unsigned char percent = static_cast<unsigned char> (GetPercentage(0, data, 0, data2));
                inst.PercentAvailableSwap_value(percent);
            }
        }

        if (meminst->GetUsedSwap(data))
        {
            // Adjust numbers from PAL to Megabytes
            data = BytesToMegaBytes(data);

            inst.UsedSwap_value(data);

            if (meminst->GetTotalSwap(data2))
            {
                // Adjust numbers from PAL to Megabytes
                data2 = BytesToMegaBytes(data2);

                unsigned char percent = static_cast<unsigned char> (GetPercentage(0, data, 0, data2));
                inst.PercentUsedSwap_value(percent);
            }
        }
    }

    context.Post(inst);
}
    /**
       Set all properties from the ProcessInstance in the SCXInstance

       \param[in]  processinst  - Process instance to get data from
       \param[in]  inst         - Instance to populate
       \param[in]  cimtype      - Type of CIM Class to return

       \throws      SCXInvalidArgumentException - If the instance can not be converted to a ProcessInstance

       This method knows how to map the values of the Process PAL to the CMPI class
       definition.

    */
    void ProcessProvider::AddProperties(SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> processinst, SCXInstance &inst, SupportedCimClasses cimtype) // private
    {
        if (processinst == NULL)
        {
            throw SCXInvalidArgumentException(L"einst", L"Not a ProcessInstance", SCXSRCLOCATION);
        }

        SCX_LOGTRACE(m_log, L"ProcessProvider AddPropeties()");

        if (eSCX_UnixProcessStatisticalInformation == cimtype)
        {
            unsigned int uint = 0;
            scxulong ulong = 0;

            if (processinst->GetRealData(ulong))
            {
                SCXProperty prop(L"RealData", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetRealStack(ulong))
            {
                SCXProperty prop(L"RealStack", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetVirtualText(ulong))
            {
                SCXProperty prop(L"VirtualText", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetVirtualData(ulong))
            {
                SCXProperty prop(L"VirtualData", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetVirtualStack(ulong))
            {
                SCXProperty prop(L"VirtualStack", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetVirtualMemoryMappedFileSize(ulong))
            {
                SCXProperty prop(L"VirtualMemoryMappedFileSize", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetVirtualSharedMemory(ulong))
            {
                SCXProperty prop(L"VirtualSharedMemory", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetCpuTimeDeadChildren(ulong))
            {
                SCXProperty prop(L"CpuTimeDeadChildren", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetSystemTimeDeadChildren(ulong))
            {
                SCXProperty prop(L"SystemTimeDeadChildren", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetRealText(ulong))
            {
                SCXProperty prop(L"RealText", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetCPUTime(uint))
            {
                SCXProperty prop(L"CPUTime", uint);
                inst.AddProperty(prop);
            }

            if (processinst->GetBlockWritesPerSecond(ulong))
            {
                SCXProperty prop(L"BlockWritesPerSecond", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetBlockReadsPerSecond(ulong))
            {
                SCXProperty prop(L"BlockReadsPerSecond", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetBlockTransfersPerSecond(ulong))
            {
                SCXProperty prop(L"BlockTransfersPerSecond", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetPercentUserTime(ulong))
            {
                SCXProperty prop(L"PercentUserTime", (unsigned char) ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetPercentPrivilegedTime(ulong))
            {
                SCXProperty prop(L"PercentPrivilegedTime", (unsigned char) ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetUsedMemory(ulong))
            {
                SCXProperty prop(L"UsedMemory", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetPercentUsedMemory(ulong))
            {
                SCXProperty prop(L"PercentUsedMemory", (unsigned char) ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetPagesReadPerSec(ulong))
            {
                SCXProperty prop(L"PagesReadPerSec", ulong);
                inst.AddProperty(prop);
            }
        }
        else if (eSCX_UnixProcess == cimtype)
        {
            std::string name("");
            std::vector<std::string> params;
            std::wstring str(L"");
            unsigned int uint = 0;
            unsigned short ushort = 0;
            scxulong ulong = 0;
            SCXCoreLib::SCXCalendarTime ctime;
            int pid = 0;

            if (processinst->GetOtherExecutionDescription(str))
            {
                SCXProperty prop(L"OtherExecutionDescription", str);
                inst.AddProperty(prop);
            }

            if (processinst->GetKernelModeTime(ulong))
            {
                SCXProperty prop(L"KernelModeTime", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetUserModeTime(ulong))
            {
                SCXProperty prop(L"UserModeTime", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetWorkingSetSize(ulong))
            {
                SCXProperty prop(L"WorkingSetSize", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetProcessSessionID(ulong))
            {
                SCXProperty prop(L"ProcessSessionID", ulong);
                inst.AddProperty(prop);
            }

            if (processinst->GetProcessTTY(name))
            {
                SCXProperty prop(L"ProcessTTY", StrFromMultibyte(name));
                inst.AddProperty(prop);
            }

            if (processinst->GetModulePath(name))
            {
                SCXProperty prop(L"ModulePath", StrFromMultibyte(name));
                inst.AddProperty(prop);
            }

            if (processinst->GetParameters(params))
            {
                std::vector<SCXProperty> props;
                for (std::vector<std::string>::const_iterator iter = params.begin();
                     iter != params.end(); ++iter)
                {
                    SCXProperty item(L"", StrFromMultibyte(*iter));
                    props.push_back(item);
                }
                SCXProperty prop(L"Parameters", props);
                inst.AddProperty(prop);
            }

            if (processinst->GetProcessWaitingForEvent(name))
            {
                SCXProperty prop(L"ProcessWaitingForEvent", StrFromMultibyte(name));
                inst.AddProperty(prop);
            }

            if (processinst->GetName(name))
            {
                SCXProperty name_prop(L"Name", StrFromMultibyte(name));
                inst.AddProperty(name_prop);
            }

            if (processinst->GetPriority(uint))
            {
                SCXProperty prio_prop(L"Priority", uint);
                inst.AddProperty(prio_prop);
            }

            if (processinst->GetExecutionState(ushort))
            {
                SCXProperty state_prop(L"ExecutionState", ushort);
                inst.AddProperty(state_prop);
            }

            if (processinst->GetCreationDate(ctime))
            {
                SCXProperty cdate_prop(L"CreationDate", ctime);
                inst.AddProperty(cdate_prop);
            }

            if (processinst->GetTerminationDate(ctime))
            {
                SCXProperty edate_prop(L"TerminationDate", ctime);
                inst.AddProperty(edate_prop);
            }

            if (processinst->GetParentProcessID(pid))
            {
                SCXProperty ppid_prop(L"ParentProcessID", StrFrom(pid));
                inst.AddProperty(ppid_prop);
            }

            if (processinst->GetRealUserID(ulong))
            {
                SCXProperty user_prop(L"RealUserID", ulong);
                inst.AddProperty(user_prop);
            }

            if (processinst->GetProcessGroupID(ulong))
            {
                SCXProperty group_prop(L"ProcessGroupID", ulong);
                inst.AddProperty(group_prop);
            }

            if (processinst->GetProcessNiceValue(uint))
            {
                SCXProperty nice_prop(L"ProcessNiceValue", uint);
                inst.AddProperty(nice_prop);
            }
        }

    }