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

Add db schema for ups-nut alerting #7622

Merged
merged 4 commits into from Nov 23, 2017

Conversation

Projects
None yet
3 participants
@erotel
Contributor

erotel commented Nov 3, 2017

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 4, 2017

Member

Thanks for submitting this. Be interested to hear what others say on this but imho table specific data is something we should be avoiding. Components could be a fit here but I'm not a fan of that personally.

My approach would be to cache the data from applications to re-use in sensors in someway and if the data doesn't exist when running sensors than obtain it again and cache it. A lot of the data you are storing is already done in the sensors model and has alerting and webui support.

Member

laf commented Nov 4, 2017

Thanks for submitting this. Be interested to hear what others say on this but imho table specific data is something we should be avoiding. Components could be a fit here but I'm not a fan of that personally.

My approach would be to cache the data from applications to re-use in sensors in someway and if the data doesn't exist when running sensors than obtain it again and cache it. A lot of the data you are storing is already done in the sensors model and has alerting and webui support.

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 4, 2017

Contributor

If I understand this, then the data from /include/polling/applications/ups-nut.inc.php are only written to the graph.
If this is not the case, then I do not understand the alert system at all.

Contributor

erotel commented Nov 4, 2017

If I understand this, then the data from /include/polling/applications/ups-nut.inc.php are only written to the graph.
If this is not the case, then I do not understand the alert system at all.

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 4, 2017

Member

Yes data in applications is typically only written to graphs and not the database.

Member

laf commented Nov 4, 2017

Yes data in applications is typically only written to graphs and not the database.

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 4, 2017

Contributor

In that case, if I understand well, I can not have an alert for ups-nut, since the alert function compares alert rules stored in db with data stored in db.
Is it right?
Sorry my English is bad, I use google translator

Contributor

erotel commented Nov 4, 2017

In that case, if I understand well, I can not have an alert for ups-nut, since the alert function compares alert rules stored in db with data stored in db.
Is it right?
Sorry my English is bad, I use google translator

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 4, 2017

Member

That's correct.

Hence my suggestion that this should be part of the sensors code to do this. It's probably unlikely to be possible to be done in yaml but php would be fine.

Member

laf commented Nov 4, 2017

That's correct.

Hence my suggestion that this should be part of the sensors code to do this. It's probably unlikely to be possible to be done in yaml but php would be fine.

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 4, 2017

Contributor

If I understand it well, should I try to write data from ups-nut.inc.php into the db table of sensors and not use my own ups-nut table?

Contributor

erotel commented Nov 4, 2017

If I understand it well, should I try to write data from ups-nut.inc.php into the db table of sensors and not use my own ups-nut table?

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 5, 2017

Member

show an snmpwalk output of the data so we can see what we're dealing with.

Member

laf commented Nov 5, 2017

show an snmpwalk output of the data so we can see what we're dealing with.

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 5, 2017

Contributor

I have already found an oid for individual sensors

Contributor

erotel commented Nov 5, 2017

I have already found an oid for individual sensors

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 5, 2017

Member

Better :)

However I would say this doesn't need calling from applications and instead should just be a native sensor for the OS type (I'm guessing it's only linux this works on).

Looks like this would be fine for conversion to yaml as well (see our docs).

Member

laf commented Nov 5, 2017

Better :)

However I would say this doesn't need calling from applications and instead should just be a native sensor for the OS type (I'm guessing it's only linux this works on).

Looks like this would be fine for conversion to yaml as well (see our docs).

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 5, 2017

Contributor

I also thought to place the discovery into linux, but above all what if someone writes an application for another system?
I'll look at the yaml format.

Contributor

erotel commented Nov 5, 2017

I also thought to place the discovery into linux, but above all what if someone writes an application for another system?
I'll look at the yaml format.

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 5, 2017

Member

What other systems though? all *nix based are discovered as linux.

Member

laf commented Nov 5, 2017

What other systems though? all *nix based are discovered as linux.

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 5, 2017

Contributor

When it's hard for you ;)
Ok to remake it.

Contributor

erotel commented Nov 5, 2017

When it's hard for you ;)
Ok to remake it.

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 6, 2017

Contributor

Hmm yaml config not work

root@speedtest:/opt/librenms/includes/definitions/discovery# snmpwalk -c public -v1 -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ 10.133.139.17 nsExtendOutLine
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".1 = STRING: 100.0
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".2 = STRING: 120
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".3 = STRING: 16020
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".4 = STRING: 54.81
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".5 = STRING: 048
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".6 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".7 = STRING: 243.3
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".8 = STRING: 030.5

