[collectd] custom perl plugin: assigning values to variable at init
adnane
mls at adnane.me
Mon Oct 20 15:51:35 CEST 2014
hello
can we assign values to a variable in a TYPE_INIT function and use it
at a read function ? I need
it to load the variable into memory only once and compare its content to
other variable at read functions
sub f_init {
$filename = 'file' ;
open IN, '<', $filename;
my @elements = <IN>;
close IN;
my %element_as_key = map { $_ => 'down' } @elements ;
return 0;
}
f_read {
my $list_size = $#elements + 1 ;
for my $el ( keys %element_as_key ) {
do the magic ..
}
}
is the example above doable ?
thank you!
More information about the collectd
mailing list