4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
33 #include "sdbc_stats.h"
34 #include "sndr_stats.h"
36 #include "multi_stats.h"
43 * do_stats() - called by main() to start monitoring
52 /* Collection/reporting loop */
53 for (pass
= 0; ; pass
++) { /* CSTYLED */
54 if (iterations
!= -1 && pass
>= iterations
)
59 if (error
== ENOMEM
|| error
== EINVAL
)
62 if (error
== EAGAIN
&& pass
== 0)
65 (void) sleep(interval
);
67 if ((error
= update()) != 0)
74 /* No stats on this system */
89 if ((kc
= kstat_open()) == NULL
)
93 sdbc_err
= sdbc_discover(kc
);
95 if (sdbc_err
&& !(mode
& MULTI
))
97 if (sdbc_err
&& (mode
& MULTI
) && sdbc_err
!= EAGAIN
)
102 sndr_err
= sndr_discover(kc
);
104 if (sndr_err
&& !(mode
& MULTI
))
106 if (sndr_err
&& (mode
& MULTI
) && sndr_err
!= EAGAIN
)
111 ii_err
= ii_discover(kc
);
113 if (ii_err
&& !(mode
& MULTI
))
115 if (ii_err
&& ii_err
!= EAGAIN
&& (mode
& MULTI
))
119 (void) kstat_close(kc
);
120 if (sdbc_err
&& sndr_err
&& ii_err
)
126 (void) kstat_close(kc
);
141 if ((kc
= kstat_open()) == NULL
)
145 sdbc_err
= sdbc_update(kc
);
147 if (sdbc_err
&& !(mode
& MULTI
))
149 if (sdbc_err
&& (mode
& MULTI
) && sdbc_err
!= EAGAIN
)
154 sndr_err
= sndr_update(kc
);
156 if (sndr_err
&& !(mode
& MULTI
))
158 if (sndr_err
&& (mode
& MULTI
) && sndr_err
!= EAGAIN
)
163 ii_err
= ii_update(kc
);
165 if (ii_err
&& !(mode
& MULTI
))
167 if (ii_err
&& (mode
& MULTI
) && ii_err
!= EAGAIN
)
171 (void) kstat_close(kc
);
172 if (sdbc_err
&& sndr_err
&& ii_err
)
178 (void) kstat_close(kc
);
191 hflags
&= (HEADERS_EXL
| HEADERS_ATT
| HEADERS_BOR
);
194 if (sndr_err
= sndr_report())
198 if (ii_err
= ii_report())
201 if ((mode
& SDBC
) && !(mode
& MULTI
))
202 if (sdbc_err
= sdbc_report())