Hi,

Does anybody have the idea on Data collector sets in Reliability and performance monitor.. I want to programmatically delete all the existing data collector sets.. any pointers plzz..

I have found the following code, to do in Windows. http://msdn.microsoft.com/en-us/library/bb509350(VS.85).aspx

But I need to do it in C#. can anyone pl tell me where to begin with?

Dani AI

Generated

Short answer for (and ): the PLA COM API is the right approach. Use IDataCollectorSetCollection::GetDataCollectorSets with the Service namespace to retrieve only the user-created (User Defined) data collector sets, then stop any running set and call IDataCollectorSet::Delete to remove its persisted copy. (learn.microsoft.com)

Practical pattern (C#): instantiate the PLA collection via its ProgID, ask for the Service namespace, enumerate the collection (use Count/Item or the COM enumerator), stop running sets, then Delete each set. Example using late binding/dynamic so you don't need the interop wrapper types:

// Example (requires running as admin)
Type t = Type.GetTypeFromProgID("PLA.DataCollectorSetCollection");
dynamic sets = Activator.CreateInstance(t);
sets.GetDataCollectorSets(null, "Service\\*");   // only user-defined sets

for (int i = sets.Count - 1; i >= 0; i--) {      // iterate backwards when deleting
    dynamic set = sets.Item(i);
    try { set.Stop(false); } catch { /* ignore if not running */ }
    try { set.Delete(); } catch (System.Runtime.InteropServices.COMException ex) {
        // log/inspect ex.HResult (permission, in-use, etc.)
    }
}

Notes and troubleshooting

  • Delete will remove the persisted set only if it is not running; Stop first to avoid errors. (learn.microsoft.com)
  • The collection can be filled for other namespaces too (Session, System, Autosession, Legacy); omit or change the filter if you need different sets. Use Count/Item or the _NewEnum enumerator to walk results. (learn.microsoft.com)
  • You must have appropriate permissions (administrator / Performance Log Users depending on action) — Commits/deletes can fail with access errors. Also system namespace sets are read-only. (learn.microsoft.com)

If enumeration returns nothing, try GetDataCollectorSets(null, null) to list every namespace, inspect each set.Name/DisplayName/Status and then filter by whatever rule you need.

I have just started with this..

using PlaLibrary;
......
......
......
DataCollectorSet dcs = new DataCollectorSetClass();

IDataCollectorSetCollection dcsCollection = new DataCollectorSetCollection();

dcsCollection.GetDataCollectorSets(null, null);

From the above method/any, is there a way to get the list of only user defined data collector sets?

PLease does anyone have an answer to this question? I am trying to get a list of all DataCollectorSets in the first place, with the intention to filter on the user defined afterwards, but I cant realize to gt a list at all... The GetDataCollectors(null,null) method unfortunately does not return something I am able to work with... :( TY

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.