-1

I am trying to configure aws cloudwatch script for monitoring memory etc. While executing the script we get below error and I upgraded the perl package the LWP version is also latest as 6 but still script is failing with below error.

I tried setting env variables as PERL_LWP_ENV_PROXY=1 and PERL_LWP_SSL_VERIFY_HOSTNAME=0 but still failing. Please help on this.

[ec2-user@ip-10-175-82-195 aws-scripts-mon]$ sudo ./mon-put-instance-data.pl --mem-util --mem-used --mem-avail --aws-credential-file=./awscreds.template

ERROR: Failed to call CloudWatch: HTTP 500. Message: Can't connect to monitoring.ap-southeast-1.amazonaws.com:443 (timeout)

LWP::Protocol::https::Socket: connect: timeout at /usr/local/share/perl5/LWP/Protocol/http.pm line 47.

For more information, run 'mon-put-instance-data.pl --help'

javaDeveloper
  • 1,403
  • 3
  • 28
  • 42
keeplearning
  • 113
  • 1
  • 9
  • For reference, the scripts are available here: http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/mon-scripts.html FWIW, I do not see anything in the stock modules and scripts that force the use of `Crypt::SSLeay`. Remember, even installing the current `Crypt::SSLeay` opts you in to use `IO::Socket::SSL` (and, by extension, `Net::SSLeay`). See https://www.nu42.com/2014/04/does-your-code-really-depend-on.html – Sinan Ünür Oct 19 '16 at 14:12

3 Answers3

2

PERL_LWP_ENV_PROXY=1

I guess this also means that you have the http_proxy environment variable set to a proxy it should use and that there is no way to the target except by using this proxy.

$ sudo ./mon-put-instance-data.pl

Calling something using sudo will run it with different privileges. For security reasons the environment variables are heavily scrubbed before by sudo before calling the program which probably means that http_proxy is empty for the program run by sudo. This again means that it will try to reach the target site directly instead of using a proxy and will timeout on connection since the site can only be reached using the proxy.

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172
  • I tried running the script as root after exporting PERL_LWP_ENV_PROXY=1 and I am getting the below error. – keeplearning Oct 19 '16 at 06:45
  • [root@ip-10-175-82-195 aws-scripts-mon]# ./mon-put-instance-data.pl --mem-util --mem-used --mem-avail --aws-credential-file=/root/.aws/awscreds ERROR: Failed to call CloudWatch: HTTP 500. Message: SSL negotiation failed: at /usr/local/share/perl5/LWP/Protocol/http.pm line 27. at /usr/local/share/perl5/LWP/Protocol/http.pm line 27. ; at /usr/local/share/perl5/LWP/Protocol/http.pm line 27. ; at /usr/local/share/perl5/LWP/Protocol/http.pm line 27. For more information, run 'mon-put-instance-data.pl --help' – keeplearning Oct 19 '16 at 06:46
  • @Keeplearning: This is a different problem and the original one (timeout) is obviously fixed since it successfully established a TCP connection to the server and only failed in the SSL handshake. Therefore please ask a new question and include the details needed to help with this new question (i.e. code, debug output when run with `-MIO::Socket::SSL=debug4`, ...) – Steffen Ullrich Oct 19 '16 at 06:52
  • Ok I will create a new question – keeplearning Oct 19 '16 at 07:13
  • @Keeplearning: don't forget to accept a correct answer to your question. – Steffen Ullrich Oct 19 '16 at 07:35
  • Hi Steffen, I tried clicking the answer but its not allowing since I am a new user. Thank you very much for your support. – keeplearning Oct 19 '16 at 08:10
  • Thanks for the feedback! Votes cast by those with less than 15 reputation are recorded, but do not change the publicly displayed post score. – keeplearning Oct 19 '16 at 08:10
0

It seems to be build-essential is not installed. Please install the build essentials. I faced the same issue. Once build- essential installed , install all the related cpan module.

sudo apt-get install build-essential

Thanks Amit

Amit
  • 889
  • 2
  • 7
  • 10
0

Try the following:

yum install openssl openssl-devel
perl -MCPAN -e 'install LWP::Protocol::https'

If the issue persists, try

perl -MCPAN -e 'install Bundle::CPAN'
perl -MCPAN -e 'install Bundle::LWP5_837'
Shabbir Bata
  • 861
  • 2
  • 11
  • 23