0

Is this possible to know via command line the network load on remote linux/windows machine . Like we can get cpu load i.e. cpu is 75% used.

3 Answers 3

1

I can't speak to the Linux piece of the question so much, and I believe the answer you're looking for is going to vary somewhat based on which flavor of Linux you're using.

Here's an answer for the Windows piece done in PowerShell:

$allCounters = Get-Counter -Counter "\Network Adapter(*)\Bytes Total/sec"

foreach ($adapter in $allCounters.CounterSamples) {
    if ($adapter.cookedValue -ne 0) {
        $adapterName = $adapter.InstanceName
        $adapterMax = (Get-Counter "\Network Adapter($adapterName)\Current Bandwidth").CounterSamples.cookedValue
        if ($adapterMax -ne 0) {
            $objResult = New-Object -TypeName psobject -Property @{
                Name = $adapterName
                Load = ($adapter.CookedValue/$adapterMax).ToString("P6")
            }
            $results+=$objResult
        }
    }
}

$results

This will return all of the currently active adapters on the system and calculate their utilization. Bear in mind that what Windows believes the max capacity of the adapter and what is actually true based on environment may not be the same number. If you know the actual bandwidth of the interface you can replace $adapterMax with a constant value instead and calculate against that (in bps).

The 0 check is there on the bandwidth for some adapters (bridges, etc) where Windows doesn't store a bandwidth value. It very much passes traffic, but since it's an aggregate of the bridge members Windows doesn't track the maximum bandwidth.

If you want to check out more for scripted access to performance metrics, look here: MSDN Get-Counter cmdlet You could adapt this same script to grab remote metrics as well pretty easily.

0

For the Linux side of things, you can use the netstat command. Depending on what exactly you want to see, there are a ton of flags you can use. (The man page is very detailed.) (The -s switch provides statistics.)

Example:

[user@host ~]$ netstat -s
Ip:
    Forwarding: 2
    17721 total packets received
    1 with invalid addresses
    0 forwarded
    0 incoming packets discarded
    17702 incoming packets delivered
    16252 requests sent out
    12 outgoing packets dropped
Icmp:
    33 ICMP messages received
    0 input ICMP message failed
    ICMP input histogram:
        destination unreachable: 33
    39 ICMP messages sent
    0 ICMP messages failed
    ICMP output histogram:
        destination unreachable: 39
IcmpMsg:
        InType3: 33
        OutType3: 39
Tcp:
    140 active connection openings
    77 passive connection openings
    6 failed connection attempts
    5 connection resets received
    0 connections established
    17554 segments received
    16134 segments sent out
    16 segments retransmitted
    0 bad segments received
    12 resets sent
Udp:
    88 packets received
    33 packets to unknown port received
    0 packet receive errors
    121 packets sent
    0 receive buffer errors
    0 send buffer errors
UdpLite:
TcpExt:
    112 TCP sockets finished time wait in fast timer
    365 delayed acks sent
    1 delayed acks further delayed because of locked socket
    2086 packets directly queued to recvmsg prequeue
    1310 bytes directly in process context from backlog
    TCPDirectCopyFromPrequeue: 1015476
    9354 packet headers predicted
    773 packet headers predicted and directly queued to user
    1112 acknowledgments not containing data payload received
    4861 predicted acknowledgments
    TCPTimeouts: 24
    5 connections reset due to unexpected data
    2 connections aborted due to timeout
    TCPDeferAcceptDrop: 12
    TCPRcvCoalesce: 2246
    TCPAutoCorking: 7
    TCPOrigDataSent: 6211
    TCPHystartTrainDetect: 4
    TCPHystartTrainCwnd: 65
    TCPKeepAlive: 115
IpExt:
    InMcastPkts: 14
    OutMcastPkts: 16
    InOctets: 52113215
    OutOctets: 26659850
    InMcastOctets: 1882
    OutMcastOctets: 1962
    InNoECTPkts: 33753
0

bmon is probably what you need. It'll display a load of info about every adapter on the system.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .