xosview  1.23
About: xosview is an X Windows based system monitor (cpu, memory, swap and network usage; interrupt and serial activities; load average).
  Fossies Dox: xosview-1.23.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

kernel.cc File Reference
#include "kernel.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <kvm.h>
#include <nlist.h>
#include <limits.h>
#include <string.h>
#include <err.h>
#include <errno.h>
#include <ifaddrs.h>
#include <sysexits.h>
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <sys/vmmeter.h>
Include dependency graph for kernel.cc:

Go to the source code of this file.

Macros

#define DUMMY_SYM   "dummy_sym"
 
#define DUMMY_0
 
#define DUMMY_1
 
#define DUMMY_2
 
#define IFA_STAT(s)   (((struct if_data *)ifa->ifa_data)->ifi_ ## s)
 

Functions

static void safe_kvm_read (unsigned long kernel_addr, void *user_addr, size_t nbytes)
 
static void safe_kvm_read_symbol (int nlstOffset, void *user_addr, size_t nbytes)
 
int ValidSymbol (int index)
 
int SymbolValue (int index)
 
void BSDInit ()
 
void SetKernelName (const char *kernelName)
 
void OpenKDIfNeeded ()
 
int BSDGetCPUSpeed ()
 
void BSDPageInit ()
 
void BSDGetPageStats (uint64_t *meminfo, uint64_t *pageinfo)
 
void BSDCPUInit ()
 
void BSDGetCPUTimes (uint64_t *timeArray, unsigned int cpu)
 
int BSDNetInit ()
 
void BSDGetNetInOut (uint64_t *inbytes, uint64_t *outbytes, const char *netIface, bool ignored)
 
int BSDSwapInit ()
 
void BSDGetSwapInfo (uint64_t *total, uint64_t *used)
 
int BSDDiskInit ()
 
uint64_t BSDGetDiskXFerBytes (uint64_t *read_bytes, uint64_t *write_bytes)
 
int BSDIntrInit ()
 
int BSDNumInts ()
 
void BSDGetIntrStats (uint64_t *intrCount, unsigned int *intrNbrs)
 
int BSDCountCpus (void)
 
void BSDGetSensor (const char *name, const char *valname, float *value, char *unit)
 
bool BSDHasBattery ()
 
void BSDGetBatteryInfo (int *remaining, unsigned int *state)
 

Variables

kvm_t * kd = NULL
 
static struct nlist nlst []
 
static char kernelFileName [_POSIX2_LINE_MAX]
 
static int mib_cpu [2] = { CTL_HW, HW_NCPU }
 

Macro Definition Documentation

◆ DUMMY_0

#define DUMMY_0

◆ DUMMY_1

#define DUMMY_1

◆ DUMMY_2

#define DUMMY_2

◆ DUMMY_SYM

#define DUMMY_SYM   "dummy_sym"

◆ IFA_STAT

#define IFA_STAT (   s)    (((struct if_data *)ifa->ifa_data)->ifi_ ## s)

Function Documentation

◆ BSDCountCpus()

int BSDCountCpus ( void  )

Definition at line 1127 of file kernel.cc.

References mib_cpu.

Referenced by BSDGetCPUSpeed(), BSDGetCPUTimes(), LoadMeter::checkResources(), and MeterMaker::makeMeters().

◆ BSDCPUInit()

void BSDCPUInit ( )

Definition at line 394 of file kernel.cc.

References OpenKDIfNeeded().

Referenced by CPUMeter::CPUMeter().

◆ BSDDiskInit()

int BSDDiskInit ( )

Definition at line 795 of file kernel.cc.

References OpenKDIfNeeded().

Referenced by DiskMeter::DiskMeter().

◆ BSDGetBatteryInfo()

void BSDGetBatteryInfo ( int *  remaining,
unsigned int *  state 
)

◆ BSDGetCPUSpeed()

int BSDGetCPUSpeed ( )

Definition at line 254 of file kernel.cc.

References BSDCountCpus().

Referenced by LoadMeter::checkevent().

◆ BSDGetCPUTimes()

void BSDGetCPUTimes ( uint64_t *  timeArray,
unsigned int  cpu 
)

Definition at line 407 of file kernel.cc.

References BSDCountCpus().

Referenced by CPUMeter::getcputime().

◆ BSDGetDiskXFerBytes()

uint64_t BSDGetDiskXFerBytes ( uint64_t *  read_bytes,
uint64_t *  write_bytes 
)

Definition at line 804 of file kernel.cc.

References safe_kvm_read(), and safe_kvm_read_symbol().

Referenced by DiskMeter::getstats().

◆ BSDGetIntrStats()

