+kill_nm_inslice(){
+ pids=$(vps aux | awk '$1 != "root" && $14 == "/usr/share/NodeManager/nm.py" {print $2}')
+ for pid in $pids ; do
+ line=$(vps aux | grep $pid)
+ echo NM found in slice. Killing PID $pid
+ echo $line
+ kill -9 $pid
+ done
+}
+
+kill_nonroot_nm(){
+ # For whatever reason, Some NM's, after fork and chcontext...don't chcontext. Kill them.
+ pids=$(ps aux | awk '$1 != "root" && $12 == "/usr/share/NodeManager/nm.py" {print $2}')
+ for pid in $pids ; do
+ line=$(ps aux | grep $pid)
+ echo NM found not belonging to root. Killing PID $pid
+ echo $line
+ kill -9 $pid
+ done
+}
+
+kill_multi_nm(){
+ # if there is more than one nm running around, kill them, then nm restart
+ pids=$(ps aux | awk '$1 == "root" && $12 == "/usr/share/NodeManager/nm.py" {print $2}')
+ i=0
+ for pid in $pids ; do
+ i=$[$i+1]
+ done
+ if [ $i -gt 1 ] ; then
+ # stop nm
+ echo "More than 1 NM found belonging to root. Restarting NM."
+ /etc/init.d/nm stop
+ pids=$(ps aux | awk '$1 == "root" && $12 == "/usr/share/NodeManager/nm.py" {print $2}')
+ for pid in $pids ; do
+ kill -9 $pid
+ done
+ /etc/init.d/nm start
+ fi
+}