get real time cpu usage of remote server

Open
#415 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Domain
backend, web-dev

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.

Description

unconfirmed bug

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
    })
}
Dominant language
TypeScript
Stars
1k
Forks
94
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from steelbrain/node-ssh

All issues in steelbrain/node-ssh

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.