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