监视客户端系统文件监视 [英] To monitor client system file monitoring

查看:101
本文介绍了监视客户端系统文件监视的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

When 3 clients are connected wtih server. I want to monitor file, after threshold has been setup.

ForExample:
 Threshold is 50% has been set.
Iam monitoring folder name as C:\Newfolder. 
Total Size of NewFolder is 500MB.
When Newfolder reaches 250MB, I want to send notification to IT Team.

How it can be achieved. This is new to me.

I have done this sample in windows service. but we cannot install windows service in N number of client system.





我尝试了什么:





What I have tried:

public void FolderMonitorTimer()
       {
           timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
           timer.Interval = 5000;
           timer.Enabled = true;
       }




<pre>// Get current system File monitor




static long DirectorySize12(DirectoryInfo dInfo, bool includeSubDir)
      {
          // Enumerate all the files
          long totalSize = dInfo.EnumerateFiles()
                       .Sum(file => file.Length);

          // If Subdirectories are to be included
          if (includeSubDir)
          {
              // Enumerate all sub-directories
              totalSize += dInfo.EnumerateDirectories()
                       .Sum(dir => DirectorySize12(dir, true));
          }
          return totalSize;
      }







private void OnElapsedTime(object source, ElapsedEventArgs e)
     {
         DirectoryInfo dInfo = new DirectoryInfo(FolderPath);

         long sizeOfDir = DirectorySize12(dInfo, true);


         usedSizeMB = ((double)sizeOfDir) / (1024 * 1024);
         availSizeMB = strDiskDefaultSize - usedSizeMB;
         availPercent = availSizeMB / strDiskDefaultSize * 100;
         UsedPercent = usedSizeMB / strDiskDefaultSize * 100;
         timer.Interval = 1000;
         WarningThreshold= 50;

         if ((Convert.ToInt32(UsedPercent) > Convert.ToInt32(WarningThreshold)))
         {
             //Send notification to IT Team

         }

推荐答案

作为 NotPoliticallyCorrect [ ^ ]提到,你不会从网上监控任何东西。

只有一个实现这一目标的方法:在客户端计算机上安装Windows服务。

另一方面,网上有大量可用的脚本,可以运行扫描客户端计算机(IT团队的角度)来了解如何空间 C:\ NewFolder 占用。
As NotPoliticallyCorrect[^] mentioned, "You are not going to monitor anything from the web."
There is only one way to achieve that: install Windows service on client computers.
On the other hand, there's tons of scripts available on net, which can be run to scan client computers (IT team perspective) to find out how much space C:\NewFolder occupied.


这篇关于监视客户端系统文件监视的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