Skip to content

Instantly share code, notes, and snippets.

View fduran's full-sized avatar

Fernando Duran fduran

View GitHub Profile

Troubleshooting

Intro

The incident management steps I have in mind when being on-call and getting an alert are:

  • Verify the issue
  • Triage
  • Communicate and scalate if needed
  • Mitigate
@fduran
fduran / Linux Bash generate a number of files of random sizes in a range
Last active January 12, 2024 19:43
Linux Bash generate a number of files of random sizes in a range
#!/bin/bash
# generate a number of files with random sizes in a range
min=1 # min size (MB)
max=10 # max size (MB)
nofiles=20 # number of files
for i in `eval echo {1..$nofiles}`
do
dd bs=1M count=$(($RANDOM%max + $min)) if=/dev/urandom of=./files/file$i
@fduran
fduran / gist:4586880
Created January 21, 2013 15:35
Create Java KeyStore from SSL certificate
# www.fduran.com
# Create Java KeyStore from SSL certificate for domain example.com
# Change format from cert.crt PEM (----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----) to DER
openssl x509 -in cert.crt -inform PEM -out cert.der -outform DER
# create KeyStore cert.jks for your domain ("alias" in keytool, "common name" or CN in openssl req)
keytool -import -trustcacerts -alias example.com -file cert.der -keystore cert.jks
@fduran
fduran / gist:4271967
Created December 12, 2012 21:52
Apache Redirect Subdomain to port
# www.fduran.com
# redirect from apache port (:8080 for ex for tomcat etc) to subdomain
# in apache config:
<VirtualHost *:80>
ServerName subdomain.example.com
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
@fduran
fduran / gist:1870527
Last active November 29, 2022 17:07
Linux making disk space
# www.fduran.com
# disk space usage
df -h
# biggest (10) directories in size (MB)
du -mxS / | sort -n | tail -10
# clean package cache
apt-get clean
@fduran
fduran / gist:1870477
Last active October 18, 2022 20:12
Linux better command history
# better command line history: more commands kept, aggregate, add timestamp
# www.fduran.com
# add in /etc/profile
shopt -s histappend
HISTSIZE=10000
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
HISTCONTROL=ignoredups
PROMPT_COMMAND="history -a;history -c;history -r;$PROMPT_COMMAND"
@fduran
fduran / gist:1870429
Created February 20, 2012 18:15
Linux disk space email alert
#!/bin/bash
# www.fduran.com
# script that will send an email to EMAIL when disk use in partition PART is bigger than %MAX
# adapt these 3 parameters to your case
MAX=95
EMAIL=alert@example.com
PART=sda1
USE=`df -h |grep $PART | awk '{ print $5 }' | cut -d'%' -f1`
if [ $USE -gt $MAX ]; then
// www.fduran.com
// send mail with Amazon AWS SES without extra library
// needs Pear: apt-get install php-pear
<?php
function mailSES($to, $subject, $body, $from)
{
include_once('Mail.php');
$headers["From"] = $from;
$headers["To"] = $to;
@fduran
fduran / gist:1870436
Created February 20, 2012 18:16
Linux Rootkit check
# chkrootkit & rkhunter:
# www.fduran.com
http://www.chkrootkit.org/download/
http://sourceforge.net/projects/rkhunter/
cd /usr/local/src/
wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
tar zxvf chkrootkit.tar.gz
cd chkrootkit-0.49/
./chkrootkit
@fduran
fduran / gist:1870554
Created February 20, 2012 18:34
Linux disk/memory stress test
# www.fduran.com
# hardware stress test
# mismatched md5sums shows a faulty disk/RAM
# time depends on hardware, ex: 1 sec per 100 count
dd if=/dev/zero of=/tmp/test.file bs=1M count=1000
for i in {1..5}; do md5sum /tmp/test.file; done