Alerting for Arista power supply/fan via ENTITY-STATE-MIB

I’m trying to alert on Arista power supply and fan status. I enabled the Entity State discovery and polling modules for the Arista devieces, and my alerts looks like so:

PSU

Rule: entPhysical.entPhysicalClass = "powersupply" AND entityState.entStateOper != 3

SQL:  SELECT * FROM devices,entityState,entPhysical WHERE (devices.device_id = ? AND devices.device_id = entityState.device_id AND devices.device_id = entPhysical.device_id) AND entPhysical.entPhysicalClass = "powersupply" AND entityState.entStateOper != 3

Fan

Rule: entPhysical.entPhysicalClass = "fan" AND entityState.entStateOper != 3

SQL:  SELECT * FROM devices,entityState,entPhysical WHERE (devices.device_id = ? AND devices.device_id = entityState.device_id AND devices.device_id = entPhysical.device_id) AND entPhysical.entPhysicalClass = "fan" AND entityState.entStateOper != 3

When I run the SQL queries directly, I get a ton of duplicate entries of false positives

MariaDB [librenms]> SELECT * FROM devices,entityState,entPhysical WHERE (devices.device_id = 2 AND devices.device_id = entityState.device_id AND devices.device_id = entPhysical.device_id) AND entPhysical.entPhysicalClass = "powersupply" AND entityState.entStateOper != 3;
...
...
...
146 rows in set (0.004 sec)

MariaDB [librenms]

A LIMIT 2 sanitized snippet from that output is below:

