Skip to content

Instantly share code, notes, and snippets.

View vadirajks's full-sized avatar

Vadiraj K.S vadirajks

View GitHub Profile
@vadirajks
vadirajks / disk_memory_usage_aerospike.sh
Last active September 15, 2024 22:00
aerospike disk and memory usage in csv
#!/bin/bash
output_csv="aerospike_cluster_stats.csv"
# Check if the output CSV exists and if not, write the header
if [[ ! -f "$output_csv" ]]; then
echo "Node,Namespace,Device Total Bytes,Device Total (MB/GB/TB),Device Used Bytes,Device Used (MB/GB/TB),Device Free %,Device Available %,High Water Disk %,Memory Total Bytes,Memory Total (MB/GB/TB),Memory Used Bytes,Memory Used (MB/GB/TB),Memory Free %,High Water Memory %,Stop Writes %" > "$output_csv"
else
mv -f "$output_csv" "${output_csv}-$(date +%s)"
echo "Node,Namespace,Device Total Bytes,Device Total (MB/GB/TB),Device Used Bytes,Device Used (MB/GB/TB),Device Free %,Device Available %,High Water Disk %,Memory Total Bytes,Memory Total (MB/GB/TB),Memory Used Bytes,Memory Used (MB/GB/TB),Memory Free %,High Water Memory %,Stop Writes %" > "$output_csv"
@vadirajks
vadirajks / sort the fields from the gcloud compute instances list command
Last active July 21, 2024 17:24
sort the fields from the gcloud compute instances list command
list_vm_gcp() {
gcloud compute instances list --project $1 '--format=json(NAME:sort=0,ZONE:sort=1,MACHINE_TYPE,PREEMPTIBLE,INTERNAL_IP,EXTERNAL_IP,STATUS,creationTimestamp:sort=2)' | jq -r '.[] |[.name, (.zone | split("/")[-1]), (.machineType | split("/")[-1]), .scheduling.preemptible, .networkInterfaces[0].networkIP, (.networkInterfaces[0].accessConfigs[0].natIP // "N/A"), .status, .creationTimestamp] | @tsv'| sort -t$'\t' -k8,8 -k2,2 -k1,1 | column -t
}
#python3 /custom-scripts/gmail_attachment_download.py --download_dir /opt/gmail_attachment_download/ --target_subject ".*spending.*" --start_date "16-May-2024" --end_date "18-May-2024"
#python3 /custom-scripts/gmail_attachment_download.py --download_dir /opt/gmail_attachment_download/ --target_subject ".*spending.*"
#python3 /custom-scripts/gmail_attachment_download.py -h
import imaplib
import email
import os
import argparse
import re
from datetime import datetime, timedelta
@vadirajks
vadirajks / certbot_install.sh
Created April 15, 2024 10:12
certbot_install.sh
sudo yum install epel-release
sudo yum install certbot-nginx
#if it is not working, follow the below steps:
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
sudo /opt/certbot/bin/pip install certbot certbot-nginx
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot
sudo certbot --nginx
sudo systemctl reload nginx
@vadirajks
vadirajks / redis_cluster_prod_setup-step-1.sh
Last active March 19, 2024 08:53
redis cluster setup using bash
#!/bin/bash
# Get the hostname
host=$(hostname -i)
# Set the input variable based on the hostname
if [[ $host == *"172.16.25.137"* ]]; then
input="m1=172.16.25.137:8001, s-m2=172.16.25.138:7001, s-m3=172.16.25.139:6001"
elif [[ $host == *"172.16.25.138"* ]]; then
input="m2=172.16.25.138:8002, s-m1=172.16.25.137:7002, s-m3=172.16.25.139:6002"
@vadirajks
vadirajks / gcp_custom_vm.sh
Created February 14, 2024 15:44
gcp_custom_vm.sh
#!/bin/bash
function list_folders_recursive {
local folder="$1"
# Fetch folder names
local folders=$(gcloud resource-manager folders list --folder="$folder" --format="csv[no-heading](name)")
# Check if folders is empty
if [ -z "$folders" ]; then
return
@vadirajks
vadirajks / gke_workload_identity.sh
Created February 6, 2024 09:56
gke_workload_identity.sh
#!/bin/bash
#https://medium.com/@rakeshsaw/workload-identity-secured-way-to-access-google-cloud-apis-from-gke-workloads-44882ec5036a
#https://luandy-4171.medium.com/how-does-gke-workload-identify-work-with-iam-service-account-b996656284f8
#https://stackoverflow.com/questions/75948510/access-to-google-cloud-storage-from-an-autopilot-gke-cluster
#https://bijukunjummen.medium.com/gke-autopilot-and-workload-identity-a2732cf256de
#https://docs.ray.io/en/latest/cluster/kubernetes/user-guides/gke-gcs-bucket.html
# Set variables
CLUSTER_NAME="<YOUR_CLUSTER_NAME>"
PROJECT_ID="<YOUR_PROJECT_ID>"
NAMESPACE="default" # Change if your workloads are deployed in a different namespace
@vadirajks
vadirajks / bq_per_table_storage_billing_recommendation.sql
Created February 6, 2024 09:53
bq_per_table_storage_billing_recommendation.sql
DECLARE active_logical_price_per_gb NUMERIC DEFAULT 0.02;
DECLARE long_term_logical_price_per_gb NUMERIC DEFAULT 0.01;
DECLARE active_physical_price_per_gb NUMERIC DEFAULT 0.04;
DECLARE long_term_physical_price_per_gb NUMERIC DEFAULT 0.02;
WITH storage AS
(
SELECT DISTINCT
tb.table_schema AS dataset,
tb.table_name,
total_rows,
@vadirajks
vadirajks / magento+varnish+nginx setup
Created October 31, 2023 10:53
magento+varnish+nginx setup
upstream fastcgi_backend {
server unix:/run/php/php7.4-fpm.sock;
}
server {
server_name example.com;
listen 127.0.0.1:8080;
set $MAGE_ROOT /var/www/html/webfolder;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
@vadirajks
vadirajks / file etc-statsd-config.js
Created August 22, 2023 10:54
file etc-statsd-config.js
{
graphitePort: 2003,
graphiteHost: "graphite",
port: 8125,
mgmt_adress: "127.0.0.1",
mgmt_port: 8126,
backends: [ "./backends/graphite" ],
graphite: {
legacyNamespace: false,
globalPrefix: "stats",