added 'agentsize' console command
Bryan Roe committed
Jan 7, 2020 at 09:51 UTC
c1e658e6c88830a4ee40d041b0d63c1256257917
1 file changed
+37
-1
agents/meshcore.js
+37
-1
@@ -1941,7 +1941,7 @@ function createMeshCore(agent) {
1941
var response = null;
1942
switch (cmd) {
1943
case 'help': { // Displays available commands
1944
- var fin = '', f = '', availcommands = 'version,help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,amt,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,amtreset,amtccm,amtacm,amtdeactivate,amtpolicy,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,scanamt,wallpaper';
1944
+ var fin = '', f = '', availcommands = 'agentsize,version,help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,amt,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,amtreset,amtccm,amtacm,amtdeactivate,amtpolicy,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,scanamt,wallpaper';
1945
if (process.platform == 'win32') { availcommands += ',safemode,wpfhwacceleration'; }
1946
availcommands = availcommands.split(',').sort();
1947
while (availcommands.length > 0) {
@@ -1952,6 +1952,42 @@ function createMeshCore(agent) {
1952
response = 'Available commands: \r\n' + fin + '.';
1953
break;
1954
}
1955
+ case 'agentsize':
1956
+ var actualSize = require('fs').statSync(process.execPath).size / 1024;
1957
+ if (process.platform == 'win32')
1958
+ {
1959
+ // Check the Agent Uninstall MetaData for correctness, as the installer may have written an incorrect value
1960
+ var writtenSize = 0;
1961
+ try
1962
+ {
1963
+ writtenSize = require('win-registry').QueryKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeshCentralAgent', 'EstimatedSize');
1964
+ }
1965
+ catch (x)
1966
+ {
1967
+ response = x;
1968
+ }
1969
+ if (writtenSize != actualSize)
1970
+ {
1971
+ response = 'Size updated from: ' + writtenSize + ' to: ' + actualSize;
1972
+ try
1973
+ {
1974
+ require('win-registry').WriteKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeshCentralAgent', 'EstimatedSize', actualSize);
1975
+ }
1976
+ catch (x2)
1977
+ {
1978
+ response = x2;
1979
+ }
1980
+ }
1981
+ else
1982
+ {
1983
+ response = 'Agent Size: ' + actualSize + ' kb';
1984
+ }
1985
+ }
1986
+ else
1987
+ {
1988
+ response = 'Agent Size: ' + actualSize + ' kb';
1989
+ }
1990
+ break;
1991
case 'version':
1992
response = 'Mesh Agent Version: ' + process.versions.meshAgent;
1993
break;