CloudWatchMonitoring脚本运行./mon-get-instance-stats.pl报错

在CentOS 6.4x86_64版本的Amazon  EC2实例安装CloudWatchMonitoring脚本后运行./mon-get-instance-stats.pl报错

ERROR: Failed to call CloudWatch service with HTTP status code 500. Message: Can’t locate object method “new” via package “LWP::Protocol::https::Socket” at /usr/local/share/perl5/LWP/Protocol/http.pm line 31.

解决办法:
yum install openssl openssl-devel
然后重新安装LWP::Protocol::https,一般问题就可以解决。

如果还是报同样的错
yum install perl-core ‘perl(Crypt::SSLeay)’ ‘perl(Digest::SHA)’ ‘perl(Net::LDAP)’ ‘perl(URI)’ ‘mod_perl’ ‘perl(Date::Format)’ ‘perl(LWP::UserAgent)’ ‘perl(Net::DNS)’ ‘perl(IO::Socket::SSL)’ ‘perl(XML::Parser)’ procmail -y

然后再执行./mon-get-instance-stats.pl 依然有报错

Instance i-2bf7f137 statistics for the last 1 hour.
ERROR: Failed to call CloudWatch service with HTTP status code 500. Message: Can’t connect to monitoring.sa-east-1.amazonaws.com:443 (Crypt-SSLeay can’t verify hostnames)
Net::SSL from Crypt-SSLeay can’t verify hostnames; either install IO::Socket::SSL or turn off verification by setting the PERL_LWP_SSL_VERIFY_HOSTNAME environment variable to 0 at /usr/local/share/perl5/LWP/Protocol/http.pm line 51.
For more information, run ‘mon-get-instance-stats.pl –help’

尝试安装IO::Socket::SSL失败

再次解决办法

设置 PERL_LWP_SSL_VERIFY_HOSTNAME 环境变量
设置方法如下:
修改如下文件:
/usr/local/share/perl5/LWP/Protocol/http.pm
将下面这行添加在整个文件的最开头:
$ENV{‘PERL_LWP_SSL_VERIFY_HOSTNAME’} = 0;

 

发表评论