root@speedtest:/opt/librenms/includes/definitions/discovery# snmpwalk -c public -v1 -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ 10.133.139.17 nsExtendOutLine."ups-nut".1
nsExtendOutLine.ups-nut.1: Unknown Object Identifier (Index out of range: ups-nut (nsExtendToken))

Contributor

erotel commented Nov 6, 2017

Hmm yaml config not work

root@speedtest:/opt/librenms/includes/definitions/discovery# snmpwalk -c public -v1 -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ 10.133.139.17 nsExtendOutLine
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".1 = STRING: 100.0
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".2 = STRING: 120
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".3 = STRING: 16020
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".4 = STRING: 54.81
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".5 = STRING: 048
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".6 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".7 = STRING: 243.3
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".8 = STRING: 030.5

root@speedtest:/opt/librenms/includes/definitions/discovery# snmpwalk -c public -v1 -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ 10.133.139.17 nsExtendOutLine."ups-nut".1
nsExtendOutLine.ups-nut.1: Unknown Object Identifier (Index out of range: ups-nut (nsExtendToken))

erotel added some commits Nov 6, 2017

@scrutinizer-notifier

This comment has been minimized.

Show comment
Hide comment
@scrutinizer-notifier

scrutinizer-notifier Nov 6, 2017

The inspection completed: No new issues

scrutinizer-notifier commented Nov 6, 2017

The inspection completed: No new issues

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 6, 2017

Member

Show the yaml as it should work fine.

Member

laf commented Nov 6, 2017

Show the yaml as it should work fine.

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 6, 2017

Contributor

Im test only one sensor

mib: NET-SNMP-EXTEND-MIB
modules:
    sensors:
        charge:
            data:
                -
                    oid:  nsExtendOutLine
                    num_oid: .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.
                    descr: Batery Charge
                    index: 'nsExtendOutLine.{{ $index }}'

discovery

poller

Contributor

erotel commented Nov 6, 2017

Im test only one sensor

mib: NET-SNMP-EXTEND-MIB
modules:
    sensors:
        charge:
            data:
                -
                    oid:  nsExtendOutLine
                    num_oid: .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.
                    descr: Batery Charge
                    index: 'nsExtendOutLine.{{ $index }}'

discovery

poller

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 6, 2017

Member

Try changing oid: nsExtendOutLine to oid: .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116

Member

laf commented Nov 6, 2017

Try changing oid: nsExtendOutLine to oid: .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 6, 2017

Contributor
Dynamic Discovery (charge): Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [oid] => .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116
                    [num_oid] => .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.
                    [descr] => Batery Charge
                    [index] => nsExtendOutLine.{{ $index }}
                )

        )

)
Data .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116: Array
(
    [ups-nut.1] => Array
        (
            [nsExtendOutLine] => 100.0
        )

    [ups-nut.2] => Array
        (
            [nsExtendOutLine] => 120
        )

    [ups-nut.3] => Array
        (
            [nsExtendOutLine] => 16500
        )

    [ups-nut.4] => Array
        (
            [nsExtendOutLine] => 54.81
        )

    [ups-nut.5] => Array
        (
            [nsExtendOutLine] => 048
        )

    [ups-nut.6] => Array
        (
            [nsExtendOutLine] => Unknown
        )

    [ups-nut.7] => Array
        (
            [nsExtendOutLine] => 247.6
        )

    [ups-nut.8] => Array
        (
            [nsExtendOutLine] => 029.9
        )

)
Final sensor value:
Final sensor value:
Final sensor value:
Final sensor value:
Final sensor value:
Final sensor value:
Final sensor value:
Final sensor value:
Contributor

erotel commented Nov 6, 2017

Dynamic Discovery (charge): Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [oid] => .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116
                    [num_oid] => .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.
                    [descr] => Batery Charge
                    [index] => nsExtendOutLine.{{ $index }}
                )

        )

)
Data .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116: Array
(
    [ups-nut.1] => Array
        (
            [nsExtendOutLine] => 100.0
        )

    [ups-nut.2] => Array
        (
            [nsExtendOutLine] => 120
        )

    [ups-nut.3] => Array
        (
            [nsExtendOutLine] => 16500
        )

    [ups-nut.4] => Array
        (
            [nsExtendOutLine] => 54.81
        )

    [ups-nut.5] => Array
        (
            [nsExtendOutLine] => 048
        )

    [ups-nut.6] => Array
        (
            [nsExtendOutLine] => Unknown
        )

    [ups-nut.7] => Array
        (
            [nsExtendOutLine] => 247.6
        )

    [ups-nut.8] => Array
        (
            [nsExtendOutLine] => 029.9
        )

)
Final sensor value:
Final sensor value:
Final sensor value:
Final sensor value:
Final sensor value:
Final sensor value:
Final sensor value:
Final sensor value:
@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 7, 2017