MariaDB [librenms]> SELECT * FROM devices,entityState,entPhysical WHERE (devices.device_id = 2 AND devices.device_id = entityState.device_id AND devices.device_id = entPhysical.device_id) AND entPhysical.entPhysicalClass = "powersupply" AND entityState.entStateOper != 3 LIMIT 2;
+-----------+---------------------+--------------+--------------+------+----------------+-----------+-----------+----------+----------------------------------+----------+----------------------------------+------------+---------+------+-----------+---------+---------+--------------+------------+-----------------------------------------------+-----------------------------------------------------------------------------------+------------+---------+-----------------+----------+-------------+------------+--------+---------------+--------+----------+--------+--------------+---------------------+---------------------+-----------------------+---------------------------+---------------------+---------------------+---------------------+---------+---------+-------------+------------+--------------+----------------------+-------+-----------------------+-----------+----------------+-----------------+-----------+----------------+---------------------+---------------+--------------+---------------+---------------+-----------------+----------------+-----------+------------------+------------------+------------------+-----------------+------------------------+------------------------+------------------------+------------------+--------------------+------------------+----------------------+-----------------------+----------------------+------------------------+-------------------------+--------------------+---------+
| device_id | inserted            | hostname     | sysName      | ip   | overwrite_ip   | community | authlevel | authname | authpass                         | authalgo | cryptopass                       | cryptoalgo | snmpver | port | transport | timeout | retries | snmp_disable | bgpLocalAs | sysObjectID                                   | sysDescr                                                                          | sysContact | version | hardware        | features | location_id | os         | status | status_reason | ignore | disabled | uptime | agent_uptime | last_polled         | last_poll_attempted | last_polled_timetaken | last_discovered_timetaken | last_discovered     | last_ping           | last_ping_timetaken | purpose | type    | serial      | icon       | poller_group | override_sysLocation | notes | port_association_mode | max_depth | disable_notify | entity_state_id | device_id | entPhysical_id | entStateLastChanged | entStateAdmin | entStateOper | entStateUsage | entStateAlarm | entStateStandby | entPhysical_id | device_id | entPhysicalIndex | entPhysicalDescr | entPhysicalClass | entPhysicalName | entPhysicalHardwareRev | entPhysicalFirmwareRev | entPhysicalSoftwareRev | entPhysicalAlias | entPhysicalAssetID | entPhysicalIsFRU | entPhysicalModelName | entPhysicalVendorType | entPhysicalSerialNum | entPhysicalContainedIn | entPhysicalParentRelPos | entPhysicalMfgName | ifIndex |
+-----------+---------------------+--------------+--------------+------+----------------+-----------+-----------+----------+----------------------------------+----------+----------------------------------+------------+---------+------+-----------+---------+---------+--------------+------------+-----------------------------------------------+-----------------------------------------------------------------------------------+------------+---------+-----------------+----------+-------------+------------+--------+---------------+--------+----------+--------+--------------+---------------------+---------------------+-----------------------+---------------------------+---------------------+---------------------+---------------------+---------+---------+-------------+------------+--------------+----------------------+-------+-----------------------+-----------+----------------+-----------------+-----------+----------------+---------------------+---------------+--------------+---------------+---------------+-----------------+----------------+-----------+------------------+------------------+------------------+-----------------+------------------------+------------------------+------------------------+------------------+--------------------+------------------+----------------------+-----------------------+----------------------+------------------------+-------------------------+--------------------+---------+
|         2 | 2020-08-12 14:54:27 | 7280sr-1.lab | 7280sr-1.lab | ��9e | 192.168.57.101 | NULL      | authPriv  | ***      | ******************************** | SHA      | ******************************** | AES        | v3      |  161 | udp       |    NULL |    NULL |            0 |      65001 | .1.3.6.1.4.1.30065.1.3011.7280.3735.48.2878.6 | Arista Networks EOS version 4.23.2F running on an Arista Networks DCS-7280SR-48C6 | NULL       | 4.23.2F | DCS-7280SR-48C6 | NULL     |        NULL | arista_eos |      1 |               |      0 |        0 | 883534 |            0 | 2020-08-21 16:38:38 | NULL                |                  4.97 |                     11.40 | 2020-08-21 16:31:29 | 2020-08-21 16:38:38 |                0.31 |         | network | JPE19362365 | arista.svg |            0 |                    0 | NULL  |                     1 |         0 |              0 |            1656 |         2 |           5817 | 2020-08-11 11:17:25 |             2 |            1 |             3 | 80            |               4 |           6065 |         2 |        100711000 | PowerSupply1     | powerSupply      |                 |                        |                        |                        |                  |                    | true             | PWR-500-DC-F         | zeroDotZero           | L101T800R6APP        |              100710000 |                       1 | ARTESYN            |    NULL |
|         2 | 2020-08-12 14:54:27 | 7280sr-1.lab | 7280sr-1.lab | ��9e | 192.168.57.101 | NULL      | authPriv  | ***      | ******************************** | SHA      | ******************************** | AES        | v3      |  161 | udp       |    NULL |    NULL |            0 |      65001 | .1.3.6.1.4.1.30065.1.3011.7280.3735.48.2878.6 | Arista Networks EOS version 4.23.2F running on an Arista Networks DCS-7280SR-48C6 | NULL       | 4.23.2F | DCS-7280SR-48C6 | NULL     |        NULL | arista_eos |      1 |               |      0 |        0 | 883534 |            0 | 2020-08-21 16:38:38 | NULL                |                  4.97 |                     11.40 | 2020-08-21 16:31:29 | 2020-08-21 16:38:38 |                0.31 |         | network | JPE19362365 | arista.svg |            0 |                    0 | NULL  |                     1 |         0 |              0 |            1658 |         2 |           5819 | 2020-08-13 16:54:20 |             2 |            1 |             3 | 80            |               4 |           6065 |         2 |        100711000 | PowerSupply1     | powerSupply      |                 |                        |                        |                        |                  |                    | true             | PWR-500-DC-F         | zeroDotZero           | L101T800R6APP        |              100710000 |                       1 | ARTESYN            |    NULL |
+-----------+---------------------+--------------+--------------+------+----------------+-----------+-----------+----------+----------------------------------+----------+----------------------------------+------------+---------+------+-----------+---------+---------+--------------+------------+-----------------------------------------------+-----------------------------------------------------------------------------------+------------+---------+-----------------+----------+-------------+------------+--------+---------------+--------+----------+--------+--------------+---------------------+---------------------+-----------------------+---------------------------+---------------------+---------------------+---------------------+---------+---------+-------------+------------+--------------+----------------------+-------+-----------------------+-----------+----------------+-----------------+-----------+----------------+---------------------+---------------+--------------+---------------+---------------+-----------------+----------------+-----------+------------------+------------------+------------------+-----------------+------------------------+------------------------+------------------------+------------------+--------------------+------------------+----------------------+-----------------------+----------------------+------------------------+-------------------------+--------------------+---------+
2 rows in set (0.002 sec)

