kstat.h revision 861bfc8941f2c557f1bcb7a6d7f62f9da98ee4db
66448911ac89c254e89afc52e114402115a497e3David Höppner * CDDL HEADER START
66448911ac89c254e89afc52e114402115a497e3David Höppner * The contents of this file are subject to the terms of the
66448911ac89c254e89afc52e114402115a497e3David Höppner * Common Development and Distribution License (the "License").
66448911ac89c254e89afc52e114402115a497e3David Höppner * You may not use this file except in compliance with the License.
66448911ac89c254e89afc52e114402115a497e3David Höppner * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
66448911ac89c254e89afc52e114402115a497e3David Höppner * See the License for the specific language governing permissions
66448911ac89c254e89afc52e114402115a497e3David Höppner * and limitations under the License.
66448911ac89c254e89afc52e114402115a497e3David Höppner * When distributing Covered Code, include this CDDL HEADER in each
66448911ac89c254e89afc52e114402115a497e3David Höppner * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
66448911ac89c254e89afc52e114402115a497e3David Höppner * If applicable, add the following below this CDDL HEADER, with the
66448911ac89c254e89afc52e114402115a497e3David Höppner * fields enclosed by brackets "[]" replaced with your own identifying
66448911ac89c254e89afc52e114402115a497e3David Höppner * information: Portions Copyright [yyyy] [name of copyright owner]
66448911ac89c254e89afc52e114402115a497e3David Höppner * CDDL HEADER END
66448911ac89c254e89afc52e114402115a497e3David Höppner * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
66448911ac89c254e89afc52e114402115a497e3David Höppner * Copyright 2013 David Hoeppner. All rights reserved.
66448911ac89c254e89afc52e114402115a497e3David Höppner * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
66448911ac89c254e89afc52e114402115a497e3David Höppner * Structures needed by the kstat reader functions.
66448911ac89c254e89afc52e114402115a497e3David Höppner#define KSTAT_DATA_HRTIME (KSTAT_DATA_STRING + 1)
66448911ac89c254e89afc52e114402115a497e3David Höppnertypedef union ks_value {
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_HRTIME(I, S, N) \
66448911ac89c254e89afc52e114402115a497e3David Höppner nvpair_insert(I, #N, &v, KSTAT_DATA_UINT64); \
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_INT32(I, S, N) \
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_UINT32(I, S, N) \
66448911ac89c254e89afc52e114402115a497e3David Höppner nvpair_insert(I, #N, &v, KSTAT_DATA_UINT32); \
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_INT64(I, S, N) \
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_UINT64(I, S, N) \
66448911ac89c254e89afc52e114402115a497e3David Höppner nvpair_insert(I, #N, &v, KSTAT_DATA_UINT64); \
66448911ac89c254e89afc52e114402115a497e3David Höppner * We dont want const "strings" because we free
66448911ac89c254e89afc52e114402115a497e3David Höppner * the instances later.
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_STRING(I, S, N) \
66448911ac89c254e89afc52e114402115a497e3David Höppner nvpair_insert(I, #N, &v, KSTAT_DATA_STRING); \
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_HRTIME_X(I, N, V) \
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_INT32_X(I, N, V) \
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_UINT32_X(I, N, V) \
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_UINT64_X(I, N, V) \
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_STRING_X(I, N, V) \
66448911ac89c254e89afc52e114402115a497e3David Höppner#define SAVE_CHAR_X(I, N, V) \
66448911ac89c254e89afc52e114402115a497e3David Höppner "module: %-30.30s instance: %-6d\n" \
66448911ac89c254e89afc52e114402115a497e3David Höppner "name: %-30.30s class: %-.30s\n"
66448911ac89c254e89afc52e114402115a497e3David Höppner "{\n\t\"module\": \"%s\",\n" \
66448911ac89c254e89afc52e114402115a497e3David Höppner "\t\"instance\": %d,\n" \
66448911ac89c254e89afc52e114402115a497e3David Höppner "\t\"name\": \"%s\",\n" \
66448911ac89c254e89afc52e114402115a497e3David Höppner "\t\"class\": \"%s\",\n" \
66448911ac89c254e89afc52e114402115a497e3David Höppner "\t\"type\": %d,\n"
66448911ac89c254e89afc52e114402115a497e3David Höppnertypedef struct ks_instance {
66448911ac89c254e89afc52e114402115a497e3David Höppnertypedef struct ks_nvpair {
66448911ac89c254e89afc52e114402115a497e3David Höppnertypedef struct ks_pattern {
66448911ac89c254e89afc52e114402115a497e3David Höppnertypedef struct ks_selector {
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void usage(void);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic int compare_instances(ks_instance_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void nvpair_insert(ks_instance_t *, char *, ks_value_t *, uchar_t);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic boolean_t ks_match(const char *, ks_pattern_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void ks_instance_print(ks_instance_t *, ks_nvpair_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void ks_instances_print(void);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic char *ks_safe_strdup(char *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void ks_sleep_until(hrtime_t *, hrtime_t, int, int *);
66448911ac89c254e89afc52e114402115a497e3David Höppner/* Raw kstat readers */
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_cpu_stat(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_var(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_ncstats(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_sysinfo(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_vminfo(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_nfs(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_sfmmu_global_stat(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_sfmmu_tsbsize_stat(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_simmstat(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppner/* Helper function for save_temperature() */
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic char *short_array_to_string(short *, int);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_temperature(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_temp_over(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_ps_shadow(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_fault_list(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppner/* Named kstat readers */
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_named(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_intr(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_io(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic void save_timer(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppner/* Typedef for raw kstat reader functions */
66448911ac89c254e89afc52e114402115a497e3David Höppnertypedef void (*kstat_raw_reader_t)(kstat_t *, ks_instance_t *);
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic struct {
66448911ac89c254e89afc52e114402115a497e3David Höppner /* Function name kstat name */
66448911ac89c254e89afc52e114402115a497e3David Höppner {save_sfmmu_global_stat, "unix:sfmmu_global_stat"},
66448911ac89c254e89afc52e114402115a497e3David Höppner {save_sfmmu_tsbsize_stat, "unix:sfmmu_tsbsize_stat"},
66448911ac89c254e89afc52e114402115a497e3David Höppner {save_temp_over, "unix:temperature override"},
66448911ac89c254e89afc52e114402115a497e3David Höppnerstatic kstat_raw_reader_t lookup_raw_kstat_fn(char *, char *);
66448911ac89c254e89afc52e114402115a497e3David Höppner#endif /* _STAT_KSTAT_H */