Skip to content

Commit

Permalink
feat: CPU speed and OS distro
Browse files Browse the repository at this point in the history
  • Loading branch information
nexmoe committed Oct 6, 2023
1 parent df36b18 commit 3765428
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Monitor Pro is a comprehensive resource monitoring tool designed to help you kee

- [ ] Resources Monitor
- [x] **CPU Usage**: Monitor the percentage of CPU utilization to understand how much processing power is being utilized by your system.
- [x] **CPU Temperature**: Monitor the temperature if it can.
- [x] **Memory Usage**: Keep an eye on the memory consumption of your computer.
- [x] **Network Usage**: Track the network activity on your machine, including incoming and outgoing data transfer rates, to monitor network performance.
- [x] **File-system Usage** (Linux, macOS): Monitor the usage of your file system, provides the read/write rate of the disk
Expand Down
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@
"default": 6,
"description": "Order of the file cpu temperature. 0 to hide."
},
"monitor-pro.order.cpuSpeed": {
"type": "number",
"order": 6,
"default": 7,
"description": "Order of the file cpu speed. 0 to hide."
},
"monitor-pro.order.os": {
"type": "number",
"order": 7,
"default": 8,
"description": "Order of the file cpu speed. 0 to hide."
},
"monitor-pro.refresh-interval": {
"type": "number",
"default": 3000,
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const orderConfigurationKeys = <const>[
"monitor-pro.order.fileSystem",
"monitor-pro.order.battery",
"monitor-pro.order.cpuTemp",
"monitor-pro.order.cpuSpeed",
"monitor-pro.order.os",
];

export type OrderConfigurationKey = (typeof orderConfigurationKeys)[number];
Expand Down
26 changes: 23 additions & 3 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ const netText = async () => {
const ns = await SI.networkStats();
return `$(cloud-download)${pretty(
ns?.[0]?.rx_sec ?? 0
)} $(cloud-upload)${pretty(ns?.[0]?.tx_sec ?? 0)}`;
)}/s $(cloud-upload)${pretty(ns?.[0]?.tx_sec ?? 0)}/s`;
};

const fsText = async () => {
const fs = await SI.fsStats();
return `$(log-in)${pretty(fs.wx_sec ?? 0)}$(log-out)${pretty(
return `$(log-in)${pretty(fs.wx_sec ?? 0)}/s $(log-out)${pretty(
fs.rx_sec ?? 0
)}`;
)}/s`;
};

const batteryText = async () => {
Expand All @@ -55,6 +55,11 @@ const batteryText = async () => {
return `$(plug)${b.percent}%${b.isCharging ? "(Charging)" : ""}`;
};

const cpuSpeedText = async () => {
let cpuCurrentSpeed = await SI.cpuCurrentSpeed();
return `$(dashboard) ${cpuCurrentSpeed.avg}GHz`;
};

const cpuTempText = async () => {
const cl = await SI.cpuTemperature();
if (!cl.main) {
Expand All @@ -63,6 +68,11 @@ const cpuTempText = async () => {
return `$(thermometer)${cl.main}°C`;
};

const osDistroText = async () => {
const os = await SI.osInfo();
return `${os.distro}`;
};

const metrics: MetricCtrProps[] = [
{
func: cpuText,
Expand Down Expand Up @@ -94,6 +104,16 @@ const metrics: MetricCtrProps[] = [
name: "CPU Temperature",
section: "monitor-pro.order.cpuTemp",
},
{
func: cpuSpeedText,
name: "CPU Speed",
section: "monitor-pro.order.cpuSpeed",
},
{
func: osDistroText,
name: "OS Distro",
section: "monitor-pro.order.os",
},
];

export default metrics;

0 comments on commit 3765428

Please sign in to comment.