Skip to content

Instantly share code, notes, and snippets.

View andreyev's full-sized avatar
💭
I may be slow to respond.

Andreyev Dias de Melo andreyev

💭
I may be slow to respond.
View GitHub Profile
worker_processes auto;
rtmp_auto_push on;
events {}
rtmp {
server {
listen 1935;
listen [::]:1935 ipv6only=on;
application live {
live on;
429147289
400651899
856483199
[
{
"targets": [
"prometheus.io"
],
"labels": {
"__meta_datacenter": "london",
"__meta_prometheus_job": "node"
}
}
@andreyev
andreyev / gist:256f25a288a6590215e98804ca8bee60
Created June 30, 2021 18:20
list and post all AWS tagged resources to prometheus pushgateway
cat <<EOF | curl --data-binary @- http://localhost:9091/metrics/job/inventory/cloud/aws
$(aws ec2 describe-regions --region us-east-1 | jq -r '.Regions[].RegionName' | sort | while read REGION; do
aws resourcegroupstaggingapi get-resources --region $REGION | jq --arg Region $REGION -r '.ResourceTagMappingList[].ResourceARN';
done | while read LINE; do echo 'resource_item{partition="'$(echo ${LINE//\//:} | cut -d ':' -f2)'",service="'$(echo ${LINE//\//:} | cut -d ':' -f3)'",region="'$(echo ${LINE//\//:} | cut -d ':' -f4)'",account_id="'$(echo ${LINE//\//:} | cut -d ':' -f5)'",resource_type="'$(echo ${LINE//\//:} | cut -d ':' -f6)'",resource_id="'$(echo ${LINE//\//:} | cut -d ':' -f7)'"} 1'; done| sort -u)
EOF
@andreyev
andreyev / gist:d73534cf3deaf159a59a924a26c1c7c9
Created June 18, 2021 17:07
list all aws resources by ARN
aws ec2 describe-regions --region us-east-1 | jq -r '.Regions[].RegionName' | sort | while read REGION; do aws resourcegroupstaggingapi get-resources --region $REGION | jq --arg Region $REGION -r '.ResourceTagMappingList[]|"\($Region):\(.ResourceARN)"'; done
@andreyev
andreyev / gist:e2590962f2fbebcdcaf8626f34ce2efb
Created June 18, 2021 16:47
compare and instances reservations on every region of aws
aws ec2 describe-regions --region us-east-1 | jq -r '.Regions[].RegionName' | sort | while read REGION; do aws --region $REGION ec2 describe-instances | jq -r '.Reservations[].Instances[]|select(.State.Name|match("running"))|"\(.InstanceType)"'| sort | uniq -c > /tmp/instances; aws --region $REGION ec2 describe-reserved-instances | jq -r '.ReservedInstances[]|select(.State|match("active"))|" \(.InstanceCount) \(.InstanceType)"'| sort > /tmp/reservations; [[ -s /tmp/instances || -s /tmp/reservations ]] && echo -ne "Region: $REGION\n-Instances:\n$(cat /tmp/instances)\n-Reservations:\n$(cat /tmp/reservations)\n"; done
#!/bin/bash
# Before run you need to cache policies files running:
# $ mkdir policies
# $ i=0 aws iam list-policies | jq -r '.Policies[]|"\(.PolicyName) \(.Arn) \(.DefaultVersionId)"' | while read name arn version; do echo $((i++)); aws iam get-policy-version --policy-arn $arn --version-id $version > policies/${name}.json; done
# And map policy name and ARN
# $ aws iam list-policies | jq -r '.Policies[]|"\(.PolicyName) \(.Arn)"' > policies-arn
# To do: handle inline policies
# usage example to get all users who have s3 action on my-bucket: `$ bash policy-inspector.sh 's3:' "arn:aws:s3:::my-bucket" policies/*`
#!/bin/bash
# Usage: curl https://gist.githubusercontent.com/andreyev/32d175147f7b31e73d1a2b84880e0906/raw/puppet-installer.sh | bash -s -- PUPPETENV
PUPPETENV=$1
which puppet || {
OS_MAJ_VERSION=$(rpm -qa \*-release | grep -Ei "centos" | cut -d"-" -f3)
[[ -z "$OS_MAJ_VERSION" ]] && { echo "Distro not supported"; exit 1;}
yum install -y https://yum.puppetlabs.com/puppetlabs-release-pc1-el-"$OS_MAJ_VERSION".noarch.rpm
yum install -y puppet
@andreyev
andreyev / speech
Created April 4, 2017 14:08
Google Translate Speech
#!/bin/bash
STRING="$*"
FILE=/tmp/${STRING// /_}.mp3
test -f $FILE || wget -q -U Mozilla -O ${FILE} "http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=${1}&h&tl=pt-BR"
mplayer ${FILE} &>/dev/null
@andreyev
andreyev / ScriptRunner REST Endpoint to update JIRA's User Property
Last active March 23, 2021 18:14
ScriptRunner REST Endpoint to update JIRA's User Property
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
import javax.servlet.http.HttpServletRequest
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.atlassian.jira.component.ComponentAccessor