Skip to content

Instantly share code, notes, and snippets.

View kholisrag's full-sized avatar

Kholis Respati Agum Gumelar kholisrag

  • Indonesia
  • 08:29 (UTC +07:00)
View GitHub Profile
@kholisrag
kholisrag / elasticsearch-indicies-reindex.sh
Created August 28, 2024 16:09
Elasticsearch Indicies Reindex Script
#!/bin/bash
# Elasticsearch credentials
ELASTIC_USER="elastic"
ELASTIC_PASSWORD="elasticpassword"
ELASTIC_URL="http://10.1.1.1:9200"
# File containing index names
INDEX_FILE="filtered-index.txt"
@kholisrag
kholisrag / update-disks-labels.sh
Last active August 26, 2024 10:38
bash script to update disk labels based on yaml input
#!/bin/bash
set -e
# YAML config file path
CONFIG_FILE="./x-disks-labels.yaml"
while read disk_name <&3
do
echo "Disk: $disk_name"
@kholisrag
kholisrag / grok-to-regex.py
Last active August 16, 2024 11:16 — forked from elementalvoid/grok-to-regex.py
Improved grok-to-regex.py to run with python 3.12 and nested grok pattern
#!/usr/bin/env python
import argparse
import re
from os import walk
from os.path import join
def get_patterns(patterns_dir):
patterns = {}
for (dirpath, _, filenames) in walk(patterns_dir):
for name in filenames:
@kholisrag
kholisrag / check.sh
Last active July 4, 2024 05:27
gcloud script to check Allow SSH from Internet (`default-allow-ssh`) in your organization / projects that you have permission to access
#!/bin/bash
projects=$(gcloud projects list --format="value(projectId)")
for project in $projects; do
echo "Checking project: $project"
if ! gcloud services list --project "$project" --enabled | grep -q compute.googleapis.com; then
echo "Compute Engine API not enabled for $project. Skipping..."
echo "--------------------"
@kholisrag
kholisrag / helmfile.yaml
Created July 2, 2024 09:49
script to integrate helm post-renderer using helmfile + kubectl apply -k / kustomize
---
helmfiles:
- "../controller/helmfile.yaml"
repositories:
- name: ghcr-actions
url: ghcr.io/actions/actions-runner-controller-charts
oci: true
releases:
@kholisrag
kholisrag / gh-rerun-pr-checks.sh
Last active July 2, 2024 04:43
Github CLI script to rerun checks for PRs used for loadtesting github arc runner scale set - autoscaler
#!/bin/bash
echo "Github CLI script to rerun checks for PRs"
# used for loadtesting github arc runner scale set - autoscaler
export GH_PAGER=""
export REPO_PREFIX="xxx-"
export LIMIT="10"
export PR_SEARCH_QUERY="is:pr is:open draft:false created:>=2024-06-01"
export REPO_SORT="updated" #best-match|forks|help-wanted-issues|stars|updated
@kholisrag
kholisrag / generate-ssh-config-gcp-vm.sh
Last active March 22, 2024 04:17
Generate SSH Config to make alias with gcp vm instances Internal IPs
#!/bin/bash
# Set the project ID
PROJECT_ID="XXXXXXXXX"
# Get instance information in JSON format
gcloud compute instances list \
--project "${PROJECT_ID}" \
--format="json" > ./instances.json
@kholisrag
kholisrag / check-cronjob.sh
Last active January 18, 2024 10:13
List All CronJob in an List of Instances defined in `instances.cfg` with gcloud compute network tags
#!/bin/bash
instance_list="instances.cfg"
date=$(date +'%FT%TZ')
mkdir -pv $(pwd)/cronjob-logs
mkdir -pv $(pwd)/cronjob-logs/$date
while read instance_name <&3
do
echo "----------------------------------------------" 2>&1 | tee -a $(pwd)/cronjob-logs/$date/$instance_name-cronjob.log
@kholisrag
kholisrag / failed-alloc-counter.go
Created June 17, 2022 15:36
Failed Alloc Counter in All Nomad Job
package main
import (
"encoding/json"
"fmt"
"github.com/hashicorp/nomad/api"
"github.com/sirupsen/logrus"
)
@kholisrag
kholisrag / nomad-failed-alloc-checker.go
Created June 17, 2022 15:33
Checking All possible alloc events details when termination already occurs
package main
import (
"encoding/json"
"fmt"
"time"
"github.com/hashicorp/nomad/api"
"github.com/sirupsen/logrus"
)