Skip to content

Instantly share code, notes, and snippets.

@NiceRath
NiceRath / fio-benchmark-nvme-64k-mssql.cnf
Last active August 25, 2025 12:46
FIO NVMe Disk-Benchmark for 64k-Performance (MSSQL Server)
# TO RUN:
# apt install fio
# add the config-file on your target system
# replace '/dev/nvmeXn1' with either:
# the path to a block-device you want to benchmark (examples: /dev/md1, /dev/sdb, /dev/nvme2n1, /zfs_nvme [or whatever zfs mountpoint you use])
# the path to a test-file on a mounted partition of ZFS-volume (performance will most likely be worse than on the block-device directly)
# start: fio test.cnf
# NOTE: You might want to lower the iodepth and numjobs to the point where you do not see any improvement - we just eye-balled it
@NiceRath
NiceRath / aruba-cx-backup-pull.sh
Last active August 1, 2025 09:30
ArubaCX Script to backup config via SSH with non-admin user (from Linux server)
#!/bin/bash
# SWITCH CONFIG:
# user-group readonly
# 10 permit cli command "show running-config"
# 20 permit cli command "show startup-config"
# 30 permit cli command "no page"
# 40 permit cli command "show logging -r"
# user backupuser group readonly password plaintext ...
# user backupuser authorized-key ssh-ed25519 ...
@NiceRath
NiceRath / get-list-of-ad-users-password-expiration.ps1
Last active July 15, 2025 17:03
Powershell script to query a list of active AD-Users which password will expire soon or has expired
# Powershell script to query a list of active AD-Users which password will expire soon or has expired
Import-Module ActiveDirectory
$SearchBase="OU=<OU>,DC=<domain>,DC=<dc>"
$users = get-aduser -SearchBase $SearchBase -Filter {(enabled -eq $true) -and (passwordNeverExpires -eq $false)} -properties sAMAccountName, displayName, PasswordNeverExpires, PasswordExpired, PasswordLastSet, EmailAddress, lastLogon, whenCreated
$DefaultmaxPasswordAge = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge
foreach ($user in $users) {
$emailaddress = $user.emailaddress
@NiceRath
NiceRath / speedtest_http_ip4_ip6.sh
Last active July 15, 2025 09:35
IPv4 vs IPv6 HTTP Speedtest Script (to CSV)
set -eo pipefail
if [[ -z "$2" ]]
then
echo 'USAGE:'
echo ' 1 > Domain to target (without www)'
echo ' 2 > Number of requests'
echo ''
echo 'OPTIONAL ENV-VARS:'
echo ' CURL_INT > Interface to use'
@NiceRath
NiceRath / speedtest_http3.sh
Last active July 15, 2025 09:36
HTTP2 vs HTTP3 Speedtest Script (to CSV)
set -eo pipefail
if [[ -z "$2" ]]
then
echo 'USAGE:'
echo ' 1 > Domain to target (without www)'
echo ' 2 > Number of requests'
echo ''
echo 'OPTIONAL ENV-VARS:'
echo ' CURL_INT > Interface to use'
@NiceRath
NiceRath / ansible-vault-rekey-file.py
Last active July 8, 2025 09:44
Script to change Ansible-Vault-Password for all Secrets in a YAML file
#!/usr/bin/env python3
# USAGE:
# python3 ansible-vault-rekey.py -i ~/.vault/old.txt -o ~/.vault/new.txt -f ./secrets/dev.yml
# BEHAVIOUR:
# reads the YAML variable-file
# processes all variable-values recursively
# if the variable-value is an Ansible-Vault-encrypted value
# it decrypts it with the old password (or throws error if failed to)
@NiceRath
NiceRath / sphinx_create_modify_timestamps_git.sh
Last active April 8, 2025 14:15
Sphinx - Add Create/Modify Timestamps (GIT-REPO)
# SCRIPT 1:
# BUILDS LIST OF FILE-to-TIMESTAMP CSV
# EXECUTE IN GIT REPO
# NOTE: if you also build the docs on your source-system, you can merge it with script #2
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")"
@NiceRath
NiceRath / sphinx_create_modify_timestamps.sh
Last active April 8, 2025 13:49
Sphinx - Add Create/Modify Timestamps (SEE LINK FOR GIT-REPO)
#!/usr/bin/env bash
# FOR GIT SUPPORT: https://gist.github.com/NiceRath/0f1e20bef3d0eea993f7439bc8fc96e6
# NOTE: you might need to change '/contentinfo\">' to whatever element you want to append the timestamps to
set -e
cd "$(dirname "$0")"
rm -rf build
@NiceRath
NiceRath / sendmail.py
Created January 21, 2025 17:01
Python3 sendmail cli with attachment
#!/usr/bin/env python3
import smtplib
from email.message import EmailMessage
from pathlib import Path
from os.path import basename
from argparse import ArgumentParser
REQUIRE_FROM_DOMAIN = '@test.com'
@NiceRath
NiceRath / mssql-agent-job-monitoring.txt
Created December 22, 2024 08:31
How to Monitor MSSQL Agent-Jobs
# discover all existing agent-jobs
SELECT name, step_name, jobs.job_id FROM msdb.dbo.sysjobsteps job_steps INNER JOIN msdb.dbo.sysjobs jobs ON jobs.job_id = job_steps.job_id
# get status for each job
SELECT subsystem, database_name, command, last_run_outcome, last_run_duration, last_run_date, last_run_time FROM msdb.dbo.sysjobsteps WHERE step_name = '{#STEP_NAME}' AND job_id = '{#JOB_ID}'
# check the status and trigger if not ok
## json query: $..last_run_outcome.first()
## error if last_run_outcome=0