LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SNMP in LabWindows!

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.

0 Kudos
Message 1 of 10
(5,066 Views)

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 .

 

 

 

0 Kudos
Message 2 of 10
(4,475 Views)

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"} };
// ------------------------------------------------------------------------------------------------------------------

 

0 Kudos
Message 3 of 10
(4,470 Views)

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?

Download All
0 Kudos
Message 4 of 10
(4,402 Views)

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. 

0 Kudos
Message 5 of 10
(4,241 Views)

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.

0 Kudos
Message 6 of 10
(4,238 Views)

Hi everyone, 

 

i have downloaded SNMP Function Panel from https://www.kazimer.com/downloads and use Demo project
 
i started a session. then i tried to perform a set or get operation, i.e,  set a value or get a value, by using SNMP_SetInt or SNMP_Get commands. 
 
While monitoring with wireshark, i realized that the OID  changed in the sense that, there is a prefix added to my OID. please check the picture attached. 
My original OID is 1.3.6.1.4.1.24912.1.11.7.6.1.0 and i didn't add and prefix or any other value to that ODI. 
however i have monitored that the "1.3.6.1.2.1." prefix was added to my OID.
 
Btw, the word “prefix” may result a missunderstanding. i would like to give additional information about the unwanted "prefix". The code (function panel) has a “snmp_setOIDPrefix” command and it works well. and i used that command by setting the prefix as “null” (just in case). 

i debug the code. The oid is correct till the oid is written to an object called “regObject”. (See attachment)

this is defined in the code as an OID internal representation (see attachment)

Untill here, the oid is correct as “1.3.6.1.4.1.24912….”(see attachment)

After than, there is a magic and the oid turns to “1.3.6.1.2.1.1.3.6.1.4.1.24912…”
The “1.3.6.1.2.1.” Part is somehow added to the beginning of my original oid (see attachment)
as i understand that this “1.3.6.1.2.1.” part is related with the windows sdk and comes from the mib. 
 
How can i solve that, i mean, i don't need the "1.3.6.1.2.1." prefix and how can stop adding that "1.3.6.1.2.1." prefix to my original OID.
 
Thanks!
0 Kudos
Message 7 of 10
(1,867 Views)

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!

0 Kudos
Message 8 of 10
(1,464 Views)

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.

0 Kudos
Message 9 of 10
(1,426 Views)

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. 😁

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 10
(1,396 Views)