root / plugins / system / cpu_ @ a3d90c8f
Historique | Voir | Annoter | Télécharger (2,45 ko)
| 1 | 149688a7 | Steve Schnepp | #! /bin/sh |
|---|---|---|---|
| 2 | # Multigraph CPU plugin |
||
| 3 | # It shows a global cpu graph, and you can drill down per-core |
||
| 4 | |||
| 5 | PLUGINBASE=$(basename $0) |
||
| 6 | |||
| 7 | emit_config() |
||
| 8 | {
|
||
| 9 | ff1c67d5 | Steve Schnepp | cat <<EOF |
| 10 | graph_title CPU usage $1 |
||
| 11 | 149688a7 | Steve Schnepp | graph_order system user nice idle iowait irq softirq |
| 12 | graph_vlabel % |
||
| 13 | graph_scale no |
||
| 14 | graph_info This graph shows how CPU time is spent. |
||
| 15 | graph_category system |
||
| 16 | graph_period second |
||
| 17 | system.label system |
||
| 18 | system.draw AREA |
||
| 19 | system.min 0 |
||
| 20 | system.type DERIVE |
||
| 21 | system.info CPU time spent by the kernel in system activities |
||
| 22 | user.label user |
||
| 23 | user.draw STACK |
||
| 24 | user.min 0 |
||
| 25 | user.type DERIVE |
||
| 26 | user.info CPU time spent by normal programs and daemons |
||
| 27 | nice.label nice |
||
| 28 | nice.draw STACK |
||
| 29 | nice.min 0 |
||
| 30 | nice.type DERIVE |
||
| 31 | nice.info CPU time spent by nice(1)d programs |
||
| 32 | idle.label idle |
||
| 33 | idle.draw STACK |
||
| 34 | idle.min 0 |
||
| 35 | idle.type DERIVE |
||
| 36 | idle.info Idle CPU time |
||
| 37 | iowait.label iowait |
||
| 38 | iowait.draw STACK |
||
| 39 | iowait.min 0 |
||
| 40 | iowait.type DERIVE |
||
| 41 | iowait.info CPU time spent waiting for I/O operations to finish when there is nothing else to do. |
||
| 42 | irq.label irq |
||
| 43 | irq.draw STACK |
||
| 44 | irq.min 0 |
||
| 45 | irq.type DERIVE |
||
| 46 | irq.info CPU time spent handling interrupts |
||
| 47 | softirq.label softirq |
||
| 48 | softirq.draw STACK |
||
| 49 | softirq.min 0 |
||
| 50 | softirq.type DERIVE |
||
| 51 | softirq.info CPU time spent handling "batched" interrupts |
||
| 52 | steal.label steal |
||
| 53 | steal.draw STACK |
||
| 54 | steal.min 0 |
||
| 55 | steal.type DERIVE |
||
| 56 | steal.info The time that a virtual CPU had runnable tasks, but the virtual CPU itself was not running |
||
| 57 | guest.label guest |
||
| 58 | guest.draw STACK |
||
| 59 | guest.min 0 |
||
| 60 | guest.type DERIVE |
||
| 61 | guest.info The time spent running a virtual CPU for guest operating systems under the control of the Linux kernel. |
||
| 62 | a3d90c8f | rkarlsba | guest_nice.label guest |
| 63 | guest_nice.draw STACK |
||
| 64 | guest_nice.min 0 |
||
| 65 | guest_nice.type DERIVE |
||
| 66 | guest_nice.info The time spent running a virtual CPU for niced guest operating systems under the control of the Linux kernel. |
||
| 67 | 149688a7 | Steve Schnepp | EOF |
| 68 | } |
||
| 69 | |||
| 70 | CPUS=$(grep '^cpu[0-9]' /proc/stat | cut -d ' ' -f 1) |
||
| 71 | |||
| 72 | if [ "$1" = "config" ] |
||
| 73 | then |
||
| 74 | echo multigraph $PLUGINBASE |
||
| 75 | emit_config |
||
| 76 | # Emit one subgraph per core |
||
| 77 | for cpu in $CPUS |
||
| 78 | do |
||
| 79 | echo multigraph $PLUGINBASE.$cpu |
||
| 80 | ff1c67d5 | Steve Schnepp | emit_config $cpu |
| 81 | 149688a7 | Steve Schnepp | done |
| 82 | |||
| 83 | exit 0 |
||
| 84 | fi |
||
| 85 | |||
| 86 | emit_values() |
||
| 87 | {
|
||
| 88 | a3d90c8f | rkarlsba | while read key user nice system idle iowait irq softirq steal guest guest_nice |
| 89 | 149688a7 | Steve Schnepp | do |
| 90 | [ "$key" != "$1" ] && continue |
||
| 91 | cat <<EOF |
||
| 92 | system.value $system |
||
| 93 | user.value $user |
||
| 94 | nice.value $nice |
||
| 95 | idle.value $idle |
||
| 96 | iowait.value $iowait |
||
| 97 | irq.value $irq |
||
| 98 | softirq.value $softirq |
||
| 99 | steal.value $steal |
||
| 100 | guest.value $guest |
||
| 101 | EOF |
||
| 102 | done < /proc/stat |
||
| 103 | } |
||
| 104 | |||
| 105 | # Values |
||
| 106 | echo multigraph $PLUGINBASE |
||
| 107 | emit_values cpu |
||
| 108 | |||
| 109 | # Emit one subgraph per core |
||
| 110 | for cpu in $CPUS |
||
| 111 | do |
||
| 112 | echo multigraph $PLUGINBASE.$cpu |
||
| 113 | emit_values $cpu |
||
| 114 | done |
||
| 115 | |||
| 116 | exit 0 |