MariaDB [librenms]>

Looks like unique entityState.entity_state_id and entityState.entPhysical_id are the culprits due to them being non-unique? In that case, what’s the move here? Create a discovery YAML to make them the same as entPhysical.entPhysical_id? Or not? If so, I was looking at some examples based on what I found here: ENTITY-STATE-MIB.entPhysicalDescr - add description field to allow matching and alerting including some other YAMLs in /opt/librenms/includes/definitions/discovery but I’m really lost on what all the available options for those files are, and the docs at https://docs.librenms.org/Developing/Sensor-State-Support/#example don’t really give any suggestions to clue-lacking people like me on how the files are supposed to work or what their capabilities are.

Any help would be greatly appreciated.

Hi,

You already said the solution, but didnt noticed.

You have to check why other rows are showed with that query and find a way to only match the ones you want.

Maybe using entPhysicalDescr too or in change of entPhysicalClass ?

I have some aristas so will check with mine and let you know if I find something.

maybe try to use something like this:
select * from entPhysical inner join entityState on entPhysical.entPhysical_id=entityState.entPhysical_id where entPhysical.device_id=? and entPhysical.entPhysicalClass=“powerSupply” and entityState.entStateOper!=3;

Hmm. Maybe I’m missing something but I feel like using entPhysicalDescr would be a little to administratively prohibitive to maintain since it’s an arbitrarily managed string that the vendor could change over time?

Thanks for this tip. I was ultimately able to find the proper query, which was essentially what you suggested, except the INNER JOIN wasn’t necessary, it seems; the results were the same with and without. That said, is there a reason the INNER JOIN might be necessary though maybe not evident right now?

