Search code examples
c#snmp

Query printer status on my d-link print server


I have an d-link dp-311p print server which provides the printer status(offline, paper out, etc) on it's interface. How can i get this oid status ?? i'm trying to find through axence nettools but there is A LOT of keys and the descriptions are not friendly... Also, i'm trying to use this code(c#) to access the print server status but no success... please, need a light, i'm completely lost! Tks everyone


Solution

  • I did it! Here is how: Search for mib browser because I didn't know the oid of the print server status. Found This one, then, I created a console app like this

    OLEPRNLib.SNMP snmp = new OLEPRNLib.SNMP();
    int Retries = 1;
    int TimeoutInMS = 2000;
    string CommunityString = "public";
    string IPAddressOfPrinter = "192.168.1.12";
    string ALLINEED;
    
    // Open the SNMP connect to the print server
    snmp.Open(IPAddressOfPrinter, CommunityString, Retries, TimeoutInMS);
    ALLINEED = snmp.Get(".1.3.6.1.4.1.11.2.3.9.1.1.3.0");
    snmp.Close();
    
    Console.Write(ALLINEED);
    

    On my machine I made a reference on the COM tab of the Add Reference dialog to “oleprn 1.0 Type Library“ which lived in “c:\Windows\System32\oleprn.dll“

    Hope this can help someone.

    Tks