I am setting up 4 Westermo switches and therefore I am making some software changes in C to decode the MIB packets. I am using IReasoning MIB Browser (RFC 1213) for this.
I am trying to get information from ifIndex (.1.3.6.1.2.1.2.2.1.1) but unfortunately I am not getting any data/values when I try to decode this OID. I am expecting data like 1,2,3,4,4096,4097,4098 etc which represents the port numbers for a switch.
However, I am able to decode other OIDs e.g sysDescr, sysUpTime, sysName, sysLocation, ifNumber, ifOperStatus.
Is there any additional checking that has to be done in C(which I have missed) although iReasoning MIB Browser displays this information when double clicked on it OR when I select to view in Table View.
Please advise.
Works for me, on the Lynx 210 on my desk, using the following command
snmpwalk -v2c -r5 -t3 -cpublic 192.168.2.200 1.3.6.1.2.1.2.2
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.17 = INTEGER: 17
IF-MIB::ifIndex.18 = INTEGER: 18
IF-MIB::ifIndex.4096 = INTEGER: 4096
IF-MIB::ifIndex.4097 = INTEGER: 4097
IF-MIB::ifIndex.4098 = INTEGER: 4098
IF-MIB::ifIndex.4099 = INTEGER: 4099
IF-MIB::ifIndex.4100 = INTEGER: 4100
IF-MIB::ifIndex.4101 = INTEGER: 4101
IF-MIB::ifIndex.4102 = INTEGER: 4102
IF-MIB::ifIndex.4103 = INTEGER: 4103
IF-MIB::ifIndex.4104 = INTEGER: 4104
IF-MIB::ifIndex.4105 = INTEGER: 4105
Related
This is my first question here, so hope it's correctly done.
Im trying to get some information from a ZTE C300 OLT.
The thing is when i try to get the SN of one of the ONTS I get the response in HEX-String
snmpwalk -cpublic -v2c [OLTIP] 1.3.6.1.4.1.3902.1082.500.10.2.2.5.1.2
And this is the response that I get
SNMPv2-SMI::enterprises.3902.1082.500.10.2.2.5.1.2.285278736.1 = Hex-STRING: 5A 54 45 47 C8 79 9B 27
This is the SN that i have on the OLT ZTEGC8799B27, but im trying to convert the HEX-STRING into text and i don't get that SN text.
Indeed i have a python script for SNMP and the response that i get for that OID is
{'1.3.6.1.4.1.3902.1082.500.10.2.2.5.1.2.285278736.1': "ZTEGÈy\x9b'"}
Can someone give me a hand on this?. I'm new on SNMP and this is giving me some headache.
Thanks in advace!
This is a 8 octet hex string, the first 4 octets are ASCII.
Just convert hex 2 ascii.
Indeed it was easier. The firts 4 bytes were encoded, and the other 4 is the actual serial number splitted every 2 digits. So i only need to decode the first part and concatenate the rest.
Works with OLT ZTE C320
def hex_str(str):
str = str.strip()
str = str.split(' ')
vendor_id = ''
serial = str[4:]
serial = "".join(serial)
for hex_byte in str[:4]:
vendor_id += chr(int(hex_byte, 16))
normalized_serial = vendor_id + serial
return normalized_serial
def ascii_to_hex(str):
arr = []
hex_byte = ''
for i in range(len(str)):
hex_byte += hex(ord(str[i]))
hex_byte = hex_byte.replace('0x', ' ')
hex_byte = hex_str(hex_byte)
return hex_byte
# value = f"5A 54 45 47 C8 79 9B 27 "
# value = f"49 54 42 53 8B 69 A2 45 "
# value = f"ZTEGÈy\x9b'"
value = f"ITBS2Lz/"
# value = f"ITBS2HP#"
if(len(value) == 24):
print(hex_str(value))
else:
print(ascii_to_hex(value))
Is there a way to get all OIDs by a given ifIndex ID using a wildcard? Say I have:
IF-MIB::ifIndex.513 = INTEGER: 513
Is there a way using snmpget or snmpbulkwalk to get only:
IF-MIB::ifIndex.513 = INTEGER: 513
IF-MIB::ifDescr.513 = STRING: Gi0/1
IF-MIB::ifType.513 = INTEGER: propVirtual(53)
IF-MIB::ifMtu.513 = INTEGER: 1420
IF-MIB::ifSpeed.513 = Gauge32: 0
The best way I can figure this out at present is to snmpwalk the device and use "| grep 513", which would be highly inefficient the more index id's I need to perform this on.
You can send single SNMP-GET request with multiple variable bindings to get the information you need:
snmpget -c public -v 2c <router_ip_address> ifIndex.513 ifDescr.513 ifType.513 ifMtu.513 ifSpeed.513
Reallly strange to me but here is the problem.
If I use an SNMP client such as ManageEngineMibBrowser to query the appliance I get what look like reasonable Numbers:
dpStatusMemoryStatusUsage.0 97
dpStatusMemoryStatusTotalMemory.0 33015552
dpStatusMemoryStatusUsedMemory.0 31928048
dpStatusMemoryStatusFreeMemory.0 1087504
dpStatusMemoryStatusReqMemory.0 4294967295
dpStatusMemoryStatusXG4Usage.0 4294967295
dpStatusMemoryStatusHoldMemory.0 4294967295
How do I justify Reasonable? Well simple maths shows that if TotalMemory is 3301552 and UsedMemory is 31928048 Then a percentage of 97% for Usage seems right (plus I double checked with the GUI :)
Now then I run the same commands on the same using snmpget on Linux and get the following (they are OIDS but in the same order as above):
SNMPv2-SMI::enterprises.14685.3.1.5.1.0 = Gauge32: 36
SNMPv2-SMI::enterprises.14685.3.1.5.2.0 = Gauge32: 99197400
SNMPv2-SMI::enterprises.14685.3.1.5.3.0 = Gauge32: 36004164
SNMPv2-SMI::enterprises.14685.3.1.5.4.0 = Gauge32: 63193236
SNMPv2-SMI::enterprises.14685.3.1.5.5.0 = Gauge32: 4294967295
SNMPv2-SMI::enterprises.14685.3.1.5.6.0 = Gauge32: 4294967295
SNMPv2-SMI::enterprises.14685.3.1.5.7.0 = Gauge32: 4294967295
As you can see they are all of the type Gauge32.... but the first 4 values are totally different! Do I need to do some kind of conversion? If so, Why are the first 4 different and the last 3 not when they are all of the same type? Am I being really dumb? :)
I have the following code:
MSCommProj.CommPort = 6
MSCommProj.RThreshold = 1
MSCommProj.Settings = "19200,N,8,1"
MSCommProj.InputLen = 0
MSCommProj.PortOpen = True
And it opens just fine and connects but when i try sending the command:
MSCommProj.Output = "21 8901 5057 31 0A" & Chr$(13)
and
MSCommProj.Output = "21 89 01 50 57 31 0A" & Chr$(13)
and
MSCommProj.Output = "3F 89 01 50 57 0A" & Chr$(13)
as instructed by the user manual, it does not come on.
Here is the pages in the manual that shows this. Maybe i am just doing it wrong?:
Are you sure that you're meant to be sending character data to the RS232 interface for that? Those look like binary sequences to me.
Rather than:
MSCommProj.Output = "3F 89 01 50 57 0A" & Chr$(13)
I'd be looking at transmitting the binary data thus:
MSCommProj.Output = chr$(63) & chr$(137) & chr$(1) & chr$(80) & chr$(87) & chr(10)
You'll note that there's no chr$(13) at the end, the spec doesn't call for that.
If you want to know what the conversions are for those hex values, start up the Windows calculator, change the view to scientific, switch to hex mode, enter the value, the switch to decimal mode.
Or you can download an ASCII table for this purpose. Or view one of my voluminous essays on the subject here.
You are required to send bytes given.
You instead send string representation of those.
Send actual bytes.
chr$(&h21) & chr$(&h89) & chr$(&h01) & chr$(&h50) etc.
It was because i did not use a cross-over cable... All the rs232 codes were correct. Blah.
Currently i use the following to figure it out:
For total memory:
.1.3.6.1.2.1.25.2.2.0
For used memory i walk the following oid (gives me usage of each process):
.1.3.6.1.2.1.25.5.1.1.2
and sum them all.
However, this is very inaccurate, because it shows much less usage than if i use WMI or the performance monitor.
Am i missing something? I do not want to use third party SNMP agents (like SNMP informant, which works correctly btw). I wanna figure it out using what's standard in windows.
Try 1.3.6.1.2.1.25.2.3.1. I received the following results with Net-SNMP's snmpwalk utility from one of our Windows Server 2003 servers:
$ snmpwalk -v1 -cpublic 10.200.80.221 1.3.6.1.2.1.25.2.3.1.3
HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: C:\ Label: Serial Number 38728140
HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: D:\
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: O:\ Label:Data Serial Number b618c4bc
HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: Q:\ Label:Quorum Serial Number 4cbbcc74
HOST-RESOURCES-MIB::hrStorageDescr.5 = STRING: Virtual Memory
HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: Physical Memory
$ snmpwalk -v1 -cpublic 10.200.80.221 1.3.6.1.2.1.25.2.3.1.4
HOST-RESOURCES-MIB::hrStorageAllocationUnits.1 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.2 = INTEGER: 0 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.3 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.4 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.5 = INTEGER: 65536 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.6 = INTEGER: 65536 Bytes
$ snmpwalk -v1 -cpublic 10.200.80.221 1.3.6.1.2.1.25.2.3.1.5
HOST-RESOURCES-MIB::hrStorageSize.1 = INTEGER: 17911195
HOST-RESOURCES-MIB::hrStorageSize.2 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageSize.3 = INTEGER: 66794245
HOST-RESOURCES-MIB::hrStorageSize.4 = INTEGER: 35836990
HOST-RESOURCES-MIB::hrStorageSize.5 = INTEGER: 128101
HOST-RESOURCES-MIB::hrStorageSize.6 = INTEGER: 98266
$ snmpwalk -v1 -cpublic 10.200.80.221 1.3.6.1.2.1.25.2.3.1.6
HOST-RESOURCES-MIB::hrStorageUsed.1 = INTEGER: 1365706
HOST-RESOURCES-MIB::hrStorageUsed.2 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageUsed.3 = INTEGER: 38290
HOST-RESOURCES-MIB::hrStorageUsed.4 = INTEGER: 17637
HOST-RESOURCES-MIB::hrStorageUsed.5 = INTEGER: 4819
HOST-RESOURCES-MIB::hrStorageUsed.6 = INTEGER: 6952
What is important here are the 5th and 6th rows of the tables. If you have fewer hard disks then you can find the values of virtual and physical memory in other rows.
You may either report this as a bug to Microsoft and wait for a fix, or simply switch to another agent.
Microsoft prefers WMI to SNMP, so you should know the agent is only a second class citizen on Windows.