node.js - How can I get top command output in real time in Mac Os -
i want monitor server , show top command output in real time on webpage. there error error: initializing curses
after program started on mac os. don't know how deal it, question how top command output in real time via node.js?
var spawn = require('child_process').spawn, com = spawn('/usr/bin/top', []); var io = require('socket.io').listen(5555); com.stdout.on('data', function(data){ io.sockets.emit('get result', data); } ); com.stderr.on('data', function(data){ console.log('stderr: ' + data); });
if run top
in command window, updates data on screen, using curses library. try using batch-mode '-b' option on top see if that'll allow node pipe output your
Comments
Post a Comment