一、脚本
[root@localhost package]# vim PerformanceData.sh
#!/bin/bash
#****************************************************
#Date: 2020-06-28
#Author: Damon Ye
#FileName: PerformanceData.sh
#Description:The test script
#****************************************************
uptime
free -m
df -h
uname -a
hostnamectl
#lscpu 查看CPU核心数量
[root@localhost package]# ssh root@10.0.0.233 'bash -s' <PerformanceData.sh >>./Information.txt
#ssh允许使用重定向文件中的数据到远程主机上作为输入,之后再将输出信息重定向到本地文件保存。
#bash -s表示从标准输入中读取命令
[root@localhost package]# cat Infomation.txt
11:58:39 up 1:14, 2 users, load average: 0.00, 0.01, 0.05
total used free shared buff/cache available
Mem: 1821 885 423 13 512 718
Swap: 2047 0 2047
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 4.7G 14G 27% /
devtmpfs 896M 0 896M 0% /dev
tmpfs 911M 0 911M 0% /dev/shm
tmpfs 911M 11M 901M 2% /run
tmpfs 911M 0 911M 0% /sys/fs/cgroup
/dev/sda1 297M 148M 149M 50% /boot
tmpfs 183M 32K 183M 1% /run/user/1000
tmpfs 183M 0 183M 0% /run/user/0
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Wed Mar 21 18:14:51 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux
Static hostname: localhost.localdomain
Icon name: computer-vm
Chassis: vm
Machine ID: 115c0614135a4249977db7ffad7565c4
Boot ID: 22b580445e4c48698d58c25e233395ad
Virtualization: vmware
Operating System: Red Hat Enterprise Linux Server 7.5 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.5:GA:server
Kernel: Linux 3.10.0-862.el7.x86_64
Architecture: x86-64