steelbrain / steelbrain/node-ssh
get real time cpu usage of remote server
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Description
hello I am trying to use ssh2 with websocket , so I can get REAL Time cpu usage , this is my code
conn.connect({
host: '127.0.0.1',
port: 22,
username: 'muhammed',
password:"Muhbu2020"
});
conn.on("ready", () => {
routerconnection.usagemonitor.channel.to(namespace).emit('ready_to_get_data');
socket.on("get_live_usage",function(){
conn.exec('cat /proc/stat', (err, stream) => {
if (err) throw err;
stream.on('data', (data) => {
console.log("recieving data");
handleMonitorResponse(routerconnection,router_id,data.toString());
})
});
});
});
actually what isgoing on is when I am emmiting get_live_usage to node js from javascript ,the server start to run a lot of instance and it return a lot of response for one emmit , which making my chart going crazy , did I missed somethings or what , I don't understand ,
this is my client side code
socket.on('live_usage',function (recieved) {
console.log("recieved"+ recieved.load)
getNewSeries(lastDate, {
min: 0,
max: 100
},recieved)
resetData()
chart.updateSeries([{
data: data
}])
});
and this is the getNewSeries function
function getNewSeries(baseval, yrange,recieved) {
console.log(recieved)
var newDate = baseval + TICKINTERVAL;
lastDate = newDate
for(var i = 0; i< data.length - 100; i++) {
// IMPORTANT
// we reset the x and y of the data which is out of drawing area
// to prevent memory leaks
data[i].x = newDate - XAXISRANGE - TICKINTERVAL
data[i].y = 0
console.log("weeeeeeare in for")
}
window['status'+admin_id+nas_id] =0;
cpu = recieved.load
var iowait = recieved.iowait;
$('#iobar').attr('style', "width:" + iowait + "%");
$('#iobar').html(iowait + "%")
$('#cpubar').attr('style', "width:" + cpu + "%");
$('#cpubar').html(cpu + "%")
$('#cpu-usage').html(cpu + "%")
socket.emit('get_live_usage', detail);
data.push({
x: newDate,
y: cpu
})
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Start by reproducing the repeated responses around the connection's ready handler, the get_live_usage event, and the client-side getNewSeries function; clarify whether one client emission should produce exactly one usage response before defining completion criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, typescript
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100