SNMP Binding - Not Getting Data From Target

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?

Hi,

well, I went to increase debug level according to documentation. Which is itself really troublesome. Simply setting log level to DEBUG does no seem to be possible. Instead I had to use the Karaf console. And set the loglevel. I hope I did it in the right way (as I was just using the provided example):
log:set TRACE org.openhab.binding.snmp
(Just a side note: after this command I was not able to leave the consoel by exit, I had to kill the ssh connection.)
I restarted the binding (sufficient? or full oepnhab restart needed?):
ssh openhab@localhost -p8101 'bundle:restart org.openhab.binding.snmp'

Looks like I have been successful so far:

root@openhab:~# ssh openhab@localhost -p8101 'log:get org.openhab.binding.snmp'
Password authentication
Password:
TRACE

Now when checking openhab.log there is no difference in logging:

2020-05-25 08:02:36.464 [WARN ] [inding.snmp.internal.SnmpServiceImpl] - could not open SNMP instance on port 162: Keine Berechtigung (Bind failed)
2020-05-25 08:02:36.491 [WARN ] [inding.snmp.internal.SnmpServiceImpl] - could not open SNMP instance on port 162: Keine Berechtigung (Bind failed)
2020-05-25 08:02:36.580 [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]
2020-05-25 08:02:36.592 [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]

In eventlog I see some further details but the do not tell me anything either:

2020-05-25 08:00:00.935 [hingStatusInfoChangedEvent] - 'snmp:target:router' changed from ONLINE to UNINITIALIZED
2020-05-25 08:00:01.009 [hingStatusInfoChangedEvent] - 'snmp:target:router' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2020-05-25 08:00:01.387 [hingStatusInfoChangedEvent] - 'snmp:target:router' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2020-05-25 08:00:01.435 [hingStatusInfoChangedEvent] - 'snmp:target:router' changed from INITIALIZING to UNKNOWN
2020-05-25 08:00:01.442 [hingStatusInfoChangedEvent] - 'snmp:target:router' changed from UNKNOWN to ONLINE

As I was unsure about my logging I restarted the system completely. And no change, still the same error, still no further details.

Thanks for your patience but I am close to give up. Or are there any further ideas?

/KNEBB

Well that is disappointing to see the increase of the logging didn’t provide any insights. :confused:

I did however copy over your Thing/Item definitions into my environment and after changing the IP/community string my OH doesn’t exhibit the same behaviour but the value is left at 0 vs the value I see when I perform a snmp walk. Looks like I am running OH 2.5.5.

Some things I thought of to test out:
When was the last full restart of OH?
Last restart of the OS?
It could be possible the snmp binding didn’t download into OH correctly, a uninstall of the binding and a reinstall may fix the issue?
Try a string value of your device, like the hostname to see if that provides a better result?

Also out of curiosity what kind of router is hosting this SNMP? This seems like a rule/ACL blocking the SNMP, but it should also refuse your snmpwalk from the same device running OH.

Did a full restart of OS (including OH of course) twice these days. Using 2.5.5-1 currently:

root@openhab:~# dpkg -l| grep openhab
ii  openhab2                              2.5.5-1                             all          openhab2

I will try to install the binding again and see if it changes as well as using a string instead- I will keep you guys updated.

[Update]
Removing the snmp binding through paperUI and reinstalling it had exactly… NO… effect on the symptoms.

However, guys, thanks for you patience. For some reason this binding is somehow … difficult. I might need to give up on it…

/KNEBB