1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Dynamic hostname support

This commit is contained in:
Nicolas Viennot 2013-06-18 05:52:00 -04:00
parent 0f2707b4f1
commit 5ce20c48bc
3 changed files with 13 additions and 6 deletions

View File

@ -13,6 +13,8 @@ StatsD.server = 'monitor:8125'
StatsD.logger = Logger.new(STDERR)
StatsD.mode = 'production'
hostname = Socket.gethostname
loop do
server_count = 0
client_count = 0
@ -30,9 +32,9 @@ loop do
end
end
StatsD.gauge('tmate.servers', server_count)
StatsD.gauge('tmate.clients', client_count)
StatsD.gauge('tmate.unique_ips', ips.uniq.count)
StatsD.gauge("tmate.#{hostname}.servers", server_count)
StatsD.gauge("tmate.#{hostname}.clients", client_count)
StatsD.gauge("tmate.#{hostname}.unique_ips", ips.uniq.count)
sleep 10
end

View File

@ -1,4 +1,5 @@
#include <ctype.h>
#include <unistd.h>
#include "tmate.h"
char *tmate_left_status, *tmate_right_status;
@ -97,6 +98,7 @@ static void unpack_array(struct tmate_unpacker *uk,
static void tmate_header(struct tmate_unpacker *uk)
{
char hostname[128];
int protocol = unpack_int(uk);
if (protocol != 1)
@ -104,8 +106,11 @@ static void tmate_header(struct tmate_unpacker *uk)
tmate_debug("new master, protocol version: %d", protocol);
tmate_notify("Remote session: ssh %s@%s",
tmate_session_token, TMATE_HOST);
if (gethostname(hostname, sizeof(hostname)) < 0)
tmate_fatal("cannot get hostname");
tmate_notify("Remote session: ssh %s@%s.%s",
tmate_session_token, hostname, TMATE_DOMAIN);
}
extern u_int next_window_pane_id;

View File

@ -17,7 +17,7 @@ do { \
/* tmate-encoder.c */
#define TMATE_HOST "a.tmate.io"
#define TMATE_DOMAIN "tmate.io"
enum tmate_client_commands {
TMATE_NOTIFY,