13 #ifndef __STOUT_OS_FREEBSD_HPP__ 14 #define __STOUT_OS_FREEBSD_HPP__ 18 #error "stout/os/freebsd.hpp is only available on FreeBSD systems." 21 #include <sys/types.h> 39 return Error(
"Failed to retrieve process table via sysctl: " +
43 foreach (
const kinfo_proc& kinfo, kinfos.
get()) {
44 if (kinfo.ki_pid == pid) {
50 kinfo.ki_rssize * pagesize,
51 kinfo.ki_rusage.ru_utime,
52 kinfo.ki_rusage.ru_stime,
54 kinfo.ki_stat == SZOMB);
64 std::set<pid_t> result;
69 foreach (
const kinfo_proc& kinfo, kinfos.
get()) {
70 result.insert(kinfo.ki_pid);
90 unsigned int freeCount;
91 size_t freeCountLength =
sizeof(freeCount);
93 "vm.stats.vm.v_free_count",
101 unsigned int inactiveCount;
102 size_t inactiveCountLength =
sizeof(inactiveCount);
104 "vm.stats.vm.v_inactive_count",
106 &inactiveCountLength,
112 memory.
free =
Bytes((freeCount + inactiveCount) * pageSize);
119 if (::sysctlnametomib(
"vm.swap_info", mib, &mibSize) != 0) {
125 size_t xswdSize =
sizeof(xswd);
126 for (
int ndev = 0; ; ndev++) {
129 if (::
sysctl(mib, 3, &xswd, &xswdSize,
nullptr, 0) != 0) {
130 if (errno == ENOENT) {
136 totalBlocks += xswd.xsw_nblks;
137 usedBlocks += xswd.xsw_used;
141 memory.
freeSwap =
Bytes((totalBlocks - usedBlocks) * pageSize);
Definition: errorbase.hpp:36
T & get()&
Definition: try.hpp:80
size_t pagesize()
Definition: pagesize.hpp:24
Definition: errorbase.hpp:50
Definition: posix_signalhandler.hpp:23
Bytes freeSwap
Definition: os.hpp:39
DWORD pid_t
Definition: windows.hpp:181
Definition: process.hpp:32
Table table(const Option< size_t > &length=None()) const
Definition: sysctl.hpp:229
Bytes totalSwap
Definition: os.hpp:38
Integer integer() const
Definition: sysctl.hpp:182
static Try error(const E &e)
Definition: try.hpp:43
Result< Process > process(pid_t pid)
Definition: freebsd.hpp:30
bool isError() const
Definition: try.hpp:78
Bytes total
Definition: os.hpp:36
Definition: sysctl.hpp:59
Try< Memory > memory()
Definition: freebsd.hpp:78
Bytes free
Definition: os.hpp:37
Try< std::set< pid_t > > pids()
Definition: freebsd.hpp:62