Sponsored Content
Full Discussion: Problems with SNMP(dev)
Top Forums Programming Problems with SNMP(dev) Post 302535022 by blast on Wednesday 29th of June 2011 11:37:12 AM
Old 06-29-2011
Problems with SNMP(dev)

Hi all,

I'm trying to develop a aplication in c to get the arp table from a router, i know the OID and using a snmpwalk (shell command) i can get it.
When i tried to code i saw an example but it was with pdu type SNMP_MSG_GET, but it gives an error (no such oid).

i found (with trace) that snmpwalk use a SNMP_MSG_GETNEXT, but when using it i just get the first MAC address without knowing from what ip is...

I can't found a good understandable example with GETNEXT..

Can anyone help? any good example? our know how to do it?



My code (juts the important part, i think):
Code:
pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);

get_node("IP-MIB::ipNetToMediaPhysAddress",id_oid, &id_len);
snmp_add_null_var(pdu,id_oid, id_len);
status=snmp_synch_response(ss_handle, pdu, &response);
for(vars = response->variables;vars;vars=vars->next_variable)
      print_value(vars->name,vars->name_length,vars);

output:
STRING: ca:0:58:c0:0:8



I need something like this (to get the ip/MAC to put it in a DB)....

[root@localhost ~]# snmpwalk -v2c -c public 192.168.56.100 IP-MIB::ipNetToMediaPhysAddress
IP-MIB::ipNetToMediaPhysAddress.1.192.168.56.1 = STRING: 8:0:27:0:cc:e1
IP-MIB::ipNetToMediaPhysAddress.1.192.168.56.100 = STRING: ca:0:6:70:0:8
IP-MIB::ipNetToMediaPhysAddress.1.192.168.56.101 = STRING: 8:0:27:35:5c:da


Many Thanks!

Last edited by jim mcnamara; 06-29-2011 at 06:05 PM..
 

10 More Discussions You Might Find Interesting

1. Solaris

What is /dev/tty /dev/null and /dev/console

Hi, Anyone can help My solaris 8 system has the following /dev/null , /dev/tty and /dev/console All permission are lrwxrwxrwx Can this be change to a non-world write ?? any impact ?? (12 Replies)
Discussion started by: civic2005
12 Replies

2. SCO

Xenix Problems - No space on dev 1/40

Hello - I'm a newbie to these forums. Please excuse me if I am posting in the wrong area. My dilemma. The HD on our ancient Xenix system apparently is full. I receive the "no space on dev 1/40" prompt. This occurred after I attempted to purge some unwanted files. This system runs our small... (1 Reply)
Discussion started by: gmbrickley
1 Replies

3. Infrastructure Monitoring

problems with Net-snmp to use with Nagios Check_hpjd

In order to get the Check_hpjd plugin for nagios to work, i have to get net-snmp (+utils) installed. If i look in the yast Control center, iwe installed everything that should have something to do with snmp. This is my first time with linux, so im abit of a noob. how do i get the plugin... (0 Replies)
Discussion started by: Nikos
0 Replies

4. IP Networking

Sending data from DELL OMSA SNMP and Custom SNMP MIB to same UDP port 161

Hi , Currently DELL OMSA SNMP sends data through default udp port 161.I want my custom SNMP MIB also to send data in the same udp port 161.Whether its possible.If yes where to configure .I tried starting my custom MIB in udp port 161,but it throws port already in use.Kindly guide. (0 Replies)
Discussion started by: prabakar4all
0 Replies

5. Red Hat

Sending data from DELL OMSA SNMP and Custom SNMP MIB to same UDP port 161

Hi , Currently DELL OMSA SNMP sends data through default udp port 161.I want my custom SNMP MIB also to send data in the same udp port 161.Whether its possible.If yes where to configure .I tried starting my custom MIB in udp port 161,but it throws port already in use.Kindly guide. (1 Reply)
Discussion started by: prabakar4all
1 Replies

6. IP Networking

SNMP packet reception problems

server A is forwarding an snmp packets to server B on agreed port. server B is listening but getting nothing on the port. Rather, packets are arriving on a different port. What can i do to receive the packets on the agreed port? (1 Reply)
Discussion started by: kamuvi71
1 Replies

7. Solaris

Lun remove, stuck in /dev/dsk and /dev/rdsk

So, we removed a LUN from the SAN and the system is refusing to remove the references to it in the /dev folder. I've done the following: devfsadm -Cv powermt -q luxadm -e offline <drive path> luxadm probe All those commands failed to remove the path. The drive stills shows up as <drive... (13 Replies)
Discussion started by: DustinT
13 Replies

