暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

超强大| linux中系统性能监控工具-glances

大侠之运维 2022-08-03
1314

点击上方蓝字  关注大侠之运维


话不多说,先来张图看下

 

glances是用python编写的一个实时监控工具,是用psutil库从系统中获取相关的监控信息

 

可以说在一个屏下尽可能的展示足够多的信息,另外对系统性能的使用也可以接受,不到2%,这款工具的监控信息还可以通过web界面展示,也提供了api接口可以取拉去对应的信息,可玩性,实用性上还是不错的.

 

相关的监控数据也可以导出为csv,也可以输出到influxdb这类时序库中

 

安装


可以通过pip安装,也可以通过yum安装

都是直接命令安装就好

    pip install glances

    如果需要web功能或者导出模块 可以通过 如下方式

      pip install glances[all]

      yum 安装的话,直接常规命令安装就好

        yum install glances -y

         

        快速入门


        直接执行glances可以展示文章开头的界面


          [root@test-3 bin]# ./glances --stdout cpu.user,mem.used,load
          cpu.user: 15.4
          mem.used: 1896566784
          load: {'min1': 0.11, 'min5': 0.19, 'min15': 0.18, 'cpucore': 4}
          cpu.user: 9.7
          mem.used: 1898405888
          load: {'min1': 0.11, 'min5': 0.19, 'min15': 0.18, 'cpucore': 4}
          cpu.user: 9.7
          mem.used: 1898405888
          load: {'min1': 0.11, 'min5': 0.19, 'min15': 0.18, 'cpucore': 4}

          可以监控远端的主机.现在服务端执行

            glances -s

            然后在客户端执行

              glances -c @server

               

              如果要通过web页面去展示的话,可以通过glances -w

              需要提前装bottle模块

               

              如果安全考虑,可以配置密码 通过 --password


                [root@test-3 bin]# ./glances -w --password
                Define the Glances webserver password (glances username):
                Password (confirm):
                Do you want to save the password? [Yes/No]: yes
                Glances Web User Interface started on http://0.0.0.0:61208/


                支持输出类型

                可以看到除了csv外,还有很多的输出支持

                 

                这个监控还做了多个终端的适配,可以在手机上展示,也可以在平板\笔记本上展示

                 

                 


                命令参考


                  usage: glances [-h] [-V] [-d] [-C CONF_FILE] [-3] [-4] [--disable-cpu]
                  [--disable-mem] [--disable-swap] [--disable-load]
                  [--disable-network] [--disable-ip] [--disable-diskio]
                  [--disable-fs] [--disable-sensors] [--disable-hddtemp]
                  [--disable-raid] [--disable-docker] [-2] [--disable-process]
                  [--disable-log] [--disable-bold] [--enable-process-extended]
                  [--enable-history] [--path-history PATH_HISTORY]
                  [--export-csv EXPORT_CSV] [--export-influxdb]
                  [--export-opentsdb] [--export-statsd] [--export-rabbitmq]
                  [-c CLIENT] [-s] [--browser] [--disable-autodiscover] [-p PORT]
                  [-B BIND_ADDRESS] [--password]
                  [--snmp-community SNMP_COMMUNITY] [--snmp-port SNMP_PORT]
                  [--snmp-version SNMP_VERSION] [--snmp-user SNMP_USER]
                  [--snmp-auth SNMP_AUTH] [--snmp-force] [-t TIME] [-w] [-q]
                  [-f PROCESS_FILTER] [--process-short-name] [-0]
                  [--hide-kernel-threads] [--tree] [-b] [--fahrenheit] [-1]
                  [--fs-free-space] [--theme-white]


                  optional arguments:
                  -h, --help show this help message and exit
                  -V, --version show program's version number and exit
                  -d, --debug enable debug mode
                  -C CONF_FILE, --config CONF_FILE
                  path to the configuration file
                  -3, --disable-quicklook
                  disable quick look module
                  -4, --full-quicklook disable all but quick look and load
                  --disable-cpu disable CPU module
                  --disable-mem disable memory module
                  --disable-swap disable swap module
                  --disable-load disable load module
                  --disable-network disable network module
                  --disable-ip disable IP module
                  --disable-diskio disable disk I/O module
                  --disable-fs disable filesystem module
                  --disable-sensors disable sensors module
                  --disable-hddtemp disable HD temperature module
                  --disable-raid disable RAID module
                  --disable-docker disable Docker module
                  -2, --disable-left-sidebar
                  disable network, disk I/O, FS and sensors modules
                  (py3sensors needed)
                  --disable-process disable process module
                  --disable-log disable log module
                  --disable-bold disable bold mode in the terminal
                  --enable-process-extended
                  enable extended stats on top process
                  --enable-history enable the history mode (matplotlib needed)
                  --path-history PATH_HISTORY
                  set the export path for graph history
                  --export-csv EXPORT_CSV
                  export stats to a CSV file
                  --export-influxdb export stats to an InfluxDB server (influxdb needed)
                  --export-opentsdb export stats to an OpenTSDB server (potsdb needed)
                  --export-statsd export stats to a StatsD server (statsd needed)
                  --export-rabbitmq export stats to rabbitmq broker (pika needed)
                  -c CLIENT, --client CLIENT
                  connect to a Glances server by IPv4/IPv6 address or
                  hostname
                  -s, --server run Glances in server mode
                  --browser start the client browser (list of servers)
                  --disable-autodiscover
                  disable autodiscover feature
                  -p PORT, --port PORT define the client/server TCP port [default: 61209]
                  -B BIND_ADDRESS, --bind BIND_ADDRESS
                  bind server to the given IPv4/IPv6 address or hostname
                  --password define a client/server password
                  --snmp-community SNMP_COMMUNITY
                  SNMP community
                  --snmp-port SNMP_PORT
                  SNMP port
                  --snmp-version SNMP_VERSION
                  SNMP version (1, 2c or 3)
                  --snmp-user SNMP_USER
                  SNMP username (only for SNMPv3)
                  --snmp-auth SNMP_AUTH
                  SNMP authentication key (only for SNMPv3)
                  --snmp-force force SNMP mode
                  -t TIME, --time TIME set refresh time in seconds [default: 3 sec]
                  -w, --webserver run Glances in web server mode (bottle needed)
                  -q, --quiet do not display the curses interface
                  -f PROCESS_FILTER, --process-filter PROCESS_FILTER
                  set the process filter pattern (regular expression)
                  --process-short-name force short name for processes name
                  -0, --disable-irix Task's cpu usage will be divided by the total number
                  of CPUs
                  --hide-kernel-threads
                  hide kernel threads in process list
                  --tree display processes as a tree
                  -b, --byte display network rate in byte per second
                  --fahrenheit display temperature in Fahrenheit (default is Celsius)
                  -1, --percpu start Glances in per CPU mode
                  --fs-free-space display FS free space instead of used
                  --theme-white optimize display colors for white background


                  Examples of use:


                  Monitor local machine (standalone mode):
                  $ glances


                  Monitor local machine with the Web interface (Web UI):
                  $ glances -w
                  Glances web server started on http://0.0.0.0:61208/


                  Monitor local machine and export stats to a CSV file (standalone mode):
                  $ glances --export-csv


                  Monitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode):
                  $ glances -t 5 --export-influxdb


                  Start a Glances server (server mode):
                  $ glances -s


                  Connect Glances to a Glances server (client mode):
                  $ glances -c <ip_server>


                  Connect Glances to a Glances server and export stats to a StatsD server (client mode):
                  $ glances -c <ip_server> --export-statsd


                  Start the client browser (browser mode):
                  $ glances --browser




                  👆点击查看更多内容👆


                  推荐阅读

                  elk8.0部署文档(rsyslog+kafka+logstash+elasticsearch+kibana))

                  ELK告警插件-elastalert2 实践,支持elk8.0版本,企微机器人告警实现 


                  记得星标记一下,下次更容易找到我

                         



                  文章转载自大侠之运维,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                  评论