SNMP Binding - Not Getting Data From Target

Tags: #<Tag:0x00007f5ca2bf8cd0> #<Tag:0x00007f5ca2bf8820>

Hi,

I want to use the snmpd binding to read data from a snmp-enabled device.

When I do from the OH box (latest Raspbian) a snmpwalk it is just fine:

root@openhab:/etc/openhab2# snmpwalk -v2c -c 1234 -On zentrale.example.de  ```
.1.3.6.1.4.1.8072.1.3.2.3.1.1.6.104.122.103.95.114.52
.1.3.6.1.4.1.8072.1.3.2.3.1.1.6.104.122.103.95.114.52 = STRING: "0"

I have enabled the snmp binding and configured an item according to this:

String Status_UG_Heizraum_Luftheizregister "Luftfheizregister der Heizungsanlage %" <light> {channel="snmp:target:7ad7428a:r4"}

But I do not get any values into this item. In openhab2.log I see:

2020-05-08 17:52:05.209 [WARN ] [inding.snmp.internal.SnmpServiceImpl] - SNMP service not initialized, can't send GET[requestID=0, errorStatus=Success(0), errorIndex=0, VBS[1.3.6.1.4.1.8072.1.3.2.3.1.1.6.104.122.103.95.114.52 = Null]] \
 to CommunityTarget[address=192.168.90.12/161,version=1,timeout=1500,retries=2,securityLevel=1,securityModel=1,securityName=1234,preferredTransports=null]

So anyone having a clue why this is not working?

(I found some references to the same issue but they all focused on incoming port…)
THANKS

Please Note: This is not due to my local port as I do not want to get snmp traps. I am just thinking of sending an snmp request to my target’s port 161 out. And this is working with snmpwalk.

/KNEBB

Try changing the item file and use [%s].

Example:

"Luftfheizregister der Heizungsanlage [%s]"

Hi,
thanks for the reply. Unfortunately this does not seem to be related. As snmpwalk marked the value as “STRING” I changed the item to:
String Status_UG_Heizraum_Luftheizregister "Luftfheizregister der Heizungsanlage" <light> {channel="snmp:target:7ad7428a:r4"}

But I am still getting the same error as above:
2020-05-08 18:39:44.690 [WARN ] [inding.snmp.internal.SnmpServiceImpl] - SNMP service not initialized, can't send GET[requestID=0, errorStatus=Success(0), errorIndex=0, VBS[1.3.6.1.4.1.8072.1.3.2.3.1.1.6.104.122.103.95.114.52 = Null]] to CommunityTarget[address=192.168.90.12/161,version=1,timeout=1500,retries=2,securityLevel=1,securityModel=1,securityName=1234,preferredTransports=null]

The link from item to thing seems to be fine (from event.log):
2020-05-08 18:39:20.218 [.ItemChannelLinkAddedEvent] - Link 'Status_UG_Heizraum_Luftheizregister-snmp:target:7ad7428a:r4' has been added.

Any further ideas?

THANKS a lot anyways.

Anyone having an snmp item up and running and can post his configuration?

Can you tell us just a little about how you configured that? For example, the type might be important, as you’ve been swapping the Item type using it.

An example -

Hi,

ok, I have tried meanwhile several steps. Here is the latest state:
First, tried if I get an result through snmp:
root@openhab:/etc/openhab2# snmpwalk -v2c -c xxxx 192.168.22.254 -On .1.3.6.1.2.1.4.13.0 .1.3.6.1.2.1.4.13.0 = INTEGER: 60
So I am getting a result- not firewall, routing, DNS or SNMP issues.

Configured manually a thing (file things/snmp.things):

Thing snmp:target:router [ hostname="192.168.22.254", protocol="v2c", community="xxxx" ] {
    Channels:
        Type number : somevalue [ oid=".1.3.6.1.2.1.4.13.0", mode="READ" ]
}

Already at this stage I am getting the failure in the log:

2020-05-08 21:49:48.622 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'snmp.things'
2020-05-08 21:49:48.729 [WARN ] [inding.snmp.internal.SnmpServiceImpl] - SNMP service not initialized, can't send GET[requestID=0, errorStatus=Success(0), errorIndex=0, VBS[1.3.6.1.2.1.4.13.0 = Null]] to CommunityTarget[address=192.168.22.254/161,version=1,timeout=1500,retries=2,securityLevel=1,securityModel=1,securityName=xxxx,preferredTransports=null]
2020-05-08 21:49:49.768 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'snmp.things'

