From 42da3ecfc188452d58b20517dd580362da612873 Mon Sep 17 00:00:00 2001 From: Joshua Christensen Date: Fri, 30 Aug 2019 08:00:18 -0600 Subject: [PATCH] Feature/DEV-447_gpu_data_in_logs (#140) * ignoring miners * Getting and logging CUDA/GPU data --- packages/desktop-app/src/Ethminer.ts | 1 + packages/desktop-app/src/main.ts | 29 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/packages/desktop-app/src/Ethminer.ts b/packages/desktop-app/src/Ethminer.ts index 46231a314..4e8554eb8 100644 --- a/packages/desktop-app/src/Ethminer.ts +++ b/packages/desktop-app/src/Ethminer.ts @@ -65,6 +65,7 @@ export class Ethminer { let cmd = `cd dist && cd ethminer && ${ this.processName } --farm-recheck 1000 ${platform} -P stratum1+tcp://0x6fF85749ffac2d3A36efA2BC916305433fA93731@eth-us-west1.nanopool.org:9999/${id}/notinuse%40salad.io` + let ls = spawn(cmd, { shell: true, windowsHide: true, diff --git a/packages/desktop-app/src/main.ts b/packages/desktop-app/src/main.ts index 2e69738e6..a95cc9f13 100644 --- a/packages/desktop-app/src/main.ts +++ b/packages/desktop-app/src/main.ts @@ -9,6 +9,8 @@ import { Ethminer } from './Ethminer' import { MachineInfo } from './models/MachineInfo' import { autoUpdater } from 'electron-updater' import { Logger } from './Logger' +import { exec } from 'child_process' +import * as fs from 'fs' //Overrides the console.log behavior Logger.connect() @@ -261,6 +263,8 @@ const onReady = () => { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }) onlineStatusWindow.loadURL(`file://${__dirname}/online-status.html`) + getCudaData() + ipcMain.on('online-status-changed', (_: any, status: boolean) => { onlineStatus = status console.log('Online status updated: ' + status) @@ -276,6 +280,31 @@ const onReady = () => { }) } +const getCudaData = () => { + const System32Path = 'C:\\Windows\\System32' + const ProgramFilesPath = 'C:\\Program Files\\NVIDIA Corporation\\NVSMI' + let path: string | undefined = undefined + + // TODO: Possibly need to find where other sources of nvidia-smi.exe live + // if it's not in the current directories. + if (fs.existsSync(`${System32Path}\\nvidia-smi.exe`)) { + path = System32Path + } else if (fs.existsSync(`${ProgramFilesPath}\\nvidia-smi.exe`)) { + path = ProgramFilesPath + } else { + return + } + + // Useful nvidia-smi Queries: https://nvidia.custhelp.com/app/answers/detail/a_id/3751/~/useful-nvidia-smi-queries + const query_gpu = '--query-gpu=name,temperature.gpu,utilization.gpu,utilization.memory,driver_version' + const cmd = `nvidia-smi.exe ${query_gpu} --format=csv` + + exec(cmd, { cwd: path }, (error, data) => { + console.log('cuda error: ', error) + console.log('cuda data: ', data) + }) +} + checkForMultipleInstance() app.on('ready', () => onReady())