Why does snmpget output give strange numbers as the result (unsigned32?) - bash

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? :)

Related

Get all oids by ifindex ID and wildcard

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

Decoding ifIndex is not returning any values

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

Encrypt and Decrypt AES with Golang and Ruby

I'm working on making two secure systems talk via a common encryption scheme. I picked AES as it seems a secure standard, but I'm not married to it, so long as I have two way encryption.
Here is the Go source and Ruby source simplified down to a really clear example to run from command line and see the differences. I'm outputting bytecode for easier literal comparison.
I'm using 128 bit CFB in both, and neither of them appear to have padding, any help is greatly appreciated!
You passed wrong key size in Ruby code. It should be 192. (because key.size is 24 bytes == 192 bits)
cipher = OpenSSL::Cipher::AES.new(192, :CFB)
cipher.encrypt
cipher.key = key
cipher.iv = iv
encrypted = cipher.update(input) + cipher.final()
puts "Output: [" + encrypted.bytes.join(" ") + "]"
output:
Output: [155 79 127 80 31 163 142 111 13 211 221 163 219 248]

Checking if pixel belongs to an image

I have written the following function that find if a pixel belongs to an image in matlab.
At the beginning, I wanted to test it as if a number in a set belongs to a vector like the following:
function traverse_pixels(img)
for i:1:length(img)
c(i) = img(i)
end
But, when I run the following commands for example, I get the error shown at the end:
>> A = [ 34 565 456 535 34 54 5 5 4532 434 2345 234 32332434];
>> traverse_pixels(A);
??? Error: File: traverse_pixels.m Line: 2 Column: 6
Unexpected MATLAB operator.
Why is that? How can I fix the problem?
Thanks.
There is a syntax error in the head of your for loop, it's supposed to be:
for i = 1:length(img)
Also, to check if an array contains a specific value you could use:
A = [1 2 3]
if sum(A==2)>0
disp('there is at least one 2 in A')
end
This should be faster since no for loop is included.
for i = 1:length(image)
silly error, not : , it is =

Figure out memory usage using SNMP on Windows

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.

Resources