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
changes cisco_fxos_sensors to base on entity_sensors (reopen PR) #363
Conversation
-> remove *fxos* files -> split entity_sensors.py in utils/enttity_sensors.py end entity_sensors.py -> new cisco_entity_sensors.py: register.snmp/parse function (not for undefined/temp) -> checks in entity_sensors.py -> new test_cisco_entity_sensors.py Known Issues: -> Service name for power_presence "Power Sensor" overlaps with power_consumption sensors -> change to "Power supply" -> default values lower for fan are in conflict with device status -> needs options like 'temperature' -> some ASA devices have no valid scaling value (always 1), posible workaround: in "parse_entity_sensors" check scaling value -> if 1 change to 9 Posible improvements: -> WATO: hw_fan.py -> change "output_metrics" -> CheckBox to FixedValue -> on click less ;-) -> name field in EntitySensor is not used -> can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides some minor issues, we should discuss the known issues you mentioned:
- Service name for power_presence "Power Sensor" overlaps with power_consumption sensors -> change to "Power supply"
Where exactly does this overlap occur? Within this plugin or are there overlaps with another plugin? - default values lower for fan are in conflict with device status -> needs options like 'temperature'
Can this for the moment be overcome by changing the lower levels with a rule? - some ASA devices have no valid scaling value (always 1), posible workaround:
in "parse_entity_sensors" check scaling value -> if 1 change to 9
What value do we get from entPhySensorScale report in such cases?
item: str, | ||
params: TempParamType, | ||
section: EntitySensorSection, | ||
item: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo these changes
item: str, | ||
params: Mapping[str, Any], | ||
section: EntitySensorSection, | ||
item: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo these changes
item: str, | ||
params: Mapping[str, Any], | ||
section: EntitySensorSection, | ||
item: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo these changes
) | ||
|
||
from cmk.base.plugins.agent_based.entity_sensors import ( | ||
check_entity_sensors_fan, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any tests for entity_sensors should be implemented in test_entity_sensors.py. Here, you should only test the parse function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any tests for entity_sensors should be implemented in test_entity_sensors.py. Here, you should only test the parse function.
Ok, so i move the test over to test_entity_sensors.py (except for the parse section), or is there than no additional testing nessecary? And I can remove these additional tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can move them over
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. If I move the discover function tests we will still use functions from both plugins. Is this ok.
e.g. "discover_entity_sensors_power_presence" and "parse_cisco_entity_sensors" in "test_discover_entity_sensors_power_presence"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, its better to not mix that. Just copy _section over to the other file. Also, I guess the discovery and the check function are well tested, so there is no need to add that many tests.
# this MIB, thus we use OID as item instead | ||
|
||
# do not add undefined and temp sensors (duplicate with cisco_temperature) | ||
if sensor_type_nr not in ['0', '8']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have quite some duplicate code here. It would be better to define a generic parse function in utils/entity_sensors.py which takes an additional input argument
sensor_types_ignore: Container[str]
You can then use this function for both snmp sections, for example
def parse_entity_sensors(string_table: List[StringTable]):
return utils.parse_entity_sensors(string_table, set())
|
which plugin?
Can 1 ever be correct? Do we have a way of knowing? |
From the MIB description of sensorValue: "Range: -1000000000 - 1000000000" |
Ok, in that case, everything is fine I would say, since its not even a plugin which is part of Checkmk
Then it would probably make sense to simply hard-code this. I.e., neither temperature nor fan sensors should ever have sensorScale =1 and if this occurs, we set sensorScale =9. However, I would suggest do this afterwards in a separate PR afterwards (small bugfix). |
This is not entirely true, these checks are already there (except for the Power consumption) but sitll in /checks.
Ok. could look like this in the parse function:
|
Ah sry, I thought you meant check plugins that you had lying around locally or something. In general, changing service descriptions is problematic, since it can affect a lot of customers (you have to maybe changes rules etc.). I don't see the overlap between checkpoint_powersupply and entity_sensors. checkpoint_powersupply has
Yes, but as I said, please in a separate commit afterwards. |
One more thing about the naming. A quick grep over your code base shows, that most of this checks use the term "Power supply" (18), some use "Powersupply" (2) or "Power supply satus" (2). and there is at least one "Power consumtion" check (fsc_sc2_power_consumption). |
Ok, what exactly do you want to rename into what? |
From:
to:
|
For now, we leave this as it is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unit tests for the parse function can all be moved to .../utils/test_entity_sensors.py. There, you can tests cases with and without exclusion.
section: EntitySensorSection = {} | ||
sensor_names = {i[0]: i[1] for i in string_table[0]} | ||
for oid_end, sensor_type_nr, scaling_nr, reading, status_nr, device_unit in string_table[1]: | ||
if sensor_type_nr not in sensor_types_ignore: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if sensor_type_nr in sensor_types_ignore:
continue
this avoid indenting the whole block afterwards
|
||
|
||
def parse_entity_sensors(string_table: List[StringTable], | ||
sensor_types_ignore: Optional[Container[str]] = None) -> EntitySensorSection: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use set()
here (and typization Container[str]
)
You mean the last test in .../utils/test_cisco_entity_sensors.py? Even if then have a cross reference betwen entity_sensors and cisco_entity_sensors? If yes, I will then remove .../utils/test_cisco_entity_sensors.py completely. |
What I mean is that there is no need to have separate tests for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from my side, are there any other changes you want to do here? Otherwise Ill go ahead and merge.
Hi Joerg, I think for now we should move forward with this PR. The oher things we discussed, I guess we need to do this at a later time. /Thomas |
Ok, then I will go ahead and merge this. Bugfixes (such as the scaling) can be handled in later PRs. |
-> remove fxos files
-> split entity_sensors.py in utils/enttity_sensors.py end entity_sensors.py
-> new cisco_entity_sensors.py: register.snmp/parse function (not for undefined/temp) -> checks in entity_sensors.py
-> new test_cisco_entity_sensors.py
Known Issues:
-> Service name for power_presence "Power Sensor" overlaps with power_consumption sensors -> change to "Power supply"
-> default values lower for fan are in conflict with device status -> needs options like 'temperature'
-> some ASA devices have no valid scaling value (always 1), posible workaround:
in "parse_entity_sensors" check scaling value -> if 1 change to 9
Posible improvements:
-> WATO: hw_fan.py -> change "output_metrics" -> CheckBox to FixedValue -> on click less ;-)
-> name field in EntitySensor is not used -> can be removed