Home | History | Annotate | Line # | Download | only in Net
      1  1.1  christos #!/usr/sbin/dtrace -s
      2  1.1  christos /*
      3  1.1  christos  * icmpstat.d - print ICMP statistics. Uses DTrace.
      4  1.1  christos  *
      5  1.1  christos  * This prints ICMP statistics every second, retrieved from the MIB provider.
      6  1.1  christos  * This is a simple script to demonstrate the ability to trace ICMP events.
      7  1.1  christos  *
      8  1.1  christos  * $Id: icmpstat.d,v 1.1.1.1 2015/09/30 22:01:09 christos Exp $
      9  1.1  christos  *
     10  1.1  christos  * USAGE:	icmpstat.d
     11  1.1  christos  *
     12  1.1  christos  * FIELDS:
     13  1.1  christos  *		STATISTIC		ICMP statistic name
     14  1.1  christos  *		VALUE			total of statistic during sample
     15  1.1  christos  *
     16  1.1  christos  * The above ICMP statistics are documented in the mib2_icmp struct
     17  1.1  christos  * in the /usr/include/inet/mib2.h file; and also in the mib provider
     18  1.1  christos  * chapter of the DTrace Guide, http://docs.sun.com/db/doc/817-6223.
     19  1.1  christos  *
     20  1.1  christos  * COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
     21  1.1  christos  *
     22  1.1  christos  * CDDL HEADER START
     23  1.1  christos  *
     24  1.1  christos  *  The contents of this file are subject to the terms of the
     25  1.1  christos  *  Common Development and Distribution License, Version 1.0 only
     26  1.1  christos  *  (the "License").  You may not use this file except in compliance
     27  1.1  christos  *  with the License.
     28  1.1  christos  *
     29  1.1  christos  *  You can obtain a copy of the license at Docs/cddl1.txt
     30  1.1  christos  *  or http://www.opensolaris.org/os/licensing.
     31  1.1  christos  *  See the License for the specific language governing permissions
     32  1.1  christos  *  and limitations under the License.
     33  1.1  christos  *
     34  1.1  christos  * CDDL HEADER END
     35  1.1  christos  *
     36  1.1  christos  * 25-Jul-2005	Brendan Gregg	Created this.
     37  1.1  christos  * 25-Jul-2005	   "      "	Last update.
     38  1.1  christos  */
     39  1.1  christos 
     40  1.1  christos #pragma D option quiet
     41  1.1  christos 
     42  1.1  christos /*
     43  1.1  christos  * Save Data
     44  1.1  christos  */
     45  1.1  christos mib:::icmp*
     46  1.1  christos {
     47  1.1  christos 	@icmp[probename] = sum(arg0);
     48  1.1  christos }
     49  1.1  christos 
     50  1.1  christos /*
     51  1.1  christos  * Print Output
     52  1.1  christos  */
     53  1.1  christos profile:::tick-1sec
     54  1.1  christos {
     55  1.1  christos 	printf("%Y,\n\n", walltimestamp);
     56  1.1  christos 	printf("%32s %8s\n", "STATISTIC", "VALUE");
     57  1.1  christos 	printa("%32s %@8d\n", @icmp);
     58  1.1  christos 	printf("\n");
     59  1.1  christos 
     60  1.1  christos 	trunc(@icmp);
     61  1.1  christos }
     62