pre-pend log timestamp

Adds a timestamp before alog from a script awk -v sec=$(date -u +%s) '{print strftime("%Y-%m-%d %H:%M:%S",sec), $0; fflush();}' in cron : awk -v sec=$(date -u +\%s) '{print strftime("\%Y-\%m-\%d \%H:\%M:\%S",sec), $0; fflush();}' So : # echo hello world | awk -v sec=$(date -u +%s) '{print strftime("%Y-%m-%d %H:%M:%S",sec), $0; fflush();}'   2014-10-30 08:40:26 test nJoy 🙂

Invalidate Varnish cache

1)   netstat -plnt 2)   varnishadm -T ban.url /wp-content/themes/catch-box -S /etc/varnish/secret   Will invalidate all content under  /wp-content/themes/catch-box.   nJoy  😛  

Fix Raid on LSI controllers when a disk is shown as ubad

This can be done with both megacli and storcli. Since the way forward is storcli this how to will be based on that.   storcli /c0 show all   Drive Information : =================   ——————————————————————————- EID:Slt DID State DG Size Intf Med SED PI SeSz Model Sp ——————————————————————————- 8:1 7 Onln 0 465.25 GB SATA HDD…

fstab entry for sshfs

Sample entry root@ /opt/kaltura/web fuse.sshfs _netdev,auto 0 0   nJoy 😉  

Decoding parameters in Bash script (1 space delimited)

This is a small script that takes a bash command and decodes the parameters in non sequential order except definers. #!/bin/bash if [ "$#" -ne 1 ] || ! [ -d "$1" ]; then echo "Usage: $0 " >&2 exit 1 fi while [[ $# > 1 ]] do key=”$1″ echo $key shift case $key…

Enable X11 Forwarding on Centos/Redhat

1) Install the following: xorg-x11-xauth xorg-x11-fonts-* xorg-x11-utils 2) Enable the following in the sshd_config file X11Forwarding yes 3) Use an appropriate X-Server on your desktop nJoy 😉

Rate Limiting in iptables

iptables -A INPUT -p tcp –syn –dport 80 -m connlimit –connlimit-above 15 –connlimit-mask 32 -j REJECT –reject-with tcp-reset

Allowing Apache to see client ip from Behind a trusted proxy.

With high speed caching based on nginx, varnish or CDNs in general the client ip gets lost. All IPs get reported as since the proxy is making the socket request. Solution is two phased: 1) enable reporting the client IP to the X-Forwarded-For header at the proxy or CDN. This depends on the proxy will…

How to test varnish vcl file

Unlike most other configuration systems varnish went with a compiled configuration so if there is a mistake all you get is :   Starting varnish HTTP accelerator: [FAILED] To check what the problem is use the following : varnishd -C -f default.vcl varnishd -C -f default.vcl Message from VCC-compiler: Expected return action name. (input Line…