Skip to content

Commit

Permalink
Merge pull request #1196 from steveschnepp/remove-unused-funcs
Browse files Browse the repository at this point in the history
Remove unused funcs
  • Loading branch information
steveschnepp authored Jun 7, 2019
2 parents 3374b99 + 457bb6b commit 4941171
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 68 deletions.
4 changes: 2 additions & 2 deletions contrib/munin-node-debug
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ sub service
$graph_data_size = "normal" if $plugin_number % 5 == 1;
$graph_data_size = "huge" if $plugin_number % 5 == 2;
$graph_data_size = "custom 10,5 10,10 10" if $plugin_number % 5 == 3;
$graph_data_size = "custom 10,5 for 10, 100s for 10d" if $plugin_number % 5 == 4;
print $client "graph_data_size $graph_data_size\n" if $graph_data_size;
$graph_data_size = "custom 10,5 for 10, 5m for 10d" if $plugin_number % 5 == 4;
for (my $i = 0; $i < $fields_per_plugin; $i ++) {
my $ds = get_ds($plugin_number, $i);
my $ds_info = get_ds_info($plugin_number, $i);
Expand All @@ -207,6 +206,7 @@ sub service
/;
my $plugin_type = $PLUGIN_TYPES[($i + $plugin_number) % 3];

print $client "$ds.graph_data_size $graph_data_size\n" if $graph_data_size;
print $client "$ds.type $plugin_type\n";
}
print $client ".\n";
Expand Down
22 changes: 0 additions & 22 deletions lib/Munin/Common/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,6 @@ my %legal = map { $_ => 1 } qw(

my %bools = map { $_ => 1} qw(yes no true false on off 1 0);

sub cl_is_keyword {
# Class-less version of is_keyword for legacy code.
my ($word) = @_;

return defined $legal{$word};
}


sub is_keyword {
my ($self, $word) = @_;

Expand Down Expand Up @@ -259,17 +251,3 @@ Returns true if $keyword is a valid configuration keyword.
Returns false if $keyword is not a valid configuration keyword.
=back
=head1 FUNCTIONS
=over
=item cl_is_keyword ($keyword)
A "classless" version of B<is_keyword>.
Returns true if $keyword is a valid configuration keyword.
Returns false if $keyword is not a valid configuration keyword.
=back
2 changes: 1 addition & 1 deletion lib/Munin/Common/Logger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ my $screen_format = sub {
my $level = $args{level};
my $message = $args{message};

$message = _remove_label($message);
$message = _remove_label($message) if $message =~ /^\[(DEBUG|INFO|NOTICE|WARNING|ERROR)\][\s:]*/;

chomp $message;

Expand Down
37 changes: 0 additions & 37 deletions lib/Munin/Master/Host.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,6 @@ sub get_full_path {
return join(";",@groups);
}


sub add_attributes_if_not_exists {
my ($self, $attributes) = @_;

%$self = (%$attributes, %$self);
}


sub get_canned_ds_config {
my ($self, $service, $data_source) = @_;

# XXX: Could this be done in some sane way?

my %ds_config;
my $svc_ds_prefix = "$service.$data_source.";

for my $svc_ds_prop (keys %$self) {
if (index($svc_ds_prop, $svc_ds_prefix) == 0) {
my $prop = substr($svc_ds_prop, length($svc_ds_prefix));
$ds_config{$prop} = $self->{$svc_ds_prop};
}
}

return \%ds_config;
}

1;


Expand Down Expand Up @@ -108,16 +82,5 @@ c<use_node_name>.
Returns the full nested named path of the host object (eg. "group1;group2;hostname").
=item B<add_attributes_if_not_exists>
$host->add_attributes_if_not_exists(\%attrs);
Merges the new attributes from %attrs into the host object, without
overwriting any existing attributes.
=item B<get_canned_ds_config>
FIX
=back
10 changes: 6 additions & 4 deletions lib/Munin/Master/Update.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ sub get_dbh {
$dbh->{RaiseError} = 1;
use Carp;
$dbh->{HandleError} = sub { confess(shift) };
}

}

# Plainly returns it, but do *not* put it in $self, as it will let Perl
# do its GC properly and closing it when out of scope.
Expand Down Expand Up @@ -235,9 +234,12 @@ sub _db_init {
my $db_driver = $ENV{MUNIN_DBDRIVER} || "$config->{dbdriver}";
$db_serial_type = "SERIAL" if $db_driver eq "Pg";

# Create DB
$dbh->begin_work();
# Sets some session vars
$dbh->do("PRAGMA journal_mode=WAL;") if $db_driver eq "SQLite";
$dbh->do("SET LOCAL client_min_messages = error") if $db_driver eq "Pg";

# Initialize DB Schema
$dbh->begin_work();
$dbh->do("CREATE TABLE IF NOT EXISTS param (name VARCHAR PRIMARY KEY, value VARCHAR)");
$dbh->do("CREATE TABLE IF NOT EXISTS grp (id $db_serial_type PRIMARY KEY, p_id INTEGER REFERENCES grp(id), name VARCHAR, path VARCHAR)");
$dbh->do("CREATE UNIQUE INDEX IF NOT EXISTS r_g_grp ON grp (p_id, name)");
Expand Down
17 changes: 15 additions & 2 deletions lib/Munin/Master/UpdateWorker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ sub do_work {
# updates, as we don't want to slurp the whole spoolfetched output
# and process it later. It will surely timeout, and use a truckload
# of RSS.
my $timestamp = $node->spoolfetch($spoolfetch_last_timestamp, sub { $self->uw_handle_config( @_ ); } );
my $timestamp = $node->spoolfetch($spoolfetch_last_timestamp, sub {
my ($plugin, $now, $data, $last_timestamp, $update_rate_ptr) = @_;
INFO "spoolfetch config ($plugin, $now)";
local $0 = "$0 t($now) c($plugin)";
$self->uw_handle_config( @_ );
} );

# update the timestamp if we spoolfetched something
$self->set_spoolfetch_timestamp($timestamp) if $timestamp;
Expand Down Expand Up @@ -513,7 +518,7 @@ sub is_fresh_enough {

DEBUG "is_fresh_enough($update_rate, $last_timestamp, $now)";

my ($is_update_aligned, $update_rate_in_sec) = parse_update_rate($update_rate);
my ($update_rate_in_sec, $is_update_aligned) = parse_update_rate($update_rate);

DEBUG "update_rate_in_sec:$update_rate_in_sec";

Expand Down Expand Up @@ -932,6 +937,14 @@ sub parse_custom_resolution {
my $multiplier = int ($nb_sec / $update_rate);
my $multiplier_nb = int ($for_sec / $nb_sec);

# Log & ignore if having a 0
unless ($multiplier && $multiplier_nb) {
ERROR "$elem"
. " -> nb_sec:$nb_sec, for_sec:$for_sec"
. " -> multiplier:$multiplier, multiplier_nb:$multiplier_nb";
next;
}

DEBUG "[DEBUG] $elem"
. " -> nb_sec:$nb_sec, for_sec:$for_sec"
. " -> multiplier:$multiplier, multiplier_nb:$multiplier_nb"
Expand Down
5 changes: 5 additions & 0 deletions t/munin_master_update.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use lib qw(t/lib);


use Test::More;
use Test::Differences;

require_ok( 'Munin::Master::Update' );
require_ok( 'Munin::Master::Config' );
Expand Down Expand Up @@ -40,6 +41,10 @@ ok($update->run() == 5);
kill('TERM', $pid_debug_node);
wait();

# cleanup the update dir
system("rm", "-Rvf", $config->{dbdir});


done_testing();

1;
1 change: 1 addition & 0 deletions t/munin_master_update_spoolfetch.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use lib qw(t/lib);


use Test::More;
use Test::Differences;

require_ok( 'Munin::Master::Update' );
require_ok( 'Munin::Master::Config' );
Expand Down
2 changes: 2 additions & 0 deletions t/munin_master_update_worker.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use lib qw(t/lib);


use Test::More;
use Test::Differences;

use Munin::Master::UpdateWorker;

# parse_update_rate
Expand Down

0 comments on commit 4941171

Please sign in to comment.