Skip to content
This repository
Browse code

show some process info instead of killing the process right away

  • Loading branch information...
commit c3ea774f50d22426f027250c7155fa0e88a1a0c4 1 parent 99c8cb6
Geoffroy Couprie authored February 26, 2013
4  process/process.sh
@@ -6,14 +6,14 @@ pids=(/proc/[0-9]*)
6 6
 pid=`basename ${pids[0]}`
7 7
 data=`awk '/(Name:|VmRSS)/{print \$2 \$3}' ${pids[0]}/status`
8 8
 array=($data)
9  
-result=$result"{\"name\" : \"${array[0]}\", \"value\":\"${array[1]}  ${array[2]}\", \"command\":\".pilotssh/process/process_kill.sh $pid ${array[0]}\"}"
  9
+result=$result"{\"name\" : \"${array[0]}\", \"value\":\"${array[1]}  ${array[2]}\", \"command\":\".pilotssh/process/process_info.sh $pid ${array[0]}\"}"
10 10
 
11 11
 for i in ${pids[*]:1}
12 12
 do
13 13
   pid=`basename $i`
14 14
   data=`awk '/(Name|VmRSS)/{print \$2 \$3}' $i/status`
15 15
   array=($data)
16  
-  result=$result", {\"name\" : \"${array[0]}\", \"value\":\"${array[1]}  ${array[2]}\", \"command\":\".pilotssh/process/process_kill.sh $pid ${array[0]}\"}"
  16
+  result=$result", {\"name\" : \"${array[0]}\", \"value\":\"${array[1]}  ${array[2]}\", \"command\":\".pilotssh/process/process_info.sh $pid ${array[0]}\"}"
17 17
 done
18 18
 
19 19
 result=$result"]}"
20  process/process_info.sh
... ...
@@ -0,0 +1,20 @@
  1
+#!/bin/sh
  2
+
  3
+result="{ \"version\": 1, \"title\": \"$2\", \"type\":\"commands\", \"values\" : [ "
  4
+
  5
+pid=$1
  6
+name=$2
  7
+#cwd=`readlink /proc/$pid/cwd`
  8
+cmdline=`ps eho command -p $pid`
  9
+cpu=`ps eho %cpu -p $pid`
  10
+mem=`ps eho %mem -p $pid`
  11
+
  12
+result=$result"{\"name\" : \"PID\", \"value\":\"$pid\", \"command\":\"\"},"
  13
+#result=$result"{\"name\" : \"CWD\", \"value\":\"$cwd\", \"command\":\"\"},"
  14
+result=$result"{\"name\" : \"CMD\", \"value\":\"$cmdline\", \"command\":\"\"},"
  15
+result=$result"{\"name\" : \"CPU\", \"value\":\"$cpu\", \"command\":\"\"},"
  16
+result=$result"{\"name\" : \"MEM\", \"value\":\"$mem\", \"command\":\"\"},"
  17
+result=$result"{\"name\" : \"Kill -9\", \"value\":\"\", \"command\":\".pilotssh/process/process_kill.sh $pid $name\"}"
  18
+result=$result" ] }"
  19
+
  20
+echo $result

0 notes on commit c3ea774

Please sign in to comment.
Something went wrong with that request. Please try again.