Skip to content

Instantly share code, notes, and snippets.

View adaam's full-sized avatar
😍
Beautiful World

Adam Chen adaam

😍
Beautiful World
  • Knowtions research
  • Taipei, Taiwan
View GitHub Profile
@adaam
adaam / SSH_AUTH_SOCK_Linux.sh
Last active May 2, 2024 06:39
Get ssh-agent SSH_AUTH_SOCK
# Search running ssh-agent
# Source: https://github.com/docker/for-mac/issues/6541#issuecomment-1304604625
SSH_AGENT_PID="$(pgrep ssh-agent)"
SSH_AUTH_SOCK="$(lsof -p "${SSH_AGENT_PID}" | awk '/ unix / {print $8}')
export SSH_AGENT_PID SSH_AUTH_SOCK
@adaam
adaam / cortex-helm-value-block-s3.yaml
Created March 4, 2021 09:44
Cortex helm chart value for AWS S3 as block storage
image:
repository: quay.io/cortexproject/cortex
tag: v1.6.0
pullPolicy: IfNotPresent
clusterDomain: cluster.local
tags:
blocks-storage-memcached: false
ingress:
enabled: true
annotations:
@adaam
adaam / zero_replica.sh
Created February 24, 2021 10:06
Set 0 replica and 1 shard for elasticsearch for new index
#!/bin/bash
curl -X PUT "localhost:9200/_template/zero_replica?pretty" -H 'Content-Type: application/json' -d'
{
"index_patterns": ["*"],
"settings": {
"number_of_shards": 1,
"number_of_replicas" : 0
}
}'
@adaam
adaam / cloudwatch_s3_size.py
Last active October 21, 2023 22:43
Query S3 bucket size by cloudwatch get-metric-data
#!/usr/bin/env python3
# inspire by https://www.slsmk.com/getting-the-size-of-an-s3-bucket-using-boto3-for-aws/
import boto3
import datetime
def main():
# Get all regions
ec2 = boto3.setup_default_session(region_name='us-east-1')
ec2 = boto3.client('ec2')
desc_regions = ec2.describe_regions()
@adaam
adaam / filebeat_nginx_access.json
Last active October 13, 2021 04:46
NGINX pipeline for elasticsearch
{
"description": "Pipeline for parsing Nginx access logs. Requires the user_agent plugins.",
"processors": [{
"grok": {
"field": "message",
"patterns":[
"\"?%{IP_LIST:nginx.access.remote_ip_list} - %{DATA:nginx.access.user_name} \\[%{HTTPDATE:nginx.access.time}\\] \"%{GREEDYDATA:nginx.access.info}\" %{NUMBER:nginx.access.response_code} %{NUMBER:nginx.access.body_sent.bytes} \"%{DATA:nginx.access.referrer}\" \"%{DATA:nginx.access.agent}\" %{DATA:nginx.access.CF_RAY} %{NUMBER:nginx.access.request_time}"
],
"pattern_definitions": {
"IP_LIST": "%{IP}(\"?,?\\s*%{IP})*"
@adaam
adaam / PMM_Error.txt
Last active October 12, 2017 06:50
PMM timeout before agent ready
root@percona_mongodb_lab:/usr/local/percona/pmm-client# pmm-admin add mongodb:queries mdb0g-testingdb --uri mongodb://root:rootpw@127.0.0.1:20010/testingdb
Error adding MongoDB queries: timeout 10s waiting on agent to connect to API.
root@percona_mongodb_lab:/usr/local/percona/pmm-client# cat /var/log/pmm-mongodb-queries-0.log
# Version: percona-qan-agent 1.3.1
# Basedir: /usr/local/percona/qan-agent
# PID: 10560
# API: 172.10.2.23/qan-api
# UUID: e84f9bbe1c094c0c7b01598a0d425776
2017/10/11 18:17:51.569074 main.go:163: Starting agent...
### Keybase proof
I hereby claim:
* I am adaam on github.
* I am cadaam (https://keybase.io/cadaam) on keybase.
* I have a public key whose fingerprint is 7167 468B BF39 D2F6 57AF 62EC C200 9DD3 4346 5BD1
To claim this, I am signing this object:
@adaam
adaam / keybase.md
Last active February 3, 2017 08:16
keybase.md

Keybase proof

I hereby claim:

  • I am adaam on github.
  • I am cadaam (https://keybase.io/cadaam) on keybase.
  • I have a public key ASBYlCMx-GBr9WSpltLY6Xqu6koUVTk-07bJvT-QaARwUAo

To claim this, I am signing this object:

@adaam
adaam / promethous-configmap.yaml
Created November 3, 2016 09:44
k8s 1.2 with promethous 0.19.2 with configmap
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus
data:
prometheus.yml: |-
global:
scrape_interval: 15s
scrape_configs:
# etcd is living outside of our cluster and we configure
@adaam
adaam / nfs_stat.sh
Created November 1, 2016 09:42
Parse "nfsstat -l" file to time serial, for gnuplot using
#!/bin/sh
while true
do
D=$(date +%s)
nfsstat -l > /home/XXX_USER/nfsstat_log/$D
sleep 5
done