From Troubleshooting systemd with SystemTap.

systemd-buffers-trace.stp

###############################################################################
#
# SystemTap script for determining where the systemd message bus writes
# are ending up
#
# Author: Mark R. Bannister, Jane Street Group LLC.
#
###############################################################################

global send_count, send_wqueue_non_zero
global write_count, read_count, make_count, bpi_count

function print_time()
{
    printf("--- %s ---\n", tz_ctime(gettimeofday_s()))
}

function get_errstr(retval)
{
    if (retval<0) return errno_str(-retval)
    return sprintf("%d", retval)
}

probe process("/usr/lib/systemd/systemd").function("bus_send_internal").return
{
    if (@entry($bus->wqueue_size)>0) send_wqueue_non_zero++
    send_count[$return]++
}

probe process("/usr/lib/systemd/systemd").function("bus_socket_write_message")
{
    write_count[$bus->output_fd]++
}

probe process("/usr/lib/systemd/systemd-logind").function("bus_socket_read_message")
{
    read_count[$bus->input_fd]++
}

probe process("/usr/lib/systemd/systemd-logind").function("bus_socket_make_message")
{
    make_count++
}

probe process("/usr/lib/systemd/systemd-logind").function("bus_process_internal").return
{
    bpi_count[$return]++
}

probe begin { print_time() }

probe timer.ms($1)
{
    print_time()

    foreach (retval in send_count)
        printf("systemd/bus_send_internal()              returned %s, %6d times\n", get_errstr(retval), send_count[retval])

    if (send_wqueue_non_zero)
        printf("systemd/bus_send_internal()              saw >0 wqueue_size, %6d times\n", send_wqueue_non_zero)

    foreach (fd in write_count)
        printf("systemd/bus_socket_write_message()       sent %6d messages -> fd %d\n", write_count[fd], fd)

    foreach (fd in read_count)
        printf("systemd-logind/bus_socket_read_message() recv %6d messages <- fd %d\n", read_count[fd], fd)

    if (make_count)
        printf("systemd-logind/bus_socket_make_message() called %6d times\n", make_count)

    foreach (retval in bpi_count)
        printf("systemd-logind/bus_process_internal()    returned %s, %6d times\n", get_errstr(retval), bpi_count[retval])

    delete send_count
    delete read_count
    delete write_count
    delete bpi_count
    make_count=send_wqueue_non_zero=0
}