Back to index

tor  0.2.3.18-rc
Functions
status.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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.

Function Documentation

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.

Definition at line 81 of file status.c.

{
  char *bw_sent = NULL;
  char *bw_rcvd = NULL;
  char *uptime = NULL;
  const routerinfo_t *me;

  const or_options_t *options = get_options();
  (void)now;

  if (public_server_mode(options)) {
    /* Let's check if we are in the current cached consensus. */
    if (!(me = router_get_my_routerinfo()))
      return -1; /* Something stinks, we won't even attempt this. */
    else
      if (!node_get_by_id(me->cache_info.identity_digest))
        log_fn(LOG_NOTICE, LD_HEARTBEAT, "Heartbeat: It seems like we are not "
               "in the cached consensus.");
  }

  uptime = secs_to_uptime(get_uptime());
  bw_rcvd = bytes_to_usage(get_bytes_read());
  bw_sent = bytes_to_usage(get_bytes_written());

  log_fn(LOG_NOTICE, LD_HEARTBEAT, "Heartbeat: Tor's uptime is %s, with %d "
         "circuits open. I've sent %s and received %s.",
         uptime, count_circuits(),bw_sent,bw_rcvd);

  tor_free(uptime);
  tor_free(bw_sent);
  tor_free(bw_rcvd);

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function: