With Drools fusion, I want to do some alarm for the cpu_idle of a computer. the condition is:
I would receive a record from the machine I monitored per 10s;
if the cpu_idle<10 , drools should open a time window maybe 10mim, and begin to count of how many times the condition cpu_idle<10 occur, the variable is occur_times .
- after 10min, drools check the occur_times.if occur_times>5 then do something alarm else do nothing.
I have no idea how to do this. I use the drools 6.1。below is the main code:
public static void main(String[] args) {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newByteArrayResource(str.getBytes()),
ResourceType.DRL );
InternalKnowledgeBase kbase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
EntryPoint atmStream = ksession.getEntryPoint("ATM Stream" );
ksession.fireAllRules();
}
I have a record bean like:
public class Record {
private double cpu_idle;
private Timestamp collecte_time;
public double getCpu_idle() {
return cpu_idle;
}
public void setCpu_idle(double cpu_idle) {
this.cpu_idle = cpu_idle;
}
public Timestamp getCollecte_time() {
return collecte_time;
}
public void setCollecte_time(Timestamp collecte_time) {
this.collecte_time = collecte_time;
}
}