Member

Can you provide an snmpwalk as per https://docs.librenms.org/#Support/FAQ/#faq8

Member

laf commented Nov 7, 2017

Can you provide an snmpwalk as per https://docs.librenms.org/#Support/FAQ/#faq8

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 7, 2017

Contributor

if use snmpbulkwalk -OUneb -v2c -c public 10.133.139.17 oid ups-nut not in tree.
Only if use

root@speedtest:~# snmpbulkwalk -On -c public -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ -v2c 10.133.139.17 nsExtendOutLine
.1.3.6.1.4.1.8072.1.3.2.4.1.2.4.116.101.115.116.1 = STRING: uname: No such file or directory
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1 = STRING: 100.0
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.2 = STRING: 120
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.3 = STRING: 16020
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.4 = STRING: 54.81
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.5 = STRING: 048
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.6 = STRING: Unknown
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.7 = STRING: 244.8
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.8 = STRING: 031.2

root@speedtest:~# snmpbulkwalk -c public -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ -v2c 10.133.139.17 nsExtendOutLine
NET-SNMP-EXTEND-MIB::nsExtendOutLine."test".1 = STRING: uname: No such file or directory
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".1 = STRING: 100.0
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".2 = STRING: 120
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".3 = STRING: 16500
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".4 = STRING: 54.81
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".5 = STRING: 048
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".6 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".7 = STRING: 246.2
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".8 = STRING: 030.5

root@speedtest:~# snmpbulkwalk  -c public -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ -v2c 10.133.139.17 nsExtendOutLine."ups-nut".7
nsExtendOutLine.ups-nut.7: Unknown Object Identifier (Index out of range: ups-nut (nsExtendToken))

root@speedtest:~# snmpbulkwalk  -c public -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ -v2c 10.133.139.17 nsExtendOutLine.\"ups-nut\".7
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".7 = STRING: 246.2

root@speedtest:~# snmptranslate -On NET-SNMP-EXTEND-MIB::nsExtendOutLine
.1.3.6.1.4.1.8072.1.3.2.4.1.2

root@speedtest:~# snmptranslate -On NET-SNMP-EXTEND-MIB::nsExtendOutLine.\"ups-nut\"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116
root@speedtest:~#

Contributor

erotel commented Nov 7, 2017

if use snmpbulkwalk -OUneb -v2c -c public 10.133.139.17 oid ups-nut not in tree.
Only if use

root@speedtest:~# snmpbulkwalk -On -c public -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ -v2c 10.133.139.17 nsExtendOutLine
.1.3.6.1.4.1.8072.1.3.2.4.1.2.4.116.101.115.116.1 = STRING: uname: No such file or directory
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1 = STRING: 100.0
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.2 = STRING: 120
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.3 = STRING: 16020
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.4 = STRING: 54.81
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.5 = STRING: 048
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.6 = STRING: Unknown
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.7 = STRING: 244.8
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.8 = STRING: 031.2

root@speedtest:~# snmpbulkwalk -c public -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ -v2c 10.133.139.17 nsExtendOutLine
NET-SNMP-EXTEND-MIB::nsExtendOutLine."test".1 = STRING: uname: No such file or directory
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".1 = STRING: 100.0
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".2 = STRING: 120
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".3 = STRING: 16500
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".4 = STRING: 54.81
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".5 = STRING: 048
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".6 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".7 = STRING: 246.2
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".8 = STRING: 030.5

root@speedtest:~# snmpbulkwalk  -c public -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ -v2c 10.133.139.17 nsExtendOutLine."ups-nut".7
nsExtendOutLine.ups-nut.7: Unknown Object Identifier (Index out of range: ups-nut (nsExtendToken))

root@speedtest:~# snmpbulkwalk  -c public -m NET-SNMP-EXTEND-MIB -M /opt/librenms/mibs/ -v2c 10.133.139.17 nsExtendOutLine.\"ups-nut\".7
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".7 = STRING: 246.2

