| 1 |
# Reference for 'top' output can be found here: |
| 2 |
# https://man7.org/linux/man-pages/man1/top.1.html |
| 3 |
# |
| 4 |
# These are top level summary values we "Filldown" to each record. |
| 5 |
# This is because TextFSM does not support storing these as a separate |
| 6 |
# dicitonary within the output |
| 7 |
# |
| 8 |
# Global values from line 1 |
| 9 |
Value Filldown GLOBAL_TIMESTAMP (\d+:\d+:\d+) |
| 10 |
Value Filldown GLOBAL_USERS (\d+) |
| 11 |
Value Filldown GLOBAL_LOAD_AVERAGE_1_MINUTES (\d+[.]?\d*) |
| 12 |
Value Filldown GLOBAL_LOAD_AVERAGE_5_MINUTES (\d+[.]?\d*) |
| 13 |
Value Filldown GLOBAL_LOAD_AVERAGE_15_MINUTES (\d+[.]?\d*) |
| 14 |
# Global values from line 2 |
| 15 |
Value Filldown GLOBAL_TASKS_TOTAL (\d+) |
| 16 |
Value Filldown GLOBAL_TASKS_RUNNING (\d+) |
| 17 |
Value Filldown GLOBAL_TASKS_SLEEPING (\d+) |
| 18 |
Value Filldown GLOBAL_TASKS_STOPPED (\d+) |
| 19 |
Value Filldown GLOBAL_TASKS_ZOMBIE (\d+) |
| 20 |
# Global values from line 3 |
| 21 |
Value Filldown GLOBAL_CPU_PERCENT_USER (\d+[.]\d+) |
| 22 |
Value Filldown GLOBAL_CPU_PERCENT_SYSTEM (\d+[.]\d+) |
| 23 |
Value Filldown GLOBAL_CPU_PERCENT_NICE (\d+[.]\d+) |
| 24 |
Value Filldown GLOBAL_CPU_PERCENT_IDLE (\d+[.]\d+) |
| 25 |
Value Filldown GLOBAL_CPU_PERCENT_IOWAIT (\d+[.]\d+) |
| 26 |
Value Filldown GLOBAL_CPU_PERCENT_HI (\d+[.]\d+) |
| 27 |
Value Filldown GLOBAL_CPU_PERCENT_SI (\d+[.]\d+) |
| 28 |
Value Filldown GLOBAL_CPU_PERCENT_STOLEN (\d+[.]\d+) |
| 29 |
# Global values from line 4 |
| 30 |
Value Filldown GLOBAL_MEM_UNIT (KiB|MiB|GiB|TiB|k|m|g|t) |
| 31 |
Value Filldown GLOBAL_MEM_TOTAL (\d+[.]?\d*) |
| 32 |
Value Filldown GLOBAL_MEM_USED (\d+[.]?\d*) |
| 33 |
Value Filldown GLOBAL_MEM_FREE (\d+[.]?\d*) |
| 34 |
Value Filldown GLOBAL_MEM_BUFFERS (\d+[.]?\d*) |
| 35 |
# Global values from line 5 |
| 36 |
Value Filldown GLOBAL_SWAP_MEM_UNIT (KiB|MiB|GiB|TiB|k|m|g|t) |
| 37 |
Value Filldown GLOBAL_SWAP_MEM_TOTAL (\d+[.]?\d*) |
| 38 |
Value Filldown GLOBAL_SWAP_MEM_USED (\d+[.]?\d*) |
| 39 |
Value Filldown GLOBAL_SWAP_MEM_FREE (\d+[.]?\d*) |
| 40 |
Value Filldown GLOBAL_SWAP_MEM_CACHED (\d+[.]?\d*) |
| 41 |
# Per process records start here |
| 42 |
Value Required PID (\d+) |
| 43 |
Value USER (\S+) |
| 44 |
Value PRIORITY (\d+|rt|RT) |
| 45 |
Value NICE (-?\d+) |
| 46 |
Value VIRTUAL_MEMORY_SIZE (\d+[.]?\d*m?) |
| 47 |
Value RESIDENT_MEMORY_SIZE (\d+[.]?\d*m?) |
| 48 |
Value SHARED_MEMORY_SIZE (\d+[.]?\d*m?) |
| 49 |
Value PROCESS_STATUS (D|I|R|S|T|t|Z) |
| 50 |
Value PERCENT_CPU (\d+[.]\d+) |
| 51 |
Value PERCENT_MEMORY (\d+[.]\d+) |
| 52 |
Value CPU_TIME (\d+:\d+\S+) |
| 53 |
Value COMMAND (\S+) |
| 54 |
|
| 55 |
|
| 56 |
Start |
| 57 |
# The top two lines are the same for all tested versions |
| 58 |
^top - ${GLOBAL_TIMESTAMP} up .*,\s+${GLOBAL_USERS} use.*,\s+load average:\s+${GLOBAL_LOAD_AVERAGE_1_MINUTES},\s+${GLOBAL_LOAD_AVERAGE_5_MINUTES},\s+${GLOBAL_LOAD_AVERAGE_15_MINUTES}$$ |
| 59 |
^Tasks:\s+${GLOBAL_TASKS_TOTAL} total,\s+${GLOBAL_TASKS_RUNNING} running,\s+${GLOBAL_TASKS_SLEEPING} sleeping,\s+${GLOBAL_TASKS_STOPPED} stopped,\s+${GLOBAL_TASKS_ZOMBIE} zombie$$ |
| 60 |
# CPU - 1st format |
| 61 |
# %Cpu(s): 2.8 us, 0.7 sy, 0.0 ni, 96.3 id, 0.0 wa, 0.2 hi, 0.0 si, 0.0 st |
| 62 |
^%Cpu[(]s[)]:\s+${GLOBAL_CPU_PERCENT_USER}\sus,\s+${GLOBAL_CPU_PERCENT_SYSTEM}\ssy,\s+${GLOBAL_CPU_PERCENT_NICE}\sni,\s+${GLOBAL_CPU_PERCENT_IDLE}\sid,\s+${GLOBAL_CPU_PERCENT_IOWAIT}\swa,\s+${GLOBAL_CPU_PERCENT_HI}\shi,\s+${GLOBAL_CPU_PERCENT_SI}\ssi,\s+${GLOBAL_CPU_PERCENT_STOLEN}\sst$$ |
| 63 |
# CPU - 2nd format |
| 64 |
# Cpu(s): 12.5%us, 2.3%sy, 0.0%ni, 84.5%id, 0.0%wa, 0.7%hi, 0.1%si, 0.0%st |
| 65 |
^Cpu[(]s[)]:\s+${GLOBAL_CPU_PERCENT_USER}%us,\s+${GLOBAL_CPU_PERCENT_SYSTEM}%sy,\s+${GLOBAL_CPU_PERCENT_NICE}%ni,\s+${GLOBAL_CPU_PERCENT_IDLE}%id,\s+${GLOBAL_CPU_PERCENT_IOWAIT}%wa,\s+${GLOBAL_CPU_PERCENT_HI}%hi,\s+${GLOBAL_CPU_PERCENT_SI}%si,\s+${GLOBAL_CPU_PERCENT_STOLEN}%st$$ |
| 66 |
# Memory - 1st format |
| 67 |
# KiB Mem: 2014520 total, 1970928 used, 43592 free, 171340 buffers |
| 68 |
^${GLOBAL_MEM_UNIT}\s+Mem.*:\s+${GLOBAL_MEM_TOTAL}\stotal,\s+${GLOBAL_MEM_USED}\sused,\s+${GLOBAL_MEM_FREE}\sfree,\s+${GLOBAL_MEM_BUFFERS}\sbuffers$$ |
| 69 |
# Memory - 2nd format |
| 70 |
# MiB Mem : 7956.2 total, 1755.3 free, 2052.9 used, 4148.0 buff/cache |
| 71 |
^${GLOBAL_MEM_UNIT}\s+Mem.*:\s+${GLOBAL_MEM_TOTAL}\stotal,\s+${GLOBAL_MEM_FREE}\sfree,\s+${GLOBAL_MEM_USED}\sused,\s+${GLOBAL_MEM_BUFFERS}\sbuff[/]cache$$ |
| 72 |
# Memory - 3rd format |
| 73 |
# Mem: 3981336k total, 2726640k used, 1254696k free, 156856k buffers |
| 74 |
^Mem.*:\s+${GLOBAL_MEM_TOTAL}${GLOBAL_MEM_UNIT}\stotal,\s+${GLOBAL_MEM_USED}[kmgt]\sused,\s+${GLOBAL_MEM_FREE}[kmgt]\sfree,\s+${GLOBAL_MEM_BUFFERS}[kmgt]\sbuffers$$ |
| 75 |
# Swap - 1st format |
| 76 |
# KiB Swap: 0 total, 0 used, 0 free, 1156836 cached |
| 77 |
^${GLOBAL_SWAP_MEM_UNIT}\s+Swap.*:\s+${GLOBAL_SWAP_MEM_TOTAL}\stotal,\s+${GLOBAL_SWAP_MEM_USED}\sused,\s+${GLOBAL_SWAP_MEM_FREE}\sfree,\s+${GLOBAL_SWAP_MEM_CACHED}\scached$$ |
| 78 |
# Swap - 2nd format |
| 79 |
# MiB Swap: 0.0 total, 0.0 free, 0.0 used. 5325.2 avail Mem |
| 80 |
^${GLOBAL_SWAP_MEM_UNIT}\s+Swap.*:\s+${GLOBAL_SWAP_MEM_TOTAL}\stotal,\s+${GLOBAL_SWAP_MEM_FREE}\sfree,\s+${GLOBAL_SWAP_MEM_USED}\sused.\s+${GLOBAL_SWAP_MEM_CACHED}\savail Mem$$ |
| 81 |
# Swap - 3rd format |
| 82 |
# Swap: 0k total, 0k used, 0k free, 1521744k cached |
| 83 |
^Swap.*:\s+${GLOBAL_SWAP_MEM_TOTAL}${GLOBAL_SWAP_MEM_UNIT}\stotal,\s+${GLOBAL_SWAP_MEM_USED}[kmgt]\sused,\s+${GLOBAL_SWAP_MEM_FREE}[kmgt]\sfree,\s+${GLOBAL_SWAP_MEM_CACHED}[kmgt]\scached$$ |
| 84 |
^$$ |
| 85 |
# Process table header |
| 86 |
^\s*PID\s+USER\s+PR\s+NI\s+VIRT\s+RES\s+SHR\s+S\s+.CPU\s+.MEM\s+TIME.\s+COMMAND\s*$$ |
| 87 |
# Process line items in table |
| 88 |
^\s*${PID}\s+${USER}\s*${PRIORITY}\s*${NICE}\s+${VIRTUAL_MEMORY_SIZE}\s+${RESIDENT_MEMORY_SIZE}\s+${SHARED_MEMORY_SIZE}\s+${PROCESS_STATUS}\s+${PERCENT_CPU}\s+${PERCENT_MEMORY}\s+${CPU_TIME}\s+${COMMAND}\s*$$ -> Record |
| 89 |
^. -> Error |