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') 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