From d106605c2dd9bf5f29924bf2f919fd26affc4174 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Wed, 12 Apr 2017 09:47:28 -0500 Subject: Dbus monitor YAML and generated file Example YAML framework and the future resulting generated source from what's defined in the YAML file for groups, triggers, conditions, and actions in an event. Change-Id: I390cb2bb26a1f43d84d9a71c923fa88e63f00fac Signed-off-by: Matthew Barth --- src/example/monitoring_defs.yaml | 55 ++++++++++++ src/generated.cpp | 184 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 src/example/monitoring_defs.yaml create mode 100644 src/generated.cpp (limited to 'src') diff --git a/src/example/monitoring_defs.yaml b/src/example/monitoring_defs.yaml new file mode 100644 index 0000000..04629db --- /dev/null +++ b/src/example/monitoring_defs.yaml @@ -0,0 +1,55 @@ +# Example sensor monitoring definition +groups: + - name: fan_zone_group + description: Group of fan tach sensors + type: fan_tach + members: + - fan0 + - fan1 + - fan2 + - fan3 + +triggers: + - name: app_start + description: The sensor group manager application started + type: start + - name: properties_changed + description: A property change dbus signal + type: signal + signature: + interface: org.freedesktop.DBus.Properties + member: PropertiesChanged + +conditions: + - name: fans_at_or_above_speed + type: countAtOrAbove + interface: xyz.openbmc_project.Sensor.Value + property: Value + parameters: + group: name + group: member + count: 3 + value: + value: 8000 + type: int64 + +actions: + - name: log_error + type: log_error + parameters: + message: string + +events: + - name: fans_over_speed + groups: + - fan_zone_group + triggers: + - name: app_start + conditions: + - fans_at_or_above_speed + - name: properties_changed + conditions: + - fans_at_or_above_speed + actions: + - name: log_error + message: "ERROR: Number of fans at or above 8000rpms reached" diff --git a/src/generated.cpp b/src/generated.cpp new file mode 100644 index 0000000..6ef7cd1 --- /dev/null +++ b/src/generated.cpp @@ -0,0 +1,184 @@ +#include "data_types.hpp" +#include "functor.hpp" +#include "monitor.hpp" +#include "conditions.hpp" +#include "actions.hpp" + +namespace phosphor +{ +namespace dbus +{ +namespace monitoring +{ + +// Example vector of sensors constructing a group +static Group fan_zone_group = { + std::make_tuple( + "/xyz/openbmc_project/sensors/fan_tach/fan0", + static_cast(0) + ), + std::make_tuple( + "/xyz/openbmc_project/sensors/fan_tach/fan1", + static_cast(0) + ), + std::make_tuple( + "/xyz/openbmc_project/sensors/fan_tach/fan2", + static_cast(0) + ), + std::make_tuple( + "/xyz/openbmc_project/sensors/fan_tach/fan3", + static_cast(0) + ) +}; + +const std::vector>, + std::vector>> + Monitor::events +{ // Example vector of Events with START trigger + {std::make_tuple(std::vector>( + { // Example vector of StartEvent + std::make_shared( + std::vector( + { // Example vector of StartEvent conditions + make_condition(propertyStart( + "/xyz/openbmc_project/sensors/fan_tach/fan0", + "xyz.openbmc_project.Sensor.Value", + "Value", + condition::countAtOrAbove( + fan_zone_group, + "/xyz/openbmc_project/sensors/fan_tach/fan0", + static_cast(3), + static_cast(8000ll) + ) + )), + make_condition(propertyStart( + "/xyz/openbmc_project/sensors/fan_tach/fan1", + "xyz.openbmc_project.Sensor.Value", + "Value", + condition::countAtOrAbove( + fan_zone_group, + "/xyz/openbmc_project/sensors/fan_tach/fan1", + static_cast(3), + static_cast(8000ll) + ) + )), + make_condition(propertyStart( + "/xyz/openbmc_project/sensors/fan_tach/fan2", + "xyz.openbmc_project.Sensor.Value", + "Value", + condition::countAtOrAbove( + fan_zone_group, + "/xyz/openbmc_project/sensors/fan_tach/fan2", + static_cast(3), + static_cast(8000ll) + ) + )), + make_condition(propertyStart( + "/xyz/openbmc_project/sensors/fan_tach/fan3", + "xyz.openbmc_project.Sensor.Value", + "Value", + condition::countAtOrAbove( + fan_zone_group, + "/xyz/openbmc_project/sensors/fan_tach/fan3", + static_cast(3), + static_cast(8000ll) + ) + )), + } + ) + ), + std::make_shared( + "interface='org.freedesktop.DBus.Properties'," + "member='PropertiesChanged'," + "type='signal'," + "path='/xyz/openbmc_project/sensors/fan_tach/fan0'", + std::vector( + { // Example vector of SignalEvent conditions + make_condition(propertySignal( + "xyz.openbmc_project.Sensor.Value", + "Value", + condition::countAtOrAbove( + fan_zone_group, + "/xyz/openbmc_project/sensors/fan_tach/fan0", + static_cast(3), + static_cast(8000ll) + ) + )) + } + ) + ), + std::make_shared( + "interface='org.freedesktop.DBus.Properties'," + "member='PropertiesChanged'," + "type='signal'," + "path='/xyz/openbmc_project/sensors/fan_tach/fan1'", + std::vector( + { // Example vector of SignalEvent conditions + make_condition(propertySignal( + "xyz.openbmc_project.Sensor.Value", + "Value", + condition::countAtOrAbove( + fan_zone_group, + "/xyz/openbmc_project/sensors/fan_tach/fan1", + static_cast(3), + static_cast(8000ll) + ) + )) + } + ) + ), + std::make_shared( + "interface='org.freedesktop.DBus.Properties'," + "member='PropertiesChanged'," + "type='signal'," + "path='/xyz/openbmc_project/sensors/fan_tach/fan2'", + std::vector( + { // Example vector of SignalEvent conditions + make_condition(propertySignal( + "xyz.openbmc_project.Sensor.Value", + "Value", + condition::countAtOrAbove( + fan_zone_group, + "/xyz/openbmc_project/sensors/fan_tach/fan2", + static_cast(3), + static_cast(8000ll) + ) + )) + } + ) + ), + std::make_shared( + "interface='org.freedesktop.DBus.Properties'," + "member='PropertiesChanged'," + "type='signal'," + "path='/xyz/openbmc_project/sensors/fan_tach/fan3'", + std::vector( + { // Example vector of SignalEvent conditions + make_condition(propertySignal( + "xyz.openbmc_project.Sensor.Value", + "Value", + condition::countAtOrAbove( + fan_zone_group, + "/xyz/openbmc_project/sensors/fan_tach/fan3", + static_cast(3), + static_cast(8000ll) + ) + )) + } + ) + ) + }), + std::vector( + { + make_action( + action::log_error( + "ERROR: Number of fans at or above 8000rpms reached" + ) + ) + }) + )} +}; + +} // namespace monitoring +} // namespace dbus +} // namespace phosphor -- cgit v1.2.1