diff --git a/docs/aoa/ps.rst b/docs/aoa/ps.rst index a546ec9e..49963f01 100644 --- a/docs/aoa/ps.rst +++ b/docs/aoa/ps.rst @@ -59,6 +59,9 @@ You can also set the sort key in the UI: * - i - --sort-processes io_counters - Sort by DISK I/O + * - j + - --programs + - Processes are display per program name (not per thread) * - m - --sort-processes memory_percent - Sort by MEM diff --git a/docs/api.rst b/docs/api.rst index 8942d3e0..d2d407da 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -66,14 +66,14 @@ GET alert Get plugin stats:: # curl http://localhost:61208/api/3/alert - [[1642243083.0, + [[1647094826.0, -1, 'WARNING', 'MEM', - 83.71248235499787, - 83.71248235499787, - 83.71248235499787, - 83.71248235499787, + 83.66218571592582, + 83.66218571592582, + 83.66218571592582, + 83.66218571592582, 1, [], '', @@ -93,7 +93,7 @@ Get plugin stats:: 'refresh': 3.0, 'regex': True, 'result': None, - 'timer': 0.41446375846862793}, + 'timer': 0.1266186237335205}, {'count': 0, 'countmax': 20.0, 'countmin': None, @@ -102,7 +102,7 @@ Get plugin stats:: 'refresh': 3.0, 'regex': True, 'result': None, - 'timer': 0.4140021800994873}] + 'timer': 0.1265122890472412}] Get a specific field:: @@ -120,7 +120,7 @@ Get a specific item when field matchs the given value:: 'refresh': 3.0, 'regex': True, 'result': None, - 'timer': 0.41446375846862793}]} + 'timer': 0.1266186237335205}]} GET core -------- @@ -150,19 +150,19 @@ Get plugin stats:: 'ctx_switches': 0, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 57.7, + 'idle': 70.1, 'interrupts': 0, - 'iowait': 0.7, + 'iowait': 0.2, 'irq': 0.0, 'nice': 0.0, 'soft_interrupts': 0, - 'softirq': 2.1, + 'softirq': 1.3, 'steal': 0.0, 'syscalls': 0, - 'system': 5.3, + 'system': 2.2, 'time_since_update': 1, - 'total': 43.1, - 'user': 34.2} + 'total': 29.9, + 'user': 26.2} Fields descriptions: @@ -184,7 +184,7 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/3/cpu/total - {'total': 43.1} + {'total': 29.9} GET diskio ---------- @@ -223,39 +223,6 @@ Get a specific item when field matchs the given value:: 'write_bytes': 0, 'write_count': 0}]} -GET docker ----------- - -Get plugin stats:: - - # curl http://localhost:61208/api/3/docker - [{'Command': ['/entrypoint.sh', 'influxd'], - 'Id': 'cf5df66383ead8b7a332b25956506bfc33573ba449d9dab98fcc606454d604cb', - 'Image': ['influxdb:latest'], - 'Names': ['dockerinfluxdb2grafana_influxdb_1'], - 'Status': 'running', - 'cpu_percent': 0.0, - 'io_r': None, - 'io_w': None, - 'key': 'name', - 'memory_usage': None, - 'name': 'dockerinfluxdb2grafana_influxdb_1', - 'network_rx': None, - 'network_tx': None}, - {'Command': ['/run.sh'], - 'Id': 'f5674bcca78935c38a085cd9d1988b4eaec167fc00e9108740126ff46a11bf83', - 'Image': ['grafana/grafana:latest'], - 'Names': ['dockerinfluxdb2grafana_grafana_1'], - 'Status': 'running', - 'cpu_percent': 0.0, - 'io_r': None, - 'io_w': None, - 'key': 'name', - 'memory_usage': None, - 'name': 'dockerinfluxdb2grafana_grafana_1', - 'network_rx': None, - 'network_tx': None}] - GET fs ------ @@ -263,30 +230,38 @@ Get plugin stats:: # curl http://localhost:61208/api/3/fs [{'device_name': '/dev/mapper/ubuntu--gnome--vg-root', - 'free': 5850710016, + 'free': 78952054784, 'fs_type': 'ext4', 'key': 'mnt_point', 'mnt_point': '/', - 'percent': 97.5, + 'percent': 65.8, 'size': 243396149248, - 'used': 225157984256}] + 'used': 152056639488}, + {'device_name': '/dev/loop31', + 'free': 0, + 'fs_type': 'squashfs', + 'key': 'mnt_point', + 'mnt_point': '/media/nicolargo/disk', + 'percent': 100.0, + 'size': 115867648, + 'used': 115867648}] Get a specific field:: # curl http://localhost:61208/api/3/fs/mnt_point - {'mnt_point': ['/']} + {'mnt_point': ['/', '/media/nicolargo/disk']} Get a specific item when field matchs the given value:: # curl http://localhost:61208/api/3/fs/mnt_point// {'/': [{'device_name': '/dev/mapper/ubuntu--gnome--vg-root', - 'free': 5850710016, + 'free': 78952054784, 'fs_type': 'ext4', 'key': 'mnt_point', 'mnt_point': '/', - 'percent': 97.5, + 'percent': 65.8, 'size': 243396149248, - 'used': 225157984256}]} + 'used': 152056639488}]} GET ip ------ @@ -311,7 +286,7 @@ GET load Get plugin stats:: # curl http://localhost:61208/api/3/load - {'cpucore': 4, 'min1': 2.36, 'min15': 1.56, 'min5': 1.67} + {'cpucore': 4, 'min1': 0.98, 'min15': 0.84, 'min5': 0.63} Fields descriptions: @@ -323,7 +298,7 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/3/load/min1 - {'min1': 2.36} + {'min1': 0.98} GET mem ------- @@ -331,16 +306,16 @@ GET mem Get plugin stats:: # curl http://localhost:61208/api/3/mem - {'active': 5074616320, - 'available': 1278410752, - 'buffers': 79331328, - 'cached': 1258463232, - 'free': 1278410752, - 'inactive': 1120292864, + {'active': 5571006464, + 'available': 1282355200, + 'buffers': 213389312, + 'cached': 1672343552, + 'free': 1282355200, + 'inactive': 1258221568, 'percent': 83.7, - 'shared': 721162240, - 'total': 7849021440, - 'used': 6570610688} + 'shared': 618840064, + 'total': 7849000960, + 'used': 6566645760} Fields descriptions: @@ -359,7 +334,7 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/3/mem/total - {'total': 7849021440} + {'total': 7849000960} GET memswap ----------- @@ -367,13 +342,13 @@ GET memswap Get plugin stats:: # curl http://localhost:61208/api/3/memswap - {'free': 6375411712, - 'percent': 21.1, - 'sin': 5680271360, - 'sout': 9946386432, + {'free': 5130543104, + 'percent': 36.5, + 'sin': 1421467648, + 'sout': 4656877568, 'time_since_update': 1, 'total': 8082419712, - 'used': 1707008000} + 'used': 2951876608} Fields descriptions: @@ -397,29 +372,29 @@ Get plugin stats:: # curl http://localhost:61208/api/3/network [{'alias': None, - 'cumulative_cx': 8512503, - 'cumulative_rx': 21687, - 'cumulative_tx': 8490816, + 'cumulative_cx': 0, + 'cumulative_rx': 0, + 'cumulative_tx': 0, 'cx': 0, - 'interface_name': 'vetha426f3c', - 'is_up': True, + 'interface_name': 'mpqemubr0', + 'is_up': False, 'key': 'interface_name', 'rx': 0, - 'speed': 10485760000, + 'speed': 0, 'time_since_update': 1, 'tx': 0}, {'alias': None, - 'cumulative_cx': 12652650, - 'cumulative_rx': 1086025, - 'cumulative_tx': 11566625, - 'cx': 0, - 'interface_name': 'veth5d13ef7', + 'cumulative_cx': 886808774, + 'cumulative_rx': 443404387, + 'cumulative_tx': 443404387, + 'cx': 200, + 'interface_name': 'lo', 'is_up': True, 'key': 'interface_name', - 'rx': 0, - 'speed': 10485760000, + 'rx': 100, + 'speed': 0, 'time_since_update': 1, - 'tx': 0}] + 'tx': 100}] Fields descriptions: @@ -436,31 +411,29 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/3/network/interface_name - {'interface_name': ['vetha426f3c', - 'veth5d13ef7', - 'docker0', - 'mpqemubr0', + {'interface_name': ['mpqemubr0', 'lo', - 'br_grafana', 'br-119e6ee04e05', 'wlp2s0', - 'br-87386b77b676']} + 'br-87386b77b676', + 'docker0', + 'br_grafana']} Get a specific item when field matchs the given value:: - # curl http://localhost:61208/api/3/network/interface_name/vetha426f3c - {'vetha426f3c': [{'alias': None, - 'cumulative_cx': 8512503, - 'cumulative_rx': 21687, - 'cumulative_tx': 8490816, - 'cx': 0, - 'interface_name': 'vetha426f3c', - 'is_up': True, - 'key': 'interface_name', - 'rx': 0, - 'speed': 10485760000, - 'time_since_update': 1, - 'tx': 0}]} + # curl http://localhost:61208/api/3/network/interface_name/mpqemubr0 + {'mpqemubr0': [{'alias': None, + 'cumulative_cx': 0, + 'cumulative_rx': 0, + 'cumulative_tx': 0, + 'cx': 0, + 'interface_name': 'mpqemubr0', + 'is_up': False, + 'key': 'interface_name', + 'rx': 0, + 'speed': 0, + 'time_since_update': 1, + 'tx': 0}]} GET now ------- @@ -468,7 +441,7 @@ GET now Get plugin stats:: # curl http://localhost:61208/api/3/now - '2022-01-15 11:38:03 CET' + '2022-03-12 15:20:26 CET' GET percpu ---------- @@ -479,29 +452,29 @@ Get plugin stats:: [{'cpu_number': 0, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 70.9, + 'idle': 93.6, + 'iowait': 0.7, + 'irq': 0.0, + 'key': 'cpu_number', + 'nice': 0.0, + 'softirq': 0.0, + 'steal': 0.0, + 'system': 1.4, + 'total': 6.4, + 'user': 4.3}, + {'cpu_number': 1, + 'guest': 0.0, + 'guest_nice': 0.0, + 'idle': 3.5, 'iowait': 0.0, 'irq': 0.0, 'key': 'cpu_number', 'nice': 0.0, - 'softirq': 0.9, + 'softirq': 0.0, 'steal': 0.0, - 'system': 2.6, - 'total': 29.1, - 'user': 25.6}, - {'cpu_number': 1, - 'guest': 0.0, - 'guest_nice': 0.0, - 'idle': 53.3, - 'iowait': 0.8, - 'irq': 0.0, - 'key': 'cpu_number', - 'nice': 0.0, - 'softirq': 3.3, - 'steal': 0.0, - 'system': 4.2, - 'total': 46.7, - 'user': 38.3}] + 'system': 2.1, + 'total': 96.5, + 'user': 94.3}] Get a specific field:: @@ -520,7 +493,7 @@ Get plugin stats:: 'port': 0, 'refresh': 30, 'rtt_warning': None, - 'status': 0.012442, + 'status': 0.006623, 'timeout': 3}] Get a specific field:: @@ -537,7 +510,7 @@ Get a specific item when field matchs the given value:: 'port': 0, 'refresh': 30, 'rtt_warning': None, - 'status': 0.012442, + 'status': 0.006623, 'timeout': 3}]} GET processcount @@ -546,7 +519,7 @@ GET processcount Get plugin stats:: # curl http://localhost:61208/api/3/processcount - {'pid_max': 0, 'running': 1, 'sleeping': 290, 'thread': 1534, 'total': 351} + {'pid_max': 0, 'running': 1, 'sleeping': 278, 'thread': 1516, 'total': 351} Get a specific field:: @@ -559,57 +532,64 @@ GET processlist Get plugin stats:: # curl http://localhost:61208/api/3/processlist - [{'cmdline': ['/usr/lib/firefox/firefox', - '-contentproc', - '-childID', - '14', - '-isForBrowser', - '-prefsLen', - '8563', - '-prefMapSize', - '252236', - '-jsInitLen', - '278884', - '-parentBuildID', - '20211215221728', - '-appDir', - '/usr/lib/firefox/browser', - '1503459', - 'true', - 'tab'], - 'cpu_percent': 0.0, - 'cpu_times': pcputimes(user=4747.52, system=1027.52, children_user=0.0, children_system=0.0, iowait=0.87), - 'gids': pgids(real=1000, effective=1000, saved=1000), - 'io_counters': [67805184, 65536, 0, 0, 0], - 'key': 'pid', - 'memory_info': pmem(rss=457805824, vms=3803693056, shared=28733440, text=643072, lib=0, data=1046167552, dirty=0), - 'memory_percent': 5.832648407187941, - 'name': 'Web Content', - 'nice': 0, - 'num_threads': 24, - 'pid': 1513121, - 'ppid': 1503459, - 'status': 'S', - 'time_since_update': 1, - 'username': 'nicolargo'}, - {'cmdline': ['/usr/share/code/code', + [{'cmdline': ['/usr/share/code/code', '--ms-enable-electron-run-as-node', '--inspect-port=0', '/usr/share/code/resources/app/out/bootstrap-fork', '--type=extensionHost', '--skipWorkspaceStorageLock'], 'cpu_percent': 0.0, - 'cpu_times': pcputimes(user=91.5, system=12.44, children_user=23.98, children_system=13.18, iowait=0.06), + 'cpu_times': pcputimes(user=1845.87, system=1003.06, children_user=598.02, children_system=1188.5, iowait=1.75), 'gids': pgids(real=1000, effective=1000, saved=1000), - 'io_counters': [189956096, 21913600, 0, 0, 0], + 'io_counters': [1861931008, 39206912, 0, 0, 0], 'key': 'pid', - 'memory_info': pmem(rss=441901056, vms=49750560768, shared=27869184, text=125038592, lib=0, data=706924544, dirty=0), - 'memory_percent': 5.630014637850192, + 'memory_info': pmem(rss=784523264, vms=49765212160, shared=20996096, text=125038592, lib=0, data=2984513536, dirty=0), + 'memory_percent': 9.995198981349086, 'name': 'code', 'nice': 0, 'num_threads': 14, - 'pid': 2195844, - 'ppid': 1484922, + 'pid': 224688, + 'ppid': 224567, + 'status': 'S', + 'time_since_update': 1, + 'username': 'nicolargo'}, + {'cmdline': ['/usr/share/code/code', + '--type=renderer', + '--disable-color-correct-rendering', + '--field-trial-handle=13126869943429715366,5011544368131150611,131072', + '--disable-features=CookiesWithoutSameSiteMustBeSecure,SameSiteByDefaultCookies,SpareRendererForSitePerProcess', + '--lang=en-US', + '--enable-crash-reporter=7c06f526-63e8-47aa-8c08-b95f6ad2ec2d,no_channel', + '--global-crash-keys=7c06f526-63e8-47aa-8c08-b95f6ad2ec2d,no_channel,_companyName=Microsoft,_productName=VSCode,_version=1.63.2', + '--user-data-dir=/home/nicolargo/.config/Code', + '--standard-schemes=vscode-webview,vscode-file', + '--secure-schemes=vscode-webview,vscode-file', + '--bypasscsp-schemes', + '--cors-schemes=vscode-webview,vscode-file', + '--fetch-schemes=vscode-webview,vscode-file', + '--service-worker-schemes=vscode-webview', + '--streaming-schemes', + '--app-path=/usr/share/code/resources/app', + '--no-sandbox', + '--no-zygote', + '--num-raster-threads=2', + '--enable-main-frame-before-activation', + '--renderer-client-id=5', + '--no-v8-untrusted-code-mitigations', + '--shared-files=v8_context_snapshot_data:100', + '--vscode-window-config=vscode:955bffb8-751b-45c3-a3c6-d5f7e223b9f9'], + 'cpu_percent': 0.0, + 'cpu_times': pcputimes(user=5377.96, system=473.59, children_user=0.0, children_system=0.0, iowait=5.02), + 'gids': pgids(real=1000, effective=1000, saved=1000), + 'io_counters': [618848256, 3588096, 0, 0, 0], + 'key': 'pid', + 'memory_info': pmem(rss=478654464, vms=54361899008, shared=49033216, text=125038592, lib=0, data=776347648, dirty=0), + 'memory_percent': 6.0982852013818585, + 'name': 'code', + 'nice': 0, + 'num_threads': 20, + 'pid': 224633, + 'ppid': 224567, 'status': 'S', 'time_since_update': 1, 'username': 'nicolargo'}] @@ -617,197 +597,193 @@ Get plugin stats:: Get a specific field:: # curl http://localhost:61208/api/3/processlist/pid - {'pid': [1513121, - 2195844, - 1503459, - 1503674, - 1503575, - 1503572, - 4092, - 2195942, - 1532561, - 1531912, - 2195826, - 2181020, - 2064119, - 2172756, - 1513158, - 1531883, - 1513179, - 2196630, - 1484922, - 1484953, - 178587, - 2194859, - 1485034, - 2195376, - 1503546, - 2195852, - 3913, - 2259, - 2199594, - 1542733, - 2193029, - 3934, - 18486, - 1542400, - 3855, - 1485057, - 1531913, - 1542791, - 1479304, - 3336, - 2430, - 2193737, - 211213, - 1484973, - 1541631, - 4265, - 4181, - 4241, - 4928, - 3853, - 2193739, - 1139, - 1, - 4116, - 4261, - 1180, - 1158, - 1517056, - 1503837, - 2196251, - 4152, + {'pid': [224688, + 224633, + 221861, + 221818, + 221571, + 221865, + 225097, + 3912, + 411872, + 387438, + 522109, + 431380, + 508306, + 425921, + 506457, + 507794, + 224601, + 224567, + 429894, + 387437, + 221653, + 224696, + 579379, + 522296, + 522193, + 400319, + 387461, + 225045, + 406478, + 223803, + 1863, + 579653, + 1812, + 3729, + 3754, + 224770, 348, - 1285, - 4266, - 2193801, - 3847, - 2193803, - 4143, - 4287, - 4164, - 1138, - 3764, - 3863, - 4121, - 237994, - 255840, - 3858, - 4078, - 1544088, - 4274, - 4129, - 4332, - 2196261, - 2195625, - 2196264, - 1575, - 4374, - 1008, - 4284, - 1548391, - 4264, - 1544077, - 3890, - 1544092, - 1484926, - 1181, - 5573, - 1541718, - 4196, - 1324, - 1176, - 4279, - 138395, - 1354, - 1484927, - 2216, - 3927, - 1147, - 3902, - 600490, - 1153, - 4048, - 4252, - 67406, - 3932, - 4276, - 4272, - 3959, - 1129, - 1537927, - 4160, - 4123, - 4340, - 1150, - 4339, - 6521, - 18537, - 4263, - 1173, - 1526429, - 4062, - 1544090, - 3896, - 4343, - 3921, - 1544091, - 2199577, - 1451, - 4137, - 1163, - 1178, - 1484929, - 5587, - 344713, - 1010, - 4273, - 4281, - 1007, - 3908, - 1135, - 1520402, - 4057, - 4267, - 2196267, - 1182, - 3883, - 344711, - 1209, - 3339, - 4262, - 2230, - 4072, - 172714, + 3674, + 368467, + 408027, + 224733, + 242690, + 296602, + 2115, + 503183, + 4200, + 224619, + 368421, + 1261, + 4004, + 4748, + 4084, + 1, + 3672, + 4058, + 222129, + 1114, + 3978, + 221247, + 3972, + 1155, + 4077, 1132, - 4260, - 4285, - 138445, - 213050, - 1166, - 1542748, - 1542646, - 4141, - 344710, - 1542688, - 4029, - 4120, - 3868, - 2199593, - 1122, - 2035, - 2229, - 2235, - 3848, - 213333, - 1214, - 997, - 1335, + 503203, + 3658, + 4085, + 4925, + 1239, + 4083, + 503202, + 3642, + 1822, + 3302, + 221629, + 221222, + 3684, + 3989, + 3947, + 3707, + 1110, + 4097, + 223820, + 4112, + 4107, + 224835, + 3898, + 3677, + 4081, + 3942, + 2063, + 3986, + 1119, + 1493, + 3951, + 2025, + 4104, + 1150, + 994, + 1096, + 3695, + 224571, + 4020, + 1818, + 3954, + 4076, + 341631, + 1129, + 3963, + 4106, + 260255, + 4157, + 4091, + 3752, + 4108, + 3779, + 224572, + 1104, + 341616, + 381, + 4087, + 1156, + 4080, + 227435, + 260268, + 3870, + 3746, + 1147, + 260265, + 301112, + 1157, + 3702, + 995, + 1121, + 4231, + 221232, + 1153, + 579641, + 1106, + 4164, + 1247, + 1105, + 993, + 4088, + 4069, + 4976, + 1160, + 1255, + 3310, + 3721, + 1291, + 224971, + 3892, + 3946, + 3725, + 3740, + 3875, + 2062, + 1108, + 260277, + 4103, + 4203, + 1368, + 2061, + 3967, + 3883, + 1138, + 1097, + 3716, + 1140, + 579652, + 2304, + 1835, + 1864, + 1849, + 509862, + 3662, + 1295, + 2265, + 1164, + 3849, + 965, + 224574, 375, 2, 3, 4, + 6, 9, 10, 11, @@ -818,6 +794,7 @@ Get a specific field:: 16, 17, 18, + 20, 21, 22, 23, @@ -836,25 +813,24 @@ Get a specific field:: 40, 41, 42, - 89, 90, 91, + 92, 94, 95, + 96, 97, 98, 99, - 100, 102, 103, 105, 106, - 107, + 108, 110, 119, 136, - 187, - 189, + 181, 190, 191, 192, @@ -862,155 +838,147 @@ Get a specific field:: 194, 195, 196, + 197, 202, 203, + 204, 207, 208, 237, - 279, - 280, - 289, - 291, - 359, - 364, - 398, + 257, + 288, + 290, + 363, + 365, + 392, + 396, + 397, 399, - 424, - 425, - 426, - 431, - 465, - 495, - 502, - 765, - 766, - 767, - 768, - 774, - 775, - 776, - 777, - 778, - 779, - 780, - 781, - 904, - 915, - 932, - 947, - 958, - 1347, - 1432, - 1433, - 1434, - 1435, - 1436, - 1437, - 1438, - 1440, - 2301, - 2325, - 3909, - 4601, - 24771, - 25388, - 57294, - 57650, - 57855, - 86491, - 86492, - 86504, - 86505, - 86506, - 86507, - 86508, - 86509, - 125413, - 126036, - 210727, - 210918, - 211155, - 211634, - 212663, - 354417, - 378648, - 378848, - 379044, - 439123, - 439461, - 507654, - 582345, - 582789, - 609671, - 609799, - 613137, - 632508, - 632584, - 1539753, - 1542716, - 2059667, - 2181763, - 2185178, - 2191796, - 2192986, - 2193330, - 2193618, - 2193622, - 2194689, - 2195181, - 2196123, - 2197142, - 2197157, - 2197703, - 2197756, - 2198100, - 2198212, - 2198623, - 2199268, - 2199269]} + 400, + 401, + 468, + 491, + 519, + 724, + 725, + 726, + 727, + 728, + 729, + 730, + 731, + 732, + 733, + 735, + 736, + 832, + 849, + 861, + 863, + 864, + 867, + 876, + 877, + 882, + 887, + 889, + 893, + 897, + 901, + 905, + 908, + 911, + 913, + 918, + 923, + 926, + 931, + 1303, + 1388, + 1390, + 1391, + 1392, + 1393, + 1394, + 1395, + 1396, + 1911, + 1917, + 2069, + 3732, + 4442, + 4619, + 7988, + 22299, + 198660, + 242630, + 243136, + 304416, + 310251, + 353156, + 438092, + 503050, + 503067, + 516417, + 516662, + 516816, + 563996, + 566615, + 568718, + 571234, + 572688, + 572972, + 574048, + 575202, + 575651, + 577454, + 578910, + 578911, + 579195, + 579196, + 579197, + 579198, + 579199, + 579200, + 579201, + 579202, + 579203, + 579204, + 579205, + 579214, + 579241, + 579255]} Get a specific item when field matchs the given value:: - # curl http://localhost:61208/api/3/processlist/pid/1513121 - {'1513121': [{'cmdline': ['/usr/lib/firefox/firefox', - '-contentproc', - '-childID', - '14', - '-isForBrowser', - '-prefsLen', - '8563', - '-prefMapSize', - '252236', - '-jsInitLen', - '278884', - '-parentBuildID', - '20211215221728', - '-appDir', - '/usr/lib/firefox/browser', - '1503459', - 'true', - 'tab'], - 'cpu_percent': 0.0, - 'cpu_times': [4747.52, 1027.52, 0.0, 0.0, 0.87], - 'gids': [1000, 1000, 1000], - 'io_counters': [67805184, 65536, 0, 0, 0], - 'key': 'pid', - 'memory_info': [457805824, - 3803693056, - 28733440, - 643072, - 0, - 1046167552, - 0], - 'memory_percent': 5.832648407187941, - 'name': 'Web Content', - 'nice': 0, - 'num_threads': 24, - 'pid': 1513121, - 'ppid': 1503459, - 'status': 'S', - 'time_since_update': 1, - 'username': 'nicolargo'}]} + # curl http://localhost:61208/api/3/processlist/pid/224688 + {'224688': [{'cmdline': ['/usr/share/code/code', + '--ms-enable-electron-run-as-node', + '--inspect-port=0', + '/usr/share/code/resources/app/out/bootstrap-fork', + '--type=extensionHost', + '--skipWorkspaceStorageLock'], + 'cpu_percent': 0.0, + 'cpu_times': [1845.87, 1003.06, 598.02, 1188.5, 1.75], + 'gids': [1000, 1000, 1000], + 'io_counters': [1861931008, 39206912, 0, 0, 0], + 'key': 'pid', + 'memory_info': [784523264, + 49765212160, + 20996096, + 125038592, + 0, + 2984513536, + 0], + 'memory_percent': 9.995198981349086, + 'name': 'code', + 'nice': 0, + 'num_threads': 14, + 'pid': 224688, + 'ppid': 224567, + 'status': 'S', + 'time_since_update': 1, + 'username': 'nicolargo'}]} GET psutilversion ----------------- @@ -1026,69 +994,69 @@ GET quicklook Get plugin stats:: # curl http://localhost:61208/api/3/quicklook - {'cpu': 43.1, - 'cpu_hz': 2025000000.0, - 'cpu_hz_current': 1420721250.0, + {'cpu': 29.9, + 'cpu_hz': 3000000000.0, + 'cpu_hz_current': 2644345000.0000005, 'cpu_name': 'Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz', 'mem': 83.7, 'percpu': [{'cpu_number': 0, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 70.9, - 'iowait': 0.0, + 'idle': 93.6, + 'iowait': 0.7, 'irq': 0.0, 'key': 'cpu_number', 'nice': 0.0, - 'softirq': 0.9, + 'softirq': 0.0, 'steal': 0.0, - 'system': 2.6, - 'total': 29.1, - 'user': 25.6}, + 'system': 1.4, + 'total': 6.4, + 'user': 4.3}, {'cpu_number': 1, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 53.3, - 'iowait': 0.8, - 'irq': 0.0, - 'key': 'cpu_number', - 'nice': 0.0, - 'softirq': 3.3, - 'steal': 0.0, - 'system': 4.2, - 'total': 46.7, - 'user': 38.3}, - {'cpu_number': 2, - 'guest': 0.0, - 'guest_nice': 0.0, - 'idle': 54.7, - 'iowait': 2.6, - 'irq': 0.0, - 'key': 'cpu_number', - 'nice': 0.0, - 'softirq': 1.7, - 'steal': 0.0, - 'system': 3.4, - 'total': 45.3, - 'user': 37.6}, - {'cpu_number': 3, - 'guest': 0.0, - 'guest_nice': 0.0, - 'idle': 45.5, + 'idle': 3.5, 'iowait': 0.0, 'irq': 0.0, 'key': 'cpu_number', 'nice': 0.0, 'softirq': 0.0, 'steal': 0.0, - 'system': 5.8, - 'total': 54.5, - 'user': 48.8}], - 'swap': 21.1} + 'system': 2.1, + 'total': 96.5, + 'user': 94.3}, + {'cpu_number': 2, + 'guest': 0.0, + 'guest_nice': 0.0, + 'idle': 93.0, + 'iowait': 0.0, + 'irq': 0.0, + 'key': 'cpu_number', + 'nice': 0.0, + 'softirq': 0.0, + 'steal': 0.0, + 'system': 2.8, + 'total': 7.0, + 'user': 4.2}, + {'cpu_number': 3, + 'guest': 0.0, + 'guest_nice': 0.0, + 'idle': 87.9, + 'iowait': 0.0, + 'irq': 0.0, + 'key': 'cpu_number', + 'nice': 0.0, + 'softirq': 5.4, + 'steal': 0.0, + 'system': 0.7, + 'total': 12.1, + 'user': 6.0}], + 'swap': 36.5} Get a specific field:: # curl http://localhost:61208/api/3/quicklook/cpu - {'cpu': 43.1} + {'cpu': 29.9} GET sensors ----------- @@ -1116,12 +1084,12 @@ Get a specific field:: # curl http://localhost:61208/api/3/sensors/label {'label': ['acpitz 1', 'acpitz 2', - 'Package id 0', - 'Core 0', - 'Core 1', 'CPU', 'Ambient', 'SODIMM', + 'Package id 0', + 'Core 0', + 'Core 1', 'BAT BAT0']} Get a specific item when field matchs the given value:: @@ -1145,7 +1113,7 @@ Get plugin stats:: 'hr_name': 'Ubuntu 20.04 64bit', 'linux_distro': 'Ubuntu 20.04', 'os_name': 'Linux', - 'os_version': '5.4.0-77-generic', + 'os_version': '5.4.0-91-generic', 'platform': '64bit'} Get a specific field:: @@ -1159,7 +1127,7 @@ GET uptime Get plugin stats:: # curl http://localhost:61208/api/3/uptime - {'seconds': 11020937} + {'seconds': 2587626} GET all stats ------------- @@ -1175,33 +1143,33 @@ GET stats history History of a plugin:: # curl http://localhost:61208/api/3/cpu/history - {'system': [['2022-01-15T11:38:03.818557', 5.3], - ['2022-01-15T11:38:04.940621', 5.3], - ['2022-01-15T11:38:06.106691', 4.6]], - 'user': [['2022-01-15T11:38:03.818543', 34.2], - ['2022-01-15T11:38:04.940614', 34.2], - ['2022-01-15T11:38:06.106677', 10.5]]} + {'system': [['2022-03-12T15:20:26.638143', 2.2], + ['2022-03-12T15:20:27.673966', 2.2], + ['2022-03-12T15:20:28.781466', 3.1]], + 'user': [['2022-03-12T15:20:26.638138', 26.2], + ['2022-03-12T15:20:27.673962', 26.2], + ['2022-03-12T15:20:28.781462', 9.7]]} Limit history to last 2 values:: # curl http://localhost:61208/api/3/cpu/history/2 - {'system': [['2022-01-15T11:38:04.940621', 5.3], - ['2022-01-15T11:38:06.106691', 4.6]], - 'user': [['2022-01-15T11:38:04.940614', 34.2], - ['2022-01-15T11:38:06.106677', 10.5]]} + {'system': [['2022-03-12T15:20:27.673966', 2.2], + ['2022-03-12T15:20:28.781466', 3.1]], + 'user': [['2022-03-12T15:20:27.673962', 26.2], + ['2022-03-12T15:20:28.781462', 9.7]]} History for a specific field:: # curl http://localhost:61208/api/3/cpu/system/history - {'system': [['2022-01-15T11:38:03.818557', 5.3], - ['2022-01-15T11:38:04.940621', 5.3], - ['2022-01-15T11:38:06.106691', 4.6]]} + {'system': [['2022-03-12T15:20:26.638143', 2.2], + ['2022-03-12T15:20:27.673966', 2.2], + ['2022-03-12T15:20:28.781466', 3.1]]} Limit history for a specific field to last 2 values:: # curl http://localhost:61208/api/3/cpu/system/history - {'system': [['2022-01-15T11:38:04.940621', 5.3], - ['2022-01-15T11:38:06.106691', 4.6]]} + {'system': [['2022-03-12T15:20:27.673966', 2.2], + ['2022-03-12T15:20:28.781466', 3.1]]} GET limits (used for thresholds) -------------------------------- diff --git a/docs/man/glances.1 b/docs/man/glances.1 index 8b5f4456..2ded4f12 100644 --- a/docs/man/glances.1 +++ b/docs/man/glances.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "GLANCES" "1" "Jan 15, 2022" "3.2.5_beta01" "Glances" +.TH "GLANCES" "1" "Mar 12, 2022" "3.2.5_beta01" "Glances" .SH NAME glances \- An eye on your system . diff --git a/glances/main.py b/glances/main.py index 5544c239..4b3482e0 100644 --- a/glances/main.py +++ b/glances/main.py @@ -253,6 +253,14 @@ Examples of use: choices=sort_processes_key_list, help='Sort processes by: {}'.format(', '.join(sort_processes_key_list)), ) + # Display processes list by program name and not by thread + parser.add_argument( + '--programs', + action='store_true', + default=False, + dest='programs', + help='Show processes as programs (not threads)', + ) # Export modules feature parser.add_argument('--export', dest='export', help='enable export module (comma separed list)') parser.add_argument( diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index 07dd9964..471d33b7 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -77,6 +77,7 @@ class _GlancesCurses(object): 'h': {'switch': 'help_tag'}, 'i': {'sort_key': 'io_counters'}, 'I': {'switch': 'disable_ip'}, + 'j': {'switch': 'programs'}, # 'k' > Kill selected process 'K': {'switch': 'disable_connections'}, 'l': {'switch': 'disable_alert'}, diff --git a/glances/outputs/static/js/components/glances/controller.js b/glances/outputs/static/js/components/glances/controller.js index a851580e..ec33b7b0 100644 --- a/glances/outputs/static/js/components/glances/controller.js +++ b/glances/outputs/static/js/components/glances/controller.js @@ -46,6 +46,14 @@ export default function GlancesController($scope, GlancesStats, hotkeys, ARGUMEN } }); + // j => Processes are display per program name (not per thread) + hotkeys.add({ + combo: 'j', + callback: function () { + ARGUMENTS.programs = !ARGUMENTS.programs; + } + }); + // k => Show/hide connections stats hotkeys.add({ combo: 'k', diff --git a/glances/outputs/static/public/glances.js b/glances/outputs/static/public/glances.js index 5513e005..8277f14e 100644 Binary files a/glances/outputs/static/public/glances.js and b/glances/outputs/static/public/glances.js differ diff --git a/glances/outputs/static/public/glances.map.js b/glances/outputs/static/public/glances.map.js index 27a772c4..735d3c97 100644 Binary files a/glances/outputs/static/public/glances.map.js and b/glances/outputs/static/public/glances.map.js differ diff --git a/glances/plugins/glances_help.py b/glances/plugins/glances_help.py index 984694a3..317960d4 100644 --- a/glances/plugins/glances_help.py +++ b/glances/plugins/glances_help.py @@ -110,6 +110,7 @@ class Plugin(GlancesPlugin): self.view_data['show_hide_raid_plugin'] = msg_col.format('R', 'Show/hide RAID plugin') self.view_data['show_hide_wifi_module'] = msg_col2.format('W', 'Show/hide Wifi module') self.view_data['enable_disable_all_but_quick_look_and_load_module'] = msg_col2.format('4', 'Enable/disable all but quick look and load module') + self.view_data['programs'] = msg_col2.format('j', 'Show processes as programs') def get_view_data(self, args=None): @@ -203,7 +204,8 @@ class Plugin(GlancesPlugin): ret.append(self.curse_add_line(self.view_data['enable_disable_all_but_quick_look_and_load_module'])) ret.append(self.curse_new_line()) ret.append(self.curse_add_line(self.view_data['quit'])) - + ret.append(self.curse_add_line(self.view_data['programs'])) + ret.append(self.curse_new_line()) ret.append(self.curse_new_line()) diff --git a/glances/plugins/glances_processcount.py b/glances/plugins/glances_processcount.py index 53032970..1a72b6b1 100644 --- a/glances/plugins/glances_processcount.py +++ b/glances/plugins/glances_processcount.py @@ -141,16 +141,17 @@ class Plugin(GlancesPlugin): ret.append(self.curse_add_line(msg)) # Display sort information + msg = 'Programs' if self.args.programs else 'Threads' try: sort_human = self.sort_for_human[glances_processes.sort_key] except KeyError: sort_human = glances_processes.sort_key if glances_processes.auto_sort: - msg = 'sorted automatically' + msg += ' sorted automatically' ret.append(self.curse_add_line(msg)) msg = ' by {}'.format(sort_human) else: - msg = 'sorted by {}'.format(sort_human) + msg += ' sorted by {}'.format(sort_human) ret.append(self.curse_add_line(msg)) # Return the message with decoration diff --git a/glances/plugins/glances_processlist.py b/glances/plugins/glances_processlist.py index 774e665a..a0a020d1 100644 --- a/glances/plugins/glances_processlist.py +++ b/glances/plugins/glances_processlist.py @@ -29,6 +29,7 @@ from glances.processes import glances_processes, sort_stats from glances.outputs.glances_unicode import unicode_message from glances.plugins.glances_core import Plugin as CorePlugin from glances.plugins.glances_plugin import GlancesPlugin +from glances.programs import processes_to_programs def seconds_to_hms(input_seconds): @@ -156,6 +157,9 @@ class Plugin(GlancesPlugin): # Note: Update is done in the processcount plugin # Just return the processes list stats = glances_processes.getlist() + if self.args.programs: + stats = processes_to_programs(stats) + elif self.input_method == 'snmp': # No SNMP grab for processes diff --git a/glances/processes.py b/glances/processes.py index 1cbcc1bb..91412a48 100644 --- a/glances/processes.py +++ b/glances/processes.py @@ -23,6 +23,7 @@ from glances.compat import iterkeys from glances.globals import BSD, LINUX, MACOS, WINDOWS from glances.timer import Timer, getTimeSinceLastUpdate from glances.filter import GlancesFilter +from glances.programs import processes_to_programs from glances.logger import logger import psutil diff --git a/glances/programs.py b/glances/programs.py new file mode 100644 index 00000000..3a652627 --- /dev/null +++ b/glances/programs.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# +# This file is part of Glances. +# +# Copyright (C) 2022 Nicolargo +# +# Glances is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Glances is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . + +# from glances.logger import logger + +# This constant defines the list of available processes sort key +sort_programs_key_list = ['cpu_percent', 'memory_percent', 'cpu_times', 'io_counters', 'name'] + + +def processes_to_programs(processes): + """Convert a list of processes to a list of programs. + + Each program is a dict containing the following keys: + - 'name': program name + - 'cpu_percent': process cpu percent (sum of all processes) + - 'memory_percent': process memory percent (sum of all processes) + - 'cpu_times': process cpu times (sum of all processes) + - 'memory_info': process memory info (sum of all processes) + - 'io_counters': process io counters (sum of all processes) + - 'children': list of children processes + """ + # Start to build a dict of programs (key is program name) + programs_dict = {} + for p in processes: + if p['name'] not in programs_dict: + # Create a new entry in the dict (new program) + programs_dict[p['name']] = { + 'cpu_percent': p['cpu_percent'], + 'memory_percent': p['memory_percent'], + 'cpu_times': p['cpu_times'], + 'memory_info': p['memory_info'], + 'io_counters': p['io_counters'], + 'children': [p['pid']], + 'time_since_update': p['time_since_update'], + # Others keys are not used + # but should be set to be compliant with the existing process_list + 'name': p['name'], + 'cmdline': [p['name']], + 'pid': '_', + 'username': p['username'], + 'nice': p['nice'], + 'status': p['status'], + } + else: + # Update a existing entry in the dict (existing program) + programs_dict[p['name']]['cpu_percent'] += p['cpu_percent'] + programs_dict[p['name']]['memory_percent'] += p['memory_percent'] + programs_dict[p['name']]['cpu_times'] += p['cpu_times'] + programs_dict[p['name']]['memory_info'] += p['memory_info'] + programs_dict[p['name']]['io_counters'] += p['io_counters'] + programs_dict[p['name']]['children'].append(p['pid']) + # If all the subprocess has the same value, display it + programs_dict[p['name']]['username'] = p['username'] if p['username'] == programs_dict[p['name']]['username'] else '_' + programs_dict[p['name']]['nice'] = p['nice'] if p['nice'] == programs_dict[p['name']]['nice'] else '_' + programs_dict[p['name']]['status'] = p['status'] if p['status'] == programs_dict[p['name']]['status'] else '_' + + # Convert the dict to a list of programs + return [programs_dict[p] for p in programs_dict] diff --git a/unitest.py b/unitest.py index e2a496c4..76c80494 100755 --- a/unitest.py +++ b/unitest.py @@ -34,6 +34,7 @@ from glances.thresholds import GlancesThresholdWarning from glances.thresholds import GlancesThresholdCritical from glances.thresholds import GlancesThresholds from glances.plugins.glances_plugin import GlancesPlugin +from glances.programs import processes_to_programs from glances.compat import subsample, range from glances.secure import secure_popen from glances.compat import PY3 @@ -283,6 +284,16 @@ class TestGlances(unittest.TestCase): print('INFO: SMART stats: %s' % stats_grab) + def test_017_programs(self): + """Check Programs function (it's not a plugin).""" + # stats_to_check = [ ] + print('INFO: [TEST_010] Check PROGRAM stats') + stats_grab = processes_to_programs(stats.get_plugin('processlist').get_raw()) + self.assertTrue(type(stats_grab) is list, msg='Programs stats is not a list') + print('INFO: PROGRAM list stats: %s items in the list' % len(stats_grab)) + # Check if number of processes in the list equal counter + # self.assertEqual(total, len(stats_grab)) + def test_094_thresholds(self): """Test thresholds classes""" print('INFO: [TEST_094] Thresholds')