mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-13 14:55:34 +02:00
Change logs output format to InfluxDB
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
|
||||
|
||||
class FrameStats {
|
||||
const std::string source_name_;
|
||||
const std::string detector_name_;
|
||||
const int module_id_;
|
||||
size_t stats_modulo_;
|
||||
|
||||
int frames_counter_;
|
||||
@@ -19,7 +20,9 @@ class FrameStats {
|
||||
void print_stats();
|
||||
|
||||
public:
|
||||
FrameStats(const std::string &source_name, const size_t stats_modulo);
|
||||
FrameStats(const std::string &detector_name,
|
||||
const int module_id,
|
||||
const size_t stats_modulo);
|
||||
void record_stats(const ModuleFrame &meta);
|
||||
};
|
||||
|
||||
|
||||
@@ -4,9 +4,13 @@
|
||||
using namespace std;
|
||||
using namespace chrono;
|
||||
|
||||
FrameStats::FrameStats(const string& source_name, const size_t stats_modulo) :
|
||||
source_name_(source_name),
|
||||
stats_modulo_(stats_modulo)
|
||||
FrameStats::FrameStats(
|
||||
const std::string &detector_name,
|
||||
const int module_id,
|
||||
const size_t stats_modulo) :
|
||||
detector_name_(detector_name),
|
||||
module_id_(module_id),
|
||||
stats_modulo_(stats_modulo)
|
||||
{
|
||||
reset_counters();
|
||||
}
|
||||
@@ -41,9 +45,19 @@ void FrameStats::print_stats()
|
||||
// * 1000 because milliseconds, 0.5 for truncation.
|
||||
int rep_rate = ((frames_counter_/interval_ms_duration) * 1000) + 0.5;
|
||||
|
||||
cout << "sf_buffer:device_name " << source_name_;
|
||||
cout << " sf_buffer:n_missed_packets " << n_missed_packets_;
|
||||
cout << " sf_buffer:n_corrupted_frames " << n_corrupted_frames_;
|
||||
cout << " sf_buffer:repetition_rate " << rep_rate;
|
||||
uint64_t timestamp = time_point_cast<nanoseconds>(
|
||||
system_clock::now()).time_since_epoch().count();
|
||||
|
||||
// Output in InfluxDB line protocol
|
||||
cout << "jf-udp-recv";
|
||||
cout << ",detector_name=" << detector_name_;
|
||||
cout << ",module_name=M" << module_id_;
|
||||
cout << " ";
|
||||
cout << ",n_missed_packets=" << n_missed_packets_ << "i";
|
||||
cout << ",n_corrupted_frames=" << n_corrupted_frames_ << "i";
|
||||
cout << ",repetition_rate=" << rep_rate << "i";
|
||||
cout << " ";
|
||||
cout << timestamp;
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ int main (int argc, char *argv[]) {
|
||||
const auto udp_port = config.start_udp_port + module_id;
|
||||
FrameUdpReceiver receiver(udp_port, module_id);
|
||||
RamBuffer buffer(config.detector_name, config.n_modules);
|
||||
const string module_name = "M" + to_string(module_id);
|
||||
FrameStats stats(module_name, STATS_MODULO);
|
||||
FrameStats stats(config.detector_name, module_id, STATS_MODULO);
|
||||
|
||||
auto ctx = zmq_ctx_new();
|
||||
auto socket = bind_socket(ctx, config.detector_name, module_id);
|
||||
|
||||
Reference in New Issue
Block a user