LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem adjusting the output (https://www.linuxquestions.org/questions/linux-newbie-8/problem-adjusting-the-output-882566/)

pinga123 05-25-2011 12:39 AM

Problem adjusting the output
 
Hi i m running a command
Code:

watch -n 1 -d netstat -i
to see the packet drops every 1 second.
but the problem is the output is so long(Due to large number of virtual interfaces) it doesn't fit into the putty prompt.

I dont need to monitor each and every network interface I m more interested in monitoring the interfaces starting from vif but whenever i run following command it doesnt display anything.
Code:

watch -n 3 -d netstat -i | grep vif*
What should i do?

T3RM1NVT0R 05-25-2011 12:55 AM

@ Reply
 
Remove grep from the command and it will work:

watch -n 3 -d netstat -i eth0

lonesoac0 05-25-2011 01:02 AM

I think that you need to include vif* next to netstat. I would try something like: watch -n 3 -d 'netstat -i vif*' I looked up the man of watch (http://linux.die.net/man/1/watch) and in the examples it states: "watch -d 'ls -l | fgrep joe'" the LS is of particular interest because it is a command. So, I am willing to bet you can do it if you place your netstat command in ''.

pinga123 05-25-2011 01:18 AM

Quote:

Originally Posted by lonesoac0 (Post 4366272)
I think that you need to include vif* next to netstat. I would try something like: watch -n 3 -d 'netstat -i vif*' I looked up the man of watch (http://linux.die.net/man/1/watch) and in the examples it states: "watch -d 'ls -l | fgrep joe'" the LS is of particular interest because it is a command. So, I am willing to bet you can do it if you place your netstat command in ''.

The above command is not working as you dont have any option specifying interface name with -i option.
Code:

# netstat -i vif*
usage: netstat [-veenNcCF] [<Af>] -r        netstat {-V|--version|-h|--help}
      netstat [-vnNcaeol] [<Socket> ...]
      netstat { [-veenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s } [delay]

        -r, --route                display routing table
        -I, --interfaces=[<Iface>] display interface table for <Iface>
        -i, --interfaces          display interface table
        -g, --groups              display multicast group memberships
        -s, --statistics          display networking statistics (like SNMP)
        -M, --masquerade          display masqueraded connections

        -v, --verbose              be verbose
        -n, --numeric              don't resolve names
        --numeric-hosts            don't resolve host names
        --numeric-ports            don't resolve port names
        --numeric-users            don't resolve user names
        -N, --symbolic            resolve hardware names
        -e, --extend              display other/more information
        -p, --programs            display PID/Program name for sockets
        -c, --continuous          continuous listing

        -l, --listening            display listening server sockets
        -a, --all, --listening    display all sockets (default: connected)
        -o, --timers              display timers
        -F, --fib                  display Forwarding Information Base (default)
        -C, --cache                display routing cache instead of FIB
        -T, --notrim              stop trimming long addresses
        -Z, --context              display SELinux security context for sockets

  <Iface>: Name of interface to monitor/list.
  <Socket>={-t|--tcp} {-u|--udp} {-S|--sctp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom
  <AF>=Use '-A <af>' or '--<af>'; default: inet
  List of possible address families (which support routing):
    inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)
    netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)
    x25 (CCITT X.25)


T3RM1NVT0R 05-25-2011 01:22 AM

@ Reply
 
Did you try:

watch -n 3 -d netstat -i eth*

it worked for me... check my previous post.

pinga123 05-25-2011 01:23 AM

Quote:

Originally Posted by T3RM1NVT0R (Post 4366266)
Remove grep from the command and it will work:

watch -n 3 -d netstat -i eth0

not valid command.
Code:

# netstat -i eth0
usage: netstat [-veenNcCF] [<Af>] -r        netstat {-V|--version|-h|--help}
      netstat [-vnNcaeol] [<Socket> ...]
      netstat { [-veenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s } [delay]

        -r, --route                display routing table
        -I, --interfaces=[<Iface>] display interface table for <Iface>
        -i, --interfaces          display interface table
        -g, --groups              display multicast group memberships
        -s, --statistics          display networking statistics (like SNMP)
        -M, --masquerade          display masqueraded connections

        -v, --verbose              be verbose
        -n, --numeric              don't resolve names
        --numeric-hosts            don't resolve host names
        --numeric-ports            don't resolve port names
        --numeric-users            don't resolve user names
        -N, --symbolic            resolve hardware names
        -e, --extend              display other/more information
        -p, --programs            display PID/Program name for sockets
        -c, --continuous          continuous listing

        -l, --listening            display listening server sockets
        -a, --all, --listening    display all sockets (default: connected)
        -o, --timers              display timers
        -F, --fib                  display Forwarding Information Base (default)
        -C, --cache                display routing cache instead of FIB
        -T, --notrim              stop trimming long addresses
        -Z, --context              display SELinux security context for sockets

  <Iface>: Name of interface to monitor/list.
  <Socket>={-t|--tcp} {-u|--udp} {-S|--sctp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom
  <AF>=Use '-A <af>' or '--<af>'; default: inet
  List of possible address families (which support routing):
    inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)
    netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)
    x25 (CCITT X.25)


lonesoac0 05-25-2011 05:23 AM

I just tried: watch -n 3 -d netstat -i eth* on Debian squeeze and it worked fine. You could try which watch and which netstat. The which command shows the exact location of the executable. You could try: /PATHWAY/TO/WATCH -n 3 -d /PATHWAY/TO/NETSTAT -i eth[0-9] The [0-9] parameter looks for the interfaces 0 through 9.

pinga123 05-25-2011 11:06 PM

Quote:

Originally Posted by lonesoac0 (Post 4366411)
I just tried: watch -n 3 -d netstat -i eth* on Debian squeeze and it worked fine. You could try which watch and which netstat. The which command shows the exact location of the executable. You could try: /PATHWAY/TO/WATCH -n 3 -d /PATHWAY/TO/NETSTAT -i eth[0-9] The [0-9] parameter looks for the interfaces 0 through 9.

Code:

watch -n 1 -d "netstat -i | grep vif*"
This has worked for me i needed to put the command in ".


All times are GMT -5. The time now is 12:48 AM.