Skip to content

Instantly share code, notes, and snippets.

View Ashishkanojia's full-sized avatar

ASHISH ASHOK KANOJIA Ashishkanojia

  • MUMBAI,MAHARASHTRA,INDIA
View GitHub Profile
@Ashishkanojia
Ashishkanojia / log_agent.sh
Last active June 5, 2021 04:47
the script to enable the logging agent in any number of compute instances on GCP
for name in $(gcloud compute instances list --format="value(name)")
do
temp_variable=$(gcloud compute instances list --format="value(name,zone)" | grep ${name})
zone=$(echo $temp_variable | awk '{print $2}')
gcloud compute ssh ${name} --zone=${zone} --command="curl -sSO https://dl.google.com/cloudagents/add-logging-agent-repo.sh"
gcloud compute ssh ${name} --zone=${zone} --command="sudo bash add-logging-agent-repo.sh --also-install --version=1.*.*"
gcloud compute ssh ${name} --zone=${zone} --command="sudo service google-fluentd restart"
echo "logging agent installed for ${name}"
done
echo "logging agent activated successfully"