I'm new to snmp4j. I used the sample code in [1] to extract some meaningful information from a SNMP stream.
In the sample code, oid and value of the variable is extracted, but the value comes without its units. For example
,oid 1.3.6.1.4.1.2021.4.6.0 (SNMP-MIB::memAvailReal.0) gives the value 13385068 without its unit KB. Is there a way to get the value with its units in snmp4j?
Can somebody please look in to this?
[1]https://gist.github.com/akirad/5597203
I believe that the value you're retrieving is simply a SCALAR of type Integer32.
The description in the MIB is "Available Real/Physical Memory Space on the host."
It doesn't even specify the units there, so I don't think there's anywhere to retrieve the units data from. Happy to be corrected by someone if I'm wrong though!
memAvailReal OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Available Real/Physical Memory Space on the host."
::= { memory 6 }
In other words, its a numeric value and the descriptive metadata from the MIB file doesn't even reveal the units so there's no where to get that info from in code.
Edit:
I googled around some more and found another version of the UCD-SNMP-MIB with this definition:
memAvailReal OBJECT-TYPE
SYNTAX Integer32
UNITS "kB"
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The amount of real/physical memory currently unused
or available."
::= { memory 6 }
So the info is available in this version of the MIB...
It looks like you can probably make use of this information using the SmiManager class:
http://www.snmp4j.org/smi/doc/com/snmp4j/smi/SmiManager.html
https://oosnmp.net/confluence/pages/viewpage.action?pageId=5799973
But integrating SmiManager into your application might not be trivial (and on looking into it a little bit further , it appears that there's a licence required to use SmiManager!).
For my own little project I'm pre-parsing MIBs and storing the parts of them I need in my NoSQL database rather than including full-blown MIB parsing support. That way I can have a dict of metadata associated with every OID that is easier to access/update and manipulate.
Hope that helps.
Related
I'm working on some powershell scripts to set values for oid's.
One of the settings requires me to wipe out the current values first. Then set new ones. But I cannot seem to find the right syntax to make this work.
The syntax is DISPLAYSTRING but I'm having to use hex values to set them.
Here what the MIB says:
Generally, you can't. That object has a MAX-ACCESS of "read-write", meaning you can read from it and write to it. It is possible that the agent reports the object as "not existing" until you write to it (which is a bit naughty; that's what "read-create" is for). But that doesn't mean you can delete it or null it out. You cannot tell it not to have a value.
However, I believe you're misinterpreting the requirements. I suggest using the "No additional mapping" value of 0; my interpretation of the description is that this is the "null mapping" it speaks of.
Alternatively, consult the documentation or vendor to find out how use of this particular MIB is intended.
I am trying to map an existing domain into HL7 FHIR.
So far it was pretty easy to find FHIR resources that more or less represent the same data and can be used for that purpose. But now I am running into a problem of which I am not sure how to solve it.
The existing domain allows that data can be anonymized depending on the users access level. e.g. a patient's name or address might be removed and marked as anonymized. Other data will be pseudonymised, for example a the birthdate in 1980 will be replaced with 01.01.1980. An Age of 37 will be replaced with a category of 30-40.
So I am unsure how to integrate that into the FHIR domain. I was thinking I could create an extension holding a boolean, indicating if a value was anonymized or not and always replace or remove the original value. This might work, but I will run into big problems when the anonymized value is of a different type than the original value (e.g. Age is replaced by a range of values)
Is that even a valid approach? I thought this might be common problem, but I could not find any examples where people described methods of how to mark data as altered. Unfortunately the documentation at http://build.fhir.org/extensibility-registry.html does not contain anything that would help my case.
You can use security labels for this purpose (Resource.meta.security). Take a look at REDACTED and SUBSETTED in the security label value set: https://www.hl7.org/fhir/valueset-security-labels.html
If you need to convey a data type other than the one allowed by the resource (e.g. wanting to convey a range rather than a birthdate), you'd need to use an extension. (Note that dates are valid even if you only include the year.)
Can anyone provide some insight on the required syntax to use to search LOINC using FHIR for a specific string in the labs descriptive text portion of an Observation resource?
Is this even possible?
The documentation is all over the place and I can't find an example for this generic kind of search.
I found similar examples here: https://www.hl7.org/fhir/2015Sep/valueset-operations.html
Such as: GET "[base]/ValueSet/23/$validate-code?system=http://loinc.org&code=1963-8&display=test"
But none of them are providing a general enough case to do a global search of the LOINC system for a specific string in an Observation resource.
None of my attempts to use the FHIR UI here, http://polaris.i3l.gatech.edu:8080/gt-fhir-webapp/search?serverId=gatechreadonly&resource=Observation , have been successful. I keep getting a 500 Internal Server Error because I don't know the correct syntax to use for the value part of the search, and I can't find any documentation out of all the copious documents online that explains this very simple concept.
Can anyone provide some insight?
Totally frustrated at this point.
Observation?code=12345-6
or
Observation?code=http://loinc.org|12345-6
where 12345-6 is whatever LOINC code you want to look for (e.g. 39802-4)
The second ensures you'll only match on LOINC codes as opposed to codes from other systems, though given the relatively unique format of LOINC codes, you're mostly safe without including that.
If you want to search for a set of codes, then you can separate the codes or the tuples with commas: E.g.
Observation?code=12345-6,12345-7
or
Observation?code=http://loinc.org|12345-6,http://loinc.org|123456
If you expect to search by a really long list of codes frequently, you can define a value set that includes all the desired codes and then filter by value set:
Observation?code:in=http://somwhere.org/whatever/ValueSet/123
Note: for readability, I haven't escaped the URL contents, but you'll need to escape the URL values appropriately.
I am currently studying the VersionInfo Resource(s) for Windows.
It is kind of confusing that you can have multiple VS_VERSIONINFO/VS_FIXEDFILEINFO structures within a VS_VERSION_INFO Resource.
As far as I get it, you can have multiple RT_VERSION->VS_VERSION_INFO Resources with different language ids. (Just as shown as in the picture)
These 2 language ids (0 and 1031) have actually 2 different VS_VERSIONINFO/VS_FIXEDFILEINFO in each.
0 is a neutral language and seems to be prioritized than your actual local language id (which is 1031).
To me this seems to be kind of a mess and confusing.
How is it possible to have multiple VS_VERSIONINFO structures within a VS_VERSION_INFO resource and what is the point? How does Windows interpret multiple Resources,Structures?
And how is it possible to get only one piece of buffer when you call GetFileVersionInfo?
It all makes little sense to me and I can't find much documentation about it.
You have to make a difference between the textual infos, and the bare VS_FIXEDFILEINFO block. The first block exist only once. The text Information is language dependent.
"Windows" does not prefers a specific one ;) What the explorer does is a different thing. It just shows the resource information. But in fact this is just the string information and not the information from the fixed version info.
When you call GetFileVersionInfo you get all language blocks! VerQueryValue is used to access he separate blocks.
The installer and other routines inside windows only use the VS_FIXEDFILEINFO block. They don't care about any text blocks. And this block only exists once.
I assume that the explorer just shows the first text block and also doesn't prefer a specific one. Just use a text editor and exchange the blocks in the resource file. But maybe the resource compiler reorders them.
To access the separate parts:
- VerQueryValue with "\" gives you the fixed version info block VS_FIXEDFILEINFO
- VerQueryValue with "\VarFileInfo\Translation" gives you a list of translations
- with "\StringFileInfo\langId_charset\keyname" you get the specific string parts
You find this information in the MSDN
I need to design MIB for SNMP analysis from scratch. I mean, we got an OID for our enterprise on the tree 2.25 now it's time to code.
However, I can't get an example of this. When looking under /usr/share/snmp/mibs directory on our Linux machine a see a lot of files (for example: HOST-RESOURCES-MIB.txt, IF-MIB.txt, etc). I understand that these files follow a format for MIB, but I just not getting it because they import some things that are completely strange to me.
For example:
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, Counter32, Gauge32, Counter64,
Integer32, TimeTicks, mib-2,
NOTIFICATION-TYPE FROM SNMPv2-SMI
TEXTUAL-CONVENTION, DisplayString,
PhysAddress, TruthValue, RowStatus,
TimeStamp, AutonomousType, TestAndIncr FROM SNMPv2-TC
MODULE-COMPLIANCE, OBJECT-GROUP,
NOTIFICATION-GROUP FROM SNMPv2-CONF
snmpTraps FROM SNMPv2-MIB
IANAifType FROM IANAifType-MIB;
Then, in every import file I see more imports and more imports. Can somebody tell me what is the top most file for that or point me in any direction faq or something?
Thanks in advance.
You should go back to its IETF RFC document,
http://www.rfc-editor.org/rfc/rfc2578.txt