0

I am creating a project for Remote Monitoring Application, that consist of the service to be hosted on the individual machines. The job of the service is to collecct the information regarding CPU usage, memory usage, etc. using WMI. The service executes the scan every 15 seconds using threading. Now I want the services on each machine to be executed at exactly same time. For eg. 8.15, 8.30, 8.45. I have written a simple logix that checks the current second count and makes the thread sleep for the time system reaches the time that falls exactly either at x.15, x.30, x.45 , etc. But implementing this itself does not assure that the value collected by the service via WMI for the same process would be at same time. For eg. CPU Usage for machine 1 and CPU Usage for machine 2 should be collected at same time so that it can be compared at run time. Same goes for other processes and metric values as well.

Any help would be appreciated.

4

2 回答 2

0

你对“完全相同的时间”的容忍度是多少?一秒钟之内?10毫秒?

如果您的系统在同一个 LAN 上并且您的网络延迟很小,那么您可以使用ZeroMQ设置 TCP/IP 发布-订阅系统,以每 15 秒触发一次脉冲,使所有系统拍摄快照。

如果系统分布广泛,那么您可以使用以下方式查询 NTP 服务器: How to Query an NTP Server using C#?

于 2013-03-18T21:45:11.257 回答
0

感谢您的帮助,实际上我得到了这个工作。这里应用的逻辑(由我妻子建议)。我有一个静态集合,并且有 2-3 个不同的线程运行每个线程,使用 WMI 查询从机器中检索不同的值集。现在,此数据收集每 1 秒(此时)发生一次,并插入到静态集合中。现在有另一个线程从集合中获取记录,这些记录是在时间为 15 的倍数的时间插入的。例如。第二个 % 15 = 0。现在这解决了问题。从集合中收集记录后,我从集合中删除当前时间之前收集的所有记录。我不确定这是否是最好的解决方案,但为我工作。

于 2013-03-21T07:00:06.617 回答