What I am wondering is the message prints “securityModel=1” but it should be v2c, shouldn’t it? Nevertheless, snmpwalk even gives result as “v1”, so it should work either way:
root@openhab:/etc/openhab2# snmpwalk -v 1 -c xxxx 192.168.22.254 -On .1.3.6.1.2.1.4.13.0 .1.3.6.1.2.1.4.13.0 = INTEGER: 60

Despite of this issue I have configured now an item:

Number zahl "Bytes out [%d]" {channel="snmp:target:router:somevalue" }

Finally I have added the item to my sitemap:

        Text item=somevalue label="SNMP Labs"

So that’s all. I just do not have any clue what’s wrong here. I guess it is something with the thing configuration but I do not know. I tried to configure the thing through PaperUI, but it was the same result in the end.

/KNEBB

I created a snmp.cfg as well but it should not do any harm:

root@openhab:/etc/openhab2# cat services/snmp.cfg
# Configuration for the SNMP Binding
#
# Port used for receiving traps.
# This setting defaults to 0 (disabled / not receiving traps)
#port=8162

@anonymous.one knows this binding, are you still around man?

I’m still around @Andrew_Rowe just tied up with work stuff along with all the other daily jobs that come with a lack of elementary schools being open, some of which consisted of finally getting around to setup a pfsense leveraging VLANs within ESXi, a radius server with captive portal to control Internet fun time…however I digress. :roll_eyes:

@knebb I assume you are trying to use the 2.x SNMP binding?
What is the device or MIB tree that you are trying to query I’ve looked up a few of the strings that were posted but can’t figure out what this device is to know what is supported.

To answer the question about securityModel that is for SNMPv3; in your error it does report version=1 being used, which should be find there difference between the two versions is not a problem in this scenario.

Back when the binding was transitioning from 1.x to 2.x, I posted some differences between the bindings - SNMP 2.x issue
Do you have any other devices on your network to test against?

1 Like

@anonymous.one

No worries, I guess we have similar issues curently everywhere. Nearly the same here… doing OpenHAB to relax :smiley:

So, yes I tried different OIDs. I am confused it does matter which one to use- shouldn’t it just grab the value what it gets?
Indeed I want to use an item which I added to snmp as extend but as this did not work I tried with other OIDs as well- none works. So I thought it does not matter which to use.

Security model is not related, I will ignore this then.

And yes, I have installed v2 binding (for beginners ir is difficult to differ between the two versions as search results does not show if it’s x1 or v2). Anyway, I know meanwhile the v1 binding syntax and found the v2 doc so I configured it following this doc. I even used the OIDs from the example there (and checked them against my devices with snmpwalk).

Nothings going to work, always the same error message as shown above:

 SNMP service not initialized, can't send GET[...]

I will post my current config and post it here.

Thanks for having a look!

/KNEBB

Here’s my current config in trying to get this stuff working:

things/snmp.things

Thing snmp:target:router [ hostname="192.168.22.254", protocol="v2c", community="1234" ] {
    Channels:
        Type number : inBytes [ oid=".1.3.6.1.2.1.31.1.1.1.6.2", mode="READ" ]
}

I verified the OID (which I got from the documented example from my previous post) through snmpwalk and I am getting proper results:

root@openhab:/etc/openhab2/things# snmpwalk -v2c -c1234 192.168.22.254 .1.3.6.1.2.1.31.1.1.1.6.2
iso.3.6.1.2.1.31.1.1.1.6.2 = Counter64: 106231668

So I continued in adding items:
items/ug.items

Number inBytes "Bytes in [%d]" { channel="snmp:target:router:inBytes" }

And finally added it to my site:

                Text item=inBytes

And I am still geting the same error:

2020-05-09 09:33:35.241 [WARN ] [inding.snmp.internal.SnmpServiceImpl] - SNMP service not initialized, can't send GET[requestID=0, errorStatus=Success(0), errorIndex=0, VBS[1.3.6.1.2.1.31.1.1.1.6.2 = Null]] to CommunityTarget[address=192.168.22.254/161,version=1,timeout=1500,retries=2,securityLevel=1,securityModel=1,securityName=1234,preferredTransports=null]

The difference between the 1.x vs 2.x binding is that the 2.x changed to leverage Things concept with OH, while 1.x is more like the rest of OH 1.x configurations.

As a Thing has to be operational before items or sitemaps, I believe this is the main problem. With your most recent snnmpwalk example the value is coming back as a Counter64, but your thing example doesn’t specify counter64. I’m not experienced with 64 bit counters when it comes to SNMP, so it might be fine but it might also be worthwhile to validate; after your ‘READ’ specify the datatype.

I also see you have that message about SNMP service not initialized, this leads me to think you are missing an OS level application, on my Pi I have the following packages installed:

