benoitgauthier / diskinfo Goto Github PK
View Code? Open in Web Editor NEWnodejs module to get disk information
License: MIT License
nodejs module to get disk information
License: MIT License
I tryed this under windows machine and works perfectly, on mac npm don't let me install.
So I downloaded the lib and runned under mac and it works with some imprecisions, so adding macOS support can be possible if you want.
Example:
const diskinfo = require('diskinfo');
setInterval(function(){
diskinfo.getDrives(function(err, aDrives) {
if(!err){
console.log(aDrives)
}
});
},2000)
/output of the console.log after repeat twice
[ { filesystem: '/dev/mapper/vg_root-LogVol01',
blocks: '36819652',
used: '28908684',
available: '6033976',
capacity: '83%',
mounted: '/' },
{ filesystem: 'tmpfs',
blocks: '16441032',
used: '28964',
available: '16412068',
capacity: '1%',
mounted: '/dev/shm' } ]
[ { filesystem: '/dev/mapper/vg_root-LogVol01',
blocks: '36819652',
used: '28908684',
available: '6033976',
capacity: '83%',
mounted: '/' },
{ filesystem: 'tmpfs',
blocks: '16441032',
used: '28964',
available: '16412068',
capacity: '1%',
mounted: '/dev/shm' },
{ filesystem: '/dev/mapper/vg_root-LogVol01',
blocks: '36819652',
used: '28908684',
available: '6033976',
capacity: '83%',
mounted: '/' },
{ filesystem: 'tmpfs',
blocks: '16441032',
used: '28964',
available: '16412068',
capacity: '1%',
mounted: '/dev/shm' } ]
The module always returns the same value, even when the size on disk has changed.
Example:
var d = require('diskinfo');
var interval = setTimeout(du, 2500);
function du () {
d.getDrives(function (error, result){
console.log(result);
});
interval = setTimeout(du, 2500)
}
function stopinterval() {
clearTimeout(interval);
}
/output of the console.log
[ { filesystem: '/dev/loop0',
blocks: '2519792',
used: '2215180',
available: '176612',
capacity: '93%',
mounted: '/' },
{ filesystem: '/dev/block/vold/259:3',
blocks: '12063840',
used: '10099392',
available: '1964448',
capacity: '84%',
mounted: '/mnt/sdcard0' } ]
[ { filesystem: '/dev/loop0',
blocks: '2519792',
used: '2215180',
available: '176612',
capacity: '93%',
mounted: '/' },
{ filesystem: '/dev/block/vold/259:3',
blocks: '12063840',
used: '10099392',
available: '1964448',
capacity: '84%',
mounted: '/mnt/sdcard0' } ]
When i call getDrives multiple times (on Windows) i get duplicated entries inside that array.
The cause seems to be multiple calls of getDrives, before one call ends.
Best regards
Michael
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.