Exemplo n.º 1
0
int CollectorSolaris::getRawHostDiskLoad(const char *name, uint64_t *disk_ms, uint64_t *total_ms)
{
    int rc = VINF_SUCCESS;
    AssertReturn(strlen(name) < KSTAT_STRLEN, VERR_INVALID_PARAMETER);
    LogFlowThisFunc(("n=%s\n", name));
    kstat_t *ksDisk = kstat_lookup(mKC, NULL, -1, (char *)name);
    if (ksDisk != 0)
    {
        if (kstat_read(mKC, ksDisk, 0) == -1)
        {
            LogRel(("kstat_read(%s) -> %d\n", name, errno));
            rc = VERR_INTERNAL_ERROR;
        }
        else
        {
            kstat_io_t *ksIo = KSTAT_IO_PTR(ksDisk);
            /*
             * We do not care for wrap possibility here, although we may
             * reconsider in about 300 years (9223372036854775807 ns).
             */
            *disk_ms = ksIo->rtime / 1000000;
            *total_ms = ksDisk->ks_snaptime / 1000000;
        }
    }
    else
    {
        LogRel(("kstat_lookup(%s) -> %d\n", name, errno));
        rc = VERR_INTERNAL_ERROR;
    }

    return rc;
}
Exemplo n.º 2
0
static int
get_kstat_vals(kstat_t *ksp, nvlist_t *stats)
{
	if (ksp->ks_type == KSTAT_TYPE_IO) {
	    kstat_io_t *kiop;

	    kiop = KSTAT_IO_PTR(ksp);

	    /* see sys/kstat.h kstat_io_t struct for more fields */

	    if (update_stat64(stats, DM_NBYTESREAD, kiop->nread) != 0) {
		return (ENOMEM);
	    }
	    if (update_stat64(stats, DM_NBYTESWRITTEN, kiop->nwritten) != 0) {
		return (ENOMEM);
	    }
	    if (update_stat64(stats, DM_NREADOPS, kiop->reads) != 0) {
		return (ENOMEM);
	    }
	    if (update_stat64(stats, DM_NWRITEOPS, kiop->writes) != 0) {
		return (ENOMEM);
	    }

	} else if (ksp->ks_type == KSTAT_TYPE_NAMED) {
	    kstat_named_t *knp;
	    int		i;

	    knp = KSTAT_NAMED_PTR(ksp);
	    for (i = 0; i < ksp->ks_ndata; i++) {
		char	*attr_name;

		if (knp[i].name[0] == 0)
		    continue;

		if ((attr_name = get_err_attr_name(knp[i].name)) == NULL) {
		    continue;

		}

		switch (knp[i].data_type) {
		case KSTAT_DATA_UINT32:
		    if (update_stat32(stats, attr_name, knp[i].value.ui32)
			!= 0) {
			return (ENOMEM);
		    }
		    break;

		default:
		    /* Right now all of the error types are uint32 */
		    break;
		}
	    }
	}
	return (0);
}
Exemplo n.º 3
0
static void
save_io(ks_returner_t *ret, kstat_t *kp, ks_instance_t *ksi)
{
	kstat_io_t	*ksio = KSTAT_IO_PTR(kp);

	SAVE_UINT64(ret, ksi, ksio, nread);
	SAVE_UINT64(ret, ksi, ksio, nwritten);
	SAVE_UINT32(ret, ksi, ksio, reads);
	SAVE_UINT32(ret, ksi, ksio, writes);
	SAVE_HRTIME(ret, ksi, ksio, wtime);
	SAVE_HRTIME(ret, ksi, ksio, wlentime);
	SAVE_HRTIME(ret, ksi, ksio, wlastupdate);
	SAVE_HRTIME(ret, ksi, ksio, rtime);
	SAVE_HRTIME(ret, ksi, ksio, rlentime);
	SAVE_HRTIME(ret, ksi, ksio, rlastupdate);
	SAVE_UINT32(ret, ksi, ksio, wcnt);
	SAVE_UINT32(ret, ksi, ksio, rcnt);
}