Skip to content

Instantly share code, notes, and snippets.

@pkazi
pkazi / saveMarathonConfig.sh
Created October 22, 2018 09:11
DCOS Save marathon configs in json format for all marathon apps
#!/bin/bash
# Save marathon configs in json format for all marathon apps
# Usage : saveMarathonConfig.sh
for service in `dcos marathon app list --quiet | tr -d "/" | sort`; do
dcos marathon app show $service | jq '. | del(.tasks, .version, .versionInfo, .tasksHealthy, .tasksRunning, .tasksStaged, .tasksUnhealthy, .deployments, .executor, .lastTaskFailure, .args, .ports, .residency, .secrets, .storeUrls, .uris, .user)' >& $service.json
done
@pkazi
pkazi / dcosDeleteUsers.sh
Created October 22, 2018 09:10
DCOS delete users from organization using CLI (Open Source DCOS)
#!/bin/bash
# Usage dcosDeleteUsers.sh <Users to delete are given in list.txt, each user on new line>
for i in `cat users.list`;
do
echo $i
curl -X DELETE -H "Authorization: Bearer $(dcos config show core.dcos_acs_token)" "$(dcos config show core.dcos_url)/acs/api/v1/users/$i" -d "{}"
done
@pkazi
pkazi / dcosAddUsers.sh
Created October 22, 2018 09:08
DCOS add users to Organization using CLI ( Open Source DCOS)
#!/bin/bash
# Uage dcosAddUsers.sh <Users to add are given in list.txt, each user on new line>
for i in `cat users.list`;
do
echo $i
curl -X PUT -H "Authorization: Bearer $(dcos config show core.dcos_acs_token)" "$(dcos config show core.dcos_url)/acs/api/v1/users/$i" -d "{}"
done
@pkazi
pkazi / dcosGetPublicIP.sh
Created October 22, 2018 09:06
DCOS Get Public IP of all Public Nodes
#!/bin/bash
for id in $(dcos node --json | jq --raw-output '.[] | select(.attributes.public_ip == "true") | .id');
do
dcos node ssh --option StrictHostKeyChecking=no --option LogLevel=quiet --master-proxy --mesos-id=$id "curl -s ifconfig.co"
done 2>/dev/null
@pkazi
pkazi / setupLocalRedisCluster.sh
Created October 16, 2018 06:50
Setup Local redis cluster with 6 nodes (3 master and 3 slaves)
#!/bin/bash
CLUSTER_HOME=$HOME/redis-cluster
echo "Cluster Home is set to : $CLUSTER_HOME"
rm -rf $CLUSTER_HOME
mkdir -p $CLUSTER_HOME
cd $CLUSTER_HOME
wget http://download.redis.io/redis-stable/src/redis-trib.rb
chmod +x redis-trib.rb
mkdir 7000 7001 7002 7003 7004 7005
@pkazi
pkazi / cloudTrailEventNames.list
Last active February 8, 2025 07:28
List of values for parameter EventName in AWS Cloudtrail events
AbortDocumentVersionUpload
AbortEnvironmentUpdate
AbortMultipartUpload
AbortVaultLock
AcceptAccountMapping
AcceptCertificateTransfer
AcceptDelegate
AcceptDirectConnectGatewayAssociationProposal
AcceptFxPaymentCurrencyTermsAndConditions
AcceptHandshake
@pkazi
pkazi / dcosTaskExec.sh
Last active June 27, 2018 06:20
Execute commands in any dcos task. dcos task exec cli is only for mesos containers, this script can be used to ssh into mesos and docker containers.
#!/bin/bash
echo "DCOS Task Exec 2.0"
if [ "$#" -eq 0 ]; then
echo "Need task name or id as input. Exiting."
exit 1
fi
taskName=$1
taskCmd=${2:-bash}
TMP_TASKLIST_JSON=/tmp/dcostasklist.json
#!/bin/bash
# Usage : bash installDCOSDataDogMetricsPlugin.sh <Datadog API KEY>
DDAPI=$1
if [[ -z $DDAPI ]]; then
echo "[Datadog Plugin] Need datadog API key as parameter."
echo "[Datadog Plugin] Usage : bash installDCOSDataDogMetricsPlugin.sh <Datadog API KEY>."
fi
@pkazi
pkazi / addDcosNodeAttributes.sh
Created June 23, 2018 08:05
Add node attributes to dcos nodes and run apps on nodes with required attributes using placement constraints.
#!/bin/bash
#1. SSH on node
#2. Create or edit file /var/lib/dcos/mesos-slave-common
#3. Add contents as :
# MESOS_ATTRIBUTES=<key>:<value>
# Example:
# MESOS_ATTRIBUTES=TYPE:DB;DB_TYPE:MONGO;
#4. Stop dcos-mesos-slave service
# systemctl stop dcos-mesos-slave
@pkazi
pkazi / getDcosNodes.sh
Last active June 23, 2018 17:27
Get DCOS nodes with node attributes, number of tasks running, memory and cpu available
#!/bin/bash
printf "\n %-15s %-18s%-18s%-10s%-15s%-10s\n" "Node Type" "Node IP" "Attribute" "Tasks" "Mem Free (MB)" "CPU Free"
printf '%.0s=' {1..90}
printf "\n"
TAB=`echo -e "\t"`
dcos node --json | jq '.[] | if (.type | contains("leader")) then "Master (leader)" elif ((.type | contains("agent")) and .attributes.public_ip != null) then "Public Agent" elif ((.type | contains("agent")) and .attributes.public_ip == null) then "Private Agent" else empty end + "\t"+ if(.type |contains("master")) then .ip else .hostname end + "\t" + (if (.attributes | length !=0) then (.attributes | to_entries[] | join(" = ")) else "NA" end) + "\t" + if(.type |contains("agent")) then (.TASK_RUNNING|tostring) + "\t" + ((.resources.mem - .used_resources.mem)| tostring) + "\t\t" + ((.resources.cpus - .used_resources.cpus)| tostring) else "\t\tNA\tNA\t\tNA" end' -r | sort -t"$TAB" -k1,1d -k3,3d -k2,2d
printf '%.0s=' {1..90}
printf "\n"