Linux巡检利器xsos的安装和使用

Linux巡检利器xsos的安装和使用

一、

一般项目基本完成的时候,后期运维工作的重点就是及时的,合理的频率巡检了,巡检的目的主要是及时发现各种各样的问题

那么,自己编写shell脚本是大部分人的第一选择,这里有个比较麻烦的地方,shell脚本可能巡检的指标不够全面,以及shell脚本难以编写的问题

🆗,这里我推荐大家使用xsos这个软件来简化巡检的工作,很多巡检工作可以使用此工具代替了

二、

xsos的下载地址

https://codeload.github.com/ryran/xsos/tar.gz/refs/tags/v0.7.33

下载完毕后,解压,将xsos这个可执行文件移动到/usr/local/bin/目录下并赋予执行权限即可使用,此软件无需任何依赖,无需任何动态链接库,可以直接使用,非常nice的,主要因为它是其实是一个写的非常长的shell脚本!!!!!!!!!!!!!!!!(有4000多行)

[root@centos7 xsos-0.7.33]# ldd /usr/local/bin/xsos

not a dynamic executable

[root@centos7 xsos-0.7.33]# file /usr/local/bin/xsos

/usr/local/bin/xsos: Bourne-Again shell script, UTF-8 Unicode text executable, with very long lines

三、

此软件下载只能在github,其它地方没有发现,需要指出的是,此软件和sosreport这个软件比较类似,是可以基于sosreport命令运行所产生的文件来工作的,当然,xsos单独也是可以工作的

单独运行此软件:

1、获取系统的信息和内存信息

xsos --os --mem

输出如下:

OS

Hostname: centos7

Distro: [redhat-release] CentOS Linux release 7.7.1908 (Core)

[centos-release] CentOS Linux release 7.7.1908 (Core)

[os-release] CentOS Linux 7 (Core) 7 (Core)

RHN: (missing)

RHSM: (missing)

YUM: 2 enabled plugins: fastestmirror, langpacks

Runlevel: N 3 (default multi-user)

SELinux: disabled (default disabled)

Arch: mach=x86_64 cpu=x86_64 platform=x86_64

Kernel:

Booted kernel: 3.10.0-1062.el7.x86_64

GRUB default: 3.10.0-1062.el7.x86_64

Build version:

Linux version 3.10.0-1062.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Wed Aug 7 18:08:02 UTC 2019

Booted kernel cmdline:

root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rhgb quiet LANG=en_US.UTF-8

GRUB default kernel cmdline:

root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rhgb quiet LANG=en_US.UTF-8

Taint-check: 0 (kernel untainted)

- - - - - - - - - - - - - - - - - - -

Sys time: Thu Oct 24 22:28:00 CST 2024

Boot time: Thu Oct 24 16:22:10 CST 2024 (epoch: 1729758130)

Time Zone: Asia/Shanghai

Uptime: 6:05, 2 users

LoadAvg: [4 CPU] 0.07 (2%), 0.07 (2%), 0.06 (2%)

/proc/stat:

procs_running: 1 procs_blocked: 0 processes [Since boot]: 19286

cpu [Utilization since boot]:

us 0%, ni 0%, sys 0%, idle 100%, iowait 0%, irq 0%, sftirq 0%, steal 0%

MEMORY

Stats graphed as percent of MemTotal:

MemUsed ▊▊▊▊▊▊▊▊▊......................................... 17.3%

Buffers .................................................. 0.2%

Cached ▊▊▊▊▊............................................. 10.7%

HugePages .................................................. 0.0%

Dirty .................................................. 0.0%

RAM:

3.9 GiB total ram

0.7 GiB (17%) used

0.2 GiB (6%) used excluding Buffers/Cached

0 GiB (0%) dirty

HugePages:

No ram pre-allocated to HugePages

THP:

0.01 GiB allocated to THP

LowMem/Slab/PageTables/Shmem:

0.11 GiB (3%) of total ram used for Slab

0 GiB (0%) of total ram used for PageTables

0.01 GiB (0%) of total ram used for Shmem

Swap:

No system swap space configured

2、

获取系统的cpu,主板以及网络相关信息

xsos --cpu --lspci --net

输出如下:

[root@centos7 xsos-0.7.33]# xsos --cpu --lspci --net

CPU

4 logical processors (4 CPU cores)

2 13th Gen Intel Core i7-13700KF (flags: aes,constant_tsc,ht,lm,nx,pae,rdrand,vmx)

└─2 threads / 2 cores each

LSPCI

Net:

(1) Advanced Micro Devices, Inc. [AMD] 79c970 [PCnet32 LANCE] (rev 10)

Storage:

(1) VMware SATA AHCI controller

VGA:

VMware SVGA II Adapter

ETHTOOL

Interface Status:

ens33 0000:02:01.0 link=up rx ring 32/512 drv pcnet32 v1.35 / fw UNKNOWN

Interface Errors:

[None]

SOFTIRQ

Backlog max is sufficient (Current value: net.core.netdev_max_backlog = 1000)

Budget is not sufficient, consider reviewing budget tunable. (Current value: net.core.netdev_budget = 300)

(see https://access.redhat.com/solutions/1241943)

NETDEV

Interface RxMiBytes RxPackets RxErrs RxDrop RxFifo RxComp RxFrame RxMultCast

========= ========= ========= ====== ====== ====== ====== ======= ==========

ens33 11 11 k 11 (0%) 6 (0%) 0 0 0 0

- - - - - - - - - - - - - - - - -

Interface TxMiBytes TxPackets TxErrs TxDrop TxFifo TxComp TxColls TxCarrier

========= ========= ========= ====== ====== ====== ====== ======= ==========

ens33 1 5 k 0 0 0 0 0 0

SOCKSTAT

sockets: used 189

TCP: inuse 4 orphan 0 tw 0 alloc 6 mem 5

UDP: inuse 0 mem 0

UDPLITE: inuse 0

RAW: inuse 0

FRAG: inuse 0 memory 0

IP4

Interface Master IF MAC Address MTU State IPv4 Address

========= ========= ================= ====== ===== ==================

lo - - 65536 up 127.0.0.1/8

ens33 - 00:0c:29:90:91:4e 1500 up 192.168.123.17/24

SS CHECK

Sessions:

lost reord_seen back_log retrans_total rq tq sock_drop app_limited dsack_dups %CPU %MEM Proto User Local Command Peer

---- ---------- -------- ------------- -- -- --------- ----------- ---------- ---- ----- ---- ----- ---- ---- -------

FIREWALL

Services enabled:

No firewall services enabled.

Rules loaded:

No rules loaded.

IFCFG

Services enabled:

FILE TYPE DEVICE NAME HWADDR ONBOOT DEFROUTE GATEWAY NM_CONTROLLED BOND/TEAM MASTER BRIDGE ETHTOOL PHYSDEV PEERDNS ZONE MTU

ifcfg-ens33 Ethernet ens33 ens33 - yes yes 192.168.123.2 - - - - - - - - -

ifcfg-lo - lo loopback - yes - - - - - - - - - - -

NET STATS

Tcp.EstabResets: 2

TcpExt.DelayedACKs: 40

TcpExt.TCPLossProbeRecovery: 3

TcpExt.TCPLossProbes: 3

TcpExt.TCPLossUndo: 1

TcpExt.TCPTimeouts: 1

3、

常用方式

Content options:

-a, --all show everything

-b, --bios show info from dmidecode

-o, --os show hostname, distro, SELinux, kernel info, uptime, etc

-k, --kdump inspect kdump configuration

-c, --cpu show info from /proc/cpuinfo

-m, --mem show info from /proc/meminfo

-d, --disks show info from /proc/partitions + dm-multipath synopsis

-t, --mpath show info from dm-multipath

-l, --lspci show info from lspci

-e, --ethtool show info from ethtool

-r, --softirq show info from /proc/net/softnet_stat

-n, --netdev show info from /proc/net/dev

-g, --bonding show info from /proc/net/bonding

-i, --ip show info from ip addr (BASH v4+ required)

--net alias for: --lspci --ethtool --softirq --netdev --bonding --ip

-s, --sysctl show important kernel sysctls

-p, --ps inspect running processes via ps

Display options:

--scrub-ip remove IP addresses & hostnames from output

--scrub-mac remove HW MAC addresses from output

see XSOS_SCRUB_IP_HN & XSOS_SCRUB_MACADDR env vars

-6, --ipv6 parse ip addr output for IPv6 addresses instead of IPv4

-q, --wwid=ID restrict dm-multipath output to a particular mpath device,

where ID is a wwid, friendly name, or LUN identifier

-u, --unit=P change byte display for /proc/meminfo & /proc/net/dev,

where P is "b" for byte, or else "k", "m", "g", or "t"

-v, --verbose=NUM specify ps verbosity level (0-4, default: 1)

-w, --width=NUM change fold-width, in columns (positive number, e.g., 80)

"0" disables wrapping, "w" autodetects width (default)

-x, --nocolor disable output colorization

-y, --less send output to `less -SR`

-z, --more send output to `more`

Special options (BASH v4+ required):

--B=FILE read from FILE containing `dmidecode` dump

--C=FILE read from FILE containing /proc/cpuinfo dump

--M=FILE read from FILE containing /proc/meminfo dump

--D=FILE read from FILE containing /proc/partitions dump

--T=FILE read from FILE containing `multipath -v4 -ll` dump

--L=FILE read from FILE containing `lspci` dump

--R=FILE read from FILE containing /proc/net/softnet_stat dump

--N=FILE read from FILE containing /proc/net/dev dump

--G=FILE read from FILE containing /proc/net/bonding/xxx dump

--I=FILE read from FILE containing `ip addr` dump

--P=FILE read from FILE containing `ps aux` dump

例如,简单的查看网络流量情况:

[root@centos7 xsos-0.7.33]# xsos -n

NETDEV

Interface RxMiBytes RxPackets RxErrs RxDrop RxFifo RxComp RxFrame RxMultCast

========= ========= ========= ====== ====== ====== ====== ======= ==========

ens33 11 11 k 11 (0%) 6 (0%) 0 0 0 0

- - - - - - - - - - - - - - - - -

Interface TxMiBytes TxPackets TxErrs TxDrop TxFifo TxComp TxColls TxCarrier

========= ========= ========= ====== ====== ====== ====== ======= ==========

ens33 1 5 k 0 0 0 0 0 0

SOCKSTAT

sockets: used 189

TCP: inuse 4 orphan 0 tw 0 alloc 6 mem 4

UDP: inuse 0 mem 0

UDPLITE: inuse 0

RAW: inuse 0

FRAG: inuse 0 memory 0

简单的查看biso信息:

[root@centos7 xsos-0.7.33]# xsos -b

DMIDECODE

BIOS:

Vend: Phoenix Technologies LTD

Vers: 6.00

Date: 11/12/2020

BIOS Rev: 4.6

FW Rev: 0.0

System:

Mfr: VMware, Inc.

Prod: VMware Virtual Platform

Vers: None

Ser: VMware-56 4d ea a7 9a 71 34 2d-80 fa b4 13 75 90 91 4e

UUID: a7ea4d56-719a-2d34-80fa-b4137590914e

CPU:

4 of 4 CPU sockets populated, 2 cores/0 threads per CPU

8 total cores, 0 total threads

Mfr: GenuineIntel

Fam: Unknown

Freq: 3433 MHz

Vers: 13th Gen Intel(R) Core(TM) i7-13700KF

Memory:

Total: 4096 MiB (4 GiB)

DIMMs: 1 of 192 populated

MaxCapacity: 5120 MiB (5 GiB / 0.00 TiB)

xsos --bios --ip --lspci --ethtool --net --ps 此命令等于xsos -bilenp

xsos --disks --mem --unit=m

输出如下:

[root@centos7 xsos-0.7.33]# xsos --disks --mem --unit=m

MEMORY

Stats graphed as percent of MemTotal:

MemUsed ▊▊▊▊▊▊▊▊▊......................................... 17.3%

Buffers .................................................. 0.2%

Cached ▊▊▊▊▊............................................. 10.8%

HugePages .................................................. 0.0%

Dirty .................................................. 0.0%

RAM:

3950 MiB total ram

682 MiB (17.3%) used

248 MiB (6.3%) used excluding Buffers/Cached

0 MiB (0%) dirty

HugePages:

No ram pre-allocated to HugePages

THP:

6 MiB allocated to THP

LowMem/Slab/PageTables/Shmem:

112 MiB (2.8%) of total ram used for Slab

4 MiB (0.1%) of total ram used for PageTables

9 MiB (0.2%) of total ram used for Shmem

Swap:

No system swap space configured

STORAGE

Whole Disks from /proc/partitions:

1 disks, totaling 100 GiB (0.10 TiB)

- - - - - - - - - - - - - - - - - - - - -

Disk Size in GiB

---- -----------

sda 100

Disk layout from lsblk:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda 8:0 0 100G 0 disk

├─sda1 8:1 0 1G 0 part /boot

└─sda2 8:2 0 80G 0 part

└─centos-root 253:0 0 80G 0 lvm /

sr0 11:0 1 4.4G 0 rom /mnt

Filesystem usage from df:

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/mapper/centos-root 83845120 1666404 82178716 2% /

/dev/sr0 4554702 4554702 0 100% /mnt

/dev/sda1 1038336 139156 899180 14% /boot

查看网络详情:

xsos --net --unit k

LSPCI

Net:

(1) Advanced Micro Devices, Inc. [AMD] 79c970 [PCnet32 LANCE] (rev 10)

Storage:

(1) VMware SATA AHCI controller

VGA:

VMware SVGA II Adapter

ETHTOOL

Interface Status:

ens33 0000:02:01.0 link=up rx ring 32/512 drv pcnet32 v1.35 / fw UNKNOWN

Interface Errors:

[None]

SOFTIRQ

Backlog max is sufficient (Current value: net.core.netdev_max_backlog = 1000)

Budget is not sufficient, consider reviewing budget tunable. (Current value: net.core.netdev_budget = 300)

(see https://access.redhat.com/solutions/1241943)

NETDEV

Interface RxKiBytes RxPackets RxErrs RxDrop RxFifo RxComp RxFrame RxMultCast

========= ========= ========= ====== ====== ====== ====== ======= ==========

ens33 11788 11296 11 (0%) 6 (0%) 0 0 0 0

- - - - - - - - - - - - - - - - -

Interface TxKiBytes TxPackets TxErrs TxDrop TxFifo TxComp TxColls TxCarrier

========= ========= ========= ====== ====== ====== ====== ======= ==========

ens33 801 5720 0 0 0 0 0 0

SOCKSTAT

sockets: used 189

TCP: inuse 4 orphan 0 tw 0 alloc 6 mem 3

UDP: inuse 0 mem 0

UDPLITE: inuse 0

RAW: inuse 0

FRAG: inuse 0 memory 0

IP4

Interface Master IF MAC Address MTU State IPv4 Address

========= ========= ================= ====== ===== ==================

lo - - 65536 up 127.0.0.1/8

ens33 - 00:0c:29:90:91:4e 1500 up 192.168.123.17/24

SS CHECK

Sessions:

lost reord_seen back_log retrans_total rq tq sock_drop app_limited dsack_dups %CPU %MEM Proto User Local Command Peer

---- ---------- -------- ------------- -- -- --------- ----------- ---------- ---- ----- ---- ----- ---- ---- -------

FIREWALL

Services enabled:

No firewall services enabled.

Rules loaded:

No rules loaded.

IFCFG

Services enabled:

FILE TYPE DEVICE NAME HWADDR ONBOOT DEFROUTE GATEWAY NM_CONTROLLED BOND/TEAM MASTER BRIDGE ETHTOOL PHYSDEV PEERDNS ZONE MTU

ifcfg-ens33 Ethernet ens33 ens33 - yes yes 192.168.123.2 - - - - - - - - -

ifcfg-lo - lo loopback - yes - - - - - - - - - - -

NET STATS

Tcp.EstabResets: 2

TcpExt.DelayedACKs: 53

TcpExt.TCPLossProbeRecovery: 3

TcpExt.TCPLossProbes: 3

TcpExt.TCPLossUndo: 1

TcpExt.TCPTimeouts: 1

总之,以上参数可以自由搭配组合得出自己喜欢的一个输出内容,从而得到一个自己所期望的巡检结果

该工具还是非常非常nice的哦~~~

相关推荐

在线漫画翻译工具
365体育投注一直进不去

在线漫画翻译工具

⌛ 06-30 👁️ 7511
乐视超级自行车成中产阶级新宠 二十多小时预约破十万
365足球体育app下载

乐视超级自行车成中产阶级新宠 二十多小时预约破十万

⌛ 08-18 👁️ 4721
俄罗斯世界杯观赛指南
365体育投注一直进不去

俄罗斯世界杯观赛指南

⌛ 07-04 👁️ 6165