आप और इस तरह से गूगल "MinimalisticTelnet" के लिए टेलनेट प्रोग्राम का उपयोग उदाहरण उपयोग कर सकते हैं इस समाधान
एक और तरीका समझने के लिए SNMP के लिए इस्तेमाल होता है इस उदाहरण के रूप में प्रोटोकॉल: नोटिस: SNMP के साथ काम करने के लिए मैं परिवर्तन लाने के लिए और SnmpSharpNet पुस्तकालय को अनुकूलित, और मेरे कार्यक्रम में इसे कहते
using SnmpSharpNet;
फिर 1 से 6 तक अक्षम बंदरगाहों के लिए इस कोड को लिखें:
Console.WriteLine("Ports Disabler ");
UdpTarget target = new UdpTarget((IPAddress)new IpAddress("192.168.1.200"));
Pdu pdu = new Pdu(PduType.Set);
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.1"), new Integer32(2));
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.2"), new Integer32(2));
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.3"), new Integer32(2));
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.4"), new Integer32(2));
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.5"), new Integer32(2));
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.6"), new Integer32(2));
AgentParameters aparam = new AgentParameters(SnmpVersion.Ver2, new OctetString("2645"));
SnmpV2Packet response;
try
{
// Send request and wait for response
response = target.Request(pdu, aparam) as SnmpV2Packet;
}
catch (Exception ex)
{
// If exception happens, it will be returned here
Console.WriteLine(String.Format("Request failed with exception: {0}", ex.Message));
target.Close();
return;
}
// Make sure we received a response
if (response == null)
{
Console.WriteLine("Error in sending SNMP request.");
}
else
{
// Check if we received an SNMP error from the agent
if (response.Pdu.ErrorStatus != 0)
{
Console.WriteLine(String.Format("SNMP agent returned ErrorStatus {0} on index {1}",
response.Pdu.ErrorStatus, response.Pdu.ErrorIndex) + response.ToString());
}
else
{
// Everything is ok. Agent will return the new value for the OID we changed
Console.WriteLine(String.Format("Agent response {0}: {1}",
response.Pdu[0].Oid.ToString(), response.Pdu[0].Value.ToString()));
}
}
मुझे आशा है कि यह उत्तर उपयोगी हो सकता है और आप मदद कर सकते हैं,
धन्यवाद निएल, आपकी जानकारी बहुत उपयोगी है। मैं अब उन पर अध्ययन करने जा रहा हूं। आप सही हैं, मुझे लगता है कि दूसरा विकल्प शायद मैं जो सोच रहा हूं। लेकिन जैसा कि आपने पहले सुझाव दिया था, मैं इसे आजमाने की कोशिश कर रहा हूं। : पी – tingfungc
मदद की खुशी है। –
मैंने टेलनेट कनेक्शन को सक्षम करने और स्विच से सफलतापूर्वक कनेक्ट करने का प्रयास किया है। तो बंदरगाह स्विचिंग करने के लिए एक सी # प्रोग्राम लिखना काफी सरल होगा। आपके विकल्प 1 के लिए धन्यवाद niall। इसके अलावा, मेरे मालिक अभी भी इस समस्या में एसएनएमपी का उपयोग करना चाहते हैं, इसलिए मैं अब विकल्प 2 का प्रयास करने जा रहा हूं। तो 1.3.6.1.2.1.2.2.1.7 लक्ष्य ओआईडी है और यह एक पूर्णांक प्रकार मान है। लेकिन मेरे पास पूरी तरह से 24 बंदरगाह हैं (फास्टइथरनेट 1-24), तो 24 मूल्य और ओआईडी होना चाहिए? – tingfungc