helpers.go 26 KB

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