Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNMP configuration #28

Closed
kkellner opened this issue Mar 3, 2020 · 15 comments
Closed

SNMP configuration #28

kkellner opened this issue Mar 3, 2020 · 15 comments

Comments

@kkellner
Copy link

kkellner commented Mar 3, 2020

How do you configure for SNMP?

I have tried the following (I got config params from https://networkupstools.org/docs/man/snmp-ups.html)

users:
  - username: myusername
    password: mypassword
    instcmds:
      - all
    actions: []
devices:
  - name: apcups
    driver: snmp-ups
    port: 172.20.0.55
    config:
      snmp_version: v3
      secLevel: authPriv
      secName: snmpprofile1
      authPassword: myauthenticationpassphrase
      privPassword: myprivatepassphrase
mode: netserver
shutdown_host: 'false'

This results in:

[cont-init.d] nut.sh: executing... 
[19:45:41] INFO: Setting mode to netserver...
[19:45:41] INFO: Generating /etc/nut/upsd.users...
[19:45:41] INFO: Configuring user: myusername
[19:45:42] INFO: Password is NOT in the Have I Been Pwned database! Nice!
[19:45:42] INFO: Configuring Device named apcups...
[19:45:42] INFO: Starting the UPS drivers...
Network UPS Tools - UPS driver controller 3.8.0-3220-g866b921892
Network UPS Tools - Generic SNMP UPS driver 0.97 (3.8.0-3220-g866b921892)
Driver exited abnormally
[cont-init.d] nut.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
@addons-assistant
Copy link

👋 Thanks for opening your first issue here! If you're reporting a 🐛 bug, please make sure you include steps to reproduce it. Also, logs, error messages and information about your hardware might be useful.

@sinclairpaul
Copy link
Member

As I'm sure you can appreciate, we can't test and validate every UPS config out there. Although in theory it should work from what I can see, is there a chance you could validate using SNMP v1/2 rather than V3?

@kkellner
Copy link
Author

kkellner commented Mar 4, 2020

Yep, I and understand not having the ability to test all configurations. I just wanted to check if you might know how SNMP can be configured. I also tried v1 with the same result. I also set logging to debug level and other then giving me some debug statements on Pwned database calls, it did not provide any additional information as to why snmp-ups is failing.

Is there any way to send/add "-DD" argument to snmp-ups executable to show detailed debug info? E.g., snmp-ups -DD

SNMP v1 config:

devices:
  - name: apcups
    driver: snmp-ups
    port: 172.20.0.55
    config:
      community: public
      snmp_version: v1
      mibs: apcc
      pollfreq: 15

@sinclairpaul
Copy link
Member

To get the addon to start, you can set the config to be something like:

devices:
  - name: myups
    driver: dummy-ups
    port: dummy.dev
    config: []

This would start using the dummy driver, you could then possibly exec into the container and run the nut executables from there.

@kkellner
Copy link
Author

kkellner commented Mar 4, 2020

Does the plugin create the ups.conf file similar to below and run the below command? I'll give the dummy command a shot.

The contents of the ups.conf file

[APC_UPS]
                   driver = snmp-ups
                   port = 172.20.0.55
                   snmp_version = v3
                   secLevel = authPriv
                   secName = snmpprofile1
                   authPassword = *********
                   authProtocol = MD5
                   privPassword = *********
                   privProtocol = DES
                   desc = "APC UPS"

Command:
$ sudo /lib/nut/snmp-ups -DD -a APC_UPS

@sinclairpaul
Copy link
Member

We generate the ups.conf

for device in $(bashio::config "devices|keys"); do

Only run the -D on debug being set today, we could change this if needed:

if bashio::debug; then

@kkellner
Copy link
Author

kkellner commented Mar 4, 2020

I was able to exec into the container.... Editing the /etc/nut/ups.conf and running /usr/lib/nut/snmp-ups -DD -a myups worked fine.

Looks like the config param values are not getting set.

This is what I have in the config (for devices):

devices:
  - name: myups
    driver: dummy-ups
    port: dummy.dev
    config: []
  - name: apcups
    driver: snmp-ups
    port: 172.20.0.55
    config:
      snmp_version: v3
      secLevel: authPriv
      secName: snmpprofile1
      authPassword: myauthenticationpassphrase
      authProtocol: MD5
      privPassword: myprivatepassphrase
      privProtocol: DES
      desc: APC UPS

And here is what is in the /etc/nut/ups.conf file:

image

@dale3h
Copy link
Collaborator

dale3h commented Mar 4, 2020

@kkellner Try an array of strings for the config option, like so:

Documentation for config option: https://github.com/hassio-addons/addon-nut/blob/master/README.md#sub-option-config

devices:
  - name: myups
    driver: dummy-ups
    port: dummy.dev
    config: []
  - name: apcups
    driver: snmp-ups
    port: 172.20.0.55
    config:
      - snmp_version = v3
      - secLevel = authPriv
      - secName = snmpprofile1
      - authPassword = myauthenticationpassphrase
      - authProtocol = MD5
      - privPassword = myprivatepassphrase
      - privProtocol = DES
      - desc = APC UPS

I believe I originally set it up this way due to validation restraints when using nested arrays in add-on config files.

@kkellner
Copy link
Author

kkellner commented Mar 4, 2020

So when I type this config section in the plugin config text box:

    config:
      snmp_version = v3
      secLevel = authPriv
      secName = snmpprofile1
      authPassword = myauthenticationpassphrase
      authProtocol = MD5
      privPassword = myprivatepassphrase
      privProtocol = DES
      desc = APC UPS

then click save, it turns to this in the config text box:

    config: >-
      snmp_version = v3 secLevel = authPriv secName = snmpprofile1 authPassword
      = myauthenticationpassphrase authProtocol = MD5 privPassword =
      myprivatepassphrase privProtocol = DES desc = APC UPS

The ups.conf ends up looking like this:
image

@dale3h
Copy link
Collaborator

dale3h commented Mar 4, 2020

Please review my sample config again carefully. The hyphens at the beginning of each line are required.

@kkellner
Copy link
Author

kkellner commented Mar 4, 2020

Sorry, too many cut/paste/edits. Your version with hyphens worked. I'm going to add the sensor next to see if I have real data.

@dale3h
Copy link
Collaborator

dale3h commented Mar 4, 2020

That is great news! Please report back your findings so that we can close this issue if nothing further needs to be implemented to get this to work without in-container modifications.

@kkellner
Copy link
Author

kkellner commented Mar 4, 2020

Looks like I've getting real data! Two questions:

  1. Where does host a0d7b954-nut come from and when might it change? I saw in another issue the statement this will change if the addon moves from the edge repo. but I don't know what that means.

  2. Is there a way to get additional attributes? E.g., current in voltage and out voltage, ups temperature?

image

@dale3h
Copy link
Collaborator

dale3h commented Mar 4, 2020

Awesome, even more great news!

  1. The host is derived from the name of the container, which I believe is generated based on the hash of the add-on repo and the name of the add-on. In this case a0d7b954 is the repo hash (Community Edge repo) and nut is the add-on slug.

  2. In a normal install, the available sensors are specific to each model of UPS device and what it exposes. I am not 100% sure on how to expose that same data via SNMP, as I have never before used SNMP.

@dale3h dale3h closed this as completed Mar 4, 2020
@addons-assistant
Copy link

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@addons-assistant addons-assistant bot locked as resolved and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants