Compare commits
3 Commits
92196dcbf8
...
2518c92ca3
| Author | SHA1 | Date |
|---|---|---|
|
|
2518c92ca3 | |
|
|
e4d1fc7156 | |
|
|
40612cc4c2 |
|
|
@ -0,0 +1,82 @@
|
||||||
|
# waybar-collectd
|
||||||
|
|
||||||
|
A Waybar graphing utility inspired by the Gnome 2 Panel system indicator. It uses collectd's `unixsock` plugin to gather metrics and renders images for the `waybar-image` plugin.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
```bash
|
||||||
|
cargo install --git https://forgejo.cerno.ch/handy/waybar-collectd.git
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuring collectd
|
||||||
|
Install and configure `collectd` with the `unixsock` plugin. For per-second updates, adjust the sampling interval. Ensure `collectd` is enabled to start on boot.
|
||||||
|
|
||||||
|
**Example config (`/etc/collectd.d/waybar.conf`):**
|
||||||
|
```conf
|
||||||
|
Interval 1 # Sample data every 1 second
|
||||||
|
|
||||||
|
LoadPlugin unixsock
|
||||||
|
|
||||||
|
# Enable the plugins you want to use
|
||||||
|
LoadPlugin cpu
|
||||||
|
LoadPlugin memory
|
||||||
|
LoadPlugin disk
|
||||||
|
LoadPlugin network
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo systemctl enable --now collectd
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuring waybar-collectd
|
||||||
|
Define your graphs and data sources in `config.toml`. To ensure the daemon runs on login, use a user systemd unit or your WM configuration.
|
||||||
|
|
||||||
|
### User systemd unit example
|
||||||
|
`~/.config/systemd/user/waybar-hwmonitor-daemon.service`
|
||||||
|
```ini
|
||||||
|
[Unit]
|
||||||
|
Description=Data collection daemon for waybar hw monitor
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=%h/.cargo/bin/waybar-collectd --config %h/.config/waybar/modules/waybar-collectd-config.toml
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=2s
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuring Waybar
|
||||||
|
Add a module for each graph to your Waybar config. Ensure the `size` matches the rendered image dimensions.
|
||||||
|
|
||||||
|
**Example config (`~/.config/waybar/config`):**
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"layer": "bottom",
|
||||||
|
"position": "top",
|
||||||
|
"modules-center": ["image#net", "image#disk", "image#mem", "image#cpu"],
|
||||||
|
"height": 24,
|
||||||
|
"image#cpu": {
|
||||||
|
"path": "/tmp/waybar-graphs/cpu.png",
|
||||||
|
"size": 120,
|
||||||
|
"interval": 1
|
||||||
|
},
|
||||||
|
"image#mem": {
|
||||||
|
"path": "/tmp/waybar-graphs/mem.png",
|
||||||
|
"size": 120,
|
||||||
|
"interval": 1
|
||||||
|
},
|
||||||
|
"image#disk": {
|
||||||
|
"path": "/tmp/waybar-graphs/disk.png",
|
||||||
|
"size": 120,
|
||||||
|
"interval": 1
|
||||||
|
},
|
||||||
|
"image#net": {
|
||||||
|
"path": "/tmp/waybar-graphs/net.png",
|
||||||
|
"size": 120,
|
||||||
|
"interval": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
[global]
|
[global]
|
||||||
period = 1
|
period = 1
|
||||||
|
socket = "/var/run/collectd-unixsock"
|
||||||
|
|
||||||
[[graph]]
|
[[graph]]
|
||||||
name = "cpu load"
|
name = "cpu load"
|
||||||
path = "cpu.png"
|
path = "/tmp/waybar-graphs/cpu.png"
|
||||||
width_px = 480
|
width_px = 480
|
||||||
height_px = 98
|
height_px = 98
|
||||||
samples = 60
|
samples = 60
|
||||||
|
|
@ -38,7 +39,7 @@ metrics = [
|
||||||
|
|
||||||
[[graph]]
|
[[graph]]
|
||||||
name = "memory"
|
name = "memory"
|
||||||
path = "mem.png"
|
path = "/tmp/waybar-graphs/mem.png"
|
||||||
width_px = 480
|
width_px = 480
|
||||||
height_px = 98
|
height_px = 98
|
||||||
samples = 90
|
samples = 90
|
||||||
|
|
@ -67,7 +68,7 @@ metrics = [
|
||||||
|
|
||||||
[[graph]]
|
[[graph]]
|
||||||
name = "disk"
|
name = "disk"
|
||||||
path = "disk.png"
|
path = "/tmp/waybar-graphs/disk.png"
|
||||||
width_px = 480
|
width_px = 480
|
||||||
height_px = 98
|
height_px = 98
|
||||||
samples = 90
|
samples = 90
|
||||||
|
|
@ -88,7 +89,7 @@ metrics = [
|
||||||
|
|
||||||
[[graph]]
|
[[graph]]
|
||||||
name = "network"
|
name = "network"
|
||||||
path = "net.png"
|
path = "/tmp/waybar-graphs/net.png"
|
||||||
width_px = 480
|
width_px = 480
|
||||||
height_px = 98
|
height_px = 98
|
||||||
samples = 90
|
samples = 90
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ pub struct Config {
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Global {
|
pub struct Global {
|
||||||
pub period: f32,
|
pub period: f32,
|
||||||
|
pub socket: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,8 @@ struct Cli {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = Cli::parse();
|
let args = Cli::parse();
|
||||||
if let Ok(mut proto) = Protocol::new("/var/run/collectd-unixsock") {
|
|
||||||
let config = parse(&args.config);
|
let config = parse(&args.config);
|
||||||
|
if let Ok(mut proto) = Protocol::new(&config.global.socket) {
|
||||||
let graphs = config
|
let graphs = config
|
||||||
.graph
|
.graph
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue