/// <summary> /// 日志文件分析 /// </summary> public static void LogFileAnalyse() { List <string> all_log = GetAllLogFile(); List <string> expire_log = GetExpireLogFile(all_log, out long allSize, out long expireSize); int all_log_count = Ls.Ok(all_log) ? all_log.Count : 0; int expire_log_count = Ls.Ok(expire_log) ? expire_log.Count : 0; R.SystemStatus.AllLogCount = all_log_count; R.SystemStatus.AllLogSize = (long)ByteConvertTool.Cvt(allSize, "KB"); R.SystemStatus.ExpireLogCount = expire_log_count; R.SystemStatus.ExpireLogSize = (long)ByteConvertTool.Cvt(expireSize, "KB"); //R.Log.I($"全部日志文件:{all_log_count} 个, 共计:{ByteConvertTool.Cvt(allSize, "GB")} GB"); //R.Log.I($"过期日志文件:{expire_log_count} 个, 共计:{ByteConvertTool.Cvt(expireSize, "GB")} GB"); }
/// <summary> /// 1分钟任务 /// </summary> public static void Do() { R.SystemStatus.DriveTotal = DriveTool.GetDriveTotalSize(R.Paths.App); R.SystemStatus.DriveAvail = DriveTool.GetDriveAvailableSize(R.Paths.App); LogCleaner.LogFileAnalyse(); R.Log.I($"全部日志文件:{R.SystemStatus.AllLogCount} 个, 共计:{ByteConvertTool.Cvt(R.SystemStatus.AllLogSize, "MB")} GB"); R.Log.I($"过期日志文件:{R.SystemStatus.ExpireLogCount} 个, 共计:{ByteConvertTool.Cvt(R.SystemStatus.ExpireLogSize, "MB")} GB"); //string toMail = "*****@*****.**"; //string subject = $"服务器状态报表:日报:{DateTime.Now.ToString("yyyy年MM月dd日")}"; //string emailBody = "测试内容"; //EmailTool et = new EmailTool( // "*****@*****.**", // toMail, subject, emailBody, // "bigbird_server","bigbird528"); //et.Send(); }
/// <summary> /// 获取文件大小(根据单位换算) /// </summary> /// <param name="fileName"></param> /// <param name="unit">B,KB,MB,GB</param> /// <returns></returns> public static double Size(string fileName, string unit) { return(ByteConvertTool.Cvt(Size(fileName), unit)); }