From 3cf7362f383d2cfa705c3897f6199087c5ddb033 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 15 Mar 2015 12:27:18 +0100 Subject: exchange connections munin plugin tor_connections started blocking and I wasn't able to find the root cause for it nor an updated version of the plugin. This also blocked munin itself, which had the issue that the node disappeared within munin. Based on https://lists.torproject.org/pipermail/tor-talk/2006-June/010486.html it seems to more or less match the open filedescriptors and hence we monitor rather this than rely on a unmanageable plugin. The only drawback is that this must run as root, as non-root users can't read the filedescriptors from proc. --- files/munin/tor_openfds | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 files/munin/tor_openfds (limited to 'files/munin/tor_openfds') diff --git a/files/munin/tor_openfds b/files/munin/tor_openfds new file mode 100644 index 0000000..69f63bc --- /dev/null +++ b/files/munin/tor_openfds @@ -0,0 +1,32 @@ +#!/usr/bin/perl -w +# https://lists.torproject.org/pipermail/tor-talk/2006-June/010486.html + +use strict; + +# Script to monitor the amount of FDs used by +# the Tor process (var/run/tor/tor.pid) + +if ($ARGV[0] and $ARGV[0] =~ /^\s*config\s*$/i) +{ + print "graph_title Open file descriptors for Tor\n"; + print "graph_args --base 1000 -l 0\n"; + print "graph_vlabel open FDs\n"; + print "graph_category network\n"; + print "count.label TorFDs\n"; + exit 0; +} + +open (PID, "/var/run/tor/tor.pid") or exit 1; +my $pid = ; +close PID; +chomp $pid; + +$pid =~ /^[0-9]+$/ or exit 1; + +opendir (FDS, "/proc/$pid/fd") or exit 1; +my @fds = readdir(FDS); +closedir FDS; + +my $count = scalar @fds - 2; + +print "count.value $count\n"; -- cgit v1.2.3 From 4bad7d07bdefaa88df8b80a9b8bf31119e1449d3 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 15 Mar 2015 15:10:09 +0100 Subject: have them all in the same category --- files/munin/tor_openfds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'files/munin/tor_openfds') diff --git a/files/munin/tor_openfds b/files/munin/tor_openfds index 69f63bc..dbf57cd 100644 --- a/files/munin/tor_openfds +++ b/files/munin/tor_openfds @@ -11,7 +11,7 @@ if ($ARGV[0] and $ARGV[0] =~ /^\s*config\s*$/i) print "graph_title Open file descriptors for Tor\n"; print "graph_args --base 1000 -l 0\n"; print "graph_vlabel open FDs\n"; - print "graph_category network\n"; + print "graph_category Tor\n"; print "count.label TorFDs\n"; exit 0; } -- cgit v1.2.3 From fb0fbe06f9c2d3c0428f9129fe67eb2c4aef8f7f Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 1 Dec 2016 11:31:01 +0100 Subject: make it work if there is no pidfile --- files/munin/tor_openfds | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'files/munin/tor_openfds') diff --git a/files/munin/tor_openfds b/files/munin/tor_openfds index dbf57cd..9c14852 100644 --- a/files/munin/tor_openfds +++ b/files/munin/tor_openfds @@ -16,9 +16,15 @@ if ($ARGV[0] and $ARGV[0] =~ /^\s*config\s*$/i) exit 0; } -open (PID, "/var/run/tor/tor.pid") or exit 1; -my $pid = ; -close PID; +my $pidfile = "/var/run/tor/tor.pid"; +my $pid = ''; +if (-e $pidfile) { + open (PID, $pidfile) or exit 1; + $pid = ; + close PID; +} else { + $pid = `pidof tor`; +} chomp $pid; $pid =~ /^[0-9]+$/ or exit 1; -- cgit v1.2.3