This file contains 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 characters
gsettings set org.ayatana.indicator.datetime time-format 'custom' | |
gsettings set org.ayatana.indicator.datetime custom-time-format '[%B/%A]-[%d-%m-%Y]-[%H:%M]-[%l:%M:%S %P]' | |
https://ubuntuhandbook.org/index.php/2015/12/time-date-format-ubuntu-panel/ |
This file contains 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 characters
#!/bin/bash | |
SlackChannelName=slack-channel | |
SlackHookURL="https://hooks.slack.com/services/dsdsdsdsds" | |
MessageBody= | |
MessageTitle="CRITICAL:/custom-scripts/gcp_commitments_alert.sh ($(hostname)/$(hostname -i))" | |
for project in prokect1 project2; do | |
gcloud compute commitments list --project $project --format="csv(selfLink.scope(regions),name,resources,startTimestamp.date('%Y-%m-%d'),endTimestamp.date('%Y-%m-%d'),type,status)" | sed "s/\"{'type': '//g" | sed "s/', 'amount': '/=/g" | sed "s/'}\",/,/g" | sed "s/'}\";/:/g" | awk -F ',' '{gsub(/[\/].*/, "", $1); print}' OFS="," > /tmp/commitments_${project}.txt || exit 2 | |
sed -i '/^self_link/d' /tmp/commitments_${project}.txt 2> /dev/null || continue | |
COUNT=0 | |
for region in $(awk -F, '{print $1}' /tmp/commitments_${project}.txt | sort | uniq); do |
This file contains 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 characters
# This playbook was meant to be executed after provisioning. | |
# Initially client side certificates where created during | |
# image cooking, but soon figured out it would not work in | |
# the long run. When I changed it to post provision execution | |
# I found errors that mentioned certificates already existed | |
# and found the issue described in GitHub. | |
--- | |
- hosts: all | |
become: yes |
This file contains 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 characters
IFS=$'\n' | |
echo "INSTANCE-GROUPS,LOCATION,SCOPE,INSTANCE-TEMPLATES,IMAGE" | |
for ig in $(gcloud compute instance-groups list | grep -v "^dataflow\|^NAME\|^gke"); do | |
result=$(echo $ig|awk 'BEGIN { OFS="," }{print $2,$3}') | |
tmresult=$(gcloud compute instance-groups managed describe $(echo $ig|awk '{print $1}') --zone $(echo $ig|awk '{print $2}') --format=json | jq -r "[.instanceGroup,.instanceTemplate]|@csv") | |
for i in $(echo ${tmresult}) ; do | |
set $(echo $i | tr "," "\n"|tr -d '"') | |
image=$(gcloud compute instance-templates describe ${2##*/} --format=json | jq -r ".properties|.disks[].initializeParams.sourceImage") | |
echo ${1##*/},$result,${2##*/},${image##*/} | |
done |
This file contains 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 characters
#!/bin/bash | |
which whisper-info >/dev/null || { | |
echo >&2 "'whisper-info' not found: please install" | |
exit 1 | |
} | |
options=('find' 'delete') | |
PS3='state your wish: ' | |
echo -e "\nfind/delete corrupt whisper-files" |
This file contains 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 characters
#!/bin/bash | |
delete_hours=3 | |
delete_sec=$(( ($delete_hours*60)*60)) | |
gcp_output_file=/tmp/app-gcp-list.txt | |
gcloud compute instances list --format="csv(name:sort=0,networkInterfaces.networkIP,zone:sort=1)" --filter="status=RUNNING AND labels.appname:app" |sed 's/\./_/g'>$gcp_output_file | |
[ ! $? -eq 0 ] && { echo >&2 "$gcp_output_file gcp command issue"; exit 1; } | |
[[ $(wc -l $gcp_output_file| awk '{print $1}') -lt 25 ]] && { echo >&2 "$gcp_output_file gcp command issue"; exit 1; } | |
for folder_list in /var/lib/carbon/whisper/asia-southeast1/app/autoscaling/vm /var/lib/carbon/whisper/asia-southeast1/app/static/vm ; do | |
[ $(echo $folder_list| awk -F/ '{print $(NF-1)}') == "static" ] && vm_type=static || vm_type=auto | |
for folder in $(ls $folder_list -1); do |
This file contains 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 characters
#!/bin/bash | |
export project=" | |
a | |
b | |
c | |
" | |
for p in $project; do | |
for disk in $(gcloud compute disks list --filter="-users:*" --format "csv(name,LOCATION)" --project "$p"); do | |
echo "deleting: ${disk}" | |
gcloud compute disks delete --zone=${disk##*,} --quiet ${disk%%,*} --project "$p" |
This file contains 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 characters
#!/bin/bash | |
project_name="Project-ID" | |
echo -e "project_id,dataset_id,table_id,creation_time,last_modified_time,row_count,size_mb,size_gb,type,partiton,partition_expiration_days,cluster_key" > /tmp/bq_out.csv | |
for dataset in $(bq ls|tail -n +3); do | |
bq query --format=csv --use_legacy_sql=false ' | |
SELECT | |
t1.project_id as project_id, | |
t1.dataset_id as dataset_id , | |
t1.table_id as table_id, | |
TIMESTAMP_MILLIS(t1.creation_time) AS creation_time, |
This file contains 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 characters
#!/bin/bash | |
SlackChannelName=abc | |
SlackHookURL="abc" | |
MessageBody= | |
MessageTitle="CRITICAL:/aerospike_space_alert.sh [$(hostname)/$(hostname -i)]" | |
AerospikeIP=192.168.0.1:3000 | |
OLDIFS=$IFS; IFS=$'\n' | |
#HWMDisk=60 | |
#HWMMem=75 | |
HWMDisk=55 |
This file contains 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 characters
root@foo:~# rm -rf test; mkdir test; touch test/test{1,2,3}; chown ubuntu test/test1; chown aptly test/test2; ls -al test/ | |
total 8 | |
drwxr-xr-x 2 root root 4096 Nov 30 10:47 . | |
drwx------ 11 root root 4096 Nov 30 10:47 .. | |
-rw-r--r-- 1 ubuntu root 0 Nov 30 10:47 test1 | |
-rw-r--r-- 1 aptly root 0 Nov 30 10:47 test2 | |
-rw-r--r-- 1 root root 0 Nov 30 10:47 test3 | |
root@foo:~# rsync -avz --chown 'nginx:www-data' -e "ssh -i ~/.ssh/my.key" --verbose test root@bar:/tmp/ | |
opening connection using: ssh -i "~/.ssh/my.key" -l root bar rsync --server -vvlogDtprze.iLsfx "--usermap=*:nginx" "--groupmap=*:www-data" . /tmp/ (13 args) |