cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
TomW
Level 7
Report Inappropriate Content
Message 1 of 2

How to view "user_data" bash script output for MWG Amazon EC2 deployments for troubleshooting

I'm automatically deploying McAfee Web Gateway (MWG) on Amazon EC2 instances using HashiCorp Terraform to manage the infrastructure code for the AWS resources. I need the MWG configuration to be fully automated so I can use an AWS Autoscaling Group.  In my Launch Template, I'm using the EC2 "User Data" feature to run a bash script to automatically make MWG configuration changes at launch time.  

I'm looking for a method that I can use to view the output of the "user_data" bash script for troubleshooting purposes when using the MWG AMI image.

For AMIs other than MWG (e.g. Amazon Linux 2), I can view the bash script output from the EC2 instance System Log from the AWS Console with commands like this:

#!/bin/bash -xe
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
echo "Hello from user-data!"

The EC2 instance System Log contains the following output:

[   17.419042] cloud-init[3785]: + exec [   17.421798] cloud-init<13>Jun 10 21:54:13 user-data: + echo 'Hello from user-data!' <13>Jun 10 21:54:13 user-data: Hello from user-data!

 

However, when I view the EC2 instance System Log from the AWS Console when using the MWG AMI image, I only see the following output:

[?25lUse the ^ and v keys to change the selection.                       

      Press 'e' to edit the selected item, or 'c' for a command prompt.          McAfee Web Gateway                                                             Advanced options for McAfee Web Gateway                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         The selected entry will be started automatically in 5s.                        The selected entry will be started automatically in 4s.                        The selected entry will be started automatically in 3s.                        The selected entry will be started automatically in 2s.                        The selected entry will be started automatically in 1s.                        The selected entry will be started automatically in 0s.                     [?25h[    0.000000] Cannot get hvm parameter CONSOLE_EVTCHN (18): -22!
[    0.547808] Cannot get hvm parameter CONSOLE_EVTCHN (18): -22!
[   24.139503] piix4_smbus 0000:00:01.3: SMBus base address uninitialized - upgrade BIOS or use force_addr=0xaddr


McAfee Web Gateway (8.2.5)
Kernel 3.18.140-5.mlos2.mwg.x86_64 on an x86_64
IPv4 Addresses:        
IPv6 Addresses:        

mwgappl login:

Question:  What method(s) can I use to view the "User Data" bash script output (e.g. from the AWS Console or from the MWG Admin UI)?

Thank you,

Tom 

 

Running commands on your Linux instance at launch:

How can I log my EC2 Linux user-data and then ship it to the console logs?

How to check whether my user data passing to EC2 instance working or not?

 

1 Reply
AaronT
Reliable Contributor
Reliable Contributor
Report Inappropriate Content
Message 2 of 2

Re: How to view "user_data" bash script output for MWG Amazon EC2 deployments for troubles

We had the same issue, and decided to just put a script in our image and run the script on initial boot.  That solved our problem.  Still with we had an answer from McAfee officially, but that's how we got past this problem in our environment

You Deserve an Award
Don't forget, when your helpful posts earn a kudos or get accepted as a solution you can unlock perks and badges. Those aren't the only badges, either. How many can you collect? Click here to learn more.

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use the McAfee Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from McAfee experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by McAfee employees.
Join the Community
Join the Community