Skip to content

Instantly share code, notes, and snippets.

@a2f0
Last active August 29, 2015 14:05
Show Gist options
  • Save a2f0/3dbf7a087a42373a6407 to your computer and use it in GitHub Desktop.
Save a2f0/3dbf7a087a42373a6407 to your computer and use it in GitHub Desktop.
detect hung passenger processes by inspecting an isolated application pool, iterating, and authing against the api
#!/bin/sh
#Isolate an application pool and iterate through and authenticate
#Written by Dan Sullivan
#Will detect hung processes
IFS=$'\n'
for i in $(rvmsudo passenger-status --verbose |
pcregrep -M '/opt(.|\n)*^/opt' |
grep -v Requests | grep -v ^/ |
grep -v "App root" | grep -v CPU |
sed ':a;N;$!ba;s/s\n/,/g' |
sed '/^$/d' | sed ':a;N;$!ba;s/\n /,/g' |
awk -F'[[:space:]:/]+' '{print $4,$16,$18}' | tr -d ','
);
do
echo $i | awk '{ print $1,$2,$3 }';
pid=`echo $i | awk '{ print $1 }'`;
port=`echo $i | awk '{ print $2 }'`;
password=`echo $i | awk '{ print $3 }'`;
echo "pid: $pid, port: $port, password: $password"
curl -H "X-Passenger-Connect-Password: $password" "http://127.0.0.1:$port"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment