0

I would like to user dart PowerSNMP for .NET to retrieve a list of all the processes and their respective pids and write them to the Visual Studio console whenever I receive a message in event. I assume this is done by walking the mib tree and then retrieving the actual values of a specific OID but I'm not too clear on how all this works.

For instance, assuming I have an agent that receives messages like so.

private void agent1_MessageReceived(Agent agent, RequestMessage request, object state)
{
        //print the processes and pids using power snmp
        String process = "";

        //concat processes and pids
                 ....


        Console.WriteLine(process);

 }
Lex Li
  • 60,503
  • 9
  • 116
  • 147
dimlee
  • 452
  • 1
  • 10
  • 22

2 Answers2

2

The library (or any other SNMP libraries) won't help you do all the tasks.

You have to implement the Host Resources MIB in your agent, so that the hrSWRunTable can then be queried by an SNMP manager,

http://www.net-snmp.org/docs/mibs/host.html#hrSWRunTable

To implement this table, you can use Process.GetProcesses as Charles indicated.

About how to extend PowerSNMP's agent, you can refer to its source code and also Dart's documentation.

Community
  • 1
  • 1
Lex Li
  • 60,503
  • 9
  • 116
  • 147
0

there is a function in .Net framework (System.Diagnostics.Process)

remember to include: using System.Diagnostics;

Process.GetProcesses();

that returns an array of processes

Charles Bretana
  • 143,358
  • 22
  • 150
  • 216
  • I need to do this with the PowerSNMP for .NET library. – dimlee Jun 10 '16 at 18:30
  • Sorry, I'm not familiar with that library, Since .Net is a framework library based system, I just assumed it must have a mechanism that allows it to call built in framework code like other .Net languages. – Charles Bretana Jun 10 '16 at 19:26