Skip to content

Instantly share code, notes, and snippets.

@nohn
nohn / puppet.md
Last active August 29, 2015 14:23

Puppet Snippets

Dynamic Load Average Limits

This snippet will dynamically set the thresholds for check_load exported resources in Icinga/Nagios via Puppet exported resources based on the processorcount fact.

@@nagios_service { "LX_LOAD_${hostname}":
  check_command       => "ssh_load!${$::processorcount*2}!${$::processorcount}!${$::processorcount*0.7}!${$::processorcount*4}!${$::processorcount*2}!${$::processorcount}",
  use                 => "generic-service",

host_name => "$fqdn",

@nohn
nohn / shell.md
Last active September 20, 2016 08:31

Shell Snippets

Dump network traffic to a file using tcpdump

This oneliner dumps network traffic on port 80 o a file for analysis in for example Wireshark

tcpdump -pnni any -s 1500 -w /tmp/tcpdump.pcap port 80

Sort directory contents by size (human readable)

Generate Threaddump of running process

kill -3 $id

#!/bin/bash
# Find log4j jars
sudo find / -type f -name "*log4j-core*jar"
# Find extracted log4j
sudo find / -type d -wholename "*/org/apache/logging/log4j/core"
# Find log4j included in jars & wars
sudo find / -type f \( -name "*.jar" -or -name "*.war" \) -exec sh -c "if zipinfo {} | grep JndiLookup.class; then echo -e '{}\n'; fi" \;
# TODO: ears can include jars and wars
@nohn
nohn / permadblogcat.sh
Created February 19, 2024 08:46
Permanently get adb logs for specific packages
#!/bin/bash
# Check if the correct number of arguments is passed
if [ "$#" -ne 4 ]; then
echo "Usage: $0 APP_PACKAGE DEVICE_HOST DEVICE_PORT LOG_DIR"
exit 1
fi
# Assign command-line arguments to variables
APP_PACKAGE="$1"