Script to check if Website alive and restart Services if necessary

I was looking into a LAMP Server these days and had one effect that some pages became unresponsive over time. While the Error was not easy to detect and fix we decided to create a check script to check a certain URL and in case of a timeout server services would be restarted automatically. Not the bast possible way but maybe the most straight forward one.

Please adjust the service commands on the top to have the right restart commands inside.

#! /usr/bin/bash
function restart {
service nginx restart
service mariadb restart
service httpd restart
}

function check {
if [ $? -ne 0 ] ; then
echo "Error occurred getting URL $1:"
if [ $? -eq 6 ]; then
echo "Unable to resolve host"
fi
if [ $? -eq 7 ]; then
echo "Unable to connect to host"
restart;
fi
restart;
exit 1
fi

}

Call for this script looks like…

/scripts/check.sh http://www.URLTOCHECK.io

Cron like

*/15 * * * * /scripts/check.sh http://www.URLTOCHECK.io

MYSQL Long kill long Querys via Script in Cron

As part of my private life i sometimes help friends with their Webservers. Recently i had a case of a LAMP Server including Maria / MySQL DB. Some Queries lasted “forever” in the DB and consumed a lot of CPU. I created small script which looks into the DB and kills thoos querys.

This Script was done for a Server where the Password of MySQL is stored in a File (Plesk) Therefore the -p Command contains a cat of the password. Please adjust the script to take the right username and password.


#!/bin/sh
# Kill long Mysql Queries
mysql -uadmin -p`cat /etc/psa/.psa.shadow` -ANe"SELECT id FROM information_schema.processlist WHERE time > 360;" | cut -d: -f2 |\
while read id
do
mysql -uadmin -p`cat /etc/psa/.psa.shadow` -ANe"kill $id;"
done

Cron looks like this to check this all 10 minutes and not receive any notification about it.

*/10 * * * * /root/killlongdbqueries.sh >/dev/null 2>&1

Synology DSM6 external USB Disk issue

Synology DSM6 external USB Disk issue

After updating my Synolog DS216play to DSM6 i had issues with my external USB3.0 Drive which i use for Backups. It was no longer detected. After opening a Support Case and some forward and backward emails they team has implemented a solution.
They created a task in the task planer which runs on bootup by root and does execute this code:

rmmod dwc3-st.ko;
sleep 3;
rmmod phy-st-usb3.ko;
sleep 1;
insmod /lib/modules/phy-st-usb3.ko miphy_ssc_off=1;
insmod /lib/modules/dwc3-st.ko;

 

Then i had to execute this actions.

  1. Shut down 216play and plug out storage (USB cable and USB power cable) so it’s powered off completely
  2. Wait for at least 1 minute
  3. Boot 216play
  4. plug in storage (USB cable and USB power cable)

Now its working fine again.

APIs around the World 2014

APIs around the World 2014

I work for Axway since quite a while and i’m on the API Product since we acquired Vordel. In 2014 we spent quite a lot of our time with Events all around the World and i was participating in that afford running events in Germany and Nordics. 2015 will also be an amazing year with a lot of oportunities for me to speak about APIs.
To visualise this is was looking for a webbased service which could show the locations and provide a link or picture. I came across CartoDB which is a nice service to do exactly this.

https://pschoene.cartodb.com/tables/api_workshops/public/map

 

Rest vs. SOAP Infographic

I had conversations with a lot of people who did not have a background on SOA or modern Webtechnologies and they allways ask why we API people make such a big thing about SOAP and Rest. This infographic which was published on the Nordic APIs Blog helps a little bit with this kind of conversations. Besides that it has a certain beauty of a modern Web design

http://nordicapis.com/rest-vs-soap-nordic-apis-infographic-comparison/