Skip to content

Instantly share code, notes, and snippets.

@dzogrim
dzogrim / dropbox-integrity.sh
Last active February 26, 2019 07:42
Dropbox wasn't syncing anymore because of some bad user:group
#!/bin/bash
[[ ! $( which jq ) ]] && exit 1
dropboxDir="$(jq -r '.personal.path' <"${HOME}/.dropbox/info.json")"
usern=${LOGNAME}
group="$(gid -ng)"
echo "Find files in Dropbox that are not my username or group:"
find "${dropboxDir}" -type f -not \( \( -user $usern \) -o \( -group $group \) \) -print
@dzogrim
dzogrim / dig-loop.sh
Created March 19, 2019 15:29
Random loop to make sure response is made each time by nameservers
#!/bin/bash
checkServer=myserver.local
NS1=10.2.10.1
NS2=10.2.10.2
ntimes=60
for ns in ${NS1} ${NS2}; do
for ((i=0 ; $ntimes - $i ; i++)); do
dig +short ${checkServer} @${ns}
@dzogrim
dzogrim / curl-loop.sh
Created March 20, 2019 14:27
Random loop to make sure response is made each time by api server
#!/bin/bash
checkServer=10.2.1.5
checkPort=8101
[ "$1" = "FAST" ] && optSleep="0" && ntimes=120
[ "$1" = "" ] && optSleep="1" && ntimes=60
echo "Starting at $(date "+%Y-%m-%dT%H:%M:%S%z")"
for ((i=0 ; $ntimes - $i ; i++)); do
@dzogrim
dzogrim / average.sh
Last active April 5, 2019 09:35
Average stats from `curl` time reporting output (to give in $1)
#!/bin/bash
usage()
{
echo -e "\n * Usage: $(basename $0) values-from-curl.txt"
exit 1
}
[ "$1" = "" ] && usage
@dzogrim
dzogrim / ObserviumUpgrade.sh
Created April 18, 2019 10:23
Update Observium CE as instructed on official documentation: https://docs.observium.org/install_debian/
#!/bin/bash
softURL=http://www.observium.org/observium-community-latest.tar.gz
tempPATH=/tmp
archiveNAME="${tempPATH}/observium-community-latest.tar.gz"
sourceLOCATION=/opt/observium
backupSTAMP="$(date +%Y-%m-%d)_$$"
# tar -czvf observium_ORIGINAL_working-backup.tar.gz "${sourceLOCATION}""
@dzogrim
dzogrim / geckodriver.sh
Created April 25, 2019 16:06
Running geckodriver in background and easily killing it after a call
#!/bin/bash
pgrep geckodriver > /dev/null 2>&1
if [[ $? = 0 ]]; then
echo "Sorry but geckodriver is already running..."
exit 1
fi
geckodriver "$@" > /dev/null 2>&1 &
@dzogrim
dzogrim / getswap.sh
Created May 9, 2019 09:23
Get current swap usage for all running processes
#!/bin/bash
[[ $(uname) == *"Darwin"* ]] && echo "Nope." && exit 1
echo "Get current swap usage for all running processes"
FILE=/tmp/swap_$$.txt
SUM=0
OVERALL=0
for DIR in $(find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]") ; do
@dzogrim
dzogrim / check-lb-pools-health.sh
Last active May 13, 2019 12:46
vTM monitoring with REST API from Pulse Secure Services-Director for Zabbix
#!/bin/bash
set -e
[[ $1 -eq "" ]] && printf "Which env?\n" && exit 1
# Services Director:
endpoint="https://10.0.1.250:8100/api/tmcm/2.2/monitoring/instance"
user="admin"
password="MY_SECURED_PASSWORD_"
@dzogrim
dzogrim / set-python-123.sh
Last active May 25, 2019 19:54
This tool will help to switch from Python v2.7 to Python v3.7 on macOS
#!/bin/bash
## This tool is only for macOS and require Mac Ports and python27/python37.
## It will help to switch from Python v2 to Python v3...
##
## Copyleft (C) 2019 dzogrim
NAME="$(basename "${0}")"
# Customized colors
@dzogrim
dzogrim / fake_syslog_msg.sh
Created June 4, 2019 13:10
Test and send a syslog message to rsyslog server
#!/bin/bash
rsyslog_serv="env-log-storeroom-001.tld.priv"
rsyslog_port="514"
stamp="$(date +"%A, %b %d, %Y %H:%M:%S")"
if [[ $(uname) == *"Darwin"* ]]; then
OPT="-c"
else
OPT="-q0"