Macros | Functions
status.c File Reference

Collect status information and log heartbeat messages. More...

#include "core/or/or.h"
#include "core/or/circuituse.h"
#include "app/config/config.h"
#include "feature/dirclient/dirclient.h"
#include "core/or/status.h"
#include "feature/nodelist/nodelist.h"
#include "core/or/relay.h"
#include "feature/relay/router.h"
#include "feature/relay/routermode.h"
#include "core/or/circuitlist.h"
#include "core/mainloop/mainloop.h"
#include "feature/stats/rephist.h"
#include "feature/hibernate/hibernate.h"
#include "app/config/statefile.h"
#include "feature/hs/hs_stats.h"
#include "feature/hs/hs_service.h"
#include "core/or/connection_st.h"
#include "core/or/dos.h"
#include "feature/stats/geoip_stats.h"
#include "app/config/or_state_st.h"
#include "feature/nodelist/routerinfo_st.h"
#include "lib/tls/tortls.h"

Go to the source code of this file.




static void log_accounting (const time_t now, const or_options_t *options)
STATIC int count_circuits (void)
STATIC char * secs_to_uptime (long secs)
STATIC char * bytes_to_usage (uint64_t bytes)
static void log_onion_service_stats (void)
void note_connection (bool inbound, const connection_t *conn)
void note_circ_closed_for_unrecognized_cells (time_t n_seconds, uint32_t n_cells)
int log_heartbeat (time_t now)


connection counts for heartbeat

Tracks incoming and outgoing connections on IPv4/IPv6, for heartbeat logs.

static unsigned n_incoming_ipv4
static unsigned n_incoming_ipv6
static unsigned n_outgoing_ipv4
static unsigned n_outgoing_ipv6
Counters for unrecognized cells

Track cells that we drop because they are unrecognized and we have nobody to send them to.

static unsigned n_circs_closed_for_unrecognized_cells
static uint64_t n_unrecognized_cells_discarded
static uint64_t n_secs_on_circs_with_unrecognized_cells

Detailed Description

Collect status information and log heartbeat messages.

This module is responsible for implementing the heartbeat log messages, which periodically inform users and operators about basic facts to do with their Tor instance. The log_heartbeat() function, invoked from main.c, is the principle entry point. It collects data from elsewhere in Tor, and logs it in a human-readable format.

Definition in file status.c.

Macro Definition Documentation



Definition at line 15 of file status.c.

Function Documentation

◆ bytes_to_usage()

STATIC char * bytes_to_usage ( uint64_t  bytes)

Take bytes and returns a newly allocated human-readable usage string.

Definition at line 80 of file status.c.

Referenced by log_heartbeat().

◆ count_circuits()

STATIC int count_circuits ( void  )

Return the total number of circuits.

Definition at line 45 of file status.c.

Referenced by log_heartbeat().

◆ log_accounting()

static void log_accounting ( const time_t  now,
const or_options_t options 

Definition at line 300 of file status.c.

◆ log_heartbeat()

int log_heartbeat ( time_t  now)

Log a "heartbeat" message describing Tor's status and history so that the user can know that there is indeed a running Tor. Return 0 on success and -1 on failure.

Now, if we are an HS service, log some stats about our usage

Definition at line 183 of file status.c.

◆ log_onion_service_stats()

static void log_onion_service_stats ( void  )

Log some usage info about our onion service(s).

Definition at line 99 of file status.c.

◆ note_circ_closed_for_unrecognized_cells()

void note_circ_closed_for_unrecognized_cells ( time_t  n_seconds,
uint32_t  n_cells 

Note that a circuit has closed n_seconds after having been created, because of one or more unrecognized cells. Also note the number of unrecognized cells n_cells.

Definition at line 171 of file status.c.

◆ note_connection()

void note_connection ( bool  inbound,
const connection_t conn 

Note that a connection has arrived or has been made, for use in the heartbeat message.

Definition at line 134 of file status.c.

◆ secs_to_uptime()

STATIC char * secs_to_uptime ( long  secs)

Take seconds secs and return a newly allocated human-readable uptime string.

Definition at line 53 of file status.c.

Referenced by log_heartbeat().

Variable Documentation

◆ n_circs_closed_for_unrecognized_cells

unsigned n_circs_closed_for_unrecognized_cells

Definition at line 160 of file status.c.

◆ n_incoming_ipv4

unsigned n_incoming_ipv4

Definition at line 123 of file status.c.

◆ n_incoming_ipv6

unsigned n_incoming_ipv6

Definition at line 124 of file status.c.

◆ n_outgoing_ipv4

unsigned n_outgoing_ipv4

Definition at line 125 of file status.c.

◆ n_outgoing_ipv6

unsigned n_outgoing_ipv6

Definition at line 126 of file status.c.

◆ n_secs_on_circs_with_unrecognized_cells

uint64_t n_secs_on_circs_with_unrecognized_cells

Definition at line 162 of file status.c.

◆ n_unrecognized_cells_discarded

uint64_t n_unrecognized_cells_discarded

Definition at line 161 of file status.c.