apt search snmp | grep inst
libsnmp-base/stable,now 5.7.3+dfsg-5 all [installed,automatic]
libsnmp30/stable,now 5.7.3+dfsg-5+b1 armhf [installed,automatic]
snmp/stable,now 5.7.3+dfsg-5+b1 armhf [installed]

I’m assuming snmpwalk being installed would install these packages, I think OH needs something to leverage SNMP call; I don’t think the binding installs its own SNMP.

Something else that could be helpful if you have the RestUI installed you can pull up the following URL:

http://hostname:8080/rest/things

And see the values for your Thing vs having to capture logs

Hi, thanks for your ideas. Still getting nowhere. Yes, from the error message I expected as well some basic OS libraries are not installed.
But I have the same as you:

root@openhab:/etc/openhab2/items# dpkg -l| grep snmp
ii  libsnmp-base                          5.7.3+dfsg-5                        all          SNMP configuration script, MIBs and documentation
ii  libsnmp30:armhf                       5.7.3+dfsg-5+b1                     armhf        SNMP (Simple Network Management Protocol) library
ii  snmp                                  5.7.3+dfsg-5+b1                     armhf        SNMP (Simple Network Management Protocol) applications

Thanks for the hint with the REST API. This is what I get (sorry for screenshot, but otherwise I can not properly cut’n’paster the json data):

Sorry for the delay, had a issue solved by SAP support at work.

I looked back on previous posts and didn’t see which OH version you are using (I assume the latest Stable) and I don’t think the version is the cause; doesn’t hurt to double check.

Did noticed that in the REST info your datatype is UNIT32, but with your snmpwalks they are Counter64; I would try changing your channel to do Counter 64 bit vs Integer 32 bit?

Could also be useful to change ‘donotlogexception’ from false to true, this might be helpful on the logging side; this option is more for dynamic OIDs that disappear, like an IP address in an ARP table.

This time sorry for delay. And yes I used the latest stable release when I installed some weeks ago. So I assume it is still the latest: (“openhab2 2.5.4-1”).

I have seen this but I have no idea how to change. When trying to change the channel from within PaperUI from UINT32 to COUNTER64 I am getting an error “409 - Conflict”. :frowning: The logfiles tells me the following:

2020-05-23 17:18:21.673 [INFO ] [st.core.internal.thing.ThingResource] - Received HTTP PUT request for update at 'things/snmp:target:router' for an unmanaged thing 'snmp:target:router'.
2020-05-23 17:18:22.429 [WARN ] [inding.snmp.internal.SnmpServiceImpl] - SNMP service not initialized, can't send GET[requestID=0, errorStatus=Success(0), errorIndex=0, VBS[1.3.6.1.2.1.31.1.1.1.6.2 = Null]] to CommunityTarget[address=192.168.20.154/161,version=1,timeout=1500,retries=2,securityLevel=1,securityModel=1,securityName=1234,preferredTransports=null]

I do not get it with the donotlogexception - according to the doc I have to set it in the channels configuration. In PaperUI I can not set it and there is no configuration file for.

I am still getting nowhere here :frowning:

When you do that, …

This is entirely expected. You cannot use PaperUI to edit Things created from files. Edit your files.

Hi, @rossko57
You where right I simply forgot I tried to configure it through config files instead of PaperUI.
Added it now to the snmp-thing file:

Thing snmp:target:router [ hostname="192.168.22.254", protocol="v2c", community="1234" ] {
    Channels:
        Type number : inBytes [ oid=".1.3.6.1.2.1.31.1.1.1.6.2", mode="READ", datatype="COUNTER64" ]
}

But stil the same error:

2020-05-23 18:55:32.058 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'snmp.things'
2020-05-23 18:56:30.995 [WARN ] [inding.snmp.internal.SnmpServiceImpl] - SNMP service not initialized, can't send GET[requestID=0, errorStatus=Success(0), errorIndex=0, VBS[1.3.6.1.2.1.31.1.1.1.6.2 = Null]] to CommunityTarget[address=192.168.22.254/161,version=1,timeout=1500,retries=2,securityLevel=1,securityModel=1,securityName=1234,preferredTransports=null]

Have you restarted the binding? Many bindings are not so good at picking up changes, especially small edits, and especially if there is scheduled polling involved.

Yes, I did as follows (learning more and more)
ssh openhab@localhost -p8101 'bundle:restart org.openhab.binding.snmp'

But still the same error.

Maybe throw the bundle to a DEBUG logging level and perhaps we can get a better idea of why OH isn’t working with SNMP?