Users Online

· Guests Online: 86

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

09_001.1 GCS & GCE Challenge Lab Startup Script.html

09_001.1 GCS & GCE Challenge Lab Startup Script.html
Certifications Courses » Google Certified Associate Cloud Engineer Certification
Categories Most Recent Top Rated Popular Courses
 
Uploader Date Added Views Rating
Superadmin 31.05.17 44 No Rating
Description
09_001.1 GCS & GCE Challenge Lab Startup Script.html


----------------------------------------------
#! /bin/bash

#
# Echo commands as they are run, to make debugging easier.
# GCE startup script output shows up in "/var/log/syslog" .
#
set -x


#
# Stop apt-get calls from trying to bring up UI.
#
export DEBIAN_FRONTEND=noninteractive


#
# Make sure installed packages are up to date with all security patches.
#
apt-get -yq update
apt-get -yq upgrade


#
# Install Google's Stackdriver logging agent, as per
# https://cloud.google.com/logging/docs/agent/installation
#
curl -sSO https://dl.google.com/cloudagents/install-logging-agent.sh
bash install-logging-agent.sh


#
# Install and run the "stress" tool to max the CPU load for a while.
#
apt-get -yq install stress
stress -c 8 -t 120


#
# Report that we're done.
#

# Metadata should be set in the "lab-logs-bucket" attribute using the "gs://mybucketname/" format.
log_bucket_metadata_name=lab-logs-bucket
log_bucket_metadata_url="http://metadata.google.internal/computeMetadata/v1/instance/attributes/${log_bucket_metadata_name}"
worker_log_bucket=$(curl -H "Metadata-Flavor: Google" "${log_bucket_metadata_url}" )

# We write a file named after this machine.
worker_log_file="machine-$(hostname)-finished.txt"
echo "Phew! Work completed at $(date)" >"${worker_log_file}"

# And we copy that file to the bucket specified in the metadata.
echo "Copying the log file to the bucket..."
gsutil cp "${worker_log_file}" "${worker_log_bucket}"

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.
Render time: 0.88 seconds
10,871,451 unique visits