|
Can't locate Nagios/Plugin.pm in @INC
#39089270
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
|
|
|
|
Всем привет!
Помогите решить проблему.
Конфигурирую систему мониторинга Nagios. Данные собираю посредством агентов. Так вот на одном из агентов состояние оперативной памяти собирается при помощи некоторого скрипта (на других серверах он работает нормально). На проблемном выдаёт ошибку:
1. 2. 3.
root@i-3971-15197-VM:/home/user# /usr/lib/nagios/plugins/check_memory
Can't locate Nagios/Plugin.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /usr/lib/nagios/plugins/check_memory line 26.
BEGIN failed--compilation aborted at /usr/lib/nagios/plugins/check_memory line 26.
Кто знаком с Perl, подскажите что делать. Предполагаю, что доставить что-то нужно, или поменять где-то какой-то путь.
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153.
#!/usr/bin/perl
#
# check_memory - Check free(1) data against given tresholds
#
# Copyright (C) 2007 Thomas Guyot-Sionnest <tguyot@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
use strict;
use warnings;
use vars qw($PROGNAME $VERSION $FREECMD $UNIT);
use Nagios::Plugin;
$PROGNAME = "check_memory";
$VERSION = '1.0.1';
$FREECMD = '/usr/bin/free';
$UNIT = 'M';
my $np = Nagios::Plugin->new(
usage => "Usage: %s [ -w <warning_threshold> ] [ -c <critical_threshold> ]\n"
. ' [ -u <unit> ]',
version => $VERSION,
plugin => $PROGNAME,
blurb => 'Check free(1) data against given tresholds',
timeout => 30,
);
$np->add_arg(
spec => 'warning|w=s',
help => "-w, --warning=THRESHOLD[%]\n"
. " Warning threshold (in bytes or percent) for free memory. See\n"
. " http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT\n"
. " for the threshold format. Alternatively this can be defined as a percentage\n"
. ' of minimum free memory (warning and critical must be in the same format).',
required => 0,
);
$np->add_arg(
spec => 'critical|c=s',
help => "-c, --critical=THRESHOLD[%]\n"
. " Critical threshold (in bytes or percent) for free memory. See\n"
. " http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT\n"
. " for the threshold format. Alternatively this can be defined as a percentage\n"
. ' of minimum free memory (warning and critical must be in the same format).',
required => 0,
);
$np->add_arg(
spec => 'unit|u=s',
help => "-u, --unit=UNIT\n"
. " Unit to use for human-redeable output. Can be 'b', 'K' 'M' or 'G' for\n"
. " bytes, KiB, MiB or GiB respectively (default: '$UNIT').",
default => $UNIT,
required => 0,
);
$np->getopts;
# Assign, then check args
my $multiple;
my $unit = $np->opts->unit;
if ($unit eq 'M') {
$multiple = 1024 * 1024;
} elsif ( $unit eq 'K') {
$multiple = 1024;
} elsif ( $unit eq 'b') {
$multiple = 1;
} elsif ( $unit eq 'G') {
$multiple = 1024 * 1024 * 1024;
} else {
$np->nagios_exit('UNKNOWN', "Unit must be one of 'b', 'K', 'M' or 'G', case-sensitive.");
}
my $verbose = $np->opts->verbose;
# Would better fit later but doing it here validates thresholds
my $warning = $np->opts->warning;
my $critical = $np->opts->critical;
$np->set_thresholds(
warning => ((defined($warning) && $warning !~ /^\d+%$/) ? $warning : undef),
critical => ((defined($critical) && $critical !~ /^\d+%$/) ? $critical : undef),
);
# Better safe than sorry
alarm $np->opts->timeout;
# We always get bytes, then calculate units ourselves
warn("Running: '$FREECMD -b'\n") if ($verbose);
open(RESULT, "$FREECMD -b |")
or $np->nagios_exit('CRITICAL', "Could not run $FREECMD");
warn("Output from $FREECMD:\n") if ($verbose > 1);
my ($used, $free);
while (<RESULT>) {
warn(" $_") if ($verbose > 1);
next unless (m#^\-/\+\ buffers/cache:\s*(\d+)\s+(\d+)#);
$used = $1;
$free = $2;
}
close(RESULT);
alarm(0);
$np->nagios_exit('CRITICAL', "Unable to interpret $FREECMD output") if (!defined($free));
my $total = $used + $free;
if (defined($warning) && $warning =~ /^\d+%$/) {
if ($warning) {
$warning =~ s/%//;
$warning = $total / 100 * $warning;
$warning .= ':';
}
warn("Calculated threshold (from percentage): warn=>$warning\n") if ($verbose);
}
if (defined($critical) && $critical =~ /^\d+%$/) {
if ($critical) {
$critical =~ s/%//;
$critical = $total / 100 * $critical;
$critical .= ':';
}
warn("Calculated threshold (from percentage): crit=>$critical\n") if ($verbose);
}
$np->set_thresholds(
warning => $warning,
critical => $critical,
);
$np->add_perfdata(
label => "free",
value => $free,
uom => 'b',
threshold => $np->threshold,
);
my $freeprint = int($free/$multiple);
$np->nagios_exit($np->check_threshold($free), "$freeprint$unit free");
Если попытаться выполнить (это нагуглил)
получим
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36.
CPAN: Storable loaded ok (v2.20)
Going to read '/root/.cpan/Metadata'
Database was generated on Wed, 21 Oct 2015 10:53:40 GMT
Running install for module 'Nagios::Plugin'
CPAN: Data::Dumper loaded ok (v2.124)
'YAML' not installed, falling back to Data::Dumper and Storable to read prefs '/ root/.cpan/prefs'
Running make for M/MS/MSTROUT/Nagios-Plugin-0.990000.tar.gz
CPAN: Digest::SHA loaded ok (v5.47)
CPAN: Compress::Zlib loaded ok (v2.02)
Checksum for /root/.cpan/sources/authors/id/M/MS/MSTROUT/Nagios-Plugin-0.990000. tar.gz ok
CPAN: Archive::Tar loaded ok (v1.52)
Nagios-Plugin-0.990000/
Nagios-Plugin-0.990000/lib/
Nagios-Plugin-0.990000/lib/Nagios/
Nagios-Plugin-0.990000/lib/Nagios/Plugin.pm
Nagios-Plugin-0.990000/META.yml
Nagios-Plugin-0.990000/META.json
Nagios-Plugin-0.990000/Makefile.PL
Nagios-Plugin-0.990000/MANIFEST
Nagios-Plugin-0.990000/t/
Nagios-Plugin-0.990000/t/no.t
CPAN: File::Temp loaded ok (v0.22)
CPAN.pm: Going to build M/MS/MSTROUT/Nagios-Plugin-0.990000.tar.gz
This is a tombstone release, not an installable distribution
Warning: No success on command[/usr/bin/perl Makefile.PL INSTALLDIRS=site]
Warning (usually harmless): 'YAML' not installed, will not store persistent stat e
MSTROUT/Nagios-Plugin-0.990000.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
Could not read '/root/.cpan/build/Nagios-Plugin-0.990000-OhiENV/META.yml'. Falli
ng back to other methods to determine prerequisites
|
|
|