mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
improve logging with broker store
This commit is contained in:
parent
1f7f42daea
commit
e206347d1a
1 changed files with 19 additions and 18 deletions
|
@ -40,7 +40,7 @@ export {
|
||||||
type AddrPortServTriplet: record {
|
type AddrPortServTriplet: record {
|
||||||
host: addr;
|
host: addr;
|
||||||
p: port;
|
p: port;
|
||||||
serv: vector of string;
|
serv: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
## Holds the set of all known services. Keys in the store are
|
## Holds the set of all known services. Keys in the store are
|
||||||
|
@ -109,28 +109,29 @@ event service_info_commit(info: ServicesInfo)
|
||||||
if ( ! Known::use_service_store )
|
if ( ! Known::use_service_store )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
local v : vector of string;
|
local tempservs = info$service;
|
||||||
for ( s in info$service )
|
for ( s in tempservs ) {
|
||||||
v += s;
|
|
||||||
sort(v, strcmp); # sort the vector for proper key comparison in put_unique
|
|
||||||
|
|
||||||
local key = AddrPortServTriplet($host = info$host, $p = info$port_num, $serv = v);
|
local key = AddrPortServTriplet($host = info$host, $p = info$port_num, $serv = s);
|
||||||
|
|
||||||
when ( local r = Broker::put_unique(Known::service_store$store, key,
|
when ( local r = Broker::put_unique(Known::service_store$store, key,
|
||||||
T, Known::service_store_expiry) )
|
T, Known::service_store_expiry) )
|
||||||
{
|
|
||||||
if ( r$status == Broker::SUCCESS )
|
|
||||||
{
|
{
|
||||||
if ( r$result as bool )
|
if ( r$status == Broker::SUCCESS )
|
||||||
Log::write(Known::SERVICES_LOG, info);
|
{
|
||||||
|
if ( r$result as bool ) {
|
||||||
|
info$service = set(s); # log one service at the time if multiservice
|
||||||
|
Log::write(Known::SERVICES_LOG, info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Reporter::error(fmt("%s: data store put_unique failure",
|
||||||
|
Known::service_store_name));
|
||||||
|
}
|
||||||
|
timeout Known::service_store_timeout
|
||||||
|
{
|
||||||
|
Log::write(Known::SERVICES_LOG, info);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Reporter::error(fmt("%s: data store put_unique failure",
|
|
||||||
Known::service_store_name));
|
|
||||||
}
|
|
||||||
timeout Known::service_store_timeout
|
|
||||||
{
|
|
||||||
Log::write(Known::SERVICES_LOG, info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue