Overall deepstream-app health - notify on errors / rtsp disconnects via kafka

hi everyone !

im trying to improve my stability on my deepstream-app , im running a simple object detection configuration on some rtsp streams.
im using the reference app deepstream-app on a rather basic configuration and sending inference results via kafka.

i would like to achieve a couple of things but im not sure how:

  1. monitor avg fps on streams ( the data that is outputted to the console … ) - aka :

**PERF: FPS 0 (Avg) FPS 1 (Avg)
**PERF: 0.00 (0.00) 0.00 (0.00)
**PERF: 29.26 (29.23) 29.26 (29.23)
**PERF: 24.99 (27.11) 24.99 (27.11)
**PERF: 25.00 (26.41) 25.00 (26.41)

to detect when and if the app is slowing down i would like to get this output via kafka - to the same topic as the detections go or a different one if possible.
would help to add the src id to the avg so i know which src has which avg.

  1. i would like to be notified when a camera is disconnected from rtsp, i know when a source loses connection theres an auto reconnect interval which works great - but i would like to monitor these outages and send them via kafka to know when a src is down.

i went through the forums and ran into a conversation that lead me to this function in the file: deemstream_source_bin.c

static GstPadProbeReturn
rtspsrc_monitor_probe_func (GstPad * pad, GstPadProbeInfo * info,
gpointer u_data)
{
NvDsSrcBin *bin = (NvDsSrcBin *) u_data;
if (info->type & GST_PAD_PROBE_TYPE_BUFFER) {
g_mutex_lock (&bin->bin_lock);
gettimeofday (&bin->last_buffer_time, NULL);
bin->have_eos = FALSE;
g_mutex_unlock (&bin->bin_lock);
}
if (info->type & GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) {
if (GST_EVENT_TYPE (info->data) == GST_EVENT_EOS) {
bin->have_eos = TRUE;
check_rtsp_reconnection_attempts (bin);
}
}
return GST_PAD_PROBE_OK;
}

problem is:
a) i dont know how or what to add to it so it sends kafka some content
b) i dont know what content runs through it
c) i dont know what or where to add this function after i alternate it to send kafka events.

  1. get the error/warning output from deepstream through kafka to monitor the app remotely, im not even sure if its possible but would be awsome to be notified when the deepstream-app crashes but i doubt it can send somthing on the way down - probably need to monitor the thread that runs the app from the outside but i was wondering how to get the rest of the output.

any information would be much appreciated,
many thanks !

You can refer to our sources\apps\sample_apps\deepstream-test4 to customize your own message.
In the osd_sink_pad_buffer_image_probe fucntion, we show an example of customizing your own messages through NVDS_CUSTOM_MSG_BLOB.

i looked into deepstream-test4 and saw the function that sends images via kafka.

im currently looking for the place where in the main referance app aka “deepstream-app” things are being called to OSD to try and somehow navigate them to kafka.

outputing the entire OSD output to a kafka topic solves everything i need as far as i can see it

You can refer to the code below.

sources\apps\sample_apps\deepstream-app\deepstream_app.c
static GstPadProbeReturn
gie_processing_done_buf_prob (GstPad * pad, GstPadProbeInfo * info,
    gpointer u_data)