Permalink
Browse files

show some process info instead of killing the process right away

  • Loading branch information...
Geal committed Feb 26, 2013
1 parent 99c8cb6 commit c3ea774f50d22426f027250c7155fa0e88a1a0c4
Showing with 22 additions and 2 deletions.
  1. +2 −2 process/process.sh
  2. +20 −0 process/process_info.sh
View
@@ -6,14 +6,14 @@ pids=(/proc/[0-9]*)
pid=`basename ${pids[0]}`
data=`awk '/(Name:|VmRSS)/{print \$2 \$3}' ${pids[0]}/status`
array=($data)
-result=$result"{\"name\" : \"${array[0]}\", \"value\":\"${array[1]} ${array[2]}\", \"command\":\".pilotssh/process/process_kill.sh $pid ${array[0]}\"}"
+result=$result"{\"name\" : \"${array[0]}\", \"value\":\"${array[1]} ${array[2]}\", \"command\":\".pilotssh/process/process_info.sh $pid ${array[0]}\"}"
for i in ${pids[*]:1}
do
pid=`basename $i`
data=`awk '/(Name|VmRSS)/{print \$2 \$3}' $i/status`
array=($data)
- result=$result", {\"name\" : \"${array[0]}\", \"value\":\"${array[1]} ${array[2]}\", \"command\":\".pilotssh/process/process_kill.sh $pid ${array[0]}\"}"
+ result=$result", {\"name\" : \"${array[0]}\", \"value\":\"${array[1]} ${array[2]}\", \"command\":\".pilotssh/process/process_info.sh $pid ${array[0]}\"}"
done
result=$result"]}"
View
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+result="{ \"version\": 1, \"title\": \"$2\", \"type\":\"commands\", \"values\" : [ "
+
+pid=$1
+name=$2
+#cwd=`readlink /proc/$pid/cwd`
+cmdline=`ps eho command -p $pid`
+cpu=`ps eho %cpu -p $pid`
+mem=`ps eho %mem -p $pid`
+
+result=$result"{\"name\" : \"PID\", \"value\":\"$pid\", \"command\":\"\"},"
+#result=$result"{\"name\" : \"CWD\", \"value\":\"$cwd\", \"command\":\"\"},"
+result=$result"{\"name\" : \"CMD\", \"value\":\"$cmdline\", \"command\":\"\"},"
+result=$result"{\"name\" : \"CPU\", \"value\":\"$cpu\", \"command\":\"\"},"
+result=$result"{\"name\" : \"MEM\", \"value\":\"$mem\", \"command\":\"\"},"
+result=$result"{\"name\" : \"Kill -9\", \"value\":\"\", \"command\":\".pilotssh/process/process_kill.sh $pid $name\"}"
+result=$result" ] }"
+
+echo $result

0 comments on commit c3ea774

Please sign in to comment.