8. UNIX for Dummies Questions & Answers

Need to transfer all kernel logs (var/log/messages) to the snmp listener as snmp trap

i am working with embedded system -Dell DCS management sub system. my question is as below: currently we are using linux kernel 2.6.30 build and we have a kernel logs stored to the /var/log/messages path. now we have to transfer all this logs to the specified SNMP target as a part of SNMP... (4 Replies)
Discussion started by: vipul_prajapati
4 Replies

9. Shell Programming and Scripting

Automating partitioning setup of /dev/sda on /dev/sdc

Objective: To recreate the partitioning setup of /dev/sda on /dev/sdc How would I parse the below information and initialize variables (an array?) that can be used to build sgdisk commands in a script, regardless of the number of partitions? Something along the lines of: sgdisk -n... (12 Replies)
Discussion started by: RogerBaran
12 Replies

10. Red Hat

Changing grub from /dev/sda to /dev/sdb

Hi, Please suggest steps to change grub from /dev/sda to /dev/sdb, (1 Reply)
Discussion started by: manoj.solaris
1 Replies
SNMPWALK(1)							     Net-SNMP							       SNMPWALK(1)

NAME
snmpwalk - retrieve a subtree of management values using SNMP GETNEXT requests SYNOPSIS
snmpwalk [APPLICATION OPTIONS] [COMMON OPTIONS] [OID] DESCRIPTION
snmpwalk is an SNMP application that uses SNMP GETNEXT requests to query a network entity for a tree of information. An object identifier (OID) may be given on the command line. This OID specifies which portion of the object identifier space will be searched using GETNEXT requests. All variables in the subtree below the given OID are queried and their values presented to the user. Each variable name is given in the format specified in variables(5). If no OID argument is present, snmpwalk will search the subtree rooted at SNMPv2-SMI::mib-2 (including any MIB object values from other MIB modules, that are defined as lying within this subtree). If the network entity has an error processing the request packet, an error packet will be returned and a message will be shown, helping to pinpoint why the request was malformed. If the tree search causes attempts to search beyond the end of the MIB, the message "End of MIB" will be displayed. OPTIONS
-Cc Do not check whether the returned OIDs are increasing. Some agents (LaserJets are an example) return OIDs out of order, but can complete the walk anyway. Other agents return OIDs that are out of order and can cause snmpwalk to loop indefinitely. By default, snmpwalk tries to detect this behavior and warns you when it hits an agent acting illegally. Use -Cc to turn off this check. -CE {OID} End the walk at the specified OID, rather than a simple subtree. This can be used to walk a partial subtree, selected columns of a table, or even two or more tables within a single command. -Ci Include the given OID in the search range. Normally snmpwalk uses GETNEXT requests starting with the OID you specified and returns all results in the MIB subtree rooted at that OID. Sometimes, you may wish to include the OID specified on the command line in the printed results if it is a valid OID in the tree itself. This option lets you do this explicitly. -CI In fact, the given OID will be retrieved automatically if the main subtree walk returns no useable values. This allows a walk of a single instance to behave as generally expected, and return the specified instance value. This option turns off this final GET request, so a walk of a single instance will return nothing. -Cp Upon completion of the walk, print the number of variables found. -Ct Upon completion of the walk, print the total wall-clock time it took to collect the data (in seconds). Note that the timer is started just before the beginning of the data request series and stopped just after it finishes. Most importantly, this means that it does not include snmp library initialization, shutdown, argument processing, and any other overhead. In addition to these options, snmpwalk takes the common options described in the snmpcmd(1) manual page. EXAMPLES
The command: snmpwalk -Os -c public -v 1 zeus system will retrieve all of the variables under system: sysDescr.0 = STRING: "SunOS zeus.net.cmu.edu 4.1.3_U1 1 sun4m" sysObjectID.0 = OID: enterprises.hp.nm.hpsystem.10.1.1 sysUpTime.0 = Timeticks: (155274552) 17 days, 23:19:05 sysContact.0 = STRING: "" sysName.0 = STRING: "zeus.net.cmu.edu" sysLocation.0 = STRING: "" sysServices.0 = INTEGER: 72 (plus the contents of the sysORTable). The command: snmpwalk -Os -c public -v 1 -CE sysORTable zeus system will retrieve the scalar values, but omit the sysORTable. SEE ALSO
snmpcmd(1), snmpbulkwalk(1), variables(5). 4th Berkeley Distribution 08 Feb 2002 SNMPWALK(1)
All times are GMT -4. The time now is 01:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy