system_stats功能用途
system_stats插件有一些功能函数组成,可以用于监控系统的cpu、磁盘、IO、内存、网络、进程、操作系统信息。
system_stats下载地址
https://github.com/EnterpriseDB/system_stats/releases/tag/v1.0
system_stats安装
[postgres@lineqi ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PGHOME=/usr/local/pgsql
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGPORT=1921
export PGDATA=/data/pg11.6
export LANG=en_US.utf8
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
tar -zxvf system_stats-1.0.tar.gz
cd system_stats-1.0
[postgres@lineqi system_stats-1.0]$ make USE_PGXS=1
"Platform is: linux"
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I./ -I/usr/local/pgsql/include/server -I/usr/local/pgsql/include/internal -D_GNU_SOURCE -c -o system_stats.o system_stats.c
……………………………………
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -shared -o system_stats.so system_stats.o linux/system_stats_utils.o linux/disk_info.o linux/io_analysis.o linux/cpu_info.o linux/cpu_usage_info.o linux/os_info.o linux/memory_info.o linux/load_avg.o linux/process_info.o linux/network_info.o linux/cpu_memory_by_process.o -L/usr/local/pgsql/lib -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags
[postgres@lineqi system_stats-1.0]$ make install USE_PGXS=1
"Platform is: linux"
/bin/mkdir -p '/usr/local/pgsql/lib'
/bin/mkdir -p '/usr/local/pgsql/share/extension'
/bin/mkdir -p '/usr/local/pgsql/share/extension'
/bin/install -c -m 755 system_stats.so '/usr/local/pgsql/lib/system_stats.so'
/bin/install -c -m 644 .//system_stats.control '/usr/local/pgsql/share/extension/'
/bin/install -c -m 644 .//system_stats--1.0.sql .//uninstall_system_stats.sql '/usr/local/pgsql/share/extension/'
/bin/mkdir -p '/usr/local/pgsql/include/server/extension/system_stats/'
/bin/install -c -m 644 .//system_stats.h '/usr/local/pgsql/include/server/extension/system_stats/'
创建插件
postgres=# \dx
List of installed extensions
Name | Version | Schema | Description
---------+---------+------------+------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(1 row)
postgres=# create extension
plperl plperlu system_stats timescaledb
postgres=# create extension system_stats ;
postgres=# \dx
List of installed extensions
Name | Version | Schema | Description
--------------+---------+------------+-------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
system_stats | 1.0 | public | System statistic functions for PostgreSQL
(2 rows)
system_stats插件提供了以下10个功能函数,都是以pg_sys开头
1、pg_sys_cpu_info
2、pg_sys_cpu_memory_by_process
3、pg_sys_cpu_usage_info
4、pg_sys_disk_info
5、 pg_sys_io_analysis_info
6、pg_sys_load_avg_info
7、pg_sys_memory_info
8、pg_sys_network_info
9、pg_sys_os_info
10、pg_sys_process_info
下一篇演示每个功能函数
总结
1、通过system_stats插件提供的函数还是非常方便的统计系统的基本信息。
2、system_stats在centos7.4+postgresql11.6安装过程十分简单,那么该插件是否支持pg12、p13呢?