Category Archives: perl

Can’t locate Perl module File/ in Opsview

I’ve been seeing these errors in our Opsview installation:

Can't locate File/ in @INC (@INC contains: /usr/local/nagios/bin/../lib /usr/local/nagios/bin/../etc /usr/local/nagios/bin/../perl/lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/nagios/bin/../lib/Opsview/ line 23.

These errors were generated by one particular crontab job:


I was able to install File::Slurp module through yum…

yum install -y perl-File-Slurp.noarch

Then, it’s asking for another module… “IPC::Run”

yum install -y perl-IPC-Run.noarch

Then, it’s asking for another module… “IPC::Run::SafeHandles”. But since there are no RPM packages for this, I am forced to do this the perl way… CPAN.

yum install -y perl-CPAN.x86_64

And then installed cpanm right after (as recommended here)

cpan App::cpanminus

Retrying the installation of “IPC::Run::SafeHandles”

cpanm IPC::Run::SafeHandles

Then, I’m stuck… The module IPC::Run::SafeHandles won’t install because it requires “List::MoreUtils::XS”. Which I cannot install because of an error with this unhelpful message:
Screen Shot 2017-08-23 at 1.41.54 PM

I did a few a google search about the module and I stumbled on this exciting discussion.

Hmmmm…. PUREPERL… maybe I need to invoke this via cpanm. Browsing through cpanm’s manual, it has a a –pp option for pure Perl.

cpanm --pp IPC::Run::SafeHandles

It installed without a hitch! 🙂

But as for the Opsview script, it still required 2 more modules:

yum install perl-Proc-Simple
yum install perl-Log-Log4perl

Now I have to find out what caused these Perl modules to be gone missing in the first place…


Request Tracker, migrating from RT 3.8.0 to RT 4.0.2

We’ve been using Request Tracker for tracking requests, incidents and resolutions for years now. A few days ago, we decided to migrate our RT server to a virtual machine so we can retire the old machine. We decided to upgrade to RT 4.0.2 as well.

The upgrade process became complicated because we decided to keep our old data. We managed to upgrade successfully but not without roadblocks.

These are the 2 major issues that we encountered:

1. RT 4.0.2 won’t start because of an issue with the Attachments table, wrong type:

fix: alter table `Attachments` change column `Content` `Content` longblob;

2. Once RT 4.0.2 is running, Perl code in Templates are not parsed properly. Our server ended up sending mails like this:

This message has been automatically generated in response to your request regarding

There is no need to reply to this message right now. Your ticket has been assigned an ID of
[ #{$Ticket->id()}].

Please include [ #{$Ticket->id()}] in the Subject line of all future correspondence about this issue.

Thank you,

The resolution email was much worse 🙂

Request Tracker was nice enough to give us some hint on how to fix it though. These errors keep on appearing on our apache logs:

[Tue Oct 18 14:48:46 2011] [warning]: Use of uninitialized value in string eq at /home/rt/sbin/../lib/RT/ line 410. (/home/rt/sbin/../lib/RT/

After reviewing the module, we came up with a fix.

fix: update Templates set Type = 'Perl';

Perl: hash, determining memory usage

I’ve done this test many times (and I always forgot what the result was).

This is just a simple test, so don’t expect a fancy or in-depth discussion. I just want to check if how much memory can a hash consume, given its values are undef, again, a very rough estimate.

With a million keys of 10 digit numbers:

perl -e ‘my $x = {}; for (my $i = 0; $i < 1_000_000; $i++) { my $key = sprintf(“%010d”, $i); $x->{$key} = undef;}; print “sleeping\n”; sleep 10;’

It consumed about 124MB of memory.

Made some change with the title, what I wrote was quite confusing. Another approach to make it simpler and accurate is to use a CPAN module, Devel::Size

use Devel::Size qw{ total_size };
my $x = {};
for (my $i = 0; $i < 1_000_000; $i++) {
    my $key = sprintf("%010d", $i); $x->{$key} = undef;
print "usage:", total_size($x), " bytes\n";