Exemple #1
1
WqlRunner.prototype.query = function(q, callback) {
	wmi.connect(this.server, this.root, function(err, wmi) {
		if (err) {
			this.emit('error', err);

			callback(err);

			return;
		}

		wmi.query(q, function(err, results) {
			if (err) {
				this.emit('error', err);

				callback(err);

				return;
			}

			this.emit('message', results);

			callback(err, results);

			wmi.dispose();
		}.bind(this));
	}.bind(this));

	return this;
};
Exemple #2
0
var Utils = require('util');
var Wmi = require('wmi');

var stats = { processor: 0, memfree: 0, totmem: 0, network: {}, proc: {} };

Wmi.connect(function(err, wmi) {
  setInterval(function () {
      wmi.query("SELECT PercentProcessorTime FROM Win32_PerfFormattedData_Counters_ProcessorInformation WHERE Name ='_Total'", function(err, results) { 
          stats['processor'] = results[0].PercentProcessorTime;
      });
      
  }, 1000);
  setInterval(function () {
      wmi.query("SELECT FreePhysicalMemory,TotalVisibleMemorySize FROM Win32_OperatingSystem", function(err, results) { 
          stats['memfree'] = results[0].FreePhysicalMemory;
          stats['totmem'] = results[0].TotalVisibleMemorySize;
      });
      wmi.query("SELECT Name,BytesReceivedPersec,BytesSentPerSec,PacketsPerSec FROM Win32_PerfRawData_Tcpip_NetworkInterface", function(err, results) {
          stats['network'] = results;
      });
      wmi.query("SELECT ThreadCount,HandleCount,PrivateBytes,WorkingSet,PercentProcessorTime,PageFaultsPerSec,Timestamp_Sys100NS,IDProcess FROM Win32_PerfRawData_PerfProc_Process", function(err, results) {
          stats['proc'] = results;
      });
      
  }, 5000);
});

//
// Create a Router object with an associated routing table
//
var router = new(journey.Router);