2

I am trying to get Network statistics on Solaris 10

Something like this when I was working on Linux::

02:42:06  IST     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
02:42:07  IST    ens192      8.00      0.00      0.52      0.00      0.00      0.00      1.00
02:42:07  IST        lo     43.00     43.00      7.98      7.98      0.00      0.00      0.00

The issue regarding this is that we can not expect user to install any additional packages apart from preinstalled packages.

What I have tried and corresponding problem:

  • dladm show-dev -s: it shows total sent and received packages. and I need per second sent and received
  • dladm show-dev -s -i 1: It does not stop. Which can not be acceptable as the script should proceed further to index data in Splunk.
  • dlstat: This command would do the trick, but it is not pre-installed in Solaris.
    • doubt here :: is there a way to install dlstat on solaris.?
  • nicstat: not preinstalled on solaris 10 or 11.

Is there any way to get this fields without installing any additional packages?

Note: Subtracting total sent and received package manually is unreliable in the case and would not be approved further for implementation.

Thank you in advanced.

1

If dladm show-dev -s ... produces the statistics you need, either use dladm show-dev -s command without the -i 1 option so it only prints once, or if you need several lines of output to get a snapshot of the current usage rates, you can time out the command.

The easiest way is the timeout utility, but I don't know if that's readily available on Solaris 10:

timeout 5 dladm show-dev -s -i 1

Alternatively, in bash, which is available on Solaris 10:

( dladm show-dev -s -i 1 ) & sleep 5; kill $!

(Note also that the dladm command on Solaris 11 is significantly different than the dladm command on Solaris 10. I don't think dladm show-dev -s ... works on Solaris 11.)

  • Thanks for the answer Andrew, I still have one doubt here... Will i be able to pass the results for further processing using Pipe.? like ( dladm show-dev -s -i 1 ) & sleep 5; kill $! | grep "e1000g0" .? – Jay Joshi Mar 22 '18 at 8:20
  • 1
    You should be able to run the first part before the pipe in a subshell: ( ( dladm show-dev -s -i 1 ) & sleep 5; kill $! ) | grep "e1000g0" – Andrew Henle Mar 22 '18 at 13:08
  • Are you sure that it would work.? I tried and it does not work as it should. It prints 5 times and then just stops. I can not do any further processing. even grep. – Jay Joshi Mar 22 '18 at 13:45
1

I believe the command you are looking for is netstat -i or a variation of it for a Solaris 10 command.

dlstat is a Solaris 11 command.

I believe you're right on nicstat not being part of Solaris 10. Memory is that I downloaded and compiled the source to use it on v8 back in the day. Solaris 11 does have the package as: pkg:diagnostic/nicstat

  • Thanks for the answer.. That's exactly how I coded to get all fields finally after checking all commands. :) However, I could not get received and transmitted KBPS from netstat -i in Solaris. Do you have any suggestions about it.? – Jay Joshi Mar 23 '18 at 7:02
0

You may use kstat util. Variables for Solaris 10 ans Solaris 11 is different, here is universal code:

KSTAT=$(kstat -p -c net '::mac:obytes64';  echo solaris10 globzone sent  >/dev/null
        kstat -p -c net '::mac:rbytes64';   echo solaris10 globzone rsv  >/dev/null
        kstat -p -c net '::phys:obytes64';  echo solaris11 globzone sent >/dev/null
        kstat -p -c net '::phys:rbytes64';  echo solaris11 globzone rcv  >/dev/null)

$KSTAT=$(echo "${KSTAT}" | sed 's/:[a-z]*:.*bytes64//; s/://; /vnic/d; /vsw/d;')

Example variable KSTAT consists sent and received traffic:

$ echo "$KSTAT"
igb0    1381124551259
igb1    0
igb2    0
igb3    0
usbecm2 509924057
igb0    803508091598
igb1    0
igb2    0
igb3    0
usbecm2 1007403041

All this counters are always grow. You may make time analysis of them to capture human-readable statistics.

Also note that if you have non-global zones, this statistics will work ONLY for exclusive IP-stack. All zones in shared IP-stack will have the same statistics.

  • Thanks for the response @Shasha. I am trying to redirect these statistics to one monitoring tool and the requirement is to get the statistics in "per second" unit. In this case, we would have to put sleep time of 1 second and then subtract. Is there any better way to get "per second" statistics using this approach? Any further suggestion would be a great help. – Jay Joshi May 8 '18 at 12:41
  • Dear Jay, I use this code in Nagios plugin. It creates temporary file in local filesystem with this counters and also with timestamp (seconds since EPOCH). At next check plugin calculates difference in counters and updates temporary file. Initially plugin was written for Linux by other people, it is opensource, and I updated it for solaris. If you want you may see them here dropmefiles.com/qeCNA – Sasha Golikov May 8 '18 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.