MariaDB [librenms]> SELECT * FROM devices,entityState,entPhysical WHERE (devices.device_id = 3 AND devices.device_id = entityState.device_id AND devices.device_id = entPhysical.device_id) AND entPhysical.entPhysicalClass = "powersupply" AND entityState.entStateOper != 3 AND entPhysical.entPhysical_id = entityState.entPhysical_id;
+-----------+---------------------+--------------+--------------+------+----------------+-----------+-----------+----------+----------------------------------+----------+----------------------------------+------------+---------+------+-----------+---------+---------+--------------+------------+-------------------------------------------------+--------------------------------------------------------------------------------------+------------+-----------+------------------+----------+-------------+------------+--------+---------------+--------+----------+---------+--------------+---------------------+---------------------+-----------------------+---------------------------+---------------------+---------------------+---------------------+---------+---------+-------------+------------+--------------+----------------------+-------+-----------------------+-----------+----------------+-----------------+-----------+----------------+---------------------+---------------+--------------+---------------+---------------+-----------------+----------------+-----------+------------------+------------------+------------------+-----------------+------------------------+------------------------+------------------------+------------------+--------------------+------------------+----------------------+-----------------------+----------------------+------------------------+-------------------------+--------------------+---------+
| device_id | inserted            | hostname     | sysName      | ip   | overwrite_ip   | community | authlevel | authname | authpass                         | authalgo | cryptopass                       | cryptoalgo | snmpver | port | transport | timeout | retries | snmp_disable | bgpLocalAs | sysObjectID                                     | sysDescr                                                                             | sysContact | version   | hardware         | features | location_id | os         | status | status_reason | ignore | disabled | uptime  | agent_uptime | last_polled         | last_poll_attempted | last_polled_timetaken | last_discovered_timetaken | last_discovered     | last_ping           | last_ping_timetaken | purpose | type    | serial      | icon       | poller_group | override_sysLocation | notes | port_association_mode | max_depth | disable_notify | entity_state_id | device_id | entPhysical_id | entStateLastChanged | entStateAdmin | entStateOper | entStateUsage | entStateAlarm | entStateStandby | entPhysical_id | device_id | entPhysicalIndex | entPhysicalDescr | entPhysicalClass | entPhysicalName | entPhysicalHardwareRev | entPhysicalFirmwareRev | entPhysicalSoftwareRev | entPhysicalAlias | entPhysicalAssetID | entPhysicalIsFRU | entPhysicalModelName | entPhysicalVendorType | entPhysicalSerialNum | entPhysicalContainedIn | entPhysicalParentRelPos | entPhysicalMfgName | ifIndex |
+-----------+---------------------+--------------+--------------+------+----------------+-----------+-----------+----------+----------------------------------+----------+----------------------------------+------------+---------+------+-----------+---------+---------+--------------+------------+-------------------------------------------------+--------------------------------------------------------------------------------------+------------+-----------+------------------+----------+-------------+------------+--------+---------------+--------+----------+---------+--------------+---------------------+---------------------+-----------------------+---------------------------+---------------------+---------------------+---------------------+---------+---------+-------------+------------+--------------+----------------------+-------+-----------------------+-----------+----------------+-----------------+-----------+----------------+---------------------+---------------+--------------+---------------+---------------+-----------------+----------------+-----------+------------------+------------------+------------------+-----------------+------------------------+------------------------+------------------------+------------------+--------------------+------------------+----------------------+-----------------------+----------------------+------------------------+-------------------------+--------------------+---------+
|         3 | 2020-08-12 14:55:19 | 7280cr-8.lab | 7280cr-8.lab | ��9l | 192.168.57.108 | NULL      | authPriv  | ***      | ******************************** | SHA      | ******************************** | AES        | v3      |  161 | udp       |    NULL |    NULL |            0 |          5 | .1.3.6.1.4.1.30065.1.3011.7280.2727.3.32.1605.4 | Arista Networks EOS version 4.24.1.1F running on an Arista Networks DCS-7280CR3-32D4 | NULL       | 4.24.1.1F | DCS-7280CR3-32D4 | NULL     |        NULL | arista_eos |      1 |               |      0 |        0 | 1729029 |            0 | 2020-08-24 13:03:46 | NULL                |                  4.79 |                     13.03 | 2020-08-24 09:57:10 | 2020-08-24 13:03:46 |                0.29 |         | network | JPE19481511 | arista.svg |            0 |                    0 | NULL  |                     1 |         0 |              0 |            3461 |         3 |           9031 | 2020-08-04 12:49:08 |             2 |            2 |             3 | 80            |               4 |           9031 |         3 |        100711000 | PowerSupply1     | powerSupply      |                 | 01                     |                        |                        |                  |                    | true             | PWR-1011-DC-RED      | zeroDotZero           | 6D00101010152GY      |              100710000 |                       1 | Liteon Power       |    NULL |
+-----------+---------------------+--------------+--------------+------+----------------+-----------+-----------+----------+----------------------------------+----------+----------------------------------+------------+---------+------+-----------+---------+---------+--------------+------------+-------------------------------------------------+--------------------------------------------------------------------------------------+------------+-----------+------------------+----------+-------------+------------+--------+---------------+--------+----------+---------+--------------+---------------------+---------------------+-----------------------+---------------------------+---------------------+---------------------+---------------------+---------+---------+-------------+------------+--------------+----------------------+-------+-----------------------+-----------+----------------+-----------------+-----------+----------------+---------------------+---------------+--------------+---------------+---------------+-----------------+----------------+-----------+------------------+------------------+------------------+-----------------+------------------------+------------------------+------------------------+------------------+--------------------+------------------+----------------------+-----------------------+----------------------+------------------------+-------------------------+--------------------+---------+
1 row in set (0.002 sec)

MariaDB [librenms]>

your sql is ok and does the trick, if its all working leave it that way.
the inner join in my sql query is more efficient thats all.
you query is basically cross-join.