check-system-info/sbin/get_sys_info.sh

42 lines
958 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
#set -x
#uagent路径地址
uagent_dir=/agent/ubackup/uagent/logs/
#创建存放的目录
report_dir="/opt/sys-info/"
mkdir -p $report_dir
IP=`hostname -I|awk '{print $1}'`
#按周创建文件,一周一个
week_number=`date +%V`
filename=${IP}-ComputerInfos-week-${week_number}.txt
file_path=$report_dir/$filename
#输出需要的信息
now=$(date +"%Y-%m-%d %H:%M:%S")
echo "-------------------------------------------" >> $file_path
echo "当前时间:$now" >> $file_path
echo "当前地址:$IP" >> $file_path
# CPU
echo "" >> $file_path
echo "内存信息:">> $file_path
free -h >> $file_path
# uagent_dir的日志大小
echo "" >> $file_path
echo "uagent日志大小">> $file_path
du -h $uagent_dir >> $file_path
# 磁盘空间使用情况
echo "" >> $file_path
echo "磁盘空间使用情况:">> $file_path
df -h >> $file_path
echo "" >> $file_path
echo "-------------------------------------------" >> $file_path