Skip to content

Instantly share code, notes, and snippets.

@alexcreek
alexcreek / weighttp-output.patch
Created April 15, 2014 00:54
Modifies weighttp's output for easier grepping
diff -rupN /home/alex/source/weighttp/src/weighttp.c weighttp/src/weighttp.c
--- /home/alex/source/weighttp/src/weighttp.c 2014-04-13 14:05:00.359685093 -0400
+++ weighttp/src/weighttp.c 2014-04-14 20:34:59.470388698 -0400
@@ -234,6 +234,7 @@ int main(int argc, char *argv[]) {
uint64_t kbps;
char **headers;
uint8_t headers_num;
+ float full_duration;
printf("weighttp - a lightweight and simple webserver benchmarking tool\n\n");
@alexcreek
alexcreek / bench.sh
Last active February 3, 2016 23:33
wrapper for weighttp
#!/bin/bash
REQUESTS=( 50 100 200 400 800 1600 3200 5000 )
USERS=( 5 10 20 40 80 160 320 500 )
LOG=/tmp/bench.log
REQ_LOG=/tmp/req.log
TIME_LOG=/tmp/time.log
WEBSERVER=[enter webserver IP] # used to remotely restart apache
# Argument checking
if [[ $# -ne 2 ]]; then
@alexcreek
alexcreek / return-address.php
Last active August 29, 2015 14:03
Usage: curl [FILE] - returns WAN IP address
<?php
$ua = getenv('HTTP_USER_AGENT');
$ip = getenv('REMOTE_ADDR');
if (strpos($ua,'curl') !== false) {
echo "$ip \n";
}
?>
@alexcreek
alexcreek / get-exit-nodes.sh
Last active March 5, 2023 00:29
Download a list of tor exit nodes from torproject.org
#!/bin/bash
curl -s https://check.torproject.org/exit-addresses | awk '/ExitAddress/ {print $2}' | sort -n
@alexcreek
alexcreek / check_connections
Created August 15, 2014 05:25
nagios plugin to monitor TCP/UDP connections
#!/bin/bash
if [[ $# -ne 2 ]]; then
echo "WARN and CRIT thresholds not defined"
exit 3
fi
warn="$1"
crit="$2"
tcp=$(ss -tan | tail -n +3 | egrep -c -v "UNCONN|LISTEN")
@alexcreek
alexcreek / apache-debug.php
Last active August 29, 2015 14:07
Display every apache variable and request header using php
<?php
echo "<h1>REQUEST HEADERS</h1>";
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
}
echo "<h1>APACHE VARIABLES</h1>";
@alexcreek
alexcreek / apache-ssl-vhost.conf
Last active August 29, 2015 14:07
SSL enabled virtualhost template
<VirtualHost *:443>
ServerName securesite.com
ServerAlias www.securesite.com
DocumentRoot /var/www/securesite.com
# OCSP Stapling
SSLStaplingCache shmcb:/tmp/stapling_cache(128000) # place outside <virtualhost></virtualhost>
SSLCACertificateFile /etc/ssl/ca-certs.pem
SSLUseStapling on
@alexcreek
alexcreek / iptables-template
Last active August 29, 2015 14:07
basic iptables ruleset
# Generated by iptables-save v1.4.12 on Tue Oct 21 17:32:08 2014
*nat
:PREROUTING ACCEPT [9:538]
:INPUT ACCEPT [9:538]
:OUTPUT ACCEPT [4:271]
:POSTROUTING ACCEPT [4:271]
COMMIT
# Completed on Tue Oct 21 17:32:08 2014
# Generated by iptables-save v1.4.12 on Tue Oct 21 17:32:08 2014
*mangle
@alexcreek
alexcreek / backup.sh
Last active May 18, 2023 13:59
simple backup script using rsync + tar
#!/bin/bash
TODAY=$(date +%Y%m%d)
TARGETS=( '/etc' '/home' '/root' '/var/www' )
BACKUP_ROOT='/backups'
BACKUP_DIR="${BACKUP_ROOT}/${TODAY}"
echo "$(date +%D" "%r): Beginning backup"
mkdir -p $BACKUP_DIR
for i in ${TARGETS[@]}; do
@alexcreek
alexcreek / zpanel-ssl.conf
Last active February 2, 2016 04:37
apache config for enabling SSL on the zpanel login
# Configuration for ZPanel control panel.
# /etc/zpanel/configs/apache/zpanel-ssl.conf
# to use this config append the include directive below to /etc/zpanel/configs/apache/httpd.conf
# Include /etc/zpanel/configs/apache/zpanel-ssl.conf
<VirtualHost *:443>
ServerAdmin zadmin@localhost
DocumentRoot "/etc/zpanel/panel/"
ServerName www.foo.bar