Index: include/strEx.h
===================================================================
--- include/strEx.h	(revision a0528c483134d88636eb730b911145853b46c5af)
+++ include/strEx.h	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -22,6 +22,30 @@
 		return ss.str();
 	}
-	inline stoi(std::string s) {
+	inline int stoi(std::string s) {
 		return atoi(s.c_str());
+	}
+	inline long long stoi64_as_BKMG(std::string s) {
+		std::string::size_type p = s.find_first_of("BMKG");
+		if (p == std::string::npos)
+			return _atoi64(s.c_str());
+		else if (s[p] == 'B') 
+			return _atoi64(s.c_str());
+		else if (s[p] == 'K') 
+			return _atoi64(s.c_str())*1024;
+		else if (s[p] == 'M') 
+			return _atoi64(s.c_str())*1024*1024;
+		else if (s[p] == 'G') 
+			return _atoi64(s.c_str())*1024*1024*1024;
+		else
+			return _atoi64(s.c_str());
+	}
+	inline std::string itos_as_BKMG(long long i) {
+		if (i > (1024*1024*1024))
+			return itos(i/(1024*1024*1024))+"G (" + itos(i) + "B)";
+		if (i > (1024*1024))
+			return itos(i/(1024*1024))+"M (" + itos(i) + "B)";
+		if (i > (1024))
+			return itos(i/(1024))+"K (" + itos(i) + "B)";
+		return itos(i>>24)+"B";
 	}
 	inline std::pair<std::string,std::string> split(std::string str, std::string key) {
Index: modules/CheckDisk/CheckDisk.cpp
===================================================================
--- modules/CheckDisk/CheckDisk.cpp	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
+++ modules/CheckDisk/CheckDisk.cpp	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -0,0 +1,121 @@
+// CheckEventLog.cpp : Defines the entry point for the DLL application.
+//
+
+#include "stdafx.h"
+#include "CheckDisk.h"
+#include <strEx.h>
+#include <time.h>
+
+CheckDisk gCheckDisk;
+
+BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
+{
+	NSCModuleWrapper::wrapDllMain(hModule, ul_reason_for_call);
+	return TRUE;
+}
+
+CheckDisk::CheckDisk() {
+}
+CheckDisk::~CheckDisk() {
+}
+
+
+bool CheckDisk::loadModule() {
+	return true;
+}
+bool CheckDisk::unloadModule() {
+	return true;
+}
+
+std::string CheckDisk::getModuleName() {
+	return "CheckDisk Various Disk related checks.";
+}
+NSCModuleWrapper::module_version CheckDisk::getModuleVersion() {
+	NSCModuleWrapper::module_version version = {0, 0, 1 };
+	return version;
+}
+
+bool CheckDisk::hasCommandHandler() {
+	return true;
+}
+bool CheckDisk::hasMessageHandler() {
+	return false;
+}
+
+typedef std::unary_function<const WIN32_FIND_DATA&, bool> baseClass;
+struct GetSize : public baseClass
+{
+	GetSize() : size(0) { }
+	result_type operator()(argument_type wfd) {
+		if (!(wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) {
+			size += (wfd.nFileSizeHigh * ((long long)MAXDWORD+1)) + (long long)wfd.nFileSizeLow;
+			NSC_LOG_ERROR_STD(wfd.cFileName + ": " + strEx::itos((wfd.nFileSizeHigh * ((long long)MAXDWORD+1)) + (long long)wfd.nFileSizeLow) + " --- " + strEx::itos(size));
+		}
+		return true;
+	}
+	inline long long getSize() {
+		return size;
+	}
+private:  
+	long long size;
+};
+
+void RecursiveScanDirectory(std::string dir, GetSize & f) {
+	std::string baseDir;
+	std::string::size_type pos = dir.find_last_of('\\');
+	if (pos == std::string::npos)
+		return;
+	baseDir = dir.substr(0, pos);
+
+	WIN32_FIND_DATA wfd;
+	HANDLE hFind = FindFirstFile(dir.c_str(), &wfd);
+	if (hFind != INVALID_HANDLE_VALUE) {
+		do {
+			if (!f(wfd))
+				break;
+			if ((wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
+				if ( (strcmp(wfd.cFileName, ".") != 0) && (strcmp(wfd.cFileName, "..") != 0) )
+					RecursiveScanDirectory(baseDir + "\\" + wfd.cFileName + "\\*.*", f);
+			}
+		} while (FindNextFile(hFind, &wfd));
+	}
+	FindClose(hFind);
+}
+
+
+// CheckDirectorySize&<Directory>&<Directory>...
+// request: CheckDirectorySize&<warning>&<max>&<Directory>&<Directory>...
+// Return: <return state>&<return string>...
+// <return state>	0 - No errors
+//					1 - Unknown
+//					2 - Errors
+// <return string>	<directory> <size mb> ...
+// test: CheckDirectorySize&1024M&4096M&c:\WINDOWS\*.*
+//       CheckDirectorySize
+#define BUFFER_SIZE 1024*64
+
+std::string CheckDisk::handleCommand(const std::string command, const unsigned int argLen, char **char_args) {
+	std::string ret;
+	if (command == "CheckDirectorySize") {
+		std::list<std::string> args = NSCHelper::makelist(argLen, char_args);
+		if (args.size() < 3)
+			return "Missing argument(s)." + strEx::itos((int)args.size());
+		int iWarn = strEx::stoi64_as_BKMG(args.front()); args.pop_front();
+		int iMax = strEx::stoi64_as_BKMG(args.front()); args.pop_front();
+
+		std::list<std::string>::const_iterator cit;
+		for (cit=args.begin();cit!=args.end();++cit) {
+			GetSize size;
+			RecursiveScanDirectory(*cit, size);
+			if (!ret.empty())
+				ret += ", ";
+			ret += (*cit) + ": " + strEx::itos_as_BKMG(size.getSize());
+		}
+	}
+	return ret;
+}
+
+
+NSC_WRAPPERS_MAIN_DEF(gCheckDisk);
+NSC_WRAPPERS_IGNORE_MSG_DEF();
+NSC_WRAPPERS_HANDLE_CMD_DEF(gCheckDisk);
Index: modules/CheckDisk/CheckDisk.def
===================================================================
--- modules/CheckDisk/CheckDisk.def	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
+++ modules/CheckDisk/CheckDisk.def	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -0,0 +1,13 @@
+LIBRARY	NSClientCompat
+
+EXPORTS
+	NSModuleHelperInit
+	NSLoadModule
+	NSGetModuleName
+	NSGetModuleVersion
+	NSHasCommandHandler
+	NSHasMessageHandler
+	NSHandleMessage
+	NSHandleCommand
+	NSUnloadModule
+
Index: modules/CheckDisk/CheckDisk.h
===================================================================
--- modules/CheckDisk/CheckDisk.h	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
+++ modules/CheckDisk/CheckDisk.h	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -0,0 +1,17 @@
+NSC_WRAPPERS_MAIN();
+
+class CheckDisk {
+private:
+
+public:
+	CheckDisk();
+	virtual ~CheckDisk();
+	// Module calls
+	bool loadModule();
+	bool unloadModule();
+	std::string getModuleName();
+	NSCModuleWrapper::module_version getModuleVersion();
+	bool hasCommandHandler();
+	bool hasMessageHandler();
+	std::string handleCommand(const std::string command, const unsigned int argLen, char **args);
+};
Index: modules/CheckDisk/CheckDisk.vcproj
===================================================================
--- modules/CheckDisk/CheckDisk.vcproj	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
+++ modules/CheckDisk/CheckDisk.vcproj	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="CheckDisk"
+	ProjectGUID="{E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CHECKDISK_EXPORTS"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="3"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/CheckDisk.dll"
+				LinkIncremental="2"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/CheckDisk.pdb"
+				SubSystem="2"
+				ImportLibrary="$(OutDir)/CheckDisk.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="../include;../../include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_STLP_USE_STATIC_LIB;SYSTRAY_EXPORTS"
+				RuntimeLibrary="0"
+				UsePrecompiledHeader="3"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="../../Release/modules/$(ProjectName).dll"
+				LinkIncremental="1"
+				ModuleDefinitionFile="CheckDisk.def"
+				GenerateDebugInformation="TRUE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/CheckDisk.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath=".\CheckDisk.cpp">
+			</File>
+			<File
+				RelativePath="..\..\include\NSCHelper.cpp">
+			</File>
+			<File
+				RelativePath=".\stdafx.cpp">
+				<FileConfiguration
+					Name="Debug|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+			<File
+				RelativePath=".\CheckDisk.h">
+			</File>
+			<File
+				RelativePath="..\..\include\NSCHelper.h">
+			</File>
+			<File
+				RelativePath=".\stdafx.h">
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt">
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: modules/CheckDisk/stdafx.cpp
===================================================================
--- modules/CheckDisk/stdafx.cpp	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
+++ modules/CheckDisk/stdafx.cpp	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// CheckDisk.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
Index: modules/CheckDisk/stdafx.h
===================================================================
--- modules/CheckDisk/stdafx.h	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
+++ modules/CheckDisk/stdafx.h	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -0,0 +1,17 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+
+#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+
+#include <string>
+#include <functional>
+
+#include <NSCAPI.h>
+#include <NSCHelper.h>
Index: modules/CheckEventLog/stdafx.h
===================================================================
--- modules/CheckEventLog/stdafx.h	(revision a0528c483134d88636eb730b911145853b46c5af)
+++ modules/CheckEventLog/stdafx.h	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -13,4 +13,5 @@
 #include <string>
 
+
 #include <NSCAPI.h>
 #include <NSCHelper.h>
Index: modules/NSClientCompat/NSClientCompat.vcproj
===================================================================
--- modules/NSClientCompat/NSClientCompat.vcproj	(revision a0528c483134d88636eb730b911145853b46c5af)
+++ modules/NSClientCompat/NSClientCompat.vcproj	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -163,7 +163,4 @@
 			</File>
 			<File
-				RelativePath="..\include\ModuleHelper.h">
-			</File>
-			<File
 				RelativePath="..\..\include\NSCHelper.h">
 			</File>
@@ -178,8 +175,5 @@
 			</File>
 			<File
-				RelativePath="..\include\PDHCollectors.h">
-			</File>
-			<File
-				RelativePath="..\include\PDHCounter.h">
+				RelativePath="..\..\include\PDHCollectors.h">
 			</File>
 			<File
Index: modules/NSClientCompat/PDHCollector.cpp
===================================================================
--- modules/NSClientCompat/PDHCollector.cpp	(revision a0528c483134d88636eb730b911145853b46c5af)
+++ modules/NSClientCompat/PDHCollector.cpp	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -20,4 +20,11 @@
 #include "stdafx.h"
 #include "PDHCollector.h"
+
+
+PDHCollector::PDHCollector() : cpu(BACK_INTERVAL*60/CHECK_INTERVAL), running_(true) {
+}
+PDHCollector::~PDHCollector() 
+{
+}
 
 /**
Index: modules/NSClientCompat/PDHCollector.h
===================================================================
--- modules/NSClientCompat/PDHCollector.h	(revision a0528c483134d88636eb730b911145853b46c5af)
+++ modules/NSClientCompat/PDHCollector.h	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -35,6 +35,6 @@
 
 public:
-	PDHCollector() : cpu(BACK_INTERVAL*60/CHECK_INTERVAL), running_(true) {
-	}
+	PDHCollector();
+	virtual ~PDHCollector();
 	DWORD threadProc(LPVOID lpParameter);
 	void exitThread(void);
Index: modules/SysTray/TrayIcon.cpp
===================================================================
--- modules/SysTray/TrayIcon.cpp	(revision 3baaa4d3627b8f5e6d8466f15be1b88da4de6cef)
+++ modules/SysTray/TrayIcon.cpp	(revision a1e1922ecabccca654b13caa1b4e56813067982a)
@@ -116,4 +116,5 @@
 		} 
 	}
+	removeIcon();
 
 	::DestroyWindow(ghDlgWnd);
