[icinga-checkins] icinga.org: icingaweb2-module-director/feature-ddo-playground: EventstreamCommant: wait for one sec and do not...
git at icinga.org
git at icinga.org
Tue Jul 19 10:31:52 CEST 2016
Module: icingaweb2-module-director
Branch: feature-ddo-playground
Commit: 72a9ae120766b62600ab88fb94a7ba6b1eae78de
URL: https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=72a9ae120766b62600ab88fb94a7ba6b1eae78de
Author: Thomas Gelf <thomas at gelf.net>
Date: Tue Jun 21 15:43:56 2016 +0200
EventstreamCommant: wait for one sec and do not...
...commit without events
---
application/clicommands/EventstreamCommand.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/application/clicommands/EventstreamCommand.php b/application/clicommands/EventstreamCommand.php
index 71d6c4f..17e9792 100644
--- a/application/clicommands/EventstreamCommand.php
+++ b/application/clicommands/EventstreamCommand.php
@@ -44,12 +44,10 @@ class EventstreamCommand extends DdoCommand
// TODO: 0 is forever, leave loop after a few sec and enter again
while (true) {
- while ($res = $redis->brpop('icinga2::events', 3)) {
+ while ($res = $redis->brpop('icinga2::events', 1)) {
// res = array(queuename, value)
$object = $list->processCheckResult(json_decode($res[1]));
- $cnt++;
-
if ($object->hasBeenModified()) {
printf("%s has been modified\n", $object->getUniqueName());
@@ -57,13 +55,14 @@ class EventstreamCommand extends DdoCommand
$db->beginTransaction();
$hasTransaction = true;
}
+ $cnt++;
$object->store();
} else {
printf("%s has not been modified\n", $object->getUniqueName());
}
if (($cnt >= 1000)
- || (($newtime = time()) - $time > 1)
+ || ($cnt > 0 && (($newtime = time()) - $time > 1))
) {
$time = $newtime;
echo "Committing $cnt events\n";
@@ -72,7 +71,8 @@ class EventstreamCommand extends DdoCommand
$hasTransaction = false;
}
}
- echo "Got nothing for 3secs\n";
+
+ echo "Got nothing for 1secs\n";
}
}
More information about the icinga-checkins
mailing list