Skip to content

Instantly share code, notes, and snippets.

@julcap
julcap / kill_long_queries.sh
Last active June 4, 2017 09:41
Kill long MySQL queries
##################################################
# Kill long queries #
# This shell script will kill queries that have #
# passed the $MAX execution time. #
# Julian Capilla-krumbak #
# lyhan_jr@hotmail.com #
# 21-05-2014 #
##################################################
#!/bin/bash
@julcap
julcap / check-cacerts.sh
Last active June 10, 2020 20:45
Check expiration date for certificates in JVM cacerts file
######################################################
# List certificates, find if a cert is expired.
# Requirements for sending emails: postfix, mailutils
#
# 15-12-2015
# Julian Capilla
# lyhan_jr@hotmail.com
######################################################
#!/bin/bash
@julcap
julcap / log_fragmenter.py
Last active May 4, 2016 13:04
Log fragmenting tool
# Log fragmenting 'tool'
# Author: Julian Capilla-krumbak
# Date: 2016-05-04
#
# Expected log format: yyyymmdd_xxxxxxxxxxxx
# It will put logs in folders per day like ./20160101/ ./20160102/ .. etc
import os,shutil
class FolderDist(object):
# The purpose of this script is to help push monitoring information gathered using other scripts to all zabbix servers
# example of usage script
# ******
# send="/etc/zabbix/zabbix_sender.sh"
# value=$(/script/to/fetch/value.py)
# if [ -z "$value" ];then value=Null;fi
# $send {zabbix.key} $value 2>&1 >/dev/null
# *******
#!/bin/bash
@julcap
julcap / id_and_email_validation.sh
Last active August 15, 2016 13:08
Shell script to validate numeric ID and email in CSV file
# The purpose of this script is to validate CSV file containing two columns,
# ID and email. ID is an integer, email can be quoted.
# It will catch inconsistent quotation marks, invalid emails and ID that is not numberic.
# Valid line examples:
# 1234567890;'email@address.com'
# 1234567890;"email@address.com"
# 1234567890;email@address.com
#!/usr/bin/env sh
@julcap
julcap / Logstash_index_management.sh
Created June 12, 2017 09:14
Manage Logstash indices, remove data of specific type
#!/bin/sh
indices="$(curator show indices --all-indices)"
_type="activitylog-syslog"
opt=$1
if [ ! "$1" ];then opt='False';fi
case $opt in
@julcap
julcap / delete_s3_all_bucket_versions.py
Created August 31, 2017 11:35
Delete all bucket object versions
#!/usr/bin/env python
BUCKET = 'your_bucket_name'
import boto3
s3 = boto3.resource('s3')
for obj in s3.Bucket(BUCKET).object_versions.all():
print(obj.delete())
@julcap
julcap / aliases.txt
Created June 18, 2018 08:18
Bash aliases
Aliases (.bashrc )
alias ll='ls -lah'
alias l='ll'
alias updateme="sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y"
screen (.screenrc)
# Set the window caption.
# I use caption instead of hardstatus, so it is available per split window too
# (hardstatus is only per complete screen).
caption always "%{= KW}%-Lw%{= wb}%n %t %{= KW}%+Lw %-=| ${USER}@%H | %M%d %c%{-}"
#!/usr/bin/env bash
export USER="user"
export AUTHORIZED_KEYS="/home/$USER/.ssh/authorized_keys"
export KEY="public key"
if [ "$1" == "-c" ];then
echo "Creating user $USER"
useradd -m -s /bin/bash $USER
fi
@julcap
julcap / qbittorrent.sh
Last active December 25, 2020 16:11
Control qbittorrent-nox running in back ground as service.
#!/usr/bin/env bash
function start {
$exe -d --webui-port=4713 --configuration=/etc/default/qbittorrent-nox --save-path=/etc/default/qbittorrent-nox/torrents
}
function status {
PROCESS=$(ps aux | grep qbittorrent-nox | grep -v 'grep')
PROCESS_ID=$(echo $PROCESS | awk -F" " '{print $2}')
}