03-18-2013 09:58 AM
For anyone looking for a way to do SNMP withing LabWindows, try the function panel located at http://www.kazimer.com/downloads/. These functions work, and they are very easy to use.
By request of the author, I am not posting his files on the NI website. But I told him, if he ever disappears, I will.
01-13-2016 03:59 PM
I am attempting to use these libraries to turn on and off ports on a Cisco SG200-18 switch using SNMP. I am not primarily a networking engineer.
Here are the Steps I took
1. Windows Side: Added the SNMP Service and SNMP Trap Service on Windows( Community set up with read and write access)
2. On the device html page
1. Enabled SNMP under security
2. Set up a read and write community
3. Enabled traps and Notifications
I noticed the the SNMP default view has 8 OID's ? Do they correspond to the 16 ports ?? Eg 1.3.6.1.6.3.13
Downloaded the kazimer fp.
I can start a session with the correct community name. I can get these 8 OID's and Get and Set them
What should I add to these eg 1.3.6.1.6.3.13.??? to be able to programitcally enable or disable a port?
I found the device Mib here
https://software.cisco.com/download/type.html?mdfid=283783779&catid=null
But cannot interpret them. Please help .
01-13-2016 04:54 PM
I have to dust off my brain -- last time I worked on this was well over a year ago. What helped me was to download and use a canned SNMP diagnostics program, such as Getif. This allows expansion of the OIDs so they can be better understood, with english descriptions. At the moment I can't remember how to use it. I'll be unavailable until Monday. Let me know if you still need help then.
Make sure th include the snmp_.lib, .fp and .h files in your project. Not sure the dll needs tobe part of your project, but it needs to be installed in the right place.
Something here might help. This was done to control an NTI networked AC power distribution unit.
char OID[1024];
char NTI_IPDU_Community[255] = "private";
// NTI IPDU Outlet Relay Control OIDs
struct {
int OutletOnOffBtnCtrl;
char OidText[128];
char OidNumber[64];
int OutletOnOffState;
} GantryPDU[8] = { {EQUIPRDTAB_IPDU_OUTLET_BTN_1, "ipdusx.masterUnit.rlyOutputs.rlyOutputTable.rlyOutputEntry.rlyOutputValue",
".1.3.6.1.4.1.3699.1.1.6.1.7.1.1.5.1"},
{EQUIPRDTAB_IPDU_OUTLET_BTN_2, "ipdusx.masterUnit.rlyOutputs.rlyOutputTable.rlyOutputEntry.rlyOutputValue",
".1.3.6.1.4.1.3699.1.1.6.1.7.1.1.5.2"},
{EQUIPRDTAB_IPDU_OUTLET_BTN_3, "ipdusx.masterUnit.rlyOutputs.rlyOutputTable.rlyOutputEntry.rlyOutputValue",
".1.3.6.1.4.1.3699.1.1.6.1.7.1.1.5.3"},
{EQUIPRDTAB_IPDU_OUTLET_BTN_4, "ipdusx.masterUnit.rlyOutputs.rlyOutputTable.rlyOutputEntry.rlyOutputValue",
".1.3.6.1.4.1.3699.1.1.6.1.7.1.1.5.4"},
{EQUIPRDTAB_IPDU_OUTLET_BTN_5, "ipdusx.masterUnit.rlyOutputs.rlyOutputTable.rlyOutputEntry.rlyOutputValue",
".1.3.6.1.4.1.3699.1.1.6.1.7.1.1.5.5"},
{EQUIPRDTAB_IPDU_OUTLET_BTN_6, "ipdusx.masterUnit.rlyOutputs.rlyOutputTable.rlyOutputEntry.rlyOutputValue",
".1.3.6.1.4.1.3699.1.1.6.1.7.1.1.5.6"},
{EQUIPRDTAB_IPDU_OUTLET_BTN_7, "ipdusx.masterUnit.rlyOutputs.rlyOutputTable.rlyOutputEntry.rlyOutputValue",
".1.3.6.1.4.1.3699.1.1.6.1.7.1.1.5.7"},
{EQUIPRDTAB_IPDU_OUTLET_BTN_8, "ipdusx.masterUnit.rlyOutputs.rlyOutputTable.rlyOutputEntry.rlyOutputValue",
".1.3.6.1.4.1.3699.1.1.6.1.7.1.1.5.8"} };
// NTI IPDU System OIDs
struct {
char OidText[256];
char OidNumber[64];
} NTI_IPDU_SysOids[5] = { {"ipdusx.masterUnit.hostSystem.sysTime",
".1.3.6.1.4.1.3699.1.1.6.1.1.1.0"},
{"ipdusx.masterUnit.hostSystem.sysEnterpriseName",
".1.3.6.1.4.1.3699.1.1.6.1.1.2.0"},
{"ipdusx.masterUnit.hostSystem.sysEnterpriseLocation",
".1.3.6.1.4.1.3699.1.1.6.1.1.3.0"},
{"ipdusx.masterUnit.hostSystem.sysEnterpriseContact",
".1.3.6.1.4.1.3699.1.1.6.1.1.4.0"},
{"ipdusx.masterUnit.hostSystem.sysEnterprisePhone",
".1.3.6.1.4.1.3699.1.1.6.1.1.5.0"} };
// NTI IPDU Voltage, Current, Temperature and RH OIDs
struct {
int SnsrNumCtrl;
char OidText[128];
char OidNumber[64];
int Value;
} NTI_IPDU_Sensors[4] = { {EQUIPRDTAB_GANTRY_PDU_VOLTAGE, "ipdusx.masterUnit.intSensors.intSensorTable.intSensorEntry.intSensorValue",
".1.3.6.1.4.1.3699.1.1.6.1.4.1.1.6.1"},
{EQUIPRDTAB_GANTRY_PDU_CURRENT, "ipdusx.masterUnit.intSensors.intSensorTable.intSensorEntry.intSensorValue",
".1.3.6.1.4.1.3699.1.1.6.1.4.1.1.6.2"},
{EQUIPRDTAB_GANTRY_PDU_TEMP, "ipdusx.masterUnit.extSensors.extSensorTable.extSensorEntry.extSensorValue",
".1.3.6.1.4.1.3699.1.1.6.1.5.1.1.7.1"},
{EQUIPRDTAB_GANTRY_PDU_RH_NUM, "ipdusx.masterUnit.extSensors.extSensorTable.extSensorEntry.extSensorValue",
".1.3.6.1.4.1.3699.1.1.6.1.5.1.1.7.2"} };
// ------------------------------------------------------------------------------------------------------------------
01-20-2016 10:12 AM
I did find the OID but am still having issues. Right now I am just playing with demo prj. I am trying to narrow down the issue.
Let me describe my procedure in detail
1. Enabled SNMP on the Cisco Switch. I accessed the html page of the switch to do this Here is how I did this:
1. Go To Change Management and Application Services
2. Click Enable SNMP Service Checkbox(attached)
3. Add a view PortTest to the views under SNMP. ( Select interfaces, this gives the OID I need, if I add2.1.7.port number I have the OID for ifadminstatus for that port)(attached)
4. Add Community (attached) with IP address of connecting PC. Ensure I have read and write access and the correct view name PortTest.
5. Enabled traps and Notifications under trap setting
6. Add Notification reciepients SNMPv1,2 with the Ip address of connecting PC, Community Name and SNMP V2 checked.
2. I am assuming that the CVI libraries use the windows service so I installed it.
1. Add/Remove Program -> turn on/off windows features
2. Check both SNMP check boxes
3. Services -> set both SNMP service and SNMp Tarp to Automatic , started
4. Under snmp Service add the community name(read and write) and host ie switch name under security, Also add the community name and host ie switch name snmp Service -> trap
Now I use the demo example. I start a session with the IP address of Switch and the Community name, I try to get or set values. Get always gives me 0 and unknown type and set has no effect on the device .
Questions
1. Is there a windows or switch set up issue?
2. Can I test this with a test application outside these libraries?
3. Is a fire wall blocking me, How do I know that?
03-02-2016 04:02 PM - edited 03-02-2016 04:02 PM
This has been solved. One must walk the tree with a mib browser like ireasoning to understand what OID to send. The actual OID is a combination of the view OID and the remaining part.
03-02-2016 04:04 PM
Exactly. I'm glad you figured this out. It had been so long since I worked with the SNMP function panel, I forgot what application I used to walk the MIB. So i was not much help.
04-18-2022 11:23 PM
Hi everyone,
11-30-2022 05:40 PM - edited 11-30-2022 05:49 PM
Folks,
1) I am amazed that this 20 year old code still works with LabWindows!
2) For numeric OIDs, adding a leading dot. Example: Use .1.3.6.1.6.3.10 and not 1.3.6.1.6.3.10. If you are using the OIDprefix, add the leading dot in the OIDprefix. Otherwise, set OIDprefix to NULL, then set OID to the full OID with a leading dot.
3) The OIDprefix was meant for cases where you are using a bunch of equipment from a single manufacturer. You can enter the manufacturer portion of the OID that is common to all the equipment you are using in the OIDprefix. Then the rest of the OID for each separate device goes into the OID variable. It was supposed to be a shortcut, but it just seems to confuse people. It is fine not to use the OIDprefix, just set it to NULL.
4) Functions starting with "SNMP_" were meant to be public functions. Everything starting with "snmp_" or anything else is considered a private/internal function; you should not need to call these directly, and doing so may cause problems.
5) Text OIDs will not work unless you install an MIB file on the OS that you are running this code on. Search for help on how to do this for your OS and equipment. Otherwise, use numeric OIDs.
Good luck!
12-03-2022 11:13 AM
I am amazed you are still around 9 years later. And don't be amazed a 20-year-old CVI library still works. If it had been LabView, it wouldn't have worked 5 years later.
12-05-2022 12:05 PM
hendra@ngms wrote:
I am amazed you are still around 9 years later. And don't be amazed a 20-year-old CVI library still works. If it had been LabView, it wouldn't have worked 5 years later.
Actually the OpenG libraries are about as old or older, and they still mostly work just fine unless the underlaying OS changed things somehow, but that is not something you can anticipate in any programming language. 😀
The fact that a lot of LabVIEW VIs are programmed poorly because it allows non-programmers to actually do something even though it may be horrible code, doesn't mean that you can't write proper VI libraries in LabVIEW. 😁