1f110b23bSJohn Baldwin.\" Copyright (c) 2008 Yahoo!, Inc. 2f110b23bSJohn Baldwin.\" All rights reserved. 3f110b23bSJohn Baldwin.\" Written by: John Baldwin <jhb@FreeBSD.org> 4f110b23bSJohn Baldwin.\" 5f110b23bSJohn Baldwin.\" Redistribution and use in source and binary forms, with or without 6f110b23bSJohn Baldwin.\" modification, are permitted provided that the following conditions 7f110b23bSJohn Baldwin.\" are met: 8f110b23bSJohn Baldwin.\" 1. Redistributions of source code must retain the above copyright 9f110b23bSJohn Baldwin.\" notice, this list of conditions and the following disclaimer. 10f110b23bSJohn Baldwin.\" 2. Redistributions in binary form must reproduce the above copyright 11f110b23bSJohn Baldwin.\" notice, this list of conditions and the following disclaimer in the 12f110b23bSJohn Baldwin.\" documentation and/or other materials provided with the distribution. 13f110b23bSJohn Baldwin.\" 3. Neither the name of the author nor the names of any co-contributors 14f110b23bSJohn Baldwin.\" may be used to endorse or promote products derived from this software 15f110b23bSJohn Baldwin.\" without specific prior written permission. 16f110b23bSJohn Baldwin.\" 17f110b23bSJohn Baldwin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18f110b23bSJohn Baldwin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19f110b23bSJohn Baldwin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20f110b23bSJohn Baldwin.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21f110b23bSJohn Baldwin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22f110b23bSJohn Baldwin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23f110b23bSJohn Baldwin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24f110b23bSJohn Baldwin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25f110b23bSJohn Baldwin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26f110b23bSJohn Baldwin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27f110b23bSJohn Baldwin.\" SUCH DAMAGE. 28f110b23bSJohn Baldwin.\" 29f110b23bSJohn Baldwin.Dd August 19, 2008 30f110b23bSJohn Baldwin.Dt KVM_GETCPTIME 3 31f110b23bSJohn Baldwin.Os 32f110b23bSJohn Baldwin.Sh NAME 33f110b23bSJohn Baldwin.Nm kvm_getcptime 34f110b23bSJohn Baldwin.Nd fetch global CPU time statistics 35f110b23bSJohn Baldwin.Sh LIBRARY 36f110b23bSJohn Baldwin.Lb libkvm 37f110b23bSJohn Baldwin.Sh SYNOPSIS 38f110b23bSJohn Baldwin.In sys/param.h 39f110b23bSJohn Baldwin.In sys/resource.h 40f110b23bSJohn Baldwin.In sys/sysctl.h 41f110b23bSJohn Baldwin.In kvm.h 42f110b23bSJohn Baldwin.Ft int 43f110b23bSJohn Baldwin.Fn kvm_getcptime "kvm_t *kd" "long *cp_time" 44f110b23bSJohn Baldwin.Sh DESCRIPTION 45f110b23bSJohn BaldwinThe 46f110b23bSJohn Baldwin.Fn kvm_getcptime 47f110b23bSJohn Baldwinfunction stores the global CPU time statistics from the kernel 48f110b23bSJohn Baldwin.Fa kd 49f110b23bSJohn Baldwinin the array of counters pointed to by 50f110b23bSJohn Baldwin.Fa cp_time . 51f110b23bSJohn BaldwinNote that 52f110b23bSJohn Baldwin.Fa cp_time 53f110b23bSJohn Baldwinshould point to an array of 54f110b23bSJohn Baldwin.Dv CPUSTATES 55f110b23bSJohn Baldwinlong integers. 56f110b23bSJohn BaldwinThe format of the counters is identical to that output by the 57f110b23bSJohn Baldwin.Va kern.cp_time 58f110b23bSJohn Baldwinsysctl. 59f110b23bSJohn Baldwin.Sh CACHING 60f110b23bSJohn BaldwinThis function caches the nlist values for various kernel variables which it 61f110b23bSJohn Baldwinreuses in successive calls. 62f110b23bSJohn BaldwinYou may call the function with 63f110b23bSJohn Baldwin.Fa kd 64f110b23bSJohn Baldwinset to 65f110b23bSJohn Baldwin.Dv NULL 66f110b23bSJohn Baldwinto clear this cache. 67f110b23bSJohn Baldwin.Sh RETURN VALUES 68f110b23bSJohn BaldwinThe 69f110b23bSJohn Baldwin.Nm kvm_getcptime 70f110b23bSJohn Baldwinfunction returns 0 on success and -1 on failure. 71f110b23bSJohn BaldwinIf an error occurs, 72f110b23bSJohn Baldwinthen an error message may be retrieved via 73f110b23bSJohn Baldwin.Xr kvm_geterr 3 . 74f110b23bSJohn Baldwin.Sh SEE ALSO 75f110b23bSJohn Baldwin.Xr kvm 3 76