helpers.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. // +build aix
  2. package perfstat
  3. /*
  4. #cgo LDFLAGS: -lperfstat
  5. #include <libperfstat.h>
  6. #include <sys/proc.h>
  7. #include "c_helpers.h"
  8. */
  9. import "C"
  10. func perfstatcpu2cpu(n *C.perfstat_cpu_t) CPU {
  11. var c CPU
  12. c.Name = C.GoString(&n.name[0])
  13. c.User = int64(n.user)
  14. c.Sys = int64(n.sys)
  15. c.Idle = int64(n.idle)
  16. c.Wait = int64(n.wait)
  17. c.PSwitch = int64(n.pswitch)
  18. c.Syscall = int64(n.syscall)
  19. c.Sysread = int64(n.sysread)
  20. c.Syswrite = int64(n.syswrite)
  21. c.Sysfork = int64(n.sysfork)
  22. c.Sysexec = int64(n.sysexec)
  23. c.Readch = int64(n.readch)
  24. c.Writech = int64(n.writech)
  25. c.Bread = int64(n.bread)
  26. c.Bwrite = int64(n.bwrite)
  27. c.Lread = int64(n.lread)
  28. c.Lwrite = int64(n.lwrite)
  29. c.Phread = int64(n.phread)
  30. c.Phwrite = int64(n.phwrite)
  31. c.Iget = int64(n.iget)
  32. c.Namei = int64(n.namei)
  33. c.Dirblk = int64(n.dirblk)
  34. c.Msg = int64(n.msg)
  35. c.Sema = int64(n.sema)
  36. c.MinFaults = int64(n.minfaults)
  37. c.MajFaults = int64(n.majfaults)
  38. c.PUser = int64(n.puser)
  39. c.PSys = int64(n.psys)
  40. c.PIdle = int64(n.pidle)
  41. c.PWait = int64(n.pwait)
  42. c.RedispSD0 = int64(n.redisp_sd0)
  43. c.RedispSD1 = int64(n.redisp_sd1)
  44. c.RedispSD2 = int64(n.redisp_sd2)
  45. c.RedispSD3 = int64(n.redisp_sd3)
  46. c.RedispSD4 = int64(n.redisp_sd4)
  47. c.RedispSD5 = int64(n.redisp_sd5)
  48. c.MigrationPush = int64(n.migration_push)
  49. c.MigrationS3grq = int64(n.migration_S3grq)
  50. c.MigrationS3pul = int64(n.migration_S3pul)
  51. c.InvolCSwitch = int64(n.invol_cswitch)
  52. c.VolCSwitch = int64(n.vol_cswitch)
  53. c.RunQueue = int64(n.runque)
  54. c.Bound = int64(n.bound)
  55. c.DecrIntrs = int64(n.decrintrs)
  56. c.MpcRIntrs = int64(n.mpcrintrs)
  57. c.MpcSIntrs = int64(n.mpcsintrs)
  58. c.SoftIntrs = int64(n.softintrs)
  59. c.DevIntrs = int64(n.devintrs)
  60. c.PhantIntrs = int64(n.phantintrs)
  61. c.IdleDonatedPurr = int64(n.idle_donated_purr)
  62. c.IdleDonatedSpurr = int64(n.idle_donated_spurr)
  63. c.BusyDonatedPurr = int64(n.busy_donated_purr)
  64. c.BusyDonatedSpurr = int64(n.busy_donated_spurr)
  65. c.IdleStolenPurr = int64(n.idle_stolen_purr)
  66. c.IdleStolenSpurr = int64(n.idle_stolen_spurr)
  67. c.BusyStolenPurr = int64(n.busy_stolen_purr)
  68. c.BusyStolenSpurr = int64(n.busy_stolen_spurr)
  69. c.Hpi = int64(n.hpi)
  70. c.Hpit = int64(n.hpit)
  71. c.PUserSpurr = int64(n.puser_spurr)
  72. c.PSysSpurr = int64(n.psys_spurr)
  73. c.PIdleSpurr = int64(n.pidle_spurr)
  74. c.PWaitSpurr = int64(n.pwait_spurr)
  75. c.SpurrFlag = int32(n.spurrflag)
  76. c.LocalDispatch = int64(n.localdispatch)
  77. c.NearDispatch = int64(n.neardispatch)
  78. c.FarDispatch = int64(n.fardispatch)
  79. c.CSwitches = int64(n.cswitches)
  80. c.Version = int64(n.version)
  81. c.TbLast = int64(n.tb_last)
  82. c.State = int(n.state)
  83. c.VtbLast = int64(n.vtb_last)
  84. c.ICountLast = int64(n.icount_last)
  85. return c
  86. }
  87. func perfstatcputotal2cputotal(n *C.perfstat_cpu_total_t) CPUTotal {
  88. var c CPUTotal
  89. c.NCpus = int(n.ncpus)
  90. c.NCpusCfg = int(n.ncpus_cfg)
  91. c.Description = C.GoString(&n.description[0])
  92. c.ProcessorHz = int64(n.processorHZ)
  93. c.User = int64(n.user)
  94. c.Sys = int64(n.sys)
  95. c.Idle = int64(n.idle)
  96. c.Wait = int64(n.wait)
  97. c.PSwitch = int64(n.pswitch)
  98. c.Syscall = int64(n.syscall)
  99. c.Sysread = int64(n.sysread)
  100. c.Syswrite = int64(n.syswrite)
  101. c.Sysfork = int64(n.sysfork)
  102. c.Sysexec = int64(n.sysexec)
  103. c.Readch = int64(n.readch)
  104. c.Writech = int64(n.writech)
  105. c.DevIntrs = int64(n.devintrs)
  106. c.SoftIntrs = int64(n.softintrs)
  107. c.Lbolt = int64(n.lbolt)
  108. c.LoadAvg1 = (float32(n.loadavg[0]) / (1 << C.SBITS))
  109. c.LoadAvg5 = (float32(n.loadavg[1]) / (1 << C.SBITS))
  110. c.LoadAvg15 = (float32(n.loadavg[2]) / (1 << C.SBITS))
  111. c.RunQueue = int64(n.runque)
  112. c.SwpQueue = int64(n.swpque)
  113. c.Bread = int64(n.bread)
  114. c.Bwrite = int64(n.bwrite)
  115. c.Lread = int64(n.lread)
  116. c.Lwrite = int64(n.lwrite)
  117. c.Phread = int64(n.phread)
  118. c.Phwrite = int64(n.phwrite)
  119. c.RunOcc = int64(n.runocc)
  120. c.SwpOcc = int64(n.swpocc)
  121. c.Iget = int64(n.iget)
  122. c.Namei = int64(n.namei)
  123. c.Dirblk = int64(n.dirblk)
  124. c.Msg = int64(n.msg)
  125. c.Sema = int64(n.sema)
  126. c.RcvInt = int64(n.rcvint)
  127. c.XmtInt = int64(n.xmtint)
  128. c.MdmInt = int64(n.mdmint)
  129. c.TtyRawInch = int64(n.tty_rawinch)
  130. c.TtyCanInch = int64(n.tty_caninch)
  131. c.TtyRawOutch = int64(n.tty_rawoutch)
  132. c.Ksched = int64(n.ksched)
  133. c.Koverf = int64(n.koverf)
  134. c.Kexit = int64(n.kexit)
  135. c.Rbread = int64(n.rbread)
  136. c.Rcread = int64(n.rcread)
  137. c.Rbwrt = int64(n.rbwrt)
  138. c.Rcwrt = int64(n.rcwrt)
  139. c.Traps = int64(n.traps)
  140. c.NCpusHigh = int64(n.ncpus_high)
  141. c.PUser = int64(n.puser)
  142. c.PSys = int64(n.psys)
  143. c.PIdle = int64(n.pidle)
  144. c.PWait = int64(n.pwait)
  145. c.DecrIntrs = int64(n.decrintrs)
  146. c.MpcRIntrs = int64(n.mpcrintrs)
  147. c.MpcSIntrs = int64(n.mpcsintrs)
  148. c.PhantIntrs = int64(n.phantintrs)
  149. c.IdleDonatedPurr = int64(n.idle_donated_purr)
  150. c.IdleDonatedSpurr = int64(n.idle_donated_spurr)
  151. c.BusyDonatedPurr = int64(n.busy_donated_purr)
  152. c.BusyDonatedSpurr = int64(n.busy_donated_spurr)
  153. c.IdleStolenPurr = int64(n.idle_stolen_purr)
  154. c.IdleStolenSpurr = int64(n.idle_stolen_spurr)
  155. c.BusyStolenPurr = int64(n.busy_stolen_purr)
  156. c.BusyStolenSpurr = int64(n.busy_stolen_spurr)
  157. c.IOWait = int32(n.iowait)
  158. c.PhysIO = int32(n.physio)
  159. c.TWait = int64(n.twait)
  160. c.Hpi = int64(n.hpi)
  161. c.Hpit = int64(n.hpit)
  162. c.PUserSpurr = int64(n.puser_spurr)
  163. c.PSysSpurr = int64(n.psys_spurr)
  164. c.PIdleSpurr = int64(n.pidle_spurr)
  165. c.PWaitSpurr = int64(n.pwait_spurr)
  166. c.SpurrFlag = int(n.spurrflag)
  167. c.Version = int64(n.version)
  168. c.TbLast = int64(n.tb_last)
  169. c.PurrCoalescing = int64(n.purr_coalescing)
  170. c.SpurrCoalescing = int64(n.spurr_coalescing)
  171. return c
  172. }
  173. func perfstatcpuutil2cpuutil(n *C.perfstat_cpu_util_t) CPUUtil {
  174. var c CPUUtil
  175. c.Version = int64(n.version)
  176. c.CpuID = C.GoString(&n.cpu_id[0])
  177. c.Entitlement = float32(n.entitlement)
  178. c.UserPct = float32(n.user_pct)
  179. c.KernPct = float32(n.kern_pct)
  180. c.IdlePct = float32(n.idle_pct)
  181. c.WaitPct = float32(n.wait_pct)
  182. c.PhysicalBusy = float32(n.physical_busy)
  183. c.PhysicalConsumed = float32(n.physical_consumed)
  184. c.FreqPct = float32(n.freq_pct)
  185. c.EntitlementPct = float32(n.entitlement_pct)
  186. c.BusyPct = float32(n.busy_pct)
  187. c.IdleDonatedPct = float32(n.idle_donated_pct)
  188. c.BusyDonatedPct = float32(n.busy_donated_pct)
  189. c.IdleStolenPct = float32(n.idle_stolen_pct)
  190. c.BusyStolenPct = float32(n.busy_stolen_pct)
  191. c.LUserPct = float32(n.l_user_pct)
  192. c.LKernPct = float32(n.l_kern_pct)
  193. c.LIdlePct = float32(n.l_idle_pct)
  194. c.LWaitPct = float32(n.l_wait_pct)
  195. c.DeltaTime = int64(n.delta_time)
  196. return c
  197. }
  198. func perfstatdisktotal2disktotal(n C.perfstat_disk_total_t) DiskTotal {
  199. var d DiskTotal
  200. d.Number = int32(n.number)
  201. d.Size = int64(n.size)
  202. d.Free = int64(n.free)
  203. d.XRate = int64(n.xrate)
  204. d.Xfers = int64(n.xfers)
  205. d.Wblks = int64(n.wblks)
  206. d.Rblks = int64(n.rblks)
  207. d.Time = int64(n.time)
  208. d.Version = int64(n.version)
  209. d.Rserv = int64(n.rserv)
  210. d.MinRserv = int64(n.min_rserv)
  211. d.MaxRserv = int64(n.max_rserv)
  212. d.RTimeOut = int64(n.rtimeout)
  213. d.RFailed = int64(n.rfailed)
  214. d.Wserv = int64(n.wserv)
  215. d.MinWserv = int64(n.min_wserv)
  216. d.MaxWserv = int64(n.max_wserv)
  217. d.WTimeOut = int64(n.wtimeout)
  218. d.WFailed = int64(n.wfailed)
  219. d.WqDepth = int64(n.wq_depth)
  220. d.WqTime = int64(n.wq_time)
  221. d.WqMinTime = int64(n.wq_min_time)
  222. d.WqMaxTime = int64(n.wq_max_time)
  223. return d
  224. }
  225. func perfstatdiskadapter2diskadapter(n *C.perfstat_diskadapter_t) DiskAdapter {
  226. var d DiskAdapter
  227. d.Name = C.GoString(&n.name[0])
  228. d.Description = C.GoString(&n.description[0])
  229. d.Number = int32(n.number)
  230. d.Size = int64(n.size)
  231. d.Free = int64(n.free)
  232. d.XRate = int64(n.xrate)
  233. d.Xfers = int64(n.xfers)
  234. d.Rblks = int64(n.rblks)
  235. d.Wblks = int64(n.wblks)
  236. d.Time = int64(n.time)
  237. d.Version = int64(n.version)
  238. d.AdapterType = int64(n.adapter_type)
  239. d.DkBSize = int64(n.dk_bsize)
  240. d.DkRserv = int64(n.dk_rserv)
  241. d.DkWserv = int64(n.dk_wserv)
  242. d.MinRserv = int64(n.min_rserv)
  243. d.MaxRserv = int64(n.max_rserv)
  244. d.MinWserv = int64(n.min_wserv)
  245. d.MaxWserv = int64(n.max_wserv)
  246. d.WqDepth = int64(n.wq_depth)
  247. d.WqSampled = int64(n.wq_sampled)
  248. d.WqTime = int64(n.wq_time)
  249. d.WqMinTime = int64(n.wq_min_time)
  250. d.WqMaxTime = int64(n.wq_max_time)
  251. d.QFull = int64(n.q_full)
  252. d.QSampled = int64(n.q_sampled)
  253. return d
  254. }
  255. func perfstatpartitionconfig2partitionconfig(n C.perfstat_partition_config_t) PartitionConfig {
  256. var p PartitionConfig
  257. p.Version = int64(n.version)
  258. p.Name = C.GoString(&n.partitionname[0])
  259. p.Node = C.GoString(&n.nodename[0])
  260. p.Conf.SmtCapable = (n.conf[0] & (1 << 7)) > 0
  261. p.Conf.SmtEnabled = (n.conf[0] & (1 << 6)) > 0
  262. p.Conf.LparCapable = (n.conf[0] & (1 << 5)) > 0
  263. p.Conf.LparEnabled = (n.conf[0] & (1 << 4)) > 0
  264. p.Conf.SharedCapable = (n.conf[0] & (1 << 3)) > 0
  265. p.Conf.SharedEnabled = (n.conf[0] & (1 << 2)) > 0
  266. p.Conf.DLparCapable = (n.conf[0] & (1 << 1)) > 0
  267. p.Conf.Capped = (n.conf[0] & (1 << 0)) > 0
  268. p.Conf.Kernel64bit = (n.conf[1] & (1 << 7)) > 0
  269. p.Conf.PoolUtilAuthority = (n.conf[1] & (1 << 6)) > 0
  270. p.Conf.DonateCapable = (n.conf[1] & (1 << 5)) > 0
  271. p.Conf.DonateEnabled = (n.conf[1] & (1 << 4)) > 0
  272. p.Conf.AmsCapable = (n.conf[1] & (1 << 3)) > 0
  273. p.Conf.AmsEnabled = (n.conf[1] & (1 << 2)) > 0
  274. p.Conf.PowerSave = (n.conf[1] & (1 << 1)) > 0
  275. p.Conf.AmeEnabled = (n.conf[1] & (1 << 0)) > 0
  276. p.Conf.SharedExtended = (n.conf[2] & (1 << 7)) > 0
  277. p.Number = int32(n.partitionnum)
  278. p.GroupID = int32(n.groupid)
  279. p.ProcessorFamily = C.GoString(&n.processorFamily[0])
  280. p.ProcessorModel = C.GoString(&n.processorModel[0])
  281. p.MachineID = C.GoString(&n.machineID[0])
  282. p.ProcessorMhz = float64(C.get_partition_mhz(n))
  283. p.NumProcessors.Online = int64(n.numProcessors.online)
  284. p.NumProcessors.Max = int64(n.numProcessors.max)
  285. p.NumProcessors.Min = int64(n.numProcessors.min)
  286. p.NumProcessors.Desired = int64(n.numProcessors.desired)
  287. p.OSName = C.GoString(&n.OSName[0])
  288. p.OSVersion = C.GoString(&n.OSVersion[0])
  289. p.OSBuild = C.GoString(&n.OSBuild[0])
  290. p.LCpus = int32(n.lcpus)
  291. p.SmtThreads = int32(n.smtthreads)
  292. p.Drives = int32(n.drives)
  293. p.NetworkAdapters = int32(n.nw_adapters)
  294. p.CpuCap.Online = int64(n.cpucap.online)
  295. p.CpuCap.Max = int64(n.cpucap.max)
  296. p.CpuCap.Min = int64(n.cpucap.min)
  297. p.CpuCap.Desired = int64(n.cpucap.desired)
  298. p.Weightage = int32(n.cpucap_weightage)
  299. p.EntCapacity = int32(n.entitled_proc_capacity)
  300. p.VCpus.Online = int64(n.vcpus.online)
  301. p.VCpus.Max = int64(n.vcpus.max)
  302. p.VCpus.Min = int64(n.vcpus.min)
  303. p.VCpus.Desired = int64(n.vcpus.desired)
  304. p.PoolID = int32(n.processor_poolid)
  305. p.ActiveCpusInPool = int32(n.activecpusinpool)
  306. p.PoolWeightage = int32(n.cpupool_weightage)
  307. p.SharedPCpu = int32(n.sharedpcpu)
  308. p.MaxPoolCap = int32(n.maxpoolcap)
  309. p.EntPoolCap = int32(n.entpoolcap)
  310. p.Mem.Online = int64(n.mem.online)
  311. p.Mem.Max = int64(n.mem.max)
  312. p.Mem.Min = int64(n.mem.min)
  313. p.Mem.Desired = int64(n.mem.desired)
  314. p.MemWeightage = int32(n.mem_weightage)
  315. p.TotalIOMemoryEntitlement = int64(n.totiomement)
  316. p.MemPoolID = int32(n.mempoolid)
  317. p.HyperPgSize = int64(n.hyperpgsize)
  318. p.ExpMem.Online = int64(n.exp_mem.online)
  319. p.ExpMem.Max = int64(n.exp_mem.max)
  320. p.ExpMem.Min = int64(n.exp_mem.min)
  321. p.ExpMem.Desired = int64(n.exp_mem.desired)
  322. p.TargetMemExpFactor = int64(n.targetmemexpfactor)
  323. p.TargetMemExpSize = int64(n.targetmemexpsize)
  324. p.SubProcessorMode = int32(n.subprocessor_mode)
  325. return p
  326. }
  327. func perfstatmemorytotal2memorytotal(n C.perfstat_memory_total_t) MemoryTotal {
  328. var m MemoryTotal
  329. m.VirtualTotal = int64(n.virt_total)
  330. m.RealTotal = int64(n.real_total)
  331. m.RealFree = int64(n.real_free)
  332. m.RealPinned = int64(n.real_pinned)
  333. m.RealInUse = int64(n.real_inuse)
  334. m.BadPages = int64(n.pgbad)
  335. m.PageFaults = int64(n.pgexct)
  336. m.PageIn = int64(n.pgins)
  337. m.PageOut = int64(n.pgouts)
  338. m.PgSpIn = int64(n.pgspins)
  339. m.PgSpOut = int64(n.pgspouts)
  340. m.Scans = int64(n.scans)
  341. m.Cycles = int64(n.cycles)
  342. m.PgSteals = int64(n.pgsteals)
  343. m.NumPerm = int64(n.numperm)
  344. m.PgSpTotal = int64(n.pgsp_total)
  345. m.PgSpFree = int64(n.pgsp_free)
  346. m.PgSpRsvd = int64(n.pgsp_rsvd)
  347. m.RealSystem = int64(n.real_system)
  348. m.RealUser = int64(n.real_user)
  349. m.RealProcess = int64(n.real_process)
  350. m.VirtualActive = int64(n.virt_active)
  351. m.IOME = int64(n.iome)
  352. m.IOMU = int64(n.iomu)
  353. m.IOHWM = int64(n.iohwm)
  354. m.PMem = int64(n.pmem)
  355. m.CompressedTotal = int64(n.comprsd_total)
  356. m.CompressedWSegPg = int64(n.comprsd_wseg_pgs)
  357. m.CPgIn = int64(n.cpgins)
  358. m.CPgOut = int64(n.cpgouts)
  359. m.TrueSize = int64(n.true_size)
  360. m.ExpandedMemory = int64(n.expanded_memory)
  361. m.CompressedWSegSize = int64(n.comprsd_wseg_size)
  362. m.TargetCPoolSize = int64(n.target_cpool_size)
  363. m.MaxCPoolSize = int64(n.max_cpool_size)
  364. m.MinUCPoolSize = int64(n.min_ucpool_size)
  365. m.CPoolSize = int64(n.cpool_size)
  366. m.UCPoolSize = int64(n.ucpool_size)
  367. m.CPoolInUse = int64(n.cpool_inuse)
  368. m.UCPoolInUse = int64(n.ucpool_inuse)
  369. m.Version = int64(n.version)
  370. m.RealAvailable = int64(n.real_avail)
  371. m.BytesCoalesced = int64(n.bytes_coalesced)
  372. m.BytesCoalescedMemPool = int64(n.bytes_coalesced_mempool)
  373. return m
  374. }
  375. func perfstatnetinterfacetotal2netifacetotal(n C.perfstat_netinterface_total_t) NetIfaceTotal {
  376. var i NetIfaceTotal
  377. i.Number = int32(n.number)
  378. i.IPackets = int64(n.ipackets)
  379. i.IBytes = int64(n.ibytes)
  380. i.IErrors = int64(n.ierrors)
  381. i.OPackets = int64(n.opackets)
  382. i.OBytes = int64(n.obytes)
  383. i.OErrors = int64(n.oerrors)
  384. i.Collisions = int64(n.collisions)
  385. i.XmitDrops = int64(n.xmitdrops)
  386. i.Version = int64(n.version)
  387. return i
  388. }
  389. func perfstatdisk2disk(n *C.perfstat_disk_t) Disk {
  390. var d Disk
  391. d.Name = C.GoString(&n.name[0])
  392. d.Description = C.GoString(&n.description[0])
  393. d.VGName = C.GoString(&n.vgname[0])
  394. d.Size = int64(n.size)
  395. d.Free = int64(n.free)
  396. d.BSize = int64(n.bsize)
  397. d.XRate = int64(n.xrate)
  398. d.Xfers = int64(n.xfers)
  399. d.Wblks = int64(n.wblks)
  400. d.Rblks = int64(n.rblks)
  401. d.QDepth = int64(n.qdepth)
  402. d.Time = int64(n.time)
  403. d.Adapter = C.GoString(&n.adapter[0])
  404. d.PathsCount = int32(n.paths_count)
  405. d.QFull = int64(n.q_full)
  406. d.Rserv = int64(n.rserv)
  407. d.RTimeOut = int64(n.rtimeout)
  408. d.Rfailed = int64(n.rfailed)
  409. d.MinRserv = int64(n.min_rserv)
  410. d.MaxRserv = int64(n.max_rserv)
  411. d.Wserv = int64(n.wserv)
  412. d.WTimeOut = int64(n.wtimeout)
  413. d.Wfailed = int64(n.wfailed)
  414. d.MinWserv = int64(n.min_wserv)
  415. d.MaxWserv = int64(n.max_wserv)
  416. d.WqDepth = int64(n.wq_depth)
  417. d.WqSampled = int64(n.wq_sampled)
  418. d.WqTime = int64(n.wq_time)
  419. d.WqMinTime = int64(n.wq_min_time)
  420. d.WqMaxTime = int64(n.wq_max_time)
  421. d.QSampled = int64(n.q_sampled)
  422. d.Version = int64(n.version)
  423. d.PseudoDisk = (n.dk_type[0] & (1 << 7)) > 0
  424. d.VTDisk = (n.dk_type[0] & (1 << 6)) > 0
  425. return d
  426. }
  427. func perfstatdiskpath2diskpath(n *C.perfstat_diskpath_t) DiskPath {
  428. var d DiskPath
  429. d.Name = C.GoString(&n.name[0])
  430. d.XRate = int64(n.xrate)
  431. d.Xfers = int64(n.xfers)
  432. d.Rblks = int64(n.rblks)
  433. d.Wblks = int64(n.wblks)
  434. d.Time = int64(n.time)
  435. d.Adapter = C.GoString(&n.adapter[0])
  436. d.QFull = int64(n.q_full)
  437. d.Rserv = int64(n.rserv)
  438. d.RTimeOut = int64(n.rtimeout)
  439. d.Rfailed = int64(n.rfailed)
  440. d.MinRserv = int64(n.min_rserv)
  441. d.MaxRserv = int64(n.max_rserv)
  442. d.Wserv = int64(n.wserv)
  443. d.WTimeOut = int64(n.wtimeout)
  444. d.Wfailed = int64(n.wfailed)
  445. d.MinWserv = int64(n.min_wserv)
  446. d.MaxWserv = int64(n.max_wserv)
  447. d.WqDepth = int64(n.wq_depth)
  448. d.WqSampled = int64(n.wq_sampled)
  449. d.WqTime = int64(n.wq_time)
  450. d.WqMinTime = int64(n.wq_min_time)
  451. d.WqMaxTime = int64(n.wq_max_time)
  452. d.QSampled = int64(n.q_sampled)
  453. d.Version = int64(n.version)
  454. return d
  455. }
  456. func perfstatfcstat2fcadapter(n *C.perfstat_fcstat_t) FCAdapter {
  457. var f FCAdapter
  458. f.Version = int64(n.version)
  459. f.Name = C.GoString(&n.name[0])
  460. f.State = int32(n.state)
  461. f.InputRequests = int64(n.InputRequests)
  462. f.OutputRequests = int64(n.OutputRequests)
  463. f.InputBytes = int64(n.InputBytes)
  464. f.OutputBytes = int64(n.OutputBytes)
  465. f.EffMaxTransfer = int64(n.EffMaxTransfer)
  466. f.NoDMAResourceCnt = int64(n.NoDMAResourceCnt)
  467. f.NoCmdResourceCnt = int64(n.NoCmdResourceCnt)
  468. f.AttentionType = int32(n.AttentionType)
  469. f.SecondsSinceLastReset = int64(n.SecondsSinceLastReset)
  470. f.TxFrames = int64(n.TxFrames)
  471. f.TxWords = int64(n.TxWords)
  472. f.RxFrames = int64(n.RxFrames)
  473. f.RxWords = int64(n.RxWords)
  474. f.LIPCount = int64(n.LIPCount)
  475. f.NOSCount = int64(n.NOSCount)
  476. f.ErrorFrames = int64(n.ErrorFrames)
  477. f.DumpedFrames = int64(n.DumpedFrames)
  478. f.LinkFailureCount = int64(n.LinkFailureCount)
  479. f.LossofSyncCount = int64(n.LossofSyncCount)
  480. f.LossofSignal = int64(n.LossofSignal)
  481. f.PrimitiveSeqProtocolErrCount = int64(n.PrimitiveSeqProtocolErrCount)
  482. f.InvalidTxWordCount = int64(n.InvalidTxWordCount)
  483. f.InvalidCRCCount = int64(n.InvalidCRCCount)
  484. f.PortFcId = int64(n.PortFcId)
  485. f.PortSpeed = int64(n.PortSpeed)
  486. f.PortType = C.GoString(&n.PortType[0])
  487. f.PortWWN = int64(n.PortWWN)
  488. f.PortSupportedSpeed = int64(n.PortSupportedSpeed)
  489. f.AdapterType = int(n.adapter_type)
  490. f.VfcName = C.GoString(&n.vfc_name[0])
  491. f.ClientPartName = C.GoString(&n.client_part_name[0])
  492. return f
  493. }
  494. func perfstatlogicalvolume2logicalvolume(n *C.perfstat_logicalvolume_t) LogicalVolume {
  495. var l LogicalVolume
  496. l.Name = C.GoString(&n.name[0])
  497. l.VGName = C.GoString(&n.vgname[0])
  498. l.OpenClose = int64(n.open_close)
  499. l.State = int64(n.state)
  500. l.MirrorPolicy = int64(n.mirror_policy)
  501. l.MirrorWriteConsistency = int64(n.mirror_write_consistency)
  502. l.WriteVerify = int64(n.write_verify)
  503. l.PPsize = int64(n.ppsize)
  504. l.LogicalPartitions = int64(n.logical_partitions)
  505. l.Mirrors = int32(n.mirrors)
  506. l.IOCnt = int64(n.iocnt)
  507. l.KBReads = int64(n.kbreads)
  508. l.KBWrites = int64(n.kbwrites)
  509. l.Version = int64(n.version)
  510. return l
  511. }
  512. func perfstatvolumegroup2volumegroup(n *C.perfstat_volumegroup_t) VolumeGroup {
  513. var v VolumeGroup
  514. v.Name = C.GoString(&n.name[0])
  515. v.TotalDisks = int64(n.total_disks)
  516. v.ActiveDisks = int64(n.active_disks)
  517. v.TotalLogicalVolumes = int64(n.total_logical_volumes)
  518. v.OpenedLogicalVolumes = int64(n.opened_logical_volumes)
  519. v.IOCnt = int64(n.iocnt)
  520. v.KBReads = int64(n.kbreads)
  521. v.KBWrites = int64(n.kbwrites)
  522. v.Version = int64(n.version)
  523. v.VariedState = int(n.variedState)
  524. return v
  525. }
  526. func perfstatmemorypage2memorypage(n *C.perfstat_memory_page_t) MemoryPage {
  527. var m MemoryPage
  528. m.PSize = int64(n.psize)
  529. m.RealTotal = int64(n.real_total)
  530. m.RealFree = int64(n.real_free)
  531. m.RealPinned = int64(n.real_pinned)
  532. m.RealInUse = int64(n.real_inuse)
  533. m.PgExct = int64(n.pgexct)
  534. m.PgIns = int64(n.pgins)
  535. m.PgOuts = int64(n.pgouts)
  536. m.PgSpIns = int64(n.pgspins)
  537. m.PgSpOuts = int64(n.pgspouts)
  538. m.Scans = int64(n.scans)
  539. m.Cycles = int64(n.cycles)
  540. m.PgSteals = int64(n.pgsteals)
  541. m.NumPerm = int64(n.numperm)
  542. m.NumPgSp = int64(n.numpgsp)
  543. m.RealSystem = int64(n.real_system)
  544. m.RealUser = int64(n.real_user)
  545. m.RealProcess = int64(n.real_process)
  546. m.VirtActive = int64(n.virt_active)
  547. m.ComprsdTotal = int64(n.comprsd_total)
  548. m.ComprsdWsegPgs = int64(n.comprsd_wseg_pgs)
  549. m.CPgIns = int64(n.cpgins)
  550. m.CPgOuts = int64(n.cpgouts)
  551. m.CPoolInUse = int64(n.cpool_inuse)
  552. m.UCPoolSize = int64(n.ucpool_size)
  553. m.ComprsdWsegSize = int64(n.comprsd_wseg_size)
  554. m.Version = int64(n.version)
  555. m.RealAvail = int64(n.real_avail)
  556. return m
  557. }
  558. func perfstatnetbuffer2netbuffer(n *C.perfstat_netbuffer_t) NetBuffer {
  559. var b NetBuffer
  560. b.Name = C.GoString(&n.name[0])
  561. b.InUse = int64(n.inuse)
  562. b.Calls = int64(n.calls)
  563. b.Delayed = int64(n.delayed)
  564. b.Free = int64(n.free)
  565. b.Failed = int64(n.failed)
  566. b.HighWatermark = int64(n.highwatermark)
  567. b.Freed = int64(n.freed)
  568. b.Version = int64(n.version)
  569. return b
  570. }
  571. func perfstatnetinterface2netiface(n *C.perfstat_netinterface_t) NetIface {
  572. var i NetIface
  573. i.Name = C.GoString(&n.name[0])
  574. i.Description = C.GoString(&n.description[0])
  575. i.Type = uint8(n._type)
  576. i.MTU = int64(n.mtu)
  577. i.IPackets = int64(n.ipackets)
  578. i.IBytes = int64(n.ibytes)
  579. i.IErrors = int64(n.ierrors)
  580. i.OPackets = int64(n.opackets)
  581. i.OBytes = int64(n.obytes)
  582. i.OErrors = int64(n.oerrors)
  583. i.Collisions = int64(n.collisions)
  584. i.Bitrate = int64(n.bitrate)
  585. i.XmitDrops = int64(n.xmitdrops)
  586. i.Version = int64(n.version)
  587. i.IfIqDrops = int64(n.if_iqdrops)
  588. i.IfArpDrops = int64(n.if_arpdrops)
  589. return i
  590. }
  591. func perfstatnetadapter2netadapter(n *C.perfstat_netadapter_t) NetAdapter {
  592. var i NetAdapter
  593. i.Version = int64(n.version)
  594. i.Name = C.GoString(&n.name[0])
  595. i.TxPackets = int64(n.tx_packets)
  596. i.TxBytes = int64(n.tx_bytes)
  597. i.TxInterrupts = int64(n.tx_interrupts)
  598. i.TxErrors = int64(n.tx_errors)
  599. i.TxPacketsDropped = int64(n.tx_packets_dropped)
  600. i.TxQueueSize = int64(n.tx_queue_size)
  601. i.TxQueueLen = int64(n.tx_queue_len)
  602. i.TxQueueOverflow = int64(n.tx_queue_overflow)
  603. i.TxBroadcastPackets = int64(n.tx_broadcast_packets)
  604. i.TxMulticastPackets = int64(n.tx_multicast_packets)
  605. i.TxCarrierSense = int64(n.tx_carrier_sense)
  606. i.TxDMAUnderrun = int64(n.tx_DMA_underrun)
  607. i.TxLostCTSErrors = int64(n.tx_lost_CTS_errors)
  608. i.TxMaxCollisionErrors = int64(n.tx_max_collision_errors)
  609. i.TxLateCollisionErrors = int64(n.tx_late_collision_errors)
  610. i.TxDeferred = int64(n.tx_deferred)
  611. i.TxTimeoutErrors = int64(n.tx_timeout_errors)
  612. i.TxSingleCollisionCount = int64(n.tx_single_collision_count)
  613. i.TxMultipleCollisionCount = int64(n.tx_multiple_collision_count)
  614. i.RxPackets = int64(n.rx_packets)
  615. i.RxBytes = int64(n.rx_bytes)
  616. i.RxInterrupts = int64(n.rx_interrupts)
  617. i.RxErrors = int64(n.rx_errors)
  618. i.RxPacketsDropped = int64(n.rx_packets_dropped)
  619. i.RxBadPackets = int64(n.rx_bad_packets)
  620. i.RxMulticastPackets = int64(n.rx_multicast_packets)
  621. i.RxBroadcastPackets = int64(n.rx_broadcast_packets)
  622. i.RxCRCErrors = int64(n.rx_CRC_errors)
  623. i.RxDMAOverrun = int64(n.rx_DMA_overrun)
  624. i.RxAlignmentErrors = int64(n.rx_alignment_errors)
  625. i.RxNoResourceErrors = int64(n.rx_noresource_errors)
  626. i.RxCollisionErrors = int64(n.rx_collision_errors)
  627. i.RxPacketTooShortErrors = int64(n.rx_packet_tooshort_errors)
  628. i.RxPacketTooLongErrors = int64(n.rx_packet_toolong_errors)
  629. i.RxPacketDiscardedByAdapter = int64(n.rx_packets_discardedbyadapter)
  630. i.AdapterType = int32(n.adapter_type)
  631. return i
  632. }
  633. func perfstatpagingspace2pagingspace(n *C.perfstat_pagingspace_t) PagingSpace {
  634. var i PagingSpace
  635. i.Name = C.GoString(&n.name[0])
  636. i.Type = uint8(n._type)
  637. i.VGName = C.GoString(C.get_ps_vgname(n))
  638. i.Hostname = C.GoString(C.get_ps_hostname(n))
  639. i.Filename = C.GoString(C.get_ps_filename(n))
  640. i.LPSize = int64(n.lp_size)
  641. i.MBSize = int64(n.mb_size)
  642. i.MBUsed = int64(n.mb_used)
  643. i.IOPending = int64(n.io_pending)
  644. i.Active = uint8(n.active)
  645. i.Automatic = uint8(n.automatic)
  646. i.Version = int64(n.version)
  647. return i
  648. }
  649. func perfstatprocess2process(n *C.perfstat_process_t) Process {
  650. var i Process
  651. i.Version = int64(n.version)
  652. i.PID = int64(n.pid)
  653. i.ProcessName = C.GoString(&n.proc_name[0])
  654. i.Priority = int32(n.proc_priority)
  655. i.NumThreads = int64(n.num_threads)
  656. i.UID = int64(n.proc_uid)
  657. i.ClassID = int64(n.proc_classid)
  658. i.Size = int64(n.proc_size)
  659. i.RealMemData = int64(n.proc_real_mem_data)
  660. i.RealMemText = int64(n.proc_real_mem_text)
  661. i.VirtMemData = int64(n.proc_virt_mem_data)
  662. i.VirtMemText = int64(n.proc_virt_mem_text)
  663. i.SharedLibDataSize = int64(n.shared_lib_data_size)
  664. i.HeapSize = int64(n.heap_size)
  665. i.RealInUse = int64(n.real_inuse)
  666. i.VirtInUse = int64(n.virt_inuse)
  667. i.Pinned = int64(n.pinned)
  668. i.PgSpInUse = int64(n.pgsp_inuse)
  669. i.FilePages = int64(n.filepages)
  670. i.RealInUseMap = int64(n.real_inuse_map)
  671. i.VirtInUseMap = int64(n.virt_inuse_map)
  672. i.PinnedInUseMap = int64(n.pinned_inuse_map)
  673. i.UCpuTime = float64(n.ucpu_time)
  674. i.SCpuTime = float64(n.scpu_time)
  675. i.LastTimeBase = int64(n.last_timebase)
  676. i.InBytes = int64(n.inBytes)
  677. i.OutBytes = int64(n.outBytes)
  678. i.InOps = int64(n.inOps)
  679. i.OutOps = int64(n.outOps)
  680. return i
  681. }
  682. func perfstatthread2thread(n *C.perfstat_thread_t) Thread {
  683. var i Thread
  684. i.TID = int64(n.tid)
  685. i.PID = int64(n.pid)
  686. i.CpuID = int64(n.cpuid)
  687. i.UCpuTime = float64(n.ucpu_time)
  688. i.SCpuTime = float64(n.scpu_time)
  689. i.LastTimeBase = int64(n.last_timebase)
  690. i.Version = int64(n.version)
  691. return i
  692. }
  693. func fsinfo2filesystem(n *C.struct_fsinfo) FileSystem {
  694. var i FileSystem
  695. i.Device = C.GoString(n.devname)
  696. i.MountPoint = C.GoString(n.fsname)
  697. i.FSType = int(n.fstype)
  698. i.Flags = int(n.flags)
  699. i.TotalBlocks = int64(n.totalblks)
  700. i.FreeBlocks = int64(n.freeblks)
  701. i.TotalInodes = int64(n.totalinodes)
  702. i.FreeInodes = int64(n.freeinodes)
  703. return i
  704. }