add globals counter
parent
ae58246f57
commit
1c356660b7
|
@ -61,7 +61,9 @@ $stats = [
|
||||||
"metrics" => [],
|
"metrics" => [],
|
||||||
];
|
];
|
||||||
$news = true;
|
$news = true;
|
||||||
$mqtt->onMessage(function ($message) use (&$data, &$stats, &$news) {
|
$globalCounter=0;
|
||||||
|
$mqtt->onMessage(function ($message) use (&$data, &$stats, &$news,&$globalCounter) {
|
||||||
|
$globalCounter++;
|
||||||
$stats["messages"][] = time();
|
$stats["messages"][] = time();
|
||||||
if (!precheck($message)) {
|
if (!precheck($message)) {
|
||||||
$stats["errors"][] = time();
|
$stats["errors"][] = time();
|
||||||
|
@ -80,6 +82,7 @@ $mqtt->subscribe($mqttTopic, $qos);
|
||||||
echo "Subscribed\n";
|
echo "Subscribed\n";
|
||||||
|
|
||||||
$timer = 0;
|
$timer = 0;
|
||||||
|
|
||||||
echo "Started listening for incoming messages\n will wait 60 seconds before starting to export data\n";
|
echo "Started listening for incoming messages\n will wait 60 seconds before starting to export data\n";
|
||||||
$realStart = time() + 15;
|
$realStart = time() + 15;
|
||||||
echo "waiting till " .
|
echo "waiting till " .
|
||||||
|
@ -166,7 +169,7 @@ function precheck(Message $message): bool
|
||||||
function output(): void
|
function output(): void
|
||||||
{
|
{
|
||||||
filter();
|
filter();
|
||||||
global $data, $stats;
|
global $data, $stats,$globalCounter;
|
||||||
$t = time();
|
$t = time();
|
||||||
|
|
||||||
$prom = "";
|
$prom = "";
|
||||||
|
@ -216,7 +219,8 @@ function output(): void
|
||||||
$prom .= "# $fkey in the last $fname: $count\n";
|
$prom .= "# $fkey in the last $fname: $count\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$prom .= "# \n";
|
||||||
|
$prom .= "# global counter: $globalCounter\n";
|
||||||
$filteredData=[];
|
$filteredData=[];
|
||||||
|
|
||||||
foreach($data as $entry){
|
foreach($data as $entry){
|
||||||
|
|
Loading…
Reference in New Issue