Guest User

Untitled

a guest
Aug 15th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. How can i get the realtime values to make my own script in BASH specially as shown the attachment
  2. /* My 10 seconds timer */
  3. t = new javax.swing.Timer(10000, new ActionListener()
  4. {
  5. public void actionPerformed(ActionEvent ae)
  6. {
  7. }
  8. });
  9.  
  10. $ sudo apt-get install bwm-ng;
  11. yum -y install bwm;
  12.  
  13. # Show me only plain mode
  14. $ bwm-ng -o plain
  15.  
  16. bwm-ng v0.6 (delay 0.500s); press 'ctrl-c' to end this
  17. /proc/net/dev
  18. | iface Rx Tx Total
  19. ==============================================================================
  20. lo: 88803.53 KB/s 88803.53 KB/s 88803.53 KB/s
  21. eth0: 0.13 KB/s 0.13 KB/s 0.13 KB/s
  22. ------------------------------------------------------------------------------
  23. total: 88803.66 KB/s 88803.66 KB/s 88803.66 KB/s
  24.  
  25. # Show only the interface that i need to see
  26. $ bwm-ng -o plain -I eth0
  27.  
  28. bwm-ng v0.6 (delay 0.500s); press 'ctrl-c' to end this
  29. /proc/net/dev
  30. | iface Rx Tx Total
  31. ==============================================================================
  32. eth0: 0.13 KB/s 0.13 KB/s 0.13 KB/s
  33. ------------------------------------------------------------------------------
  34. total: 0.13 KB/s 0.13 KB/s 0.13 KB/s
  35.  
  36. # Show only in MB format or KB format
  37. # by skiping -d will default show as KB
  38. $ bwm-ng -o plain -d
  39.  
  40. bwm-ng v0.6 (delay 0.500s); press 'ctrl-c' to end this
  41. /proc/net/dev
  42. / iface Rx Tx Total
  43. ==============================================================================
  44. lo: 85.79 MB/s 85.79 MB/s 85.79 MB/s
  45. eth0: 246.58 B/s 246.58 B/s 246.58 B/s
  46. ------------------------------------------------------------------------------
  47. total: 85.79 MB/s 85.79 MB/s 85.79 MB/s
  48.  
  49. $ bwm-ng -o plain -N -d | grep total:
  50. total: 0.00 B/s 0.00 B/s 0.00 B/s
  51. total: 1.28 MB/s 1.28 MB/s 1.28 MB/s
  52. total: 1.19 MB/s 1.19 MB/s 1.19 MB/s
  53. total: 1.19 MB/s 1.19 MB/s 1.19 MB/s
  54.  
  55.  
  56. # another tool i used apt-get install vnstat
  57. # bwm-ng was doing wrong strange on other interfaces but this one
  58. # now showing correct
  59. $ vnstat -u -i lo
  60. $ vnstat -u -i eth0
  61. $ vnstat
  62. $ iftop -i eth0
  63.  
  64. default_device=$(awk ' { if ($2 == '00000000') print $1 ; } ' < /proc/net/route)
  65. while true
  66. do
  67. bytesin=$(grep $default_device /proc/net/dev | cut -d':' -f2 | awk ' { print $1; } ')
  68. bytesout=$(grep $default_device /proc/net/dev | cut -d':' -f2 | awk ' { print $9; } ')
  69. echo bytesin=$bytesin bytesout=$bytesout
  70. sleep 2
  71. done
  72.  
  73. bytesin=622734605 bytesout=1249429296
  74. bytesin=622735091 bytesout=1249429620
  75. bytesin=622735523 bytesout=1249430120
  76. bytesin=622736268 bytesout=1249430481
  77. bytesin=622736874 bytesout=1249430535
Add Comment
Please, Sign In to add comment