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;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章