|
| 1 | + |
| 2 | +:sectnums: |
| 3 | +:sectnumlevels: 5 |
| 4 | + |
| 5 | += plpgsql_check |
| 6 | + |
| 7 | +== Overview |
| 8 | +system_stats is a Postgres extension that provides functions to access system level statistics that can be used for monitoring. |
| 9 | + |
| 10 | +== Installation |
| 11 | + |
| 12 | +[TIP] |
| 13 | +The source code installation environment is Ubuntu 24.04 (x86_64), in which IvorySQL 5 or a later version has been installed. The installation path is /usr/local/ivorysql/ivorysql-5. |
| 14 | + |
| 15 | +=== Source Code Installation |
| 16 | + |
| 17 | +[literal] |
| 18 | +---- |
| 19 | +# download source code package from: https://github.com/EnterpriseDB/system_stats/releases/tag/v3.2 |
| 20 | +unzip v3.2.zip |
| 21 | +cd system_stats-3.2 |
| 22 | +
|
| 23 | +# compile and install the extension |
| 24 | +make PG_CONFIG=/usr/local/ivorysql/ivorysql-5/bin/pg_config |
| 25 | +make PG_CONFIG=/usr/local/ivorysql/ivorysql-5/bin/pg_config install |
| 26 | +---- |
| 27 | + |
| 28 | +== Create extension and confirm the version |
| 29 | + |
| 30 | +connect the database with psql in Oracle compatible mode and execute the following commands: |
| 31 | + |
| 32 | +[literal] |
| 33 | +---- |
| 34 | +ivorysql=# CREATE EXTENSION system_stats; |
| 35 | +CREATE EXTENSION |
| 36 | +
|
| 37 | +ivorysql=# SELECT * FROM pg_available_extensions WHERE name = 'system_stats'; |
| 38 | + name | default_version | installed_version | comment |
| 39 | +--------------+-----------------+-------------------+----------------------------------------------- |
| 40 | + system_stats | 3.0 | 3.0 | EnterpriseDB system statistics for PostgreSQL |
| 41 | +(1 row) |
| 42 | +---- |
| 43 | + |
| 44 | +== 使用 |
| 45 | + |
| 46 | +[literal] |
| 47 | +---- |
| 48 | +ivorysql=> select pg_sys_os_info() from dual; |
| 49 | + pg_sys_os_info |
| 50 | +-------------------------------------------------------------------------- |
| 51 | + ("""Ubuntu 24.04.1 LTS"" + |
| 52 | + ","Linux 6.14.0-29-generic",Ubuntu,"(none)",5568,292,532,x86_64,,864122) |
| 53 | +(1 row) |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +ivorysql=> select pg_sys_cpu_info() from dual; |
| 58 | + pg_sys_cpu_info |
| 59 | +------------------------------------------------------------------------------------------------------------------------------------- |
| 60 | + (GenuineIntel,"GenuineIntel model 154 family 6","12th Gen Intel(R) Core(TM) i7-1260P",,0,2,1,x86_64,2496000000,,,,48,32,1280,18432) |
| 61 | +(1 row) |
| 62 | +
|
| 63 | +
|
| 64 | +ivorysql=> select pg_sys_cpu_usage_info() from dual; |
| 65 | + pg_sys_cpu_usage_info |
| 66 | +----------------------- |
| 67 | + (0,0,0,100,0,0,0,,,,) |
| 68 | +(1 row) |
| 69 | + |
| 70 | + |
| 71 | +ivorysql=> select pg_sys_memory_info() from dual; |
| 72 | + pg_sys_memory_info |
| 73 | +----------------------------------------------------------------------------------- |
| 74 | + (4055482368,3911159808,144322560,4055887872,233725952,3822161920,2638602240,,,,,) |
| 75 | +(1 row) |
| 76 | +
|
| 77 | +
|
| 78 | +ivorysql=> select pg_sys_io_analysis_info() from dual; |
| 79 | + pg_sys_io_analysis_info |
| 80 | +--------------------------------------------------------------- |
| 81 | + (loop0,15,0,21504,0,1,0) |
| 82 | + (loop1,1362,0,27916288,0,680,0) |
| 83 | + (loop2,175,0,3354624,0,131,0) |
| 84 | + (loop3,141,0,1827840,0,83,0) |
| 85 | + (loop4,918,0,32752640,0,212,0) |
| 86 | + (loop5,156,0,2617344,0,67,0) |
| 87 | + (loop6,3707,0,131992576,0,828,0) |
| 88 | + (loop7,243,0,4321280,0,95,0) |
| 89 | + (fd0,0,0,0,0,0,0) |
| 90 | + (sda,639286,1580583,26547332096,240138948608,402702,2744653) |
| 91 | + (sda1,561,0,22966272,0,61,0) |
| 92 | + (sda2,636820,1580583,26491053056,240138948608,402316,2744653) |
| 93 | + (sr0,87,0,3219456,0,45,0) |
| 94 | + (sr1,0,0,0,0,0,0) |
| 95 | + (loop8,228,0,2491392,0,120,0) |
| 96 | + (loop10,2333,0,36571136,0,1628,0) |
| 97 | + (loop9,3730,0,66532352,0,3973,0) |
| 98 | + (loop11,87,0,709632,0,50,0) |
| 99 | + (loop12,156,0,1948672,0,52,0) |
| 100 | + (loop14,2579,0,97446912,0,2083,0) |
| 101 | + (loop13,30,0,102400,0,14,0) |
| 102 | + (loop15,82,0,1189888,0,117,0) |
| 103 | + (loop16,1357,0,28335104,0,500,0) |
| 104 | + (loop17,110,0,2187264,0,93,0) |
| 105 | + (loop18,129,0,2355200,0,28,0) |
| 106 | + (loop19,110,0,2202624,0,55,0) |
| 107 | +(26 rows) |
| 108 | + |
| 109 | + |
| 110 | +ivorysql=> select pg_sys_disk_info() from dual; |
| 111 | + pg_sys_disk_info |
| 112 | +---------------------------------------------------------------------------------- |
| 113 | + (/,/dev/sda2,,,ext4,105086115840,50903396352,48797392896,6553600,619735,5933865) |
| 114 | +(1 row) |
| 115 | +
|
| 116 | +
|
| 117 | +ivorysql=> select pg_sys_load_avg_info() from dual; |
| 118 | + pg_sys_load_avg_info |
| 119 | +---------------------- |
| 120 | + (0,0,0,) |
| 121 | +(1 row) |
| 122 | + |
| 123 | + |
| 124 | +ivorysql=> select pg_sys_process_info() from dual; |
| 125 | + pg_sys_process_info |
| 126 | +--------------------- |
| 127 | + (294,1,201,0,0) |
| 128 | +(1 row) |
| 129 | +
|
| 130 | +
|
| 131 | +ivorysql=> select pg_sys_network_info() from dual; |
| 132 | + pg_sys_network_info |
| 133 | +----------------------------------------------------------------------------- |
| 134 | + (lo,127.0.0.1,1071575,5643,0,0,1071575,5643,0,0,0) |
| 135 | + (ens33,192.168.198.128,619877515,1490961,0,161,5540250106,4345449,0,0,1000) |
| 136 | +(2 rows) |
| 137 | + |
| 138 | + |
| 139 | +ivorysql=> select pg_sys_cpu_memory_by_process() from dual; |
| 140 | + pg_sys_cpu_memory_by_process |
| 141 | +----------------------------------------------------------------------- |
| 142 | + (1,"(systemd)",864793,0,0.34,13840384) |
| 143 | + (2,"(kthreadd)",864793,0,0,0) |
| 144 | + (3,"(pool_workqueue_release)",864793,0,0,0) |
| 145 | + (4,"(kworker/R-rcu_gp)",864793,0,0,0) |
| 146 | +...... |
| 147 | +---- |
| 148 | + |
0 commit comments