Skip to content

Commit

Permalink
[perlcritic] allow usage of $$
Browse files Browse the repository at this point in the history
  • Loading branch information
cgzones committed Aug 20, 2018
1 parent 39b4ecb commit c9d904c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .perlcriticrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ profile-strictness = quiet

[Variables::ProhibitPunctuationVars]
severity = 5
allow = $_ $! $0 $@
allow = $_ $! $0 $@ $$

[CodeLayout::RequireTidyCode]
perltidyrc = perltidyrc
Expand Down
4 changes: 1 addition & 3 deletions lib/Munin/Common/Logger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ our @EXPORT
use Params::Validate qw(validate SCALAR);
use POSIX;

use English qw(-no_match_vars);

sub _program_name {
my @path = split( '/', $0 );
return $path[-1];
Expand Down Expand Up @@ -49,7 +47,7 @@ my $screen_format = sub {

chomp $message;

return sprintf( "%s [%s][%06d]: %s\n", _timestamp, $level, $PID, $message );
return sprintf( "%s [%s][%06d]: %s\n", _timestamp, $level, $$, $message );
};

my $file_format = $screen_format;
Expand Down
2 changes: 1 addition & 1 deletion lib/Munin/Master/LimitsOld.pm
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ sub generate_service_message {
# See https://github.com/munin-monitoring/munin/issues/382
# and https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=291168.
close(STDOUT);
exec($cmd) or WARN "[WARNING] Failed to exec for contact $c in pid $PID";
exec($cmd) or WARN "[WARNING] Failed to exec for contact $c in pid $$";
exit;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Munin/Master/UpdateWorker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ sub do_work {
# Having a local handle looks easier
my $node = $self->{node};

INFO "[INFO] starting work in $PID for $nodedesignation.\n";
INFO "[INFO] starting work in $$ for $nodedesignation.\n";
my $done = $node->do_in_session(sub {

# A I/O timeout results in a violent exit. Catch and handle.
Expand Down
4 changes: 2 additions & 2 deletions lib/Munin/Master/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ sub munin_getlock {
seek(LOCK, 0, 0);
}
DEBUG "[DEBUG] Writing out PID to lock file $lockname";
print LOCK $PID; # we want the pid inside for later use
if (defined($pid) && length $PID < length $pid) {
print LOCK $$; # we want the pid inside for later use
if (defined($pid) && length $$ < length $pid) {
# Since pid was defined we need to truncate in case len($) < len($pid)
truncate(LOCK, tell(LOCK))
}
Expand Down
22 changes: 11 additions & 11 deletions script/munin-asyncd
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ my $process_name = "main";

my $plugins = {};
{
INFO("[$PID][$process_name] Reading config from $host");
INFO("[$$][$process_name] Reading config from $host");
my $sock = new IO::Socket::INET(
PeerAddr => "$host",
Proto => 'tcp'
Expand Down Expand Up @@ -207,7 +207,7 @@ MAIN: while($keepgoing) {
$when_next = $should_be_next;
}

DEBUG("[$PID][$process_name] $plugin: should_have_been $should_have_been (" .
DEBUG("[$$][$process_name] $plugin: should_have_been $should_have_been (" .
localtime($should_have_been) .
"), should_be_next: $should_be_next (" .
localtime($should_be_next) .
Expand Down Expand Up @@ -250,10 +250,10 @@ MAIN: while($keepgoing) {
if ($sock)
{
if ( $sock->connected ) {
print STDERR "[$PID][$process_name][>] quit\n" if $verbose;
print STDERR "[$$][$process_name][>] quit\n" if $verbose;
print $sock "quit\n" ;
}
print STDERR "[$PID][$process_name] closing sock\n" if $verbose;
print STDERR "[$$][$process_name] closing sock\n" if $verbose;
$sock = undef;
}

Expand All @@ -267,14 +267,14 @@ MAIN: while($keepgoing) {
my $sleep_sec = $when_next - time;

if ($sleep_sec > 0) {
INFO("[$PID][$process_name] Sleeping $sleep_sec sec");
INFO("[$$][$process_name] Sleeping $sleep_sec sec");
sleep $sleep_sec;
} else {
INFO("[$PID][$process_name] Already late : should sleep $sleep_sec sec\n");
INFO("[$$][$process_name] Already late : should sleep $sleep_sec sec\n");
}
}

print STDERR "[$PID][$process_name] Exiting\n" if $verbose;
print STDERR "[$$][$process_name] Exiting\n" if $verbose;

sub fetch_data
{
Expand All @@ -284,9 +284,9 @@ sub fetch_data
my $sock = shift;


print STDERR "[$PID][$process_name][>][$plugin] asking for config\n" if $verbose;
print STDERR "[$$][$process_name][>][$plugin] asking for config\n" if $verbose;

print STDERR "[$PID][$process_name][>][$plugin][sock] config $plugin\n" if $debug;
print STDERR "[$$][$process_name][>][$plugin][sock] config $plugin\n" if $debug;
print $sock "config $plugin\n";

my $is_dirtyconfig;
Expand All @@ -295,7 +295,7 @@ sub fetch_data

while(my $line = <$sock>) {
chomp($line);
print STDERR "[$PID][$process_name][<][$plugin][sock] $line\n" if $debug;
print STDERR "[$$][$process_name][<][$plugin][sock] $line\n" if $debug;

if ($line =~ m/^\./) {
# Starting with . => end
Expand All @@ -322,7 +322,7 @@ sub fetch_data
# if dirty config, bypass the "fetch" part
goto WRITE_SPOOL if $is_dirtyconfig;

INFO("[$PID][$process_name][>][$plugin] asking for data\n");
INFO("[$$][$process_name][>][$plugin] asking for data\n");
DEBUG("[sock][>][$plugin] fetch $plugin\n");
print $sock "fetch $plugin\n";

Expand Down

0 comments on commit c9d904c

Please sign in to comment.