diff --git a/Document/使用方法.docx b/Document/使用方法.docx new file mode 100644 index 0000000..1efa56f Binary files /dev/null and b/Document/使用方法.docx differ diff --git a/sbin/SendCheckBackupReport.py b/sbin/SendCheckBackupReport.py deleted file mode 100644 index daed274..0000000 --- a/sbin/SendCheckBackupReport.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- -import smtplib -import subprocess -import shutil -import os - -from email.mime.text import MIMEText -from email.header import Header -from email.mime.multipart import MIMEMultipart -from datetime import datetime - -""" -执行备份集检查,将检查结果发送邮件 - -使用方法: - 1.先手动确认backupCheckTool.jar运行无问题 - 2.将本脚本和backupCheckTool.jar放在同一个目录中 - 3.修改邮箱的收发件人地址 - 4.执行脚本 - -""" - - - -#公共的 -now=os.path.dirname(os.path.abspath(__file__)) -week = str(datetime.now().isocalendar()[1]) - -file_path=os.path.join(now,"report.txt") -file_name_week="report" + week + ".txt" -file_week_path=os.path.join(now,file_name_week) - -#检查工具 -checktool=os.path.join(now,"backupCheckTool.jar") -if not os.path.exists(checktool): - assert False,u'backupCheckTool.jar not found,please check it!!' - -def send_mail(): - # 发件人 - sender = 'mh@unamail.com' - # 接收邮件,可以发给多人 - receivers = ['mh@unamail.com'] - # 邮件主体 - msg = MIMEMultipart() - # 正文 - #文本内容太多了,不放了。 - #with open(file_path, "r") as f: # 打开文本 - # msgdata = f.read() - msgdata="" - message = "第{0}周,备份集检测已完成,检测内容将附件\n{1}".format( - week, msgdata) - msg.attach(MIMEText(message, 'plain', _charset="utf-8")) - # 发送者 - msg['From'] = Header(sender, 'utf-8') - # 接收者 - msg['To'] = Header(receivers[0], 'utf-8') - # 主题 - subject = '【长期任务】备份集检查-W{0}'.format(week) - msg['Subject'] = Header(subject, 'utf-8') - # 附件信息 - att = MIMEText(open(file_week_path, 'rb').read(), 'base64', 'utf-8') - att["Content-Type"] = 'application/octet-stream' - att["Content-Disposition"] = 'attachment; filename="{}"'.format( - file_name_week) - msg.attach(att) - - try: - smtpObj = smtplib.SMTP('10.10.110.102') - smtpObj.sendmail(sender, receivers, msg.as_string()) - print("邮件发送成功") - except smtplib.SMTPException: - print("Error: 无法发送邮件") - - -def main(): - #删除之前的文件 - if os.path.exists(file_path): - os.remove(file_path) - #运行检查工具 - commdline = ['java', '-jar', '-Dusername=unadba', '-Dpassword=1223Bc@2008', 'backupCheckTool.jar'] - recode=subprocess.call(commdline) - #处理检查结果 - shutil.copy2(file_path,file_week_path) - #发邮件 - send_mail() - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/sbin/check_job_sucessful.sh b/sbin/check_job_sucessful.sh deleted file mode 100644 index bbbf2c4..0000000 --- a/sbin/check_job_sucessful.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -#set -x - -PRG="$0" -while [ -h "$PRG" ]; do - ls=$(ls -ld "$PRG") - link=$(expr "$ls" : '.*-> \(.*\)$') - if expr "$link" : '.*/.*' >/dev/null; then - PRG="$link" - else - PRG=$(dirname "$PRG")/"$link" - fi -done -PRGDIR=$(dirname "$PRG") - -#full path -cd $PRGDIR -ROOT_DIR=$(pwd) -cd - >/dev/null - - -# 加载Python3环境 -if [ -f /opt/rh/rh-python38/enable ]; then - source /opt/rh/rh-python38/enable -fi - - -function check_sucessful -recode=`mysql -uunadba -p1223Bc@2008 unary -e 'select 1-(tb1.n1/tb2.n2) from ( (select sum(number) as n1 from ( select operdesc,count(*) as number from tbl_jobhistory where policyname="长期系统" and compid="bd22ea57feecb5a7f96e67035c204e02" group by operdesc) as tmp1 where tmp1.operdesc like "%失败%") as tb1 right JOIN (select count(*) as n2 from tbl_jobhistory where policyname="长期系统" and compid="bd22ea57feecb5a7f96e67035c204e02") tb2 on 1=1);' | tail -1` - diff --git a/sbin/get_sys_info.bat b/sbin/get_sys_info.bat deleted file mode 100644 index bcfcf6f..0000000 --- a/sbin/get_sys_info.bat +++ /dev/null @@ -1,45 +0,0 @@ -@echo off -echo ʼȡϢԵ...... - -rem logs· -set agentlog="D:\agent\ubackup\uagent\logs" - -rem ļ -for /f "tokens=*" %%i in ('powershell -c "Get-Date -UFormat %%V"') do ( - set vars=%%i -) - -set filename=C:\ComputerInfos_week_%vars%.txt - -echo ǵ:%vars% >>%filename% - - -SET CurrentTime=%date:~0,10% %time:~0,5% -echo ʱ䣺%CurrentTime% >>%filename% - - -rem 鿴ڴʹ -echo 1.ڴʹ>>%filename% -wmic OS get FreePhysicalMemory| findstr /r /v "^$" | more >>%filename% -wmic ComputerSystem get TotalPhysicalMemory| findstr /r /v "^$" |more >>%filename% - -rem 鿴ʹ -echo 2.ʹ>>%filename% - wmic logicaldisk get caption,freespace,size| findstr /r /v "^$"|more >>%filename% - -rem 鿴CPUʹ -echo 3.CPUʹʣ>>%filename% - wmic cpu get loadpercentage| findstr /r /v "^$"|more >>%filename% - - -rem 鿴־ļС -echo 4.־ļ·>>%filename% - -dir %agentlog% >>%filename% - -echo "===================%CurrentTime%ѾȡϵͳϢ================ " >>%filename% - - - - - \ No newline at end of file diff --git a/sbin/get_sys_info.sh b/sbin/get_sys_info.sh deleted file mode 100644 index a4ec9c7..0000000 --- a/sbin/get_sys_info.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/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 -