From bfebb8d8b9c3c984866d3023734f3e624847b847 Mon Sep 17 00:00:00 2001 From: "Erdem U. Altinyurt" Date: Sun, 6 Jan 2019 18:51:19 +0300 Subject: [PATCH] Addition of custom SmartCtl quert for NVME devices. --- .../smartctlUtil.js | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 freon@UshakovVasilii_Github.yahoo.com/smartctlUtil.js diff --git a/freon@UshakovVasilii_Github.yahoo.com/smartctlUtil.js b/freon@UshakovVasilii_Github.yahoo.com/smartctlUtil.js new file mode 100644 index 0000000..351e108 --- /dev/null +++ b/freon@UshakovVasilii_Github.yahoo.com/smartctlUtil.js @@ -0,0 +1,52 @@ +const Lang = imports.lang; +const GLib = imports.gi.GLib; + +const Me = imports.misc.extensionUtils.getCurrentExtension(); +const CommandLineUtil = Me.imports.commandLineUtil; + +var smartctlUtil = new Lang.Class({ + Name: 'smartctlUtil', + Extends: CommandLineUtil.CommandLineUtil, + + _init: function() { + this.parent(); + let path = GLib.find_program_in_path('smartctl'); + this._argv = path ? [path, '-x', '/dev/nvme0'] : null; + }, + + get temp() { + if(!this._output) + return []; + + let smartctlOutput = []; + smartctlOutput = this._output; + + let sensors = []; + + let slabel="Temperature Sensor"; + for (let line of smartctlOutput) { + let matchModel = /Model Number:/.exec( line.toString() ); + if(matchModel){ + let sline=line.split(/\s+/); + slabel=sline.slice(2).join(" "); + } + //let line = "Temperature Sensor 1: 37 Celsius" + let match = /Temperature Sensor \d: *\w\d Celsius/.exec( line.toString() ); + //let match = /Use smartctl.*/.exec( line.toString() ); + //let match = /.*\[Temperature Sensor \d: .*\d Celcius.*/.exec(line.toString()); + if(match){ + let sline=line.split(/\s+/); + let sensor = { label: slabel+" "+sline[2][0], temp: parseFloat(sline[3]) }; + sensors.push(sensor); + } + } + return sensors; + + }, + + get available(){ + return true; + }, + +}); +