void BSDGetIntrStats ( uint64_t *  intrCount,
unsigned int *  intrNbrs 
)

Definition at line 976 of file kernel.cc.

References nlst, and safe_kvm_read().

Referenced by IrqRateMeter::checkResources(), IrqRateMeter::getinfo(), and IntMeter::getirqs().

◆ BSDGetNetInOut()

void BSDGetNetInOut ( uint64_t *  inbytes,
uint64_t *  outbytes,
const char *  netIface,
bool  ignored 
)

Definition at line 492 of file kernel.cc.

References IFA_STAT.

Referenced by NetMeter::getstats(), and NetMeter::NetMeter().

◆ BSDGetPageStats()

void BSDGetPageStats ( uint64_t *  meminfo,
uint64_t *  pageinfo 
)

Definition at line 301 of file kernel.cc.

Referenced by MemMeter::getmeminfo(), PageMeter::getpageinfo(), and PageMeter::PageMeter().

◆ BSDGetSensor()

void BSDGetSensor ( const char *  name,
const char *  valname,
float *  value,
char *  unit 
)

◆ BSDGetSwapInfo()

void BSDGetSwapInfo ( uint64_t *  total,
uint64_t *  used 
)

Definition at line 531 of file kernel.cc.

References kd, and OpenKDIfNeeded().

Referenced by SwapMeter::getswapinfo().

◆ BSDHasBattery()

bool BSDHasBattery ( )

Definition at line 1532 of file kernel.cc.

References BSDGetSensor().

Referenced by MeterMaker::makeMeters().

◆ BSDInit()

void BSDInit ( )

Definition at line 198 of file kernel.cc.

References kernelFileName.

Referenced by XOSView::XOSView().

◆ BSDIntrInit()

int BSDIntrInit ( )

◆ BSDNetInit()

int BSDNetInit ( )

Definition at line 486 of file kernel.cc.

References OpenKDIfNeeded().

Referenced by NetMeter::NetMeter().

◆ BSDNumInts()

int BSDNumInts ( )

Definition at line 873 of file kernel.cc.

References nlst, and safe_kvm_read().

Referenced by IntMeter::IntMeter(), and IrqRateMeter::IrqRateMeter().

◆ BSDPageInit()

void BSDPageInit ( )

Definition at line 294 of file kernel.cc.

References OpenKDIfNeeded().

Referenced by MemMeter::MemMeter(), and PageMeter::PageMeter().

◆ BSDSwapInit()

int BSDSwapInit ( )

Definition at line 525 of file kernel.cc.

References OpenKDIfNeeded().

Referenced by SwapMeter::SwapMeter().

◆ OpenKDIfNeeded()

void OpenKDIfNeeded ( )

◆ safe_kvm_read()

static void safe_kvm_read ( unsigned long  kernel_addr,
void *  user_addr,
size_t  nbytes 
)
inlinestatic

Definition at line 167 of file kernel.cc.

References kd.

Referenced by BSDGetDiskXFerBytes(), BSDGetIntrStats(), BSDIntrInit(), BSDNumInts(), and safe_kvm_read_symbol().

◆ safe_kvm_read_symbol()

static void safe_kvm_read_symbol ( int  nlstOffset,
void *  user_addr,
size_t  nbytes 
)
inlinestatic

Definition at line 183 of file kernel.cc.

References nlst, and safe_kvm_read().

Referenced by BSDGetDiskXFerBytes().

◆ SetKernelName()

void SetKernelName ( const char *  kernelName)

Definition at line 203 of file kernel.cc.

References kernelFileName.

Referenced by XOSView::checkArgs().

◆ SymbolValue()

int SymbolValue ( int  index)

Definition at line 193 of file kernel.cc.

References nlst.

Referenced by BSDIntrInit().

◆ ValidSymbol()

int ValidSymbol ( int  index)

Definition at line 188 of file kernel.cc.

References nlst.

Referenced by BSDIntrInit().

Variable Documentation

◆ kd

kvm_t* kd = NULL

Definition at line 110 of file kernel.cc.

Referenced by BSDGetSwapInfo(), OpenKDIfNeeded(), and safe_kvm_read().

◆ kernelFileName

char kernelFileName[_POSIX2_LINE_MAX]
static

Definition at line 158 of file kernel.cc.

Referenced by BSDInit(), OpenKDIfNeeded(), and SetKernelName().

◆ mib_cpu

int mib_cpu[2] = { CTL_HW, HW_NCPU }
static

Definition at line 1124 of file kernel.cc.

Referenced by BSDCountCpus().

◆ nlst

struct nlist nlst[]
static