#!/bin/sh mem=$(LC_ALL=C free | awk '/Mem:/ {print $4}') swap=$(LC_ALL=C free | awk '/Swap:/ {print $3}') if [ $mem -lt $swap ]; then echo "ERROR: not enough RAM to write swap back, nothing done" >&2 exit 1 fi swapoff -a && swapon -a
#!/bin/sh mem=$(LC_ALL=C free | awk '/Mem:/ {print $4}') swap=$(LC_ALL=C free | awk '/Swap:/ {print $3}') if [ $mem -lt $swap ]; then echo "ERROR: not enough RAM to write swap back, nothing done" >&2 exit 1 fi swapoff -a && swapon -a
Nowadays there are many professional solutions to monitor your application for the errors. Some web frameworks have even build-in tools or support plugins to catch the programming exceptions and act accordingly.
Anyway, I wanted just to build a simple proof of concept how to monitor the web server error file and, when an event occurs and the file is changed, the monitoring script should send out an email. To monitor the log file I used pyinotify python module. This is an implementation on top of inotify, offering an easy interface to interact with the changes of the filesystem.
Continue reading Monitor an error log with python and RabbitMQ
In my working environment I am connecting to the production server using a gateway where I have my public key but sometimes I need to copy files from/to production servers.
I could copy it first on the ssh gateway and after that in my machine, but I prefer to do it through an SSH tunnel.