Hi Carsten,
On Tue, Jul 30, 2013 at 11:12 AM, Carsten Ziegeler <[email protected]> wrote:
>... I think there isn't necessarily a 1:1 mapping between a check and an
> expression, e.g. if you have a check for "are all bundles active" this is
> very hard to express as an expression...
Not really, it can be either
hc.osgi.inactiveBundlesCount == 0
or
hc.osgi.inactiveBundlesList.isEmpty()
but I see your point, having a generic HealthCheck service makes
sense, I'll draft that below.
> I also would avoid the name "rule" for this - it's a check :)
ok
> We need some result, I'm not sure whether restricting this to a boolean is
> flexible enough. For example if you have a check for available free memory,
> just returning a boolean might not be enough. Maybe we also want to support
> additional information like "this looks wrong ,please check here and there"
Yes, that's the purpose of the mini-logs that the current code is
using, I think those are very useful, for the free memory example the
mini-log might output
INFO MBean java.lang:service=memory attribute=heap value=123456
WARN 123456 is less than configured limit 123457, check fails
That's already implemented and also returned as part of MBean output,
and we can easily add INFO messages with recommendation about how to
fix things. Any log message at or above WARN causes the rule to fail,
which also makes it simpler to detect problems in rule evaluation.
> ...Please note, I'm not talking about how to implement a check - this can be
> done through the scripts you already have - right now I'm just talking
> about the consumer API of such a check...
Ok, so how about
public interface HealthCheck {
HealthCheckResult execute();
// Unique ID (path of the Resource used to define
/ this item, OSGi config PID, etc.)
public String getId();
// Tags are used to select HCItems when checking a subset of them
public Set<String> getTags();
// Additional info: name, description, how to fix etc
public Map<String, String> getInfo();
}
public interface HealthCheckResult {
public HealthCheck getHealthCheck();
// If this is false, all checks were successful
public boolean anythingToReport();
public List<LogMessage> getLogMessages();
}
And HealthCheck are just OSGi services.
-Bertrand