Skip to content

Instantly share code, notes, and snippets.

@aravindavk
aravindavk / missing_errnos.cr
Created June 30, 2020 17:23
Missing Errnos - Crystal lang
# Run this using
# touch sample.txt
# crystal run missing_errnos.cr -- sample.txt
# Above command fails to compile if we uncomment the line 39
lib LibXAttr
{% if flag?(:linux) %}
fun getxattr(path : LibC::Char*, name : LibC::Char*, value : LibC::Char*, size : LibC::SizeT) : LibC::Int
{% end %}
{% if flag?(:darwin) %}
fun getxattr(path : LibC::Char*, name : LibC::Char*, value : LibC::Char*, size : LibC::SizeT, position : LibC::UInt32T, options : LibC::Int) : LibC::Int
MASTER=master.example.com
N1=kube-node1.example.com
N2=kube-node2.example.com
N3=kube-node3.example.com
STORAGE_POOL_NAME=sp1
OPERATOR_YAML=operator.yaml
PVC_NAME=pv1
PVC_FILE_NAME=pv1.yaml
APP_POD_NAME=pod1
APP_POD_FILE=pod1.yaml
@aravindavk
aravindavk / failurelogs.d
Last active June 7, 2019 13:03
`./failurelogs.d regression-1.log > failed_logs_1.log` (D language (https://dlang.org/), `dmd` is required to run this script)
#!/usr/bin/rdmd
import std.stdio;
import std.string;
import std.conv;
void main(string[] args)
{
string[] records;
bool inRecord;
import sys
from datetime import datetime
first_ts = None
FMT = "%Y-%m-%d %H:%M:%S"
class Result(object):
def __init__(self):
self.start_ts = None
self.total = 0
# Collects the stats of PVC claims created in Kubernetes
# Install dependencies using `pip3 install kubernetes`
# Run this file and redirect the output to a file
# KUBECONFIG=<path_to_kube_config> python3 pv_claims_stats.py > data.txt
# For example, kubeconfig file will be available in the gcs/deploy directory
# KUBECONFIG=/root/gcs/deploy/kubeconfig python3 pv_claims_stats.py > data.txt
import time
from datetime import datetime
from kubernetes import client, config

Gluster Management APIs

Gluster Management APIs

Get Volumes information

URL

/volumes

HTTP Method

get

@aravindavk
aravindavk / glustercli-auth-header.py
Last active July 17, 2018 05:56
Glusterd2 REST API Authentication Helper script for curl
#!/usr/bin/python3
import sys
from datetime import datetime, timedelta
import jwt
def jwt_token(user, secret):
claims = dict()
openapi: 3.0.0
info:
title: Gluster Management APIs
description: Gluster Peer and Volume Management APIs
version: 1
servers:
- url: http://gluster.example.com/v1
description: Gluster node
paths:
/volumes:
import sys
defines = {
"VKEY_DIAG_LAT_MEASUREMENT" : "diagnostics.latency-measurement",
"VKEY_DIAG_CNT_FOP_HITS" : "diagnostics.count-fop-hits",
"AUTH_ALLOW_MAP_KEY" : "auth.allow",
"AUTH_REJECT_MAP_KEY" : "auth.reject",
"SSL_OWN_CERT_OPT" : "ssl.own-cert",
"SSL_PRIVATE_KEY_OPT" : "ssl.private-key",
"SSL_CA_LIST_OPT" : "ssl.ca-list",
@aravindavk
aravindavk / watch_stime.py
Created September 7, 2017 12:20
Watch stime Geo-replication
import xattr
import struct
import sys
from datetime import datetime
DEFAULT_STATUS = "-"
def human_time(ts):
try: