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.
Related
I'm pretty new to coding. I'm trying to read a PT100 rtd via my Raspberry Pi 3. I read that I needed the Max31865 RTD amplifier to properly read the data because the resistances are so small. I am fairly certain I have it plugged in correctly.
I'm using this code, only slightly editted.
https://github.com/steve71/MAX31865
I'm getting two different outputs so far but it doesn't seem to correlate with anything I'm changing (The byte associated with the readTemp mostly) since I've run the same code twice and gotten both outputs. The outputs are as follows:
config register byte: ff
RTD ADC Code: 32767
PT100 Resistance: 429.986877 ohms
Straight Line Approx. Temp: 767.968750 degC
Callendar-Van Dusen Temp (degC > 0): 988.792111 degC
high fault threshold: 32767
low fault threshold: 32767
and
config register byte: 08
RTD ADC Code: 0
PT100 Resistance: 0.000000 ohms
Straight Line Approx. Temp: -256.000000 degC
Callendar-Van Dusen Temp (degC > 0): -246.861024 degC
high fault threshold: 0
low fault threshold: 0
Any help would be appreciated.
I'am dealing exactly with the same issue right now. Do you use your Pt100 with 3- or 4-wires?
I fixed the problem by setting the correct configuration status register in Line 78 of the original code (https://github.com/steve71/MAX31865) to 0xA2
self.writeRegister(0, 0xA2)
I am using 4-wires, so i had to change bit4 from 1 (3-wires) to 0 (2- or 4-wires)
0xb10100010
After this, i've got this as output
config register byte: 80
RTD ADC Code: 8333
PT100 Resistance: 101.721191 ohms
Straight Line Approx. Temp: 4.406250 degC
Callendar-Van Dusen Temp (degC > 0): 4.406808 degC
high fault threshold: 32767
low fault threshold: 0
Brrr... it's very cold in my room, isn't it? To fix this, i had to change the reference resistance in Line 170 to 430 Ohm
R_REF = 430.0 # Reference Resistor
It's curious, because i red a lot of times, there is a 400 Ohm resistance mounted on this devices as the reference. Indeed, on the SMD resistor is a 3-digit Code "431" which means 430 Ohm. Humm...
But now i have it nice and warm in here
Callendar-Van Dusen Temp (degC > 0): 25.091629 degC
Best regards
Did you get this resolved ? In case you didn't, the below python class method works for me. I remember that I had some trouble with wiring the force terminals, from memory for 2-wire you have to bridge both force terminals.
def _take_Resistance_Reading(self):
msg = '%s: taking resistance reading...' % self.Name
try:
self.Logger.debug(msg + 'entered method take_resistance_Reading()')
with self._RLock:
reg = self.spi.readbytes(9)
del reg[0] # delete 0th dummy data
self.Logger.debug("%s: register values: %s", self.Name, reg)
RTDdata = reg[1] << 8 | reg[2]
self.Logger.debug("%s: RTD data: %s", self.Name, hex(RTDdata))
ADCcode = RTDdata >> 1
self.Logger.debug("%s: ADC code: %s", self.Name, hex(ADCcode))
self.Vout = ADCcode
self._Resistance = round(ADCcode * self.Rref / 8192, 1)
self.Logger.debug(msg + "success, Vout: %s, resistance: %s Ohm" % (self.Vout, self._Resistance))
return True
except Exception as e:
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
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
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'd like to do the equivalent of what I can do in C via:
pread(fdesc, tgtbuf, size, file_offset);
or the combination:
lseek(fd, file_offset, SEEK_SET);
read(fd, tgtbuf, size)
as a shell command.
For some sizes/offsets, one can use:
dd if=file bs=size skip=$((file_offset/size)) count=1
That works ... but only if file_offset is divisible by size. Which isn't sufficient for my usecase, unfortunately.
The device I'm attempting to read from is "blocked" in 8-byte units for read but allows (requires) byte offsets for seek. dd always reads in units of bs/ibs but also always seeks in these units, which in my case is mutually exclusive.
I know I can do this via perl/python/C/... - but is there a way to do this from a simple shell script ?
EDIT: Since it was suggested to use dd bs=1 count=8 ... here - NO THIS DOES NOT WORK. strace it and you'll see that this does:
$ strace -e lseek,read dd if=/dev/zero bs=1 skip=1234 count=8
[ ... ]
lseek(0, 1234, SEEK_CUR) = 0
read(0, "\0", 1) = 1
read(0, "\0", 1) = 1
read(0, "\0", 1) = 1
read(0, "\0", 1) = 1
read(0, "\0", 1) = 1
read(0, "\0", 1) = 1
read(0, "\0", 1) = 1
read(0, "\0", 1) = 1
Which is not what I need - it must be a single read().
Edit2:
The device (/dev/cpu/<ID>/msr) I'm trying to read from is strange in the sense that the offset is treated as an index number, but you'll always have to read eight bytes else the driver gives EINVAL on read.
But every index returns a different 8-byte value, so you cannot "reconstruct" reading from offset x+1 by reading x and x+8 and extracting the bytes. This is highly unusual ... but it's the way /dev/cpu/<ID>/msr works in Linux.
bs=size : size can be 1 byte, or more ... (it is an indication to dd on how to access the device, but for a file you can use whatever you need.. it's usually more efficient reading blocks of larger sizes, though)
try:
dd if=file bs=1 skip=whateveryouneed count=8 #to read 8 bytes starting at whateveryouneed
if (contrary to what you seem to state in the question) you can only seek to multiple of 8 (and read 8 bytes from there):
dd if=file bs=8 skip=X count=1 #to read 8 bytes starting at whateveryouneed
#X being: whateveryouneed / 8 (ex: echo "4000 / 8" | bc )
(as I say in my comment, I really have troubles to imagine a device that allows you to seek anywhere, and force you to read 8 bytes from anywhere, if anywhere is not also a multiple of 8 ... but, hey, anything is possible ^^ If so, you'll need another tool than dd, i'm afraid)
If it really is so weird: extract 2 blocks of 8 bytes around the adress you need, and then extract the exact part you need from it :
blockoffset=$(($address/8))
blockstart=$(($blockoffset*8))
shift=$(($address - $blockstart))
if [ "$shift" -eq 0 ]
dd if=file bs=8 skip=$blockoffset count=1 > final
else
dd if=file bs=8 skip=$blockoffset count=2 > bigger #we read 2 blocks from blockoffset
dd if=bigger bs=1 skip=$shift count=8 > final
fi
Given the amount of trouble you've gone to already, just put the C code into an executable program. Or get really ambitious and make the program into a bash extension with "enable -f pread.so pread"
http://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html
likely over the top. A separate program is easier.