root@speedtest:~# snmptranslate -On NET-SNMP-EXTEND-MIB::nsExtendOutLine
.1.3.6.1.4.1.8072.1.3.2.4.1.2

root@speedtest:~# snmptranslate -On NET-SNMP-EXTEND-MIB::nsExtendOutLine.\"ups-nut\"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116
root@speedtest:~#

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 15, 2017

Member

@erotel it needs to be the full walk as per the FAQ I linked to so that I can use it to simulate the device.

Member

laf commented Nov 15, 2017

@erotel it needs to be the full walk as per the FAQ I linked to so that I can use it to simulate the device.

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 21, 2017

Contributor

here,but im delete routing info,file is very big

Contributor

erotel commented Nov 21, 2017

here,but im delete routing info,file is very big

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 22, 2017

Member

That output doesn't contain the values from .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116 Can you re-run it with that oid on the end instead of the .

Member

laf commented Nov 22, 2017

That output doesn't contain the values from .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116 Can you re-run it with that oid on the end instead of the .

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 22, 2017

Contributor
root@speedtest:~# snmpbulkwalk -OUneb -v2c -c public 10.133.139.17 .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1 = STRING: "100.0"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.2 = STRING: "120"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.3 = STRING: "16500"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.4 = STRING: "54.81"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.5 = STRING: "048"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.6 = STRING: "Unknown"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.7 = STRING: "247.6"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.8 = STRING: "029.9"
Contributor

erotel commented Nov 22, 2017

root@speedtest:~# snmpbulkwalk -OUneb -v2c -c public 10.133.139.17 .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1 = STRING: "100.0"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.2 = STRING: "120"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.3 = STRING: "16500"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.4 = STRING: "54.81"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.5 = STRING: "048"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.6 = STRING: "Unknown"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.7 = STRING: "247.6"
.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.8 = STRING: "029.9"
@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 22, 2017

Member

Ok, here's what works for me (yaml file + php patch):

modules:
    sensors:
        charge:
            data:
                -
                    oid: .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1
                    num_oid: .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.
                    value: 1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1
                    snmp_flags: '-OneQU'
                    descr: Batery Charge
                    index: 'nsExtendOutLine.1'

Notice the oid has the index on, this is because you don't care about the full table here and just a single OID per sensor type.

diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php
index f785d8c4b..f684341ec 100644
--- a/includes/discovery/functions.inc.php
+++ b/includes/discovery/functions.inc.php
@@ -984,7 +984,13 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
                 // get the value for this sensor, check 'value' and 'oid', if state string, translate to a number
                 $data_name = isset($data['value']) ? $data['value'] : $data['oid'];  // fallback to oid if value is not set

-                $tmp_value = $snmp_data[$data_name];
+                if (is_array($snmp_data)) {
+                    $array_values = array_values($snmp_data);
+                    $tmp_value = $array_values[0];
+                    unset($array_values);
+                } else {
+                    $tmp_value = $snmp_data[$data_name];
+                }
                 if (!is_numeric($tmp_value)) {
                     preg_match('/-?\d*\.?\d+/', $tmp_value, $temp_response);
                     if (!empty($temp_response[0])) {
Member

laf commented Nov 22, 2017

Ok, here's what works for me (yaml file + php patch):

modules:
    sensors:
        charge:
            data:
                -
                    oid: .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1
                    num_oid: .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.
                    value: 1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1
                    snmp_flags: '-OneQU'
                    descr: Batery Charge
                    index: 'nsExtendOutLine.1'

Notice the oid has the index on, this is because you don't care about the full table here and just a single OID per sensor type.

diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php
index f785d8c4b..f684341ec 100644
--- a/includes/discovery/functions.inc.php
+++ b/includes/discovery/functions.inc.php
@@ -984,7 +984,13 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
                 // get the value for this sensor, check 'value' and 'oid', if state string, translate to a number
                 $data_name = isset($data['value']) ? $data['value'] : $data['oid'];  // fallback to oid if value is not set

-                $tmp_value = $snmp_data[$data_name];
+                if (is_array($snmp_data)) {
+                    $array_values = array_values($snmp_data);
+                    $tmp_value = $array_values[0];
+                    unset($array_values);
+                } else {
+                    $tmp_value = $snmp_data[$data_name];
+                }
                 if (!is_numeric($tmp_value)) {
                     preg_match('/-?\d*\.?\d+/', $tmp_value, $temp_response);
                     if (!empty($temp_response[0])) {
@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Nov 23, 2017

Contributor

I'm not sure if I have your patch well applied but if you look at the line find sensor there is an oid there twice. This is stored in db and poller.php then reports a non-oid.

Dynamic Discovery (charge): Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [oid] => .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1
                    [num_oid] => .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.
                    [value] => 1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1
                    [snmp_flags] => -OneQU
                    [descr] => Batery Charge
                    [index] => nsExtendOutLine.1
                )

        )

)
Data .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1: Array
(
    [1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1] => Array
        (
            [] => 100.0
        )

)
Final sensor value: 100.0
Discover sensor: .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1, nsExtendOutLine.1, linux, Batery Charge, snmp, 1, 1, , 100
SQL[SELECT COUNT(sensor_id) FROM `sensors` WHERE `poller_type`= 'snmp' AND `sensor_class` = 'charge' AND `device_id` = '31' AND sensor_type = 'linux' AND `sensor_index` = 'nsExtendOutLine.1']
SQL[INSERT INTO `sensors` (`poller_type`,`sensor_class`,`device_id`,`sensor_oid`,`sensor_index`,`sensor_type`,`sensor_descr`,`sensor_divisor`,`sensor_multiplier`,`sensor_current`)  VALUES ('snmp','charge','31','.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1','nsExtendOutLine.1','linux','Batery Charge','1','1','100')]
( 321 inserted )


SNMP[/usr/bin/snmpget -v2c -c COMMUNITY -OUQnt -M /opt/librenms/mibs:/opt/librenms/mibs/supermicro:/opt/librenms/mibs/dell udp:HOSTNAME:161 .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1]
.*.4.1.8*.*.*.*.*.1.8*.*.*.* = No Such Instance currently exists at this OID

Checking (snmp) charge Batery Charge...
0
RRD[update /opt/librenms/rrd/10.133.139.17/sensor-charge-linux-nsExtendOutLine.1.rrd N:0]

Contributor

erotel commented Nov 23, 2017

I'm not sure if I have your patch well applied but if you look at the line find sensor there is an oid there twice. This is stored in db and poller.php then reports a non-oid.

Dynamic Discovery (charge): Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [oid] => .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1
                    [num_oid] => .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.
                    [value] => 1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1
                    [snmp_flags] => -OneQU
                    [descr] => Batery Charge
                    [index] => nsExtendOutLine.1
                )

        )

)
Data .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1: Array
(
    [1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1] => Array
        (
            [] => 100.0
        )

)
Final sensor value: 100.0
Discover sensor: .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1, nsExtendOutLine.1, linux, Batery Charge, snmp, 1, 1, , 100
SQL[SELECT COUNT(sensor_id) FROM `sensors` WHERE `poller_type`= 'snmp' AND `sensor_class` = 'charge' AND `device_id` = '31' AND sensor_type = 'linux' AND `sensor_index` = 'nsExtendOutLine.1']
SQL[INSERT INTO `sensors` (`poller_type`,`sensor_class`,`device_id`,`sensor_oid`,`sensor_index`,`sensor_type`,`sensor_descr`,`sensor_divisor`,`sensor_multiplier`,`sensor_current`)  VALUES ('snmp','charge','31','.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1','nsExtendOutLine.1','linux','Batery Charge','1','1','100')]
( 321 inserted )


SNMP[/usr/bin/snmpget -v2c -c COMMUNITY -OUQnt -M /opt/librenms/mibs:/opt/librenms/mibs/supermicro:/opt/librenms/mibs/dell udp:HOSTNAME:161 .1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.1]
.*.4.1.8*.*.*.*.*.1.8*.*.*.* = No Such Instance currently exists at this OID

Checking (snmp) charge Batery Charge...
0
RRD[update /opt/librenms/rrd/10.133.139.17/sensor-charge-linux-nsExtendOutLine.1.rrd N:0]

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Nov 23, 2017

Member

Thanks for giving it a shot, I think we'll just have to go with the php version for now - thanks for all the feedback and nice work on the PR :)

Member

laf commented Nov 23, 2017

Thanks for giving it a shot, I think we'll just have to go with the php version for now - thanks for all the feedback and nice work on the PR :)

@laf laf merged commit 8c8a2e0 into librenms:master Nov 23, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details
@lock

This comment has been minimized.

Show comment
Hide comment
@lock

lock bot May 16, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed.

lock bot commented May 16, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed.

@lock lock bot locked as resolved and limited conversation to collaborators May 16, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.