@@ -43,6 +43,10 @@ namespace px {
43
43
namespace vizier {
44
44
namespace funcs {
45
45
namespace md {
46
+
47
+ constexpr std::string_view kKernelHeadersInstalledDesc =
48
+ " Whether the agent had linux headers pre-installed" ;
49
+
46
50
template <typename TUDTF>
47
51
class UDTFWithMDFactory : public carnot ::udf::UDTFFactory {
48
52
public:
@@ -295,7 +299,9 @@ class GetAgentStatus final : public carnot::udf::UDTF<GetAgentStatus> {
295
299
ColInfo (" create_time" , types::DataType::TIME64NS, types::PatternType::GENERAL,
296
300
" The creation time of the agent" ),
297
301
ColInfo (" last_heartbeat_ns" , types::DataType::INT64, types::PatternType::GENERAL,
298
- " Time (in nanoseconds) since the last heartbeat" ));
302
+ " Time (in nanoseconds) since the last heartbeat" ),
303
+ ColInfo (" kernel_headers_installed" , types::DataType::BOOLEAN, types::PatternType::GENERAL,
304
+ kKernelHeadersInstalledDesc ));
299
305
}
300
306
301
307
Status Init (FunctionContext*) {
@@ -330,6 +336,8 @@ class GetAgentStatus final : public carnot::udf::UDTF<GetAgentStatus> {
330
336
rw->Append <IndexOf (" agent_state" )>(StringValue (magic_enum::enum_name (agent_status.state ())));
331
337
rw->Append <IndexOf (" create_time" )>(agent_info.create_time_ns ());
332
338
rw->Append <IndexOf (" last_heartbeat_ns" )>(agent_status.ns_since_last_heartbeat ());
339
+ rw->Append <IndexOf (" kernel_headers_installed" )>(
340
+ agent_info.info ().host_info ().kernel_headers_installed ());
333
341
334
342
++idx_;
335
343
return idx_ < resp_->info_size ();
@@ -396,6 +404,60 @@ class GetProfilerSamplingPeriodMS final : public carnot::udf::UDTF<GetProfilerSa
396
404
std::function<void (grpc::ClientContext*)> add_context_authentication_func_;
397
405
};
398
406
407
+ /* *
408
+ * This UDTF retrieves the status of the agents' Linux headers installation.
409
+ */
410
+ class GetLinuxHeadersStatus final : public carnot::udf::UDTF<GetLinuxHeadersStatus> {
411
+ public:
412
+ using MDSStub = vizier::services::metadata::MetadataService::Stub;
413
+ using SchemaResponse = vizier::services::metadata::SchemaResponse;
414
+ GetLinuxHeadersStatus () = delete ;
415
+ GetLinuxHeadersStatus (std::shared_ptr<MDSStub> stub,
416
+ std::function<void (grpc::ClientContext*)> add_context_authentication)
417
+ : idx_(0 ), stub_(stub), add_context_authentication_func_(add_context_authentication) {}
418
+
419
+ static constexpr auto Executor () { return carnot::udfspb::UDTFSourceExecutor::UDTF_ONE_KELVIN; }
420
+
421
+ static constexpr auto OutputRelation () {
422
+ return MakeArray (
423
+ ColInfo (" asid" , types::DataType::INT64, types::PatternType::GENERAL, " The Agent Short ID" ),
424
+ ColInfo (" kernel_headers_installed" , types::DataType::BOOLEAN, types::PatternType::GENERAL,
425
+ kKernelHeadersInstalledDesc ));
426
+ }
427
+
428
+ Status Init (FunctionContext*) {
429
+ px::vizier::services::metadata::AgentInfoRequest req;
430
+ resp_ = std::make_unique<px::vizier::services::metadata::AgentInfoResponse>();
431
+
432
+ grpc::ClientContext ctx;
433
+ add_context_authentication_func_ (&ctx);
434
+ auto s = stub_->GetAgentInfo (&ctx, req, resp_.get ());
435
+ if (!s.ok ()) {
436
+ return error::Internal (" Failed to make RPC call to GetAgentInfo" );
437
+ }
438
+ return Status::OK ();
439
+ }
440
+
441
+ bool NextRecord (FunctionContext*, RecordWriter* rw) {
442
+ const auto & agent_metadata = resp_->info (idx_);
443
+ const auto & agent_info = agent_metadata.agent ();
444
+
445
+ const auto asid = agent_info.asid ();
446
+ const auto kernel_headers_installed = agent_info.info ().host_info ().kernel_headers_installed ();
447
+ rw->Append <IndexOf (" asid" )>(asid);
448
+ rw->Append <IndexOf (" kernel_headers_installed" )>(kernel_headers_installed);
449
+
450
+ ++idx_;
451
+ return idx_ < resp_->info_size ();
452
+ }
453
+
454
+ private:
455
+ int idx_ = 0 ;
456
+ std::unique_ptr<px::vizier::services::metadata::AgentInfoResponse> resp_;
457
+ std::shared_ptr<MDSStub> stub_;
458
+ std::function<void (grpc::ClientContext*)> add_context_authentication_func_;
459
+ };
460
+
399
461
namespace internal {
400
462
inline rapidjson::GenericStringRef<char > StringRef (std::string_view s) {
401
463
return rapidjson::GenericStringRef<char >(s.data (), s.size ());
0 commit comments