-
-
Save ramnathv/0ce715a32c119be870a2d68f319858e3 to your computer and use it in GitHub Desktop.
Revisions
-
justinshenk revised this gist
Jul 3, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ # instance-name --metadata-from-file startup-script=idle-shutdown.sh` and reboot # NOTE: requires `bc`, eg, sudo apt-get install bc # Modified from https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage threshold=0.1 count=0 wait_minutes=60 -
justinshenk revised this gist
Jul 3, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ wait_minutes=60 while true do load=$(uptime | sed -e 's/.*load average: //g' | awk '{ print $1 }') # 1-minute average load load="${load//,}" # remove trailing comma res=$(echo $load'<'$threshold | bc -l) if (( $res )) -
justinshenk revised this gist
Jun 25, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,8 @@ wait_minutes=60 while true do load=$(uptime | sed -e 's/.*load average: //g' | awk '{ print $3 }') # 1-minute average load load="${load//,}" # remove trailing comma res=$(echo $load'<'$threshold | bc -l) if (( $res )) then -
justinshenk revised this gist
Jun 24, 2018 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,6 @@ threshold=0.4 count=0 wait_minutes=60 while true do -
justinshenk revised this gist
Jun 24, 2018 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,8 @@ threshold=0.4 count=0 wait_minutes=60 while true do @@ -18,7 +20,7 @@ do fi echo "Idle minutes count = $count" if (( count>wait_minutes )) then echo Shutting down # wait a little bit more before actually pulling the plug -
justinshenk revised this gist
Jun 24, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash # Add to instance metadata with `gcloud compute instances add-metadata \ # instance-name --metadata-from-file startup-script=idle-shutdown.sh` and reboot # NOTE: requires `bc`, eg, sudo apt-get install bc # Modified from https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage threshold=0.4 -
justinshenk revised this gist
Jun 24, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash # Add to instance metadata with `gcloud compute instances add-metadata \ # instance-name --metadata-from-file startup-script=idle-shutdown.sh` # NOTE: requires `bc`, eg, sudo apt-get install bc # Modified from https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage threshold=0.4 -
justinshenk revised this gist
Jun 24, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ #!/bin/bash # Add to instance metadata with gcloud compute instances add-metadata \ # instance-name --metadata-from-file startup-script=idle-shutdown.sh # NOTE: requires `bc`, eg, sudo apt-get install bc # Modified from https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage threshold=0.4 -
justinshenk renamed this gist
Jun 24, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash # Add to instance metadata with gcloud compute instances add-metadata \ # instance-name --metadata-from-file startup-script=idle-shutdown.sh # Modified from https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage threshold=0.4 -
justinshenk created this gist
Jun 24, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/bash # Add to instance metadata with gcloud compute instances add-metadata \ # instance-name --metadata-from-file startup-script=auto-shutdown.sh # Modified from https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage threshold=0.4 count=0 while true do load=$(uptime | sed -e 's/.*load average: //g' | awk '{ print $1 }') # 1-minute average load res=$(echo $load'<'$threshold | bc -l) if (( $res )) then echo "Idling.." ((count+=1)) fi echo "Idle minutes count = $count" if (( count>60 )) # number of minutes then echo Shutting down # wait a little bit more before actually pulling the plug sleep 300 sudo poweroff fi sleep 60 done