2016-07-29 168 views
0

Microsoft.Diagnostics.Tracing.TraceEvent库的使用上监控ETW日志可以很容易在local machineETW日志的工作 - 但真的有办法做同样的remote server?这是我如何获得本地机器上感兴趣的事件。真正感兴趣的是,在不同的机器产生事件的情况下,如何实现相同的结果。远程计算机

public LoggingEventArgs ListenForEvent(string eventName, int level, int maxWaitTimeInSec = 30) 
    { 
     if (!(TraceEventSession.IsElevated() ?? false)) 
     {     
      _logger.Error("To turn on ETW events you need to be Administrator."); 
      return null; 
     } 

     LoggingEventArgs result = null; 

     _logger.Info("Creating a '{0}' session", _sessionName); 
     using (var session = new TraceEventSession(_sessionName)) 
     { 
      _timer = ConstructTimerForSession(session, maxWaitTimeInSec); 

      TargetEventReceived += delegate (object sender, LoggingEventArgs e) 
      { 
       //if level is not negative, check for specific level of incoming event. 
       //Otherwise track all levels 
       bool condition = level > 0 ? e.Level == level : true;      
       if (condition) 
       { 
        result = e; 
        StopListeningForEvents(session); 
       } 
      }; 

      AddCallbackForProviderEvent(session, _providerName, eventName); 

      StartListeningForEvents(session, _providerName, _timer); 
     } 
     return result; 
    } 
+0

远程运行通过PSEXEC您CMDLINE工具:https://technet.microsoft.com/en-us/sysinternals/pxexec – magicandre1981

回答

0

这可能不是你在寻找什么,但你最好的选择是使用Semantic Logging Application Block(SLAB)出它安装在远程机器上的代理程序选项。然后,SLAB进程可以将日志写入远程SQL服务器或远程文件。

+0

看起来有希望的,谢谢你的指点这个选项了!肯定会给它一个尝试,虽然我看起来都放弃了这个想法远程机监视器 - 看起来并不像100%有效的事情之一,会做 - 更像是打破三项赛的概念 –