https://github.com/mdavidsaver/linstat
EPICS Driver to serve up Linux system and/or process specific information
https://github.com/mdavidsaver/linstat
epics
Last synced: 5 months ago
JSON representation
EPICS Driver to serve up Linux system and/or process specific information
- Host: GitHub
- URL: https://github.com/mdavidsaver/linstat
- Owner: mdavidsaver
- License: lgpl-3.0
- Created: 2024-06-03T18:47:23.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2025-09-30T22:26:48.000Z (6 months ago)
- Last Synced: 2025-10-01T00:10:51.266Z (6 months ago)
- Topics: epics
- Language: C++
- Homepage:
- Size: 399 KB
- Stars: 5
- Watchers: 1
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Copyright: COPYRIGHT
Awesome Lists containing this project
README
# Linux Statistics Driver
An EPICS Driver to serve up Linux system and/or process
specific information from an IOC.
Requires:
- EPICS Base >= 7.0.4
- gcc or clang with c++17 support (GCC >= 8.5)
- Linux >= 4.12

## Comparison with iocStats
This module provides a super-set for the information provided by
[iocStats](https://github.com/epics-modules/iocStats)
where possible with the same record names.
However unlike iocStats, this module is limited to Linux.
| linStat | iocStats | Description |
|---------|----------|-------------|
| X | X | CPU Usage |
| X | X | Mem Usage |
| X | X | FD Usage |
| X | X | DB Scan stats. |
| X | | malloc() stats |
| X | | Swap Usage |
| X | | IP Stats. |
| X | | NIC Stats. |
| X | | FS Usage |
Additional information provided by linStat includes:
- `$(IOC):SYS_TOT_LOAD` CPU usage including overheads (IRQ handling, I/O waits, ...)
- IP stack statistics, host and process
- Network Interface Card (NIC) statistics
- File System usage
## Building
```sh
git clone https://github.com/mdavidsaver/linStat
cd linStat
echo "EPICS_BASE=/path/to/epics-base" >> configure/RELEASE.local
make
# Optionally "make LINSTAT_BUILD_EXAMPLE=NO"
# to omit building linStatDemo application.
```
## Including in an IOC
Starting from a template produced by:
```sh
makeBaseApp.pl -t ioc my
makeBaseApp.pl -t ioc -i -p myApp myioc
```
Edit and append `configure/RELEASE` (or create `configure/RELEASE.local`)
to set the path to the built linStat tree.
```make
LINSTAT=/path/to/linStat
```
Optionally edit `myApp/Db/Makefile`.
Recommended when building with `STATIC_BUILD=NO`.
```make
# ADD MACRO DEFINITIONS AFTER THIS LINE
ifdef LINSTAT_0_0_0 # <----- Add
DB_INSTALLS += $(wildcard $(LINSTAT_TOP)/db/linStat*.db) # <----- Add
endif # <----- Add
```
Edit `myApp/src/Makefile`.
```make
# ... myApp/src/Makefile
PROD_IOC += myapp
DBD += myapp.dbd
...
myapp_SRCS += myapp_registerRecordDeviceDriver.cpp
myapp_DBD += base.dbd
ifdef LINSTAT_0_0_0 # <----- Add
linStatDemo_DBD += linStat.dbd # <----- Add
linStatDemo_LIBS += linStat # <----- Add
endif # <----- Add
myapp_LIBS += $(EPICS_BASE_IOC_LIBS)
```
Create/overwrite `iocBoot/iocmyioc/st.cmd`.
```sh
# iocBoot/iocmyioc/st.cmd
#!../../linux-x86_64/myapp
# search PATH for dbLoadRecords()
# If no DB_INSTALLS for linStat*.db, then append LINSTAT /db directory.
epicsEnvSet("EPICS_DB_INCLUDE_PATH", "$(PWD)../../db")
dbLoadDatabase("../../dbd/myapp.dbd")
myapp_registerRecordDeviceDriver(pdbbase)
# Replace "LOCALHOST" with a unique record name prefix
epicsEnvSet("IOC", "LOCALHOST")
# Optional information
#epicsEnvSet("ENGINEER", "Respectible Name")
#epicsEnvSet("LOCATION", "Where am I?")
# (un)comment some or all of the following dbLoadRecords before iocInit.
# System-wide information
dbLoadRecords("../../db/linStatHost.db","IOC=$(IOC)")
# IOC process specific information
dbLoadRecords("../../db/linStatProc.db","IOC=$(IOC)")
# Network interface information
dbLoadRecords("../../db/linStatNIC.db","IOC=$(IOC),NIC=lo")
# may repeat with different NIC= network interface name(s)
#dbLoadRecords("../../db/linStatNIC.db","IOC=$(IOC),NIC=eth0")
# File system mount point information
dbLoadRecords("../../db/linStatFS.db","P=$(IOC):ROOT,DIR=/")
# may repeat with different file system mount points
# change both P= and DIR=
#dbLoadRecords("../../db/linStatFS.db","P=$(IOC):DATA,DIR=/data")
iocInit()
```