diff --git a/conf/glances.conf b/conf/glances.conf index 0ec433af..9856540a 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -875,9 +875,8 @@ password=password [duckdb] # database defines where data are stored, can be one of: -# :memory: (see https://duckdb.org/docs/stable/clients/python/dbapi#in-memory-connection) -# :memory:glances (see https://duckdb.org/docs/stable/clients/python/dbapi#in-memory-connection) # /path/to/glances.db (see https://duckdb.org/docs/stable/clients/python/dbapi#file-based-connection) +# :memory:glances (see https://duckdb.org/docs/stable/clients/python/dbapi#in-memory-connection) # Or anyone else supported by the API (see https://duckdb.org/docs/stable/clients/python/dbapi) # database=:memory: database=/tmp/glances.db diff --git a/docs/api/python.rst b/docs/api/python.rst index 99074d4d..ff1809c6 100644 --- a/docs/api/python.rst +++ b/docs/api/python.rst @@ -22,25 +22,25 @@ use the following code: >>> gl = api.GlancesAPI() >>> gl.cpu {'cpucore': 16, - 'ctx_switches': 305832907, + 'ctx_switches': 320732562, 'guest': 0.0, - 'idle': 91.8, - 'interrupts': 248220322, - 'iowait': 0.4, + 'idle': 93.4, + 'interrupts': 260548066, + 'iowait': 0.3, 'irq': 0.0, 'nice': 0.0, - 'soft_interrupts': 100550229, + 'soft_interrupts': 105596536, 'steal': 0.0, 'syscalls': 0, - 'system': 4.6, - 'total': 5.6, - 'user': 3.2} + 'system': 4.3, + 'total': 6.6, + 'user': 1.9} >>> gl.cpu["total"] - 5.6 + 6.6 >>> gl.mem["used"] - 10240561152 + 10288771072 >>> gl.auto_unit(gl.mem["used"]) - 9.54G + 9.58G If the stats return a list of items (like network interfaces or processes), you can access them by their name: @@ -52,18 +52,18 @@ access them by their name: >>> gl.network["wlp0s20f3"] {'alias': None, 'bytes_all': 0, - 'bytes_all_gauge': 3100588600, + 'bytes_all_gauge': 3136480531, 'bytes_all_rate_per_sec': 0.0, 'bytes_recv': 0, - 'bytes_recv_gauge': 2247529593, + 'bytes_recv_gauge': 2268638346, 'bytes_recv_rate_per_sec': 0.0, 'bytes_sent': 0, - 'bytes_sent_gauge': 853059007, + 'bytes_sent_gauge': 867842185, 'bytes_sent_rate_per_sec': 0.0, 'interface_name': 'wlp0s20f3', 'key': 'interface_name', 'speed': 0, - 'time_since_update': 0.18211889266967773} + 'time_since_update': 0.1277766227722168} Init Glances Python API ----------------------- @@ -95,18 +95,18 @@ Alert stats: >>> type(gl.alert) >>> gl.alert - [{'avg': 91.4376177192857, - 'begin': 1758441568, + [{'avg': 89.02157690198602, + 'begin': 1758460132, 'count': 2, 'desc': '', 'end': -1, 'global_msg': 'High swap (paging) usage', - 'max': 91.4376177192857, - 'min': 91.4376177192857, + 'max': 89.02157690198602, + 'min': 89.02157690198602, 'sort': 'memory_percent', - 'state': 'CRITICAL', - 'sum': 182.8752354385714, - 'top': ['code', 'code', 'code'], + 'state': 'WARNING', + 'sum': 178.04315380397205, + 'top': [], 'type': 'MEMSWAP'}] Alert fields description: @@ -182,14 +182,14 @@ Diskio stats: >>> gl.diskio["nvme0n1"] {'disk_name': 'nvme0n1', 'key': 'disk_name', - 'read_bytes': 18528616960, - 'read_count': 959426, + 'read_bytes': 18841174528, + 'read_count': 995790, 'read_latency': 0, - 'read_time': 284132, - 'write_bytes': 26236740608, - 'write_count': 2366204, + 'read_time': 299584, + 'write_bytes': 27118343168, + 'write_count': 2440073, 'write_latency': 0, - 'write_time': 2119741} + 'write_time': 2247044} Diskio fields description: @@ -272,11 +272,11 @@ Processcount stats: >>> type(gl.processcount) >>> gl.processcount - {'pid_max': 0, 'running': 1, 'sleeping': 431, 'thread': 2464, 'total': 569} + {'pid_max': 0, 'running': 1, 'sleeping': 423, 'thread': 2223, 'total': 555} >>> gl.processcount.keys() ['total', 'running', 'sleeping', 'thread', 'pid_max'] >>> gl.processcount["total"] - 569 + 555 Processcount fields description: @@ -349,7 +349,7 @@ Percpu stats: 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 56.0, + 'idle': 31.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -358,7 +358,7 @@ Percpu stats: 'softirq': 0.0, 'steal': 0.0, 'system': 9.0, - 'total': 44.0, + 'total': 69.0, 'user': 1.0} Percpu fields description: @@ -449,18 +449,18 @@ Network stats: >>> gl.network["wlp0s20f3"] {'alias': None, 'bytes_all': 0, - 'bytes_all_gauge': 3100588600, + 'bytes_all_gauge': 3136480531, 'bytes_all_rate_per_sec': 0.0, 'bytes_recv': 0, - 'bytes_recv_gauge': 2247529593, + 'bytes_recv_gauge': 2268638346, 'bytes_recv_rate_per_sec': 0.0, 'bytes_sent': 0, - 'bytes_sent_gauge': 853059007, + 'bytes_sent_gauge': 867842185, 'bytes_sent_rate_per_sec': 0.0, 'interface_name': 'wlp0s20f3', 'key': 'interface_name', 'speed': 0, - 'time_since_update': 0.0034186840057373047} + 'time_since_update': 0.0025174617767333984} Network fields description: @@ -501,23 +501,23 @@ Cpu stats: >>> gl.cpu {'cpucore': 16, - 'ctx_switches': 305832907, + 'ctx_switches': 320732562, 'guest': 0.0, - 'idle': 91.8, - 'interrupts': 248220322, - 'iowait': 0.4, + 'idle': 93.4, + 'interrupts': 260548066, + 'iowait': 0.3, 'irq': 0.0, 'nice': 0.0, - 'soft_interrupts': 100550229, + 'soft_interrupts': 105596536, 'steal': 0.0, 'syscalls': 0, - 'system': 4.6, - 'total': 5.6, - 'user': 3.2} + 'system': 4.3, + 'total': 6.6, + 'user': 1.9} >>> gl.cpu.keys() ['total', 'user', 'nice', 'system', 'idle', 'iowait', 'irq', 'steal', 'guest', 'ctx_switches', 'interrupts', 'soft_interrupts', 'syscalls', 'cpucore'] >>> gl.cpu["total"] - 5.6 + 6.6 Cpu fields description: @@ -589,7 +589,7 @@ Amps stats: 'refresh': 3.0, 'regex': True, 'result': None, - 'timer': 0.30202817916870117} + 'timer': 0.1950986385345459} Amps fields description: @@ -620,7 +620,7 @@ Processlist stats: >>> gl.processlist Return a dict of dict with key= >>> gl.processlist.keys() - [110899, 112061, 22460, 6683, 6059, 7262, 7250, 8474, 448774, 390113, 7258, 5046, 96461, 391029, 6409, 111133, 390871, 390155, 22312, 409614, 21168, 199912, 233089, 18180, 409705, 112323, 221853, 234880, 275603, 344651, 22523, 111268, 111261, 20799, 19815, 21230, 22429, 504380, 504332, 504441, 24044, 507910, 500290, 448971, 22524, 111385, 111384, 111382, 3478, 6003, 240741, 6419, 240742, 22410, 2516, 111284, 724, 111848, 5626, 111192, 22786, 5474, 7068, 12361, 5623, 136828, 111283, 2879, 6388, 5652, 5173, 112290, 5414, 111386, 240756, 6478, 240771, 1, 2511, 111267, 5158, 2616, 4721, 6376, 5284, 2619, 6015, 8698, 111341, 5166, 8639, 5291, 4747, 4744, 5208, 6037, 2539, 5684, 6039, 2719, 4698, 5606, 5343, 5521, 5187, 5580, 2499, 5207, 8086, 448339, 5190, 2828, 4988, 5204, 5235, 3472, 5224, 5201, 4758, 2921, 5447, 5213, 3531, 2534, 5297, 3459, 2376, 5485, 5191, 5421, 5461, 4975, 14662, 5031, 22315, 2846, 24073, 5445, 5170, 5925, 322017, 5228, 4809, 2506, 5547, 2519, 5477, 2498, 5189, 5139, 760, 5221, 5337, 14670, 2523, 107652, 4871, 5218, 4813, 2722, 5231, 2377, 2537, 4985, 2503, 5366, 5429, 22912, 4740, 3617, 5044, 2514, 3483, 4746, 507906, 2497, 3075, 2375, 2665, 476625, 3496, 3358, 4741, 507909, 3359, 67282, 4958, 2521, 2542, 3488, 5851, 2869, 2550, 4960, 4886, 22329, 3363, 4728, 6044, 22314, 111134, 6151, 22835, 2615, 330048, 2854, 2858, 111149, 4820, 3076, 2, 3, 4, 5, 6, 7, 8, 10, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 118, 121, 122, 123, 124, 125, 126, 127, 129, 132, 134, 135, 136, 137, 138, 139, 141, 142, 143, 144, 145, 146, 148, 151, 152, 154, 155, 156, 163, 174, 185, 186, 214, 215, 237, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 347, 349, 354, 355, 356, 357, 361, 439, 440, 602, 607, 608, 609, 615, 666, 667, 787, 970, 991, 992, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1137, 1164, 1274, 1331, 1334, 1335, 1336, 1337, 1398, 1399, 1481, 1488, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1876, 1877, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1984, 1985, 1986, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2014, 3421, 3422, 3423, 3424, 3793, 233310, 358608, 446510, 448136, 448145, 455365, 455369, 463479, 464074, 464755, 468944, 471022, 471300, 475029, 475987, 476570, 482523, 484291, 484677, 487183, 487213, 487370, 489052, 489373, 490299, 493432, 494056, 494125, 494166, 494638, 495000, 495262, 495276, 495668, 496527, 497602, 497698, 498555, 498684, 500372, 500667, 500805, 501010, 501024, 501025, 501026, 501027, 501217, 501270, 501479, 502852, 505729, 506364, 506417, 506802, 506803, 507295, 507348, 507380, 507500, 507789, 507933] + [110899, 112061, 22460, 6683, 7262, 7250, 6059, 96461, 8474, 5046, 7258, 111133, 6409, 22312, 21168, 504332, 199912, 22523, 504380, 18180, 112323, 20799, 111268, 344651, 111261, 233089, 19815, 21230, 528342, 528026, 22429, 528189, 22524, 24044, 536370, 500290, 514291, 111385, 111384, 111382, 3478, 6003, 240741, 240742, 2516, 6419, 22410, 724, 111284, 22786, 111848, 5626, 111192, 5623, 136828, 7068, 5474, 12361, 111283, 2879, 6388, 5652, 5173, 112290, 5414, 111386, 240756, 5166, 6478, 240771, 1, 2511, 111267, 5158, 4721, 2616, 6376, 111341, 5284, 2619, 6015, 8698, 8639, 5291, 4747, 4744, 5208, 6037, 2539, 5684, 6039, 2719, 4698, 5606, 5343, 5521, 5187, 5580, 2499, 5207, 512959, 8086, 5190, 2828, 4988, 24073, 5204, 5235, 3472, 5224, 5201, 4758, 2921, 5447, 5213, 3531, 2534, 5297, 3459, 2376, 5485, 5191, 2846, 5421, 5461, 4975, 14662, 5031, 22315, 5445, 5170, 5925, 322017, 5228, 4809, 2506, 67282, 5547, 2519, 5477, 2498, 5189, 5139, 760, 5221, 5337, 14670, 2523, 107652, 4871, 5218, 4813, 2722, 5231, 2377, 2537, 4985, 2503, 5366, 5429, 22912, 4740, 3617, 5044, 2514, 3483, 536366, 4746, 2497, 3075, 2375, 2665, 535036, 22329, 512366, 3496, 3358, 4741, 3359, 536369, 4958, 2521, 2542, 3488, 5851, 2869, 2550, 4960, 4886, 3363, 4728, 6044, 22314, 111134, 6151, 22835, 2615, 2854, 2858, 111149, 4820, 3076, 2, 3, 4, 5, 6, 7, 8, 10, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 118, 121, 122, 123, 124, 125, 126, 127, 129, 132, 134, 135, 136, 137, 138, 139, 141, 142, 143, 144, 145, 146, 148, 151, 152, 154, 155, 156, 163, 174, 185, 186, 214, 215, 237, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 347, 349, 354, 355, 356, 357, 361, 439, 440, 602, 607, 608, 609, 615, 666, 667, 787, 970, 991, 992, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1137, 1164, 1274, 1331, 1334, 1335, 1336, 1337, 1398, 1399, 1481, 1488, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1876, 1877, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1984, 1985, 1986, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2014, 3421, 3422, 3423, 3424, 3793, 233310, 358608, 482523, 493432, 496527, 506417, 507933, 509745, 510267, 512301, 512694, 512798, 512806, 512819, 512844, 512853, 514442, 518958, 519636, 519648, 520712, 520713, 521234, 522034, 522511, 523546, 523679, 525395, 526422, 528124, 528125, 528556, 528634, 528918, 528919, 528920, 528922, 530007, 530009, 530013, 530076, 530800, 530823, 531835, 532833, 532991, 533161, 533837, 533850, 534282, 534999, 535540, 535552, 535636, 535673, 535786] >>> gl.processlist["110899"] {'cmdline': ['/proc/self/exe', '--type=utility', @@ -645,66 +645,66 @@ Processlist stats: '--enable-features=DocumentPolicyIncludeJSCallStacksInCrashReports,EarlyEstablishGpuChannel,EstablishGpuChannelAsync', '--disable-features=CalculateNativeWinOcclusion,FontationsLinuxSystemFonts,ScreenAIOCREnabled,SpareRendererForSitePerProcess', '--variations-seed-version'], - 'cpu_percent': 1.9, - 'cpu_times': {'children_system': 1117.77, - 'children_user': 1369.92, + 'cpu_percent': 0.0, + 'cpu_times': {'children_system': 1171.81, + 'children_user': 1402.69, 'iowait': 0.0, - 'system': 1272.29, - 'user': 4766.5}, + 'system': 1346.04, + 'user': 5083.5}, 'gids': {'effective': 1000, 'real': 1000, 'saved': 1000}, - 'io_counters': [2014217216, - 1436655616, - 2014217216, - 1436655616, + 'io_counters': [2045707264, + 1520226304, + 2045707264, + 1520226304, 1, - 111648768, + 119644160, 688128, - 111648768, + 119644160, 688128, 1, - 209947648, - 413696, - 209947648, - 413696, + 210056192, + 417792, + 210056192, + 417792, 1, 27337728, 4206592, 27337728, 4206592, 1, - 3401198592, - 1180692480, - 3401198592, - 1180692480, + 3401456640, + 1192022016, + 3401456640, + 1192022016, 1, - 93603840, + 350585856, + 2969100288, + 350585856, + 2969100288, + 1, + 93652992, 0, - 93603840, + 93652992, 0, 1, + 12365824, + 8192, + 12365824, + 8192, + 1, 27540480, 1413120, 27540480, 1413120, 1, - 346797056, - 2969100288, - 346797056, - 2969100288, - 1, - 7426048, - 8192, - 7426048, - 8192, - 1, - 32229376, + 32574464, 0, - 32229376, + 32574464, 0, 1, - 75408384, + 82027520, 0, - 75408384, + 82027520, 0, 1, 1559552, @@ -717,39 +717,39 @@ Processlist stats: 3833856, 0, 1, - 23600128, - 23175168, - 23600128, - 23175168, + 23604224, + 23769088, + 23604224, + 23769088, 1, - 6934528, + 7024640, 0, - 6934528, + 7024640, 0, 1, - 6627328, + 14196736, 0, - 6627328, + 14196736, 0, 1, - 1983488, + 6631424, 0, - 1983488, + 6631424, 0, 1, - 14069760, + 2044928, 0, - 14069760, + 2044928, 0, 1, - 1885184, + 2634752, 0, - 1885184, + 2634752, 0, 1, - 2438144, + 2536448, 0, - 2438144, + 2536448, 0, 1, 10924032, @@ -762,9 +762,9 @@ Processlist stats: 159744, 8192, 1, - 2541568, + 2545664, 2846720, - 2541568, + 2545664, 2846720, 1, 12880896, @@ -778,20 +778,20 @@ Processlist stats: 0, 1], 'key': 'pid', - 'memory_info': {'data': 4763049984, + 'memory_info': {'data': 4896391168, 'dirty': 0, 'lib': 0, - 'rss': 2159456256, - 'shared': 79568896, + 'rss': 2315513856, + 'shared': 80236544, 'text': 148705280, 'vms': 1526338510848}, - 'memory_percent': 13.149072251547079, + 'memory_percent': 14.09931731999964, 'name': 'code', 'nice': 0, 'num_threads': 58, 'pid': 110899, 'status': 'S', - 'time_since_update': 0.5535836219787598, + 'time_since_update': 0.4007854461669922, 'username': 'nicolargo'} Processlist fields description: @@ -876,13 +876,13 @@ Load stats: >>> gl.load {'cpucore': 16, - 'min1': 0.97705078125, - 'min15': 1.5791015625, - 'min5': 1.697265625} + 'min1': 0.35302734375, + 'min15': 0.83642578125, + 'min5': 0.712890625} >>> gl.load.keys() ['min1', 'min5', 'min15', 'cpucore'] >>> gl.load["min1"] - 0.97705078125 + 0.35302734375 Load fields description: @@ -959,7 +959,7 @@ Uptime stats: >>> type(gl.uptime) >>> gl.uptime - '8 days, 0:38:58' + '8 days, 5:48:20' Uptime limits: @@ -978,11 +978,11 @@ Now stats: >>> type(gl.now) >>> gl.now - {'custom': '2025-09-21 09:59:29 CEST', 'iso': '2025-09-21T09:59:29+02:00'} + {'custom': '2025-09-21 15:08:52 CEST', 'iso': '2025-09-21T15:08:52+02:00'} >>> gl.now.keys() ['iso', 'custom'] >>> gl.now["iso"] - '2025-09-21T09:59:29+02:00' + '2025-09-21T15:08:52+02:00' Now fields description: @@ -1011,14 +1011,14 @@ Fs stats: ['/', '/zsfpool'] >>> gl.fs["/"] {'device_name': '/dev/mapper/ubuntu--vg-ubuntu--lv', - 'free': 716746481664, + 'free': 716730462208, 'fs_type': 'ext4', 'key': 'mnt_point', 'mnt_point': '/', 'options': 'rw,relatime', 'percent': 24.8, 'size': 1003736440832, - 'used': 235927453696} + 'used': 235943473152} Fs fields description: @@ -1058,8 +1058,8 @@ Wifi stats: ['wlp0s20f3'] >>> gl.wifi["wlp0s20f3"] {'key': 'ssid', - 'quality_level': -62.0, - 'quality_link': 48.0, + 'quality_level': -64.0, + 'quality_link': 46.0, 'ssid': 'wlp0s20f3'} Wifi limits: @@ -1191,16 +1191,16 @@ Mem stats: >>> type(gl.mem) >>> gl.mem - {'active': 7853846528, - 'available': 6182318080, - 'buffers': 272400384, - 'cached': 5119221760, - 'free': 6182318080, - 'inactive': 6526087168, - 'percent': 62.4, - 'shared': 736985088, + {'active': 8278609920, + 'available': 6134108160, + 'buffers': 313073664, + 'cached': 4285337600, + 'free': 6134108160, + 'inactive': 5272354816, + 'percent': 62.6, + 'shared': 748851200, 'total': 16422879232, - 'used': 10240561152} + 'used': 10288771072} >>> gl.mem.keys() ['total', 'available', 'percent', 'used', 'free', 'active', 'inactive', 'buffers', 'cached', 'shared'] >>> gl.mem["total"] @@ -1270,19 +1270,19 @@ Quicklook stats: >>> type(gl.quicklook) >>> gl.quicklook - {'cpu': 5.6, + {'cpu': 6.6, 'cpu_hz': 4475000000.0, - 'cpu_hz_current': 916671999.9999999, + 'cpu_hz_current': 1087108374.9999998, 'cpu_log_core': 16, 'cpu_name': '13th Gen Intel(R) Core(TM) i7-13620H', 'cpu_phys_core': 10, - 'load': 9.9, - 'mem': 62.4, + 'load': 5.2, + 'mem': 62.6, 'percpu': [{'cpu_number': 0, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 56.0, + 'idle': 31.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1291,13 +1291,13 @@ Quicklook stats: 'softirq': 0.0, 'steal': 0.0, 'system': 9.0, - 'total': 44.0, + 'total': 69.0, 'user': 1.0}, {'cpu_number': 1, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 66.0, + 'idle': 40.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1306,13 +1306,13 @@ Quicklook stats: 'softirq': 0.0, 'steal': 0.0, 'system': 0.0, - 'total': 34.0, + 'total': 60.0, 'user': 0.0}, {'cpu_number': 2, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 63.0, + 'idle': 39.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1321,13 +1321,13 @@ Quicklook stats: 'softirq': 0.0, 'steal': 0.0, 'system': 1.0, - 'total': 37.0, + 'total': 61.0, 'user': 1.0}, {'cpu_number': 3, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 67.0, + 'idle': 42.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1336,13 +1336,43 @@ Quicklook stats: 'softirq': 0.0, 'steal': 0.0, 'system': 0.0, - 'total': 33.0, + 'total': 58.0, 'user': 0.0}, {'cpu_number': 4, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 45.0, + 'idle': 38.0, + 'interrupt': None, + 'iowait': 0.0, + 'irq': 0.0, + 'key': 'cpu_number', + 'nice': 0.0, + 'softirq': 0.0, + 'steal': 0.0, + 'system': 0.0, + 'total': 62.0, + 'user': 2.0}, + {'cpu_number': 5, + 'dpc': None, + 'guest': 0.0, + 'guest_nice': 0.0, + 'idle': 42.0, + 'interrupt': None, + 'iowait': 0.0, + 'irq': 0.0, + 'key': 'cpu_number', + 'nice': 0.0, + 'softirq': 0.0, + 'steal': 0.0, + 'system': 0.0, + 'total': 58.0, + 'user': 0.0}, + {'cpu_number': 6, + 'dpc': None, + 'guest': 0.0, + 'guest_nice': 0.0, + 'idle': 22.0, 'interrupt': None, 'iowait': 2.0, 'irq': 0.0, @@ -1350,44 +1380,14 @@ Quicklook stats: 'nice': 0.0, 'softirq': 0.0, 'steal': 0.0, - 'system': 11.0, - 'total': 55.0, - 'user': 8.0}, - {'cpu_number': 5, - 'dpc': None, - 'guest': 0.0, - 'guest_nice': 0.0, - 'idle': 49.0, - 'interrupt': None, - 'iowait': 0.0, - 'irq': 0.0, - 'key': 'cpu_number', - 'nice': 0.0, - 'softirq': 0.0, - 'steal': 0.0, - 'system': 11.0, - 'total': 51.0, - 'user': 4.0}, - {'cpu_number': 6, - 'dpc': None, - 'guest': 0.0, - 'guest_nice': 0.0, - 'idle': 60.0, - 'interrupt': None, - 'iowait': 0.0, - 'irq': 0.0, - 'key': 'cpu_number', - 'nice': 0.0, - 'softirq': 0.0, - 'steal': 0.0, - 'system': 1.0, - 'total': 40.0, - 'user': 4.0}, + 'system': 9.0, + 'total': 78.0, + 'user': 6.0}, {'cpu_number': 7, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 66.0, + 'idle': 33.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1395,14 +1395,14 @@ Quicklook stats: 'nice': 0.0, 'softirq': 0.0, 'steal': 0.0, - 'system': 0.0, - 'total': 34.0, - 'user': 1.0}, + 'system': 6.0, + 'total': 67.0, + 'user': 2.0}, {'cpu_number': 8, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 65.0, + 'idle': 41.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1411,13 +1411,13 @@ Quicklook stats: 'softirq': 0.0, 'steal': 0.0, 'system': 0.0, - 'total': 35.0, + 'total': 59.0, 'user': 1.0}, {'cpu_number': 9, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 66.0, + 'idle': 41.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1426,13 +1426,13 @@ Quicklook stats: 'softirq': 0.0, 'steal': 0.0, 'system': 0.0, - 'total': 34.0, + 'total': 59.0, 'user': 0.0}, {'cpu_number': 10, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 64.0, + 'idle': 41.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1440,14 +1440,14 @@ Quicklook stats: 'nice': 0.0, 'softirq': 0.0, 'steal': 0.0, - 'system': 1.0, - 'total': 36.0, + 'system': 0.0, + 'total': 59.0, 'user': 1.0}, {'cpu_number': 11, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 66.0, + 'idle': 42.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1456,13 +1456,28 @@ Quicklook stats: 'softirq': 0.0, 'steal': 0.0, 'system': 0.0, - 'total': 34.0, + 'total': 58.0, 'user': 0.0}, {'cpu_number': 12, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 65.0, + 'idle': 40.0, + 'interrupt': None, + 'iowait': 0.0, + 'irq': 0.0, + 'key': 'cpu_number', + 'nice': 0.0, + 'softirq': 0.0, + 'steal': 0.0, + 'system': 1.0, + 'total': 60.0, + 'user': 2.0}, + {'cpu_number': 13, + 'dpc': None, + 'guest': 0.0, + 'guest_nice': 0.0, + 'idle': 41.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1471,28 +1486,13 @@ Quicklook stats: 'softirq': 0.0, 'steal': 0.0, 'system': 0.0, - 'total': 35.0, + 'total': 59.0, 'user': 1.0}, - {'cpu_number': 13, - 'dpc': None, - 'guest': 0.0, - 'guest_nice': 0.0, - 'idle': 66.0, - 'interrupt': None, - 'iowait': 0.0, - 'irq': 0.0, - 'key': 'cpu_number', - 'nice': 0.0, - 'softirq': 0.0, - 'steal': 0.0, - 'system': 1.0, - 'total': 34.0, - 'user': 0.0}, {'cpu_number': 14, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 66.0, + 'idle': 41.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1501,13 +1501,13 @@ Quicklook stats: 'softirq': 0.0, 'steal': 0.0, 'system': 1.0, - 'total': 34.0, + 'total': 59.0, 'user': 0.0}, {'cpu_number': 15, 'dpc': None, 'guest': 0.0, 'guest_nice': 0.0, - 'idle': 65.0, + 'idle': 41.0, 'interrupt': None, 'iowait': 0.0, 'irq': 0.0, @@ -1516,9 +1516,9 @@ Quicklook stats: 'softirq': 0.0, 'steal': 0.0, 'system': 0.0, - 'total': 35.0, - 'user': 1.0}], - 'swap': 91.4} + 'total': 59.0, + 'user': 0.0}], + 'swap': 89.0} >>> gl.quicklook.keys() ['cpu_name', 'cpu_hz_current', 'cpu_hz', 'cpu', 'percpu', 'mem', 'swap', 'cpu_log_core', 'cpu_phys_core', 'load'] >>> gl.quicklook["cpu_name"] @@ -1568,13 +1568,13 @@ Memswap stats: >>> type(gl.memswap) >>> gl.memswap - {'free': 367751168, - 'percent': 91.4, - 'sin': 1177866240, - 'sout': 5795123200, - 'time_since_update': 0.5103552341461182, + {'free': 471519232, + 'percent': 89.0, + 'sin': 1292869632, + 'sout': 5862129664, + 'time_since_update': 0.3358321189880371, 'total': 4294963200, - 'used': 3927212032} + 'used': 3823443968} >>> gl.memswap.keys() ['total', 'used', 'free', 'percent', 'sin', 'sout', 'time_since_update'] >>> gl.memswap["total"] @@ -1609,10 +1609,10 @@ Use auto_unit() function to generate a human-readable string with the unit: .. code-block:: python >>> gl.mem["used"] - 10240561152 + 10288771072 >>> gl.auto_unit(gl.mem["used"]) - 9.54G + 9.58G Args: @@ -1668,7 +1668,7 @@ Use top_process() function to generate a list of top processes sorted by CPU or .. code-block:: python >>> gl.top_process() - [{'pid': 5046, 'cpu_percent': 19.0, 'memory_percent': 1.6104035124649207, 'cpu_times': {'user': 2416.46, 'system': 1318.57, 'children_user': 16.92, 'children_system': 6.47, 'iowait': 0.0}, 'gids': {'real': 1000, 'effective': 1000, 'saved': 1000}, 'io_counters': [300045312, 1191936, 300045312, 1191936, 1], 'name': 'gnome-shell', 'memory_info': {'rss': 264474624, 'vms': 5903314944, 'shared': 87982080, 'text': 8192, 'lib': 0, 'data': 529833984, 'dirty': 0}, 'status': 'S', 'nice': 0, 'num_threads': 40, 'key': 'pid', 'time_since_update': 0.5535836219787598, 'cmdline': ['/usr/bin/gnome-shell'], 'username': 'nicolargo'}, {'pid': 129, 'cpu_percent': 7.4, 'memory_percent': 0.0, 'cpu_times': {'user': 0.0, 'system': 65.91, 'children_user': 0.0, 'children_system': 0.0, 'iowait': 0.0}, 'gids': {'real': 0, 'effective': 0, 'saved': 0}, 'io_counters': [0, 0, 0, 0, 0], 'name': 'irq/9-acpi', 'memory_info': {'rss': 0, 'vms': 0, 'shared': 0, 'text': 0, 'lib': 0, 'data': 0, 'dirty': 0}, 'status': 'S', 'nice': 0, 'num_threads': 1, 'key': 'pid', 'time_since_update': 0.5535836219787598, 'cmdline': [], 'username': 'root'}, {'pid': 199912, 'cpu_percent': 3.8, 'memory_percent': 0.826713209553729, 'cpu_times': {'user': 104.04, 'system': 28.85, 'children_user': 0.06, 'children_system': 0.21, 'iowait': 0.0}, 'gids': {'real': 1000, 'effective': 1000, 'saved': 1000}, 'io_counters': [183361536, 24653824, 183361536, 24649728, 1], 'name': 'dropbox', 'memory_info': {'rss': 135770112, 'vms': 7175544832, 'shared': 49795072, 'text': 4096, 'lib': 0, 'data': 923680768, 'dirty': 0}, 'status': 'S', 'nice': 0, 'num_threads': 90, 'key': 'pid', 'time_since_update': 0.5535836219787598, 'cmdline': ['/home/nicolargo/.dropbox-dist/dropbox-lnx.x86_64-232.4.5988/dropbox'], 'username': 'nicolargo'}] + [{'pid': 129, 'gids': {'real': 0, 'effective': 0, 'saved': 0}, 'io_counters': [0, 0, 0, 0, 0], 'memory_percent': 0.0, 'name': 'irq/9-acpi', 'num_threads': 1, 'cpu_percent': 7.8, 'memory_info': {'rss': 0, 'vms': 0, 'shared': 0, 'text': 0, 'lib': 0, 'data': 0, 'dirty': 0}, 'nice': 0, 'status': 'S', 'cpu_times': {'user': 0.0, 'system': 70.99, 'children_user': 0.0, 'children_system': 0.0, 'iowait': 0.0}, 'key': 'pid', 'time_since_update': 0.4007854461669922, 'cmdline': [], 'username': 'root'}, {'pid': 22460, 'gids': {'real': 1000, 'effective': 1000, 'saved': 1000}, 'io_counters': [210056192, 417792, 210056192, 417792, 1], 'memory_percent': 6.115911940964092, 'name': 'code', 'num_threads': 25, 'cpu_percent': 5.4, 'memory_info': {'rss': 1004408832, 'vms': 1517491322880, 'shared': 125255680, 'text': 148705280, 'lib': 0, 'data': 2264506368, 'dirty': 0}, 'nice': 0, 'status': 'S', 'cpu_times': {'user': 8437.24, 'system': 563.13, 'children_user': 0.0, 'children_system': 0.0, 'iowait': 0.0}, 'key': 'pid', 'time_since_update': 0.4007854461669922, 'cmdline': ['/snap/code/206/usr/share/code/code', '--type=zygote', '--no-sandbox'], 'username': 'nicolargo'}, {'pid': 5046, 'gids': {'real': 1000, 'effective': 1000, 'saved': 1000}, 'io_counters': [301712384, 1843200, 301712384, 1843200, 1], 'memory_percent': 1.6135959368418742, 'name': 'gnome-shell', 'num_threads': 39, 'cpu_percent': 2.7, 'memory_info': {'rss': 264998912, 'vms': 5914505216, 'shared': 87699456, 'text': 8192, 'lib': 0, 'data': 530882560, 'dirty': 0}, 'nice': 0, 'status': 'S', 'cpu_times': {'user': 2561.04, 'system': 1392.06, 'children_user': 19.05, 'children_system': 6.86, 'iowait': 0.0}, 'key': 'pid', 'time_since_update': 0.4007854461669922, 'cmdline': ['/usr/bin/gnome-shell'], 'username': 'nicolargo'}] Args: diff --git a/docs/api/restful.rst b/docs/api/restful.rst index 75ec7379..c4322bea 100644 --- a/docs/api/restful.rst +++ b/docs/api/restful.rst @@ -160,7 +160,7 @@ Get plugin stats:: "refresh": 3.0, "regex": True, "result": None, - "timer": 0.5016987323760986}, + "timer": 0.40419769287109375}, {"count": 0, "countmax": 20.0, "countmin": None, @@ -169,7 +169,7 @@ Get plugin stats:: "refresh": 3.0, "regex": True, "result": None, - "timer": 0.5015974044799805}] + "timer": 0.4041402339935303}] Fields descriptions: @@ -197,7 +197,7 @@ Get a specific item when field matches the given value:: "refresh": 3.0, "regex": True, "result": None, - "timer": 0.5016987323760986}]} + "timer": 0.40419769287109375}]} GET cloud --------- @@ -286,19 +286,19 @@ Get plugin stats:: # curl http://localhost:61208/api/4/cpu {"cpucore": 16, - "ctx_switches": 305848485, + "ctx_switches": 320750950, "guest": 0.0, - "idle": 93.2, - "interrupts": 248231354, - "iowait": 0.2, + "idle": 93.5, + "interrupts": 260558806, + "iowait": 0.4, "irq": 0.0, "nice": 0.0, - "soft_interrupts": 100557273, + "soft_interrupts": 105603787, "steal": 0.0, "syscalls": 0, - "system": 2.8, - "total": 6.3, - "user": 3.7} + "system": 2.7, + "total": 5.5, + "user": 3.4} Fields descriptions: @@ -331,7 +331,7 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/4/cpu/total - {"total": 6.3} + {"total": 5.5} GET diskio ---------- @@ -341,14 +341,14 @@ Get plugin stats:: # curl http://localhost:61208/api/4/diskio [{"disk_name": "nvme0n1", "key": "disk_name", - "read_bytes": 18529010176, - "read_count": 959481, + "read_bytes": 18841506304, + "read_count": 995834, "read_latency": 0, - "read_time": 284217, - "write_bytes": 26236916736, - "write_count": 2366213, + "read_time": 299638, + "write_bytes": 27118728192, + "write_count": 2440100, "write_latency": 0, - "write_time": 2119813}, + "write_time": 2247286}, {"disk_name": "nvme0n1p1", "key": "disk_name", "read_bytes": 9021440, @@ -400,14 +400,14 @@ Get a specific item when field matches the given value:: # curl http://localhost:61208/api/4/diskio/disk_name/value/nvme0n1 {"nvme0n1": [{"disk_name": "nvme0n1", "key": "disk_name", - "read_bytes": 18529010176, - "read_count": 959481, + "read_bytes": 18841506304, + "read_count": 995834, "read_latency": 0, - "read_time": 284217, - "write_bytes": 26236916736, - "write_count": 2366213, + "read_time": 299638, + "write_bytes": 27118728192, + "write_count": 2440100, "write_latency": 0, - "write_time": 2119813}]} + "write_time": 2247286}]} GET folders ----------- @@ -434,14 +434,14 @@ Get plugin stats:: # curl http://localhost:61208/api/4/fs [{"device_name": "/dev/mapper/ubuntu--vg-ubuntu--lv", - "free": 716746493952, + "free": 716730499072, "fs_type": "ext4", "key": "mnt_point", "mnt_point": "/", "options": "rw,relatime", "percent": 24.8, "size": 1003736440832, - "used": 235927441408}, + "used": 235943436288}, {"device_name": "zsfpool", "free": 41680896, "fs_type": "zfs", @@ -472,14 +472,14 @@ Get a specific item when field matches the given value:: # curl http://localhost:61208/api/4/fs/mnt_point/value// {"/": [{"device_name": "/dev/mapper/ubuntu--vg-ubuntu--lv", - "free": 716746493952, + "free": 716730499072, "fs_type": "ext4", "key": "mnt_point", "mnt_point": "/", "options": "rw,relatime", "percent": 24.8, "size": 1003736440832, - "used": 235927441408}]} + "used": 235943436288}]} GET gpu ------- @@ -552,9 +552,9 @@ Get plugin stats:: # curl http://localhost:61208/api/4/load {"cpucore": 16, - "min1": 0.97900390625, - "min15": 1.57568359375, - "min5": 1.685546875} + "min1": 0.4052734375, + "min15": 0.83740234375, + "min5": 0.7177734375} Fields descriptions: @@ -566,7 +566,7 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/4/load/min1 - {"min1": 0.97900390625} + {"min1": 0.4052734375} GET mem ------- @@ -574,16 +574,16 @@ GET mem Get plugin stats:: # curl http://localhost:61208/api/4/mem - {"active": 7844958208, - "available": 6212390912, - "buffers": 272408576, - "cached": 5124861952, - "free": 6212390912, - "inactive": 6526513152, - "percent": 62.2, - "shared": 742211584, + {"active": 8269934592, + "available": 6152994816, + "buffers": 313081856, + "cached": 4285882368, + "free": 6152994816, + "inactive": 5272625152, + "percent": 62.5, + "shared": 749125632, "total": 16422879232, - "used": 10210488320} + "used": 10269884416} Fields descriptions: @@ -610,13 +610,13 @@ GET memswap Get plugin stats:: # curl http://localhost:61208/api/4/memswap - {"free": 367816704, - "percent": 91.4, - "sin": 1177907200, - "sout": 5795123200, + {"free": 471543808, + "percent": 89.0, + "sin": 1292894208, + "sout": 5862129664, "time_since_update": 1, "total": 4294963200, - "used": 3927146496} + "used": 3823419392} Fields descriptions: @@ -641,18 +641,18 @@ Get plugin stats:: # curl http://localhost:61208/api/4/network [{"alias": None, "bytes_all": 0, - "bytes_all_gauge": 3100599416, + "bytes_all_gauge": 3136484513, "bytes_all_rate_per_sec": 0, "bytes_recv": 0, - "bytes_recv_gauge": 2247533379, + "bytes_recv_gauge": 2268639661, "bytes_recv_rate_per_sec": 0, "bytes_sent": 0, - "bytes_sent_gauge": 853066037, + "bytes_sent_gauge": 867844852, "bytes_sent_rate_per_sec": 0, "interface_name": "wlp0s20f3", "key": "interface_name", "speed": 0, - "time_since_update": 0.5043454170227051}] + "time_since_update": 0.4058811664581299}] Fields descriptions: @@ -681,18 +681,18 @@ Get a specific item when field matches the given value:: # curl http://localhost:61208/api/4/network/interface_name/value/wlp0s20f3 {"wlp0s20f3": [{"alias": None, "bytes_all": 0, - "bytes_all_gauge": 3100599416, + "bytes_all_gauge": 3136484513, "bytes_all_rate_per_sec": 0, "bytes_recv": 0, - "bytes_recv_gauge": 2247533379, + "bytes_recv_gauge": 2268639661, "bytes_recv_rate_per_sec": 0, "bytes_sent": 0, - "bytes_sent_gauge": 853066037, + "bytes_sent_gauge": 867844852, "bytes_sent_rate_per_sec": 0, "interface_name": "wlp0s20f3", "key": "interface_name", "speed": 0, - "time_since_update": 0.5043454170227051}]} + "time_since_update": 0.4058811664581299}]} GET now ------- @@ -700,7 +700,7 @@ GET now Get plugin stats:: # curl http://localhost:61208/api/4/now - {"custom": "2025-09-21 09:59:33 CEST", "iso": "2025-09-21T09:59:33+02:00"} + {"custom": "2025-09-21 15:08:57 CEST", "iso": "2025-09-21T15:08:57+02:00"} Fields descriptions: @@ -710,7 +710,7 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/4/now/iso - {"iso": "2025-09-21T09:59:33+02:00"} + {"iso": "2025-09-21T15:08:57+02:00"} GET percpu ---------- @@ -722,7 +722,7 @@ Get plugin stats:: "dpc": None, "guest": 0.0, "guest_nice": 0.0, - "idle": 38.0, + "idle": 29.0, "interrupt": None, "iowait": 0.0, "irq": 0.0, @@ -730,14 +730,14 @@ Get plugin stats:: "nice": 0.0, "softirq": 0.0, "steal": 0.0, - "system": 10.0, - "total": 62.0, + "system": 6.0, + "total": 71.0, "user": 0.0}, {"cpu_number": 1, "dpc": None, "guest": 0.0, "guest_nice": 0.0, - "idle": 48.0, + "idle": 40.0, "interrupt": None, "iowait": 0.0, "irq": 0.0, @@ -746,7 +746,7 @@ Get plugin stats:: "softirq": 0.0, "steal": 0.0, "system": 0.0, - "total": 52.0, + "total": 60.0, "user": 0.0}] Fields descriptions: @@ -796,7 +796,7 @@ GET processcount Get plugin stats:: # curl http://localhost:61208/api/4/processcount - {"pid_max": 0, "running": 1, "sleeping": 431, "thread": 2461, "total": 569} + {"pid_max": 0, "running": 1, "sleeping": 423, "thread": 2221, "total": 555} Fields descriptions: @@ -809,7 +809,7 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/4/processcount/total - {"total": 569} + {"total": 555} GET processlist --------------- @@ -841,24 +841,24 @@ Get plugin stats:: "--disable-features=CalculateNativeWinOcclusion,FontationsLinuxSystemFonts,ScreenAIOCREnabled,SpareRendererForSitePerProcess", "--variations-seed-version"], "cpu_percent": 0.0, - "cpu_times": {"children_system": 1117.86, - "children_user": 1369.94, + "cpu_times": {"children_system": 1171.85, + "children_user": 1402.71, "iowait": 0.0, - "system": 1272.38, - "user": 4766.65}, + "system": 1346.12, + "user": 5083.59}, "gids": {"effective": 1000, "real": 1000, "saved": 1000}, - "io_counters": [2014217216, - 1436655616, + "io_counters": [2045707264, + 1520226304, 0, 0, 0, - 111648768, + 119644160, 688128, 0, 0, 0, - 209947648, - 413696, + 210056192, + 417792, 0, 0, 0, @@ -867,37 +867,37 @@ Get plugin stats:: 0, 0, 0, - 3401198592, - 1180692480, + 3401456640, + 1192022016, 0, 0, 0, - 93640704, + 350585856, + 2969100288, 0, 0, 0, + 93661184, + 0, + 0, + 0, + 0, + 12365824, + 8192, + 0, + 0, 0, 27540480, 1413120, 0, 0, 0, - 346797056, - 2969100288, - 0, - 0, - 0, - 7426048, - 8192, - 0, - 0, - 0, - 32229376, + 32574464, 0, 0, 0, 0, - 75408384, + 82027520, 0, 0, 0, @@ -912,37 +912,37 @@ Get plugin stats:: 0, 0, 0, - 23600128, - 23175168, + 23604224, + 23769088, 0, 0, 0, - 6934528, + 7024640, 0, 0, 0, 0, - 6627328, + 14196736, 0, 0, 0, 0, - 1983488, + 6631424, 0, 0, 0, 0, - 14069760, + 2044928, 0, 0, 0, 0, - 1885184, + 2634752, 0, 0, 0, 0, - 2438144, + 2536448, 0, 0, 0, @@ -957,7 +957,7 @@ Get plugin stats:: 0, 0, 0, - 2541568, + 2545664, 2846720, 0, 0, @@ -973,14 +973,14 @@ Get plugin stats:: 0, 0], "key": "pid", - "memory_info": {"data": 4761477120, + "memory_info": {"data": 4895604736, "dirty": 0, "lib": 0, - "rss": 2158960640, - "shared": 79568896, + "rss": 2315325440, + "shared": 80236544, "text": 148705280, "vms": 1526338510848}, - "memory_percent": 13.14605441287824, + "memory_percent": 14.098170042489173, "name": "code", "nice": 0, "num_threads": 58, @@ -994,22 +994,22 @@ Get plugin stats:: "--node-ipc", "--clientProcessId=110899"], "cpu_percent": 0.0, - "cpu_times": {"children_system": 0.52, - "children_user": 2.02, + "cpu_times": {"children_system": 0.57, + "children_user": 2.11, "iowait": 0.0, - "system": 53.93, - "user": 1116.32}, + "system": 55.6, + "user": 1147.7}, "gids": {"effective": 1000, "real": 1000, "saved": 1000}, - "io_counters": [111648768, 688128, 0, 0, 0], + "io_counters": [119644160, 688128, 0, 0, 0], "key": "pid", - "memory_info": {"data": 2290892800, + "memory_info": {"data": 2404552704, "dirty": 0, "lib": 0, - "rss": 1164738560, - "shared": 32759808, + "rss": 1274724352, + "shared": 33509376, "text": 148705280, "vms": 1501606547456}, - "memory_percent": 7.092170279925735, + "memory_percent": 7.76188105625351, "name": "code", "nice": 0, "num_threads": 16, @@ -1045,19 +1045,19 @@ Get plugin stats:: 22460, 111133, 22312, - 112323, - 344651, 22523, + 112323, 111268, + 344651, 22429, 22524, 240741, 240742, 22410, 111284, + 22786, 111848, 111192, - 22786, 136828, 111283, 112290, @@ -1067,22 +1067,22 @@ Get plugin stats:: 22314], "cmdline": ["code"], "cpu_percent": 0, - "cpu_times": {"children_system": 1685.32, - "children_user": 3833.36, - "system": 2501.81, - "user": 17066.89}, - "io_counters": [2014217216, - 1436655616, + "cpu_times": {"children_system": 1739.36, + "children_user": 3866.2200000000003, + "system": 2612.130000000001, + "user": 17807.919999999995}, + "io_counters": [2045707264, + 1520226304, 0, 0, 0, - 111648768, + 119644160, 688128, 0, 0, 0, - 209947648, - 413696, + 210056192, + 417792, 0, 0, 0, @@ -1091,37 +1091,37 @@ Get plugin stats:: 0, 0, 0, - 3401198592, - 1180692480, + 3401456640, + 1192022016, 0, 0, 0, - 93640704, + 350585856, + 2969100288, 0, 0, 0, + 93661184, + 0, + 0, + 0, + 0, + 12365824, + 8192, + 0, + 0, 0, 27540480, 1413120, 0, 0, 0, - 346797056, - 2969100288, - 0, - 0, - 0, - 7426048, - 8192, - 0, - 0, - 0, - 32229376, + 32574464, 0, 0, 0, 0, - 75408384, + 82027520, 0, 0, 0, @@ -1136,37 +1136,37 @@ Get plugin stats:: 0, 0, 0, - 23600128, - 23175168, + 23604224, + 23769088, 0, 0, 0, - 6934528, + 7024640, 0, 0, 0, 0, - 6627328, + 14196736, 0, 0, 0, 0, - 1983488, + 6631424, 0, 0, 0, 0, - 14069760, + 2044928, 0, 0, 0, 0, - 1885184, + 2634752, 0, 0, 0, 0, - 2438144, + 2536448, 0, 0, 0, @@ -1181,7 +1181,7 @@ Get plugin stats:: 0, 0, 0, - 2541568, + 2545664, 2846720, 0, 0, @@ -1196,16 +1196,16 @@ Get plugin stats:: 0, 0, 0], - "memory_info": {"data": 23349264384, - "rss": 5558693888, - "shared": 809234432, + "memory_info": {"data": 23625658368, + "rss": 5878284288, + "shared": 807088128, "text": 3717632000, - "vms": 31613675048960}, - "memory_percent": 33.847255462786805, + "vms": 31611896705024}, + "memory_percent": 35.79326258787894, "name": "code", "nice": 0, "nprocs": 25, - "num_threads": 368, + "num_threads": 367, "pid": "_", "status": "S", "time_since_update": 1, @@ -1216,17 +1216,17 @@ Get plugin stats:: "cpu_times": {"children_system": 0.0, "children_user": 0.0, "iowait": 0.0, - "system": 96.4, - "user": 599.66}, - "io_counters": [40433664, 0, 0, 0, 0], - "memory_info": {"data": 920674304, + "system": 101.32, + "user": 630.68}, + "io_counters": [41474048, 0, 0, 0, 0], + "memory_info": {"data": 927956992, "dirty": 0, "lib": 0, - "rss": 649555968, - "shared": 67686400, + "rss": 656478208, + "shared": 73568256, "text": 823296, - "vms": 25131753472}, - "memory_percent": 3.9551893357063688, + "vms": 25129656320}, + "memory_percent": 3.9973393138083324, "name": "WebExtensions", "nice": 0, "nprocs": 1, @@ -1266,15 +1266,60 @@ GET quicklook Get plugin stats:: # curl http://localhost:61208/api/4/quicklook - {"cpu": 6.3, + {"cpu": 5.5, "cpu_hz": 4475000000.0, - "cpu_hz_current": 775303750.0, + "cpu_hz_current": 1137631250.0, "cpu_log_core": 16, "cpu_name": "13th Gen Intel(R) Core(TM) i7-13620H", "cpu_phys_core": 10, - "load": 9.8, - "mem": 62.2, + "load": 5.2, + "mem": 62.5, "percpu": [{"cpu_number": 0, + "dpc": None, + "guest": 0.0, + "guest_nice": 0.0, + "idle": 29.0, + "interrupt": None, + "iowait": 0.0, + "irq": 0.0, + "key": "cpu_number", + "nice": 0.0, + "softirq": 0.0, + "steal": 0.0, + "system": 6.0, + "total": 71.0, + "user": 0.0}, + {"cpu_number": 1, + "dpc": None, + "guest": 0.0, + "guest_nice": 0.0, + "idle": 40.0, + "interrupt": None, + "iowait": 0.0, + "irq": 0.0, + "key": "cpu_number", + "nice": 0.0, + "softirq": 0.0, + "steal": 0.0, + "system": 0.0, + "total": 60.0, + "user": 0.0}, + {"cpu_number": 2, + "dpc": None, + "guest": 0.0, + "guest_nice": 0.0, + "idle": 39.0, + "interrupt": None, + "iowait": 0.0, + "irq": 0.0, + "key": "cpu_number", + "nice": 0.0, + "softirq": 0.0, + "steal": 0.0, + "system": 0.0, + "total": 61.0, + "user": 0.0}, + {"cpu_number": 3, "dpc": None, "guest": 0.0, "guest_nice": 0.0, @@ -1286,104 +1331,14 @@ Get plugin stats:: "nice": 0.0, "softirq": 0.0, "steal": 0.0, - "system": 10.0, + "system": 1.0, "total": 62.0, "user": 0.0}, - {"cpu_number": 1, - "dpc": None, - "guest": 0.0, - "guest_nice": 0.0, - "idle": 48.0, - "interrupt": None, - "iowait": 0.0, - "irq": 0.0, - "key": "cpu_number", - "nice": 0.0, - "softirq": 0.0, - "steal": 0.0, - "system": 0.0, - "total": 52.0, - "user": 0.0}, - {"cpu_number": 2, - "dpc": None, - "guest": 0.0, - "guest_nice": 0.0, - "idle": 48.0, - "interrupt": None, - "iowait": 0.0, - "irq": 0.0, - "key": "cpu_number", - "nice": 0.0, - "softirq": 0.0, - "steal": 0.0, - "system": 0.0, - "total": 52.0, - "user": 0.0}, - {"cpu_number": 3, - "dpc": None, - "guest": 0.0, - "guest_nice": 0.0, - "idle": 49.0, - "interrupt": None, - "iowait": 0.0, - "irq": 0.0, - "key": "cpu_number", - "nice": 0.0, - "softirq": 0.0, - "steal": 0.0, - "system": 0.0, - "total": 51.0, - "user": 0.0}, {"cpu_number": 4, "dpc": None, "guest": 0.0, "guest_nice": 0.0, - "idle": 29.0, - "interrupt": None, - "iowait": 2.0, - "irq": 0.0, - "key": "cpu_number", - "nice": 0.0, - "softirq": 0.0, - "steal": 0.0, - "system": 13.0, - "total": 71.0, - "user": 2.0}, - {"cpu_number": 5, - "dpc": None, - "guest": 0.0, - "guest_nice": 0.0, - "idle": 44.0, - "interrupt": None, - "iowait": 0.0, - "irq": 0.0, - "key": "cpu_number", - "nice": 0.0, - "softirq": 0.0, - "steal": 0.0, - "system": 3.0, - "total": 56.0, - "user": 1.0}, - {"cpu_number": 6, - "dpc": None, - "guest": 0.0, - "guest_nice": 0.0, - "idle": 48.0, - "interrupt": None, - "iowait": 0.0, - "irq": 0.0, - "key": "cpu_number", - "nice": 0.0, - "softirq": 0.0, - "steal": 0.0, - "system": 1.0, - "total": 52.0, - "user": 1.0}, - {"cpu_number": 7, - "dpc": None, - "guest": 0.0, - "guest_nice": 0.0, - "idle": 36.0, + "idle": 35.0, "interrupt": None, "iowait": 0.0, "irq": 0.0, @@ -1392,28 +1347,73 @@ Get plugin stats:: "softirq": 0.0, "steal": 0.0, "system": 4.0, - "total": 64.0, - "user": 9.0}, + "total": 65.0, + "user": 0.0}, + {"cpu_number": 5, + "dpc": None, + "guest": 0.0, + "guest_nice": 0.0, + "idle": 40.0, + "interrupt": None, + "iowait": 0.0, + "irq": 0.0, + "key": "cpu_number", + "nice": 0.0, + "softirq": 0.0, + "steal": 0.0, + "system": 1.0, + "total": 60.0, + "user": 0.0}, + {"cpu_number": 6, + "dpc": None, + "guest": 0.0, + "guest_nice": 0.0, + "idle": 30.0, + "interrupt": None, + "iowait": 2.0, + "irq": 0.0, + "key": "cpu_number", + "nice": 0.0, + "softirq": 0.0, + "steal": 0.0, + "system": 6.0, + "total": 70.0, + "user": 2.0}, + {"cpu_number": 7, + "dpc": None, + "guest": 0.0, + "guest_nice": 0.0, + "idle": 29.0, + "interrupt": None, + "iowait": 0.0, + "irq": 0.0, + "key": "cpu_number", + "nice": 0.0, + "softirq": 0.0, + "steal": 0.0, + "system": 5.0, + "total": 71.0, + "user": 5.0}, {"cpu_number": 8, "dpc": None, "guest": 0.0, "guest_nice": 0.0, - "idle": 48.0, + "idle": 38.0, "interrupt": None, - "iowait": 0.0, + "iowait": 1.0, "irq": 0.0, "key": "cpu_number", "nice": 0.0, "softirq": 0.0, "steal": 0.0, - "system": 0.0, - "total": 52.0, - "user": 0.0}, + "system": 1.0, + "total": 62.0, + "user": 1.0}, {"cpu_number": 9, "dpc": None, "guest": 0.0, "guest_nice": 0.0, - "idle": 49.0, + "idle": 40.0, "interrupt": None, "iowait": 0.0, "irq": 0.0, @@ -1422,13 +1422,13 @@ Get plugin stats:: "softirq": 0.0, "steal": 0.0, "system": 0.0, - "total": 51.0, + "total": 60.0, "user": 0.0}, {"cpu_number": 10, "dpc": None, "guest": 0.0, "guest_nice": 0.0, - "idle": 48.0, + "idle": 39.0, "interrupt": None, "iowait": 0.0, "irq": 0.0, @@ -1437,13 +1437,13 @@ Get plugin stats:: "softirq": 0.0, "steal": 0.0, "system": 0.0, - "total": 52.0, + "total": 61.0, "user": 0.0}, {"cpu_number": 11, "dpc": None, "guest": 0.0, "guest_nice": 0.0, - "idle": 49.0, + "idle": 40.0, "interrupt": None, "iowait": 0.0, "irq": 0.0, @@ -1452,58 +1452,13 @@ Get plugin stats:: "softirq": 0.0, "steal": 0.0, "system": 0.0, - "total": 51.0, + "total": 60.0, "user": 0.0}, {"cpu_number": 12, "dpc": None, "guest": 0.0, "guest_nice": 0.0, - "idle": 48.0, - "interrupt": None, - "iowait": 0.0, - "irq": 0.0, - "key": "cpu_number", - "nice": 0.0, - "softirq": 0.0, - "steal": 0.0, - "system": 1.0, - "total": 52.0, - "user": 1.0}, - {"cpu_number": 13, - "dpc": None, - "guest": 0.0, - "guest_nice": 0.0, - "idle": 48.0, - "interrupt": None, - "iowait": 0.0, - "irq": 0.0, - "key": "cpu_number", - "nice": 0.0, - "softirq": 0.0, - "steal": 0.0, - "system": 1.0, - "total": 52.0, - "user": 1.0}, - {"cpu_number": 14, - "dpc": None, - "guest": 0.0, - "guest_nice": 0.0, - "idle": 49.0, - "interrupt": None, - "iowait": 0.0, - "irq": 0.0, - "key": "cpu_number", - "nice": 0.0, - "softirq": 0.0, - "steal": 0.0, - "system": 1.0, - "total": 51.0, - "user": 0.0}, - {"cpu_number": 15, - "dpc": None, - "guest": 0.0, - "guest_nice": 0.0, - "idle": 48.0, + "idle": 38.0, "interrupt": None, "iowait": 0.0, "irq": 0.0, @@ -1512,9 +1467,54 @@ Get plugin stats:: "softirq": 0.0, "steal": 0.0, "system": 0.0, - "total": 52.0, + "total": 62.0, + "user": 1.0}, + {"cpu_number": 13, + "dpc": None, + "guest": 0.0, + "guest_nice": 0.0, + "idle": 38.0, + "interrupt": None, + "iowait": 0.0, + "irq": 0.0, + "key": "cpu_number", + "nice": 0.0, + "softirq": 0.0, + "steal": 0.0, + "system": 0.0, + "total": 62.0, + "user": 1.0}, + {"cpu_number": 14, + "dpc": None, + "guest": 0.0, + "guest_nice": 0.0, + "idle": 39.0, + "interrupt": None, + "iowait": 0.0, + "irq": 0.0, + "key": "cpu_number", + "nice": 0.0, + "softirq": 0.0, + "steal": 0.0, + "system": 0.0, + "total": 61.0, + "user": 0.0}, + {"cpu_number": 15, + "dpc": None, + "guest": 0.0, + "guest_nice": 0.0, + "idle": 39.0, + "interrupt": None, + "iowait": 0.0, + "irq": 0.0, + "key": "cpu_number", + "nice": 0.0, + "softirq": 0.0, + "steal": 0.0, + "system": 0.0, + "total": 61.0, "user": 0.0}], - "swap": 91.4} + "swap": 89.0} Fields descriptions: @@ -1552,7 +1552,7 @@ Get plugin stats:: "label": "Ambient", "type": "temperature_core", "unit": "C", - "value": 38, + "value": 39, "warning": 0}, {"critical": None, "key": "label", @@ -1623,7 +1623,7 @@ Get a specific item when field matches the given value:: "label": "Ambient", "type": "temperature_core", "unit": "C", - "value": 38, + "value": 39, "warning": 0}]} GET smart @@ -1667,7 +1667,7 @@ GET uptime Get plugin stats:: # curl http://localhost:61208/api/4/uptime - "8 days, 0:39:02" + "8 days, 5:48:25" GET version ----------- @@ -1712,8 +1712,8 @@ Get plugin stats:: # curl http://localhost:61208/api/4/wifi [{"key": "ssid", - "quality_level": -60.0, - "quality_link": 50.0, + "quality_level": -64.0, + "quality_link": 46.0, "ssid": "wlp0s20f3"}] Get a specific field:: @@ -1725,8 +1725,8 @@ Get a specific item when field matches the given value:: # curl http://localhost:61208/api/4/wifi/ssid/value/wlp0s20f3 {"wlp0s20f3": [{"key": "ssid", - "quality_level": -60.0, - "quality_link": 50.0, + "quality_level": -64.0, + "quality_link": 46.0, "ssid": "wlp0s20f3"}]} GET all stats @@ -1790,34 +1790,34 @@ GET stats history History of a plugin:: # curl http://localhost:61208/api/4/cpu/history - {"system": [["2025-09-21T07:59:35.021130+00:00", 2.8], - ["2025-09-21T07:59:36.122241+00:00", 1.0], - ["2025-09-21T07:59:37.152781+00:00", 1.0]], - "user": [["2025-09-21T07:59:35.021127+00:00", 3.7], - ["2025-09-21T07:59:36.122238+00:00", 0.9], - ["2025-09-21T07:59:37.152778+00:00", 0.9]]} + {"system": [["2025-09-21T13:08:58.201070+00:00", 2.7], + ["2025-09-21T13:08:59.267325+00:00", 0.8], + ["2025-09-21T13:09:00.290829+00:00", 0.8]], + "user": [["2025-09-21T13:08:58.201068+00:00", 3.4], + ["2025-09-21T13:08:59.267323+00:00", 0.9], + ["2025-09-21T13:09:00.290826+00:00", 0.9]]} Limit history to last 2 values:: # curl http://localhost:61208/api/4/cpu/history/2 - {"system": [["2025-09-21T07:59:36.122241+00:00", 1.0], - ["2025-09-21T07:59:37.152781+00:00", 1.0]], - "user": [["2025-09-21T07:59:36.122238+00:00", 0.9], - ["2025-09-21T07:59:37.152778+00:00", 0.9]]} + {"system": [["2025-09-21T13:08:59.267325+00:00", 0.8], + ["2025-09-21T13:09:00.290829+00:00", 0.8]], + "user": [["2025-09-21T13:08:59.267323+00:00", 0.9], + ["2025-09-21T13:09:00.290826+00:00", 0.9]]} History for a specific field:: # curl http://localhost:61208/api/4/cpu/system/history - {"system": [["2025-09-21T07:59:33.802374+00:00", 2.8], - ["2025-09-21T07:59:35.021130+00:00", 2.8], - ["2025-09-21T07:59:36.122241+00:00", 1.0], - ["2025-09-21T07:59:37.152781+00:00", 1.0]]} + {"system": [["2025-09-21T13:08:57.041994+00:00", 2.7], + ["2025-09-21T13:08:58.201070+00:00", 2.7], + ["2025-09-21T13:08:59.267325+00:00", 0.8], + ["2025-09-21T13:09:00.290829+00:00", 0.8]]} Limit history for a specific field to last 2 values:: # curl http://localhost:61208/api/4/cpu/system/history - {"system": [["2025-09-21T07:59:36.122241+00:00", 1.0], - ["2025-09-21T07:59:37.152781+00:00", 1.0]]} + {"system": [["2025-09-21T13:08:59.267325+00:00", 0.8], + ["2025-09-21T13:09:00.290829+00:00", 0.8]]} GET limits (used for thresholds) -------------------------------- diff --git a/docs/gw/duckdb.rst b/docs/gw/duckdb.rst index 33f7fd94..28aa01f1 100644 --- a/docs/gw/duckdb.rst +++ b/docs/gw/duckdb.rst @@ -14,11 +14,10 @@ following: [duckdb] # database defines where data are stored, can be one of: - # :memory: (see https://duckdb.org/docs/stable/clients/python/dbapi#in-memory-connection) - # :memory:glances (see https://duckdb.org/docs/stable/clients/python/dbapi#in-memory-connection) # /path/to/glances.db (see https://duckdb.org/docs/stable/clients/python/dbapi#file-based-connection) + # :memory:glances (see https://duckdb.org/docs/stable/clients/python/dbapi#in-memory-connection) # Or anyone else supported by the API (see https://duckdb.org/docs/stable/clients/python/dbapi) - database=:memory: + database=/tmp/glances.db and run Glances with: @@ -29,10 +28,83 @@ and run Glances with: Data model ----------- +The data model is composed of one table per Glances plugin. + +Example: + +.. code-block:: python + + >>> import duckdb + >>> db = duckdb.connect(database='/tmp/glances.db', read_only=True) + + >>> db.sql("SELECT * from cpu") + ┌─────────────────────┬─────────────────┬────────┬────────┬────────┬───┬────────────────────┬─────────────────────┬──────────────────────┬──────────────────────┬──────────────────────┐ + │ time │ hostname_id │ total │ user │ nice │ … │ cpu_iowait_warning │ cpu_iowait_critical │ cpu_ctx_switches_c… │ cpu_ctx_switches_w… │ cpu_ctx_switches_c… │ + │ time with time zone │ varchar │ double │ double │ double │ │ double │ double │ double │ double │ double │ + ├─────────────────────┼─────────────────┼────────┼────────┼────────┼───┼────────────────────┼─────────────────────┼──────────────────────┼──────────────────────┼──────────────────────┤ + │ 11:50:25+00 │ nicolargo-xps15 │ 8.0 │ 5.6 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:50:27+00 │ nicolargo-xps15 │ 4.3 │ 3.2 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:50:29+00 │ nicolargo-xps15 │ 4.3 │ 3.2 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:50:31+00 │ nicolargo-xps15 │ 14.9 │ 15.7 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:50:33+00 │ nicolargo-xps15 │ 14.9 │ 15.7 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:50:35+00 │ nicolargo-xps15 │ 8.2 │ 7.8 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:50:37+00 │ nicolargo-xps15 │ 8.2 │ 7.8 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:50:39+00 │ nicolargo-xps15 │ 12.7 │ 10.3 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:50:41+00 │ nicolargo-xps15 │ 12.7 │ 10.3 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:50:43+00 │ nicolargo-xps15 │ 12.2 │ 10.3 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ + │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ + │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ + │ 11:51:29+00 │ nicolargo-xps15 │ 10.1 │ 7.4 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:51:32+00 │ nicolargo-xps15 │ 10.1 │ 7.4 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:51:34+00 │ nicolargo-xps15 │ 6.6 │ 4.9 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:51:36+00 │ nicolargo-xps15 │ 6.6 │ 4.9 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:51:38+00 │ nicolargo-xps15 │ 9.9 │ 7.5 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:51:40+00 │ nicolargo-xps15 │ 9.9 │ 7.5 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:51:42+00 │ nicolargo-xps15 │ 4.0 │ 3.1 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:51:44+00 │ nicolargo-xps15 │ 4.0 │ 3.1 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:51:46+00 │ nicolargo-xps15 │ 11.1 │ 8.8 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + │ 11:51:48+00 │ nicolargo-xps15 │ 11.1 │ 8.8 │ 0.0 │ … │ 5.625 │ 6.25 │ 640000.0 │ 720000.0 │ 800000.0 │ + ├─────────────────────┴─────────────────┴────────┴────────┴────────┴───┴────────────────────┴─────────────────────┴──────────────────────┴──────────────────────┴──────────────────────┤ + │ 41 rows (20 shown) 47 columns (10 shown) │ + └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + + >>> db.sql("SELECT * from cpu").fetchall()[0] + (datetime.time(11, 50, 25, tzinfo=datetime.timezone.utc), 'nicolargo-xps15', 8.0, 5.6, 0.0, 2.3, 91.9, 0.1, 0.0, 0.0, 0.0, 0, 0, 0, 0, 16, 2.4103684425354004, 90724823, 0, 63323797, 0, 30704572, 0, 0, 0, 1200.0, 65.0, 75.0, 85.0, True, 50.0, 70.0, 90.0, True, 50.0, 70.0, 90.0, True, 50.0, 70.0, 90.0, 5.0, 5.625, 6.25, 640000.0, 720000.0, 800000.0) -Current limitations -------------------- + >>> db.sql("SELECT * from network") + ┌─────────────────────┬─────────────────┬────────────────┬────────────┬────────────┬───┬─────────────────────┬────────────────┬────────────────────┬────────────────────┬───────────────────┐ + │ time │ hostname_id │ key_id │ bytes_sent │ bytes_recv │ … │ network_tx_critical │ network_hide │ network_hide_no_up │ network_hide_no_ip │ network_hide_zero │ + │ time with time zone │ varchar │ varchar │ int64 │ int64 │ │ double │ varchar │ boolean │ boolean │ boolean │ + ├─────────────────────┼─────────────────┼────────────────┼────────────┼────────────┼───┼─────────────────────┼────────────────┼────────────────────┼────────────────────┼───────────────────┤ + │ 11:50:25+00 │ nicolargo-xps15 │ interface_name │ 407761 │ 32730 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:50:27+00 │ nicolargo-xps15 │ interface_name │ 2877 │ 4857 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:50:29+00 │ nicolargo-xps15 │ interface_name │ 44504 │ 32555 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:50:31+00 │ nicolargo-xps15 │ interface_name │ 1092285 │ 48600 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:50:33+00 │ nicolargo-xps15 │ interface_name │ 150119 │ 43805 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:50:35+00 │ nicolargo-xps15 │ interface_name │ 34424 │ 14825 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:50:37+00 │ nicolargo-xps15 │ interface_name │ 19382 │ 33614 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:50:39+00 │ nicolargo-xps15 │ interface_name │ 53060 │ 39780 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:50:41+00 │ nicolargo-xps15 │ interface_name │ 371914 │ 78626 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:50:43+00 │ nicolargo-xps15 │ interface_name │ 82356 │ 60612 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ + │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ + │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ + │ 11:51:29+00 │ nicolargo-xps15 │ interface_name │ 3766 │ 9977 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:51:32+00 │ nicolargo-xps15 │ interface_name │ 188036 │ 18668 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:51:34+00 │ nicolargo-xps15 │ interface_name │ 543 │ 2451 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:51:36+00 │ nicolargo-xps15 │ interface_name │ 8247 │ 7275 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:51:38+00 │ nicolargo-xps15 │ interface_name │ 7252 │ 986 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:51:40+00 │ nicolargo-xps15 │ interface_name │ 172 │ 132 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:51:42+00 │ nicolargo-xps15 │ interface_name │ 8080 │ 6640 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:51:44+00 │ nicolargo-xps15 │ interface_name │ 19660 │ 17830 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:51:46+00 │ nicolargo-xps15 │ interface_name │ 1007030 │ 84170 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + │ 11:51:48+00 │ nicolargo-xps15 │ interface_name │ 128947 │ 18087 │ … │ 90.0 │ [docker.*, lo] │ true │ true │ true │ + ├─────────────────────┴─────────────────┴────────────────┴────────────┴────────────┴───┴─────────────────────┴────────────────┴────────────────────┴────────────────────┴───────────────────┤ + │ 41 rows (20 shown) 28 columns (10 shown) │ + └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + .. _duckdb: https://duckdb.org/ diff --git a/glances/exports/glances_duckdb/__init__.py b/glances/exports/glances_duckdb/__init__.py index 2507df64..4ec061f0 100644 --- a/glances/exports/glances_duckdb/__init__.py +++ b/glances/exports/glances_duckdb/__init__.py @@ -76,6 +76,9 @@ class Export(GlancesExport): return db def normalize(self, value): + # Nothing to do... + if isinstance(value, list) and len(value) == 1 and value[0] in ['True', 'False']: + return bool(value[0]) return value def update(self, stats): @@ -91,6 +94,7 @@ class Export(GlancesExport): # Loop over plugins to export for plugin in self.last_exported_list(): + # Remove some fields if isinstance(all_stats[plugin], dict): all_stats[plugin].update(all_limits[plugin]) # Remove the _disable field @@ -111,25 +115,26 @@ class Export(GlancesExport): creation_list.append('time TIMETZ') creation_list.append('hostname_id VARCHAR') for key, value in plugin_stats.items(): - creation_list.append(f"{key} {convert_types[type(value).__name__]}") + creation_list.append(f"{key} {convert_types[type(self.normalize(value)).__name__]}") # Create the list of values to insert - values_list.append(self.normalize(datetime.now().replace(microsecond=0))) - values_list.append(f"{self.hostname}") - values_list.extend([self.normalize(value) for value in plugin_stats.values()]) - values_list = [values_list] + item_list = [] + item_list.append(self.normalize(datetime.now().replace(microsecond=0))) + item_list.append(self.normalize(f"{self.hostname}")) + item_list.extend([self.normalize(value) for value in plugin_stats.values()]) + values_list = [item_list] elif isinstance(plugin_stats, list) and len(plugin_stats) > 0 and 'key' in plugin_stats[0]: # Create the list to create the table creation_list.append('time TIMETZ') creation_list.append('hostname_id VARCHAR') creation_list.append('key_id VARCHAR') for key, value in plugin_stats[0].items(): - creation_list.append(f"{key} {convert_types[type(value).__name__]}") + creation_list.append(f"{key} {convert_types[type(self.normalize(value)).__name__]}") # Create the list of values to insert for plugin_item in plugin_stats: item_list = [] item_list.append(self.normalize(datetime.now().replace(microsecond=0))) - item_list.append(f"{self.hostname}") - item_list.append(f"{plugin_item.get('key')}") + item_list.append(self.normalize(f"{self.hostname}")) + item_list.append(self.normalize(f"{plugin_item.get('key')}")) item_list.extend([self.normalize(value) for value in plugin_item.values()]) values_list.append(item_list) else: diff --git a/tests-data/tools/csvcheck.py b/tests-data/tools/csvcheck.py index 0dc5417b..28fae001 100755 --- a/tests-data/tools/csvcheck.py +++ b/tests-data/tools/csvcheck.py @@ -74,7 +74,7 @@ def main(): success = check_csv(args.input, args.lines, args.columns) if success: - print("All checks passed successfully!") + print("CSV - All checks passed successfully!") sys.exit(0) else: print("CSV validation failed.") diff --git a/tests-data/tools/duckdbcheck.py b/tests-data/tools/duckdbcheck.py new file mode 100755 index 00000000..8cdce1b3 --- /dev/null +++ b/tests-data/tools/duckdbcheck.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# +# Check a DuckDB file. +# The input DuckDB file should be given as an input with the -i option. +# Check the following thinks: +# - number of line (without the header) should be equal to the number given with the -l option +# - each line should have the same number of columns +# - if the optional -c option is given, each line should have the the same number of columns + +import argparse +import sys + +import duckdb + + +def check_duckdb(input_file, expected_lines, expected_columns=None): + try: + db = duckdb.connect(database='/tmp/glances.db', read_only=True) + + result = db.sql("SELECT * from cpu").fetchall() + + # Check 1: Number of lines for CPU + row_count = len(result) + if row_count != expected_lines: + print(f"Error: Expected {expected_lines} CPU lines, but found {row_count}") + return False + + result = db.sql("SELECT * from network").fetchall() + + # Check 2: Number of lines for Network + row_count = len(result) + if row_count != expected_lines: + print(f"Error: Expected {expected_lines} Network lines, but found {row_count}") + return False + + return True + + except FileNotFoundError: + print(f"Error: File '{input_file}' not found") + return False + except Exception as e: + print(f"Error processing DuckDB file: {str(e)}") + return False + + +def main(): + parser = argparse.ArgumentParser(description='Check a DuckDB file for various properties.') + parser.add_argument('-i', '--input', required=True, help='Input CSV file') + parser.add_argument('-l', '--lines', type=int, required=True, help='Expected number of lines (excluding header)') + parser.add_argument('-c', '--columns', type=int, help='Expected number of columns (optional)') + + args = parser.parse_args() + + success = check_duckdb(args.input, args.lines, args.columns) + + if success: + print("DuckDB - All checks passed successfully!") + sys.exit(0) + else: + print("DuckDB validation failed.") + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/tests/test_export_duckdb.sh b/tests/test_export_duckdb.sh new file mode 100755 index 00000000..275bd546 --- /dev/null +++ b/tests/test_export_duckdb.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Exit on error +set -e + +# Remove previous test database +echo "Remove previous test database..." +rm -f /tmp/glances.db + +# Run glances with export to DuckDB, stopping after 10 writes +# This will run synchronously now since we're using --stop-after +echo "Glances to export system stats to DuckDB (duration: ~ 20 seconds)" +./venv/bin/python -m glances --config ./conf/glances.conf --export duckdb --stop-after 10 --quiet + +echo "Checking DuckDB database..." +./venv/bin/python ./tests-data/tools/duckdbcheck.py -i /tmp/glances.db -l 9 + +echo "Script completed successfully!" \ No newline at end of file