summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2016-12-01 11:31:01 +0100
committermh <mh@immerda.ch>2016-12-01 11:31:01 +0100
commitfb0fbe06f9c2d3c0428f9129fe67eb2c4aef8f7f (patch)
tree20f2c565f70725d1682915fba2a4dbba29e94703
parentb80f81eb4594ddd4a2a62f21b0c5802e762f8fcc (diff)
make it work if there is no pidfile
-rw-r--r--files/munin/tor_openfds12
1 files changed, 9 insertions, 3 deletions
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 = <PID>;
-close PID;
+my $pidfile = "/var/run/tor/tor.pid";
+my $pid = '';
+if (-e $pidfile) {
+ open (PID, $pidfile) or exit 1;
+ $pid = <PID>;
+ close PID;
+} else {
+ $pid = `pidof tor`;
+}
chomp $pid;
$pid =~ /^[0-9]+$/ or exit 1;