#化鲲为鹏,我有话说#鲲鹏生态构建
768
2022-05-29
一、背景
目前使用华为云鲲鹏服务器,对登录一个系统,快速查看其系统信息,检查系统各项指标及参数,编写系统快速检查脚本,输出系统信息到脚本运行的logs目录下。
二、脚本
git地址
#!/bin/bash # auth:kaliarch # func:sys info check # version:v1.0 # sys:centos6.x/7.x [ $(id -u) -gt 0 ] && echo "请用root用户执行此脚本!" && exit 1 sysversion=$(rpm -q centos-release|cut -d- -f3) line="-------------------------------------------------" [ -d logs ] || mkdir logs sys_check_file="logs/$(ip a show dev eth0|grep -w inet|awk '{print }'|awk -F '/' '{print }')-`date +%Y%m%d`.txt" # 获取系统cpu信息 function get_cpu_info() { Physical_CPUs=$(grep "physical id" /proc/cpuinfo| sort | uniq | wc -l) Virt_CPUs=$(grep "processor" /proc/cpuinfo | wc -l) CPU_Kernels=$(grep "cores" /proc/cpuinfo|uniq| awk -F ': ' '{print }') CPU_Type=$(grep "model name" /proc/cpuinfo | awk -F ': ' '{print }' | sort | uniq) CPU_Arch=$(uname -m) cat <
三、测试
鲲鹏服务器测试
采集鲲鹏服务器信息
CPU信息: 物理CPU个数: 0 逻辑CPU个数: 2 每CPU核心数: CPU型号: CPU架构: aarch64 ------------------------------------------------- 内存信息: total used free shared buff/cache available Mem: 3482 393 2081 20 1007 2514 Swap: 0 0 0 ------------------------------------------------- IP信息: 系统公网地址: 121.36.1.227 系统私网地址: 192.168.0.17 网关地址: 192.168.0.1 MAC地址: fa:16:3e:50:d8:50 02:42:9b:e4:84:bd d6:77:f9:49:14:8f 路由信息: Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 eth0 169.254.169.254 192.168.0.1 255.255.255.255 UGH 100 0 0 eth0 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0 192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0 DNS 信息: search openstacklocal nameserver 100.125.1.250 nameserver 100.125.129.250 options single-request-reopen ------------------------------------------------- 磁盘信息: Disk /dev/vda: 42.9 GB Disk /dev/vdb: 107.4 GB 磁盘使用: Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 1.7G 0 1.7G 0% /dev /dev/vda2 ext4 39G 3.4G 33G 10% / /dev/vda1 vfat 1022M 7.7M 1015M 1% /boot/efi overlay overlay 39G 3.4G 33G 10% /var/lib/docker/overlay2/6fde1851846f50e525be6b6fc104715c604c66b38f5d9e640f403dbc95f54def/merged inode信息: Filesystem Inodes IUsed IFree IUse% Mounted on devtmpfs 28K 303 27K 2% /dev /dev/vda2 2.5M 78K 2.4M 4% / /dev/vda1 0 0 0 - /boot/efi overlay 2.5M 78K 2.4M 4% /var/lib/docker/overlay2/6fde1851846f50e525be6b6fc104715c604c66b38f5d9e640f403dbc95f54def/merged ------------------------------------------------- 系统信息: 系统: GNU/Linux 发行版本: CentOS Linux release 7.4.1708 (AltArch) 系统内核: 4.14.0-115.5.1.el7a.aarch64 主机名: ecs-kc1-large-2-linux-20191111131638 selinux状态: Disabled 系统语言: en_US.UTF-8 系统当前时间: Wed Nov 13 17:53:35 CST 2019 系统最后重启时间: 2019-11-11 13:18 系统运行时间: 2 days 系统负载: 0.00, 0.00, 0.00 ------------------------------------------------- 服务启动配置: atd.service enabled auditd.service enabled autovt@.service enabled cloud-config.service enabled cloud-final.service enabled cloud-init-local.service enabled cloud-init.service enabled crond.service enabled dbus-org.freedesktop.NetworkManager.service enabled dbus-org.freedesktop.nm-dispatcher.service enabled docker.service enabled getty@.service enabled irqbalance.service enabled kdump.service enabled lvm2-monitor.service enabled NetworkManager-dispatcher.service enabled NetworkManager.service enabled ntpd.service enabled postfix.service enabled rsyslog.service enabled sshd.service enabled systemd-readahead-collect.service enabled systemd-readahead-drop.service enabled systemd-readahead-replay.service enabled tuned.service enabled ------------------------------------------------- 运行的服务: atd.service loaded active running Job spooling tools auditd.service loaded active running Security Auditing Service cloudResetPwdUpdateAgent.service loaded active running LSB: @app.long.name@ containerd.service loaded active running containerd container runtime crond.service loaded active running Command Scheduler dbus.service loaded active running D-Bus System Message Bus denyhosts.service loaded active running LSB: denyhosts docker.service loaded active running Docker Application Container Engine getty@tty1.service loaded active running Getty on tty1 irqbalance.service loaded active running irqbalance daemon lvm2-lvmetad.service loaded active running LVM2 metadata daemon NetworkManager.service loaded active running Network Manager ntpd.service loaded active running Network Time Service polkit.service loaded active running Authorization Manager postfix.service loaded active running Postfix Mail Transport Agent rsyslog.service loaded active running System Logging Service serial-getty@ttyAMA0.service loaded active running Serial Getty on ttyAMA0 sshd.service loaded active running OpenSSH server daemon systemd-journald.service loaded active running Journal Service systemd-logind.service loaded active running Login Service systemd-udevd.service loaded active running udev Kernel Device Manager tuned.service loaded active running Dynamic System Tuning Daemon ------------------------------------------------- 监听端口: Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1293/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 990/master tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 7695/./src/redis-se tcp6 0 0 :::80 :::* LISTEN 9992/docker-proxy tcp6 0 0 :::22 :::* LISTEN 1293/sshd tcp6 0 0 ::1:25 :::* LISTEN 990/master tcp6 0 0 :::6379 :::* LISTEN 7695/./src/redis-se udp 0 0 0.0.0.0:7945 0.0.0.0:* 621/dhclient udp 0 0 0.0.0.0:68 0.0.0.0:* 621/dhclient udp 0 0 172.17.0.1:123 0.0.0.0:* 548/ntpd udp 0 0 192.168.0.17:123 0.0.0.0:* 548/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 548/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 548/ntpd udp6 0 0 fe80::d477:f9ff:fe4:123 :::* 548/ntpd udp6 0 0 fe80::42:9bff:fee4::123 :::* 548/ntpd udp6 0 0 fe80::f816:3eff:fe5:123 :::* 548/ntpd udp6 0 0 ::1:123 :::* 548/ntpd udp6 0 0 :::123 :::* 548/ntpd udp6 0 0 :::58458 :::* 621/dhclient ------------------------------------------------- 内核参考配置: ------------------------------------------------- 系统登录用户: root:x:0:0:root:/root:/bin/bash ------------------------------------------------- ssh 配置信息: HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_ecdsa_key HostKey /etc/ssh/ssh_host_ed25519_key SyslogFacility AUTHPRIV AuthorizedKeysFile .ssh/authorized_keys ChallengeResponseAuthentication no GSSAPIAuthentication yes GSSAPICleanupCredentials no UsePAM yes X11Forwarding yes AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE AcceptEnv XMODIFIERS Subsystem sftp /usr/libexec/openssh/sftp-server PermitRootLogin yes PasswordAuthentication yes UseDNS no ------------------------------------------------- sudo 配置用户: root ALL=(ALL) ALL %wheel ALL=(ALL) ALL ------------------------------------------------- 定时任务配置: ------------------------------------------------- hosts 信息: ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 127.0.0.1 localhost localhost 127.0.0.1 ecs-kc1-large-2-linux-20191111131638 ecs-kc1-large-2-linux-20191111131638 ------------------------------------------------- CPU占用top10: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 9536 8192 4224 S 0.0 0.2 0:02.49 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H 6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq 7 root 20 0 0 0 0 S 0.0 0.0 0:00.12 ksoftirqd/0 8 root 20 0 0 0 0 I 0.0 0.0 0:19.98 rcu_sched 9 root 20 0 0 0 0 I 0.0 0.0 0:00.00 rcu_bh 10 root rt 0 0 0 0 S 0.0 0.0 0:00.02 migration/0 11 root rt 0 0 0 0 S 0.0 0.0 0:00.14 watchdog/0 12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0 内存占用top10: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 9536 8192 4224 S 0.0 0.2 0:02.49 systemd 8 root 20 0 0 0 0 I 0.0 0.0 0:19.98 rcu_sched 11 root rt 0 0 0 0 S 0.0 0.0 0:00.14 watchdog/0 7 root 20 0 0 0 0 S 0.0 0.0 0:00.12 ksoftirqd/0 10 root rt 0 0 0 0 S 0.0 0.0 0:00.02 migration/0 9 root 20 0 0 0 0 I 0.0 0.0 0:00.00 rcu_bh 6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq 4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
鲲鹏
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。