linux 信息查看及命令

關於雲服務器系統的基礎信息通常在購買時就有標明,至於一些資源的使用在雲服務器服務商的控制檯上也有相應的監控node

若是你對監控有更細緻化的需求,採用 node exporter + cadvisor + prometheus + grafana 也能夠作地更爲精細。linux

可是最重要的是: 你要了解哪些指標,以及它們如何在服務器上用命令敲出來shell

  • 如何查看 linux 版本和 centos 版本號
  • 如何查看內存配額
  • 如何查看CPU核心數量以及頻率
  • 如何查看服務器的平均負載 (附: 什麼是平均負載)
  • 如何獲取服務器的公網 IP 以及私網 IP
  • 如何查看服務器登陸的全部用戶

關於監控更多內容能夠參考如下章節: linux 各項監控指標後端

linux 版本和 centos 版本

# 查看 linux 版本
$ uname -a
Linux shanyue 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
 # 查看 centos 版本號
$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)
複製代碼

內存配額

查看還有多少內存,available 指還有多少可用內存centos

# -h 指打印可視化信息
$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.7G        154M        2.1G        512K        1.5G        3.3G
Swap:            0B          0B          0B
複製代碼

平均負載

load average 指單位時間內的平均進程數bash

$ uptime
 16:48:09 up 2 days, 23:43,  2 users,  load average: 0.01, 0.21, 0.20
複製代碼

IP

# 公網IP
$ curl ifconfig.me
59.110.216.155
 # 公網IP,上個地址的連通性不太好
$ curl icanhazip.com
59.110.216.155
 # 私網IP
$ ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.68.39  netmask 255.255.240.0  broadcast 172.17.79.255
        ether 00:16:3e:0e:01:d8  txqueuelen 1000  (Ethernet)
        RX packets 416550  bytes 505253322 (481.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 194374  bytes 67561825 (64.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
複製代碼

登陸用戶

$ who -u
who -u
root     pts/0        Oct 18 15:04 04:25       16860 (124.200.184.74)
root     pts/2        Oct 18 18:10 01:22        2545 (124.200.184.74)
root     pts/5        Oct 18 19:33   .         24952 (124.200.184.74)
 $ last -a | head -6
root     pts/5        Fri Oct 18 19:33   still logged in    124.200.184.74
root     pts/2        Fri Oct 18 18:10   still logged in    124.200.184.74
root     pts/2        Fri Oct 18 18:10 - 18:10  (00:00)     124.200.184.74
root     pts/2        Fri Oct 18 17:54 - 18:10  (00:16)     124.200.184.74
root     pts/2        Fri Oct 18 17:49 - 17:53  (00:03)     124.200.184.74
root     pts/2        Fri Oct 18 16:49 - 17:25  (00:36)     124.200.184.74
複製代碼

歡迎關注公衆號山月行,我會按期分享一些先後端以及運維的文章,而且會有技術與生活上的每日回顧與總結,歡迎關注交流服務器

歡迎關注公衆號山月行,在這裏記錄個人技術成長,歡迎交流
相關文章
相關標籤/搜索