From e67aa92d56c818176335cf867d5465614617730c Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Mon, 4 Jan 2021 07:35:58 +0100 Subject: [PATCH] graphics() nvidia-smi detection improved --- CHANGELOG.md | 1 + LICENSE | 2 +- README.md | 2 +- docs/history.html | 5 +++++ docs/index.html | 2 +- lib/battery.js | 2 +- lib/cli.js | 5 +++++ lib/cpu.js | 2 +- lib/docker.js | 2 +- lib/dockerSocket.js | 2 +- lib/filesystem.js | 2 +- lib/graphics.js | 16 ++++++++++------ lib/index.js | 2 +- lib/internet.js | 2 +- lib/memory.js | 2 +- lib/network.js | 2 +- lib/osinfo.js | 2 +- lib/processes.js | 2 +- lib/system.js | 2 +- lib/users.js | 2 +- lib/util.js | 2 +- lib/virtualbox.js | 2 +- lib/wifi.js | 2 +- 23 files changed, 40 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e765e90..39ca1bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.33.7 | 2020-01-04 | `graphics()` nvidia-smi detection improved | | 4.33.6 | 2021-01-02 | `dockerContainerStats()` fix `tx` changed to `wx` as documented | | 4.33.5 | 2020-12-30 | `graphics()` vram (nvidia-smi) | | 4.33.4 | 2020-12-28 | `typescript` typings fix | diff --git a/LICENSE b/LICENSE index 87ed830..72cc9fe 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2020 Sebastian Hildebrandt +Copyright (c) 2014-2021 Sebastian Hildebrandt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 3710adf..65a701d 100644 --- a/README.md +++ b/README.md @@ -851,7 +851,7 @@ All other trademarks are the property of their respective owners. >The [`MIT`][license-url] License (MIT) > ->Copyright © 2014-2020 Sebastian Hildebrandt, [+innovations](http://www.plus-innovations.com). +>Copyright © 2014-2021 Sebastian Hildebrandt, [+innovations](http://www.plus-innovations.com). > >Permission is hereby granted, free of charge, to any person obtaining a copy >of this software and associated documentation files (the "Software"), to deal diff --git a/docs/history.html b/docs/history.html index b4e7982..a590830 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.33.7 + 2020-01-04 + graphics() nvidia-smi detection improved + 4.33.6 2021-01-02 diff --git a/docs/index.html b/docs/index.html index f96886b..56ebbd9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -169,7 +169,7 @@
systeminformation
-
Current Version: 4.33.6
+
Current Version: 4.33.7
diff --git a/lib/battery.js b/lib/battery.js index 48a7248..d211924 100644 --- a/lib/battery.js +++ b/lib/battery.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/cli.js b/lib/cli.js index 30bdd5b..1e92ce4 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -5,6 +5,11 @@ // ================================================================================== // cli.js // ---------------------------------------------------------------------------------- +// Description: System Information - library +// for Node.js +// Copyright: (c) 2014 - 2021 +// Author: Sebastian Hildebrandt +// ---------------------------------------------------------------------------------- // License: MIT // ================================================================================== diff --git a/lib/cpu.js b/lib/cpu.js index 2e23e35..345d1ae 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/docker.js b/lib/docker.js index 5f1f045..6251d87 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/dockerSocket.js b/lib/dockerSocket.js index 704050a..86c68d4 100644 --- a/lib/dockerSocket.js +++ b/lib/dockerSocket.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/filesystem.js b/lib/filesystem.js index edcc0e0..8e1cbdf 100755 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/graphics.js b/lib/graphics.js index 46a9235..8363268 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT @@ -378,11 +378,15 @@ function graphics(callback) { if (_windows) { try { const basePath = util.WINDIR + '\\System32\\DriverStore\\FileRepository'; - const dirContent = fs.readdirSync(basePath); - const candidateDirs = dirContent.filter(dir => dir.startsWith('nv')); - const targetDir = candidateDirs.find(dir => { - const content = fs.readdirSync([basePath, dir].join('/')); - return content.includes('nvidia-smi.exe'); + // find all directories that have an nvidia-smi.exe file + const candidateDirs = fs.readdirSync(basePath).filter(dir => { + return fs.readdirSync([basePath, dir].join('/')).includes('nvidia-smi.exe'); + }); + // use the directory with the most recently created nvidia-smi.exe file + const targetDir = candidateDirs.reduce((prevDir, currentDir) => { + const previousNvidiaSmi = fs.statSync([basePath, prevDir, 'nvidia-smi.exe'].join('/')); + const currentNvidiaSmi = fs.statSync([basePath, currentDir, 'nvidia-smi.exe'].join('/')); + return (previousNvidiaSmi.ctimeMs > currentNvidiaSmi.ctimeMs) ? prevDir : currentDir; }); if (targetDir) { diff --git a/lib/index.js b/lib/index.js index 3c77372..8f22129 100755 --- a/lib/index.js +++ b/lib/index.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // Contributors: Guillaume Legrain (https://github.com/glegrain) diff --git a/lib/internet.js b/lib/internet.js index 30c2e12..1360204 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/memory.js b/lib/memory.js index ac662b0..5afe5fa 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/network.js b/lib/network.js index 3d3ed96..85f1fcc 100644 --- a/lib/network.js +++ b/lib/network.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/osinfo.js b/lib/osinfo.js index c1ffdd2..e90a769 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/processes.js b/lib/processes.js index b558990..857905f 100644 --- a/lib/processes.js +++ b/lib/processes.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/system.js b/lib/system.js index db66f16..19bda21 100644 --- a/lib/system.js +++ b/lib/system.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/users.js b/lib/users.js index a1589a4..32cced8 100644 --- a/lib/users.js +++ b/lib/users.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/util.js b/lib/util.js index 3a9b51f..5a2e772 100644 --- a/lib/util.js +++ b/lib/util.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/virtualbox.js b/lib/virtualbox.js index 958ef6b..3138c8d 100644 --- a/lib/virtualbox.js +++ b/lib/virtualbox.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT diff --git a/lib/wifi.js b/lib/wifi.js index c5ec608..997ab46 100644 --- a/lib/wifi.js +++ b/lib/wifi.js @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------------- // Description: System Information - library // for Node.js -// Copyright: (c) 2014 - 2020 +// Copyright: (c) 2014 - 2021 // Author: Sebastian Hildebrandt // ---------------------------------------------------------------------------------- // License: MIT