Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b24bfad
feat : Added Linux support only in the Cpu monitor header file
RayBreeze Jun 25, 2025
9ef8880
test: Testing the file compiled in Windows
RayBreeze Jun 25, 2025
320d87a
feat: Added Linux Support in the Memory monitor header
RayBreeze Jun 25, 2025
dfc8fe0
Merge branch 'linux_dev' of https://github.com/RayBreeze/SysMood into…
RayBreeze Jun 25, 2025
93f18f1
Add: More info about CPU
D3LET3-57 Oct 8, 2025
ba5457a
Refactor: Adding memory info and cpu stats
D3LET3-57 Oct 8, 2025
1b51ed4
Add: Linux Binary
D3LET3-57 Oct 8, 2025
9541491
Adjust CMakeList to include iphlpapi lib
AndersonTsaiTW Oct 12, 2025
0226fd7
add the network mood in main
AndersonTsaiTW Oct 12, 2025
3d94a94
chore(ci): Update to CI Workflow to use Linux(Ubuntu-Latest) with Win…
RayBreeze Oct 12, 2025
9748cb3
Merge pull request #6 from D3LET3-57/d3let3
RayBreeze Oct 12, 2025
58896aa
chore(ci): Extended CI Workflow to linux_dev branch
RayBreeze Oct 12, 2025
7dbe9ca
chore(ci): Extended CI Workflow to linux_dev branch
RayBreeze Oct 12, 2025
2af6013
chore(linux_dev): Bug Fixes
RayBreeze Oct 12, 2025
a9e25dd
Merge pull request #9 from RayBreeze/linux_dev
RayBreeze Oct 12, 2025
b8c307f
Update README with CI badge and contributors info
RayBreeze Oct 12, 2025
25d5aa4
Adjust CMakeList to include iphlpapi lib
AndersonTsaiTW Oct 12, 2025
b14f5dd
add the network mood in main
AndersonTsaiTW Oct 12, 2025
1759c53
Rebase and finished the network monitoring
AndersonTsaiTW Oct 12, 2025
139a46c
Merge branch 'feature/network-monitor-windows' of https://github.com/…
AndersonTsaiTW Oct 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ name: CI

on:
push:
branches: [ main ]
branches: [ main, linux_dev ]
pull_request:
branches: [ main ]
branches: [ main, linux_dev ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
os: [windows-latest, ubuntu-latest]

steps:
- uses: actions/checkout@v4

- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y build-essential cmake

- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ target_include_directories(SysMood PRIVATE
${CMAKE_SOURCE_DIR}/include
)

if(WIN32)
target_link_libraries(SysMood PRIVATE Iphlpapi)
endif()

# Enable testing (used later)
include(CTest)
enable_testing()
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SysMood
[![CI](https://github.com/RayBreeze/SysMood/actions/workflows/ci.yml/badge.svg)](https://github.com/RayBreeze/SysMood/actions/workflows/ci.yml)

Hey there, the lone wonderer here!
**SysMood** is a fun little console program for Windows that checks your CPU and memory usage, then tells you how your system is "feeling"—with some quirky moods and a splash of ASCII art.
Expand All @@ -19,6 +20,8 @@ Hey there, the lone wonderer here!
- **ASCII Art Banner:**
Because every program deserves a cool entrance.

and many more....

---

## How to Use
Expand Down Expand Up @@ -53,7 +56,7 @@ g++ -Iinclude src/main.cpp -o SysMood.exe
winget install SysMood
```

## What You’ll See
## What You’ll See [This is Demo of Release 1.0.0, future versions might differ...]

```sh
________ ___ ___ ________ _____ ______ ________ ________ ________
Expand Down Expand Up @@ -93,7 +96,7 @@ So much free memory! I could host a party in here!

## What You Need

- Windows (Linux folks—coming soon don't worry!)
- OS [ Windows or Linux ]
- C++17 or newer (tested with g++ and MSVC)

---
Expand All @@ -106,7 +109,17 @@ MIT License. See [LICENSE](LICENSE) for the legal stuff.

## Who Made This?

Made with ☕ and curiosity by [Samman Das (RayBreeze)](https://github.com/RayBreeze)
Made with ☕ and curiosity by [Samman Das (RayBreeze)](https://github.com/RayBreeze) and with the help of fellow Contributors across the Globe

---

## Contributors

<a href="https://github.com/RayBreeze/SysMood/graphs/contributors">
<img src="https://contrib.rocks/image?repo=RayBreeze/SysMood" />
</a>

Made with [contrib.rocks](https://contrib.rocks).

---

Expand Down
Binary file added SysMood.exe
Binary file not shown.
Binary file added bin/sysMood
Binary file not shown.
180 changes: 154 additions & 26 deletions include/cpu_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,176 @@
// - this file is mostly chill, unless your system's on fire 🔥
// - not responsible if your computer gets feelings 🥲
// - if you find a bug, please report it to me on github
//
//
#define _WIN32_WINNT 0x0602
#include <stdio.h>
#include <cstdint>
#include <windows.h>
#include <stdlib.h>
uint64_t FromFileTime( const FILETIME& ft ) {
ULARGE_INTEGER uli = { 0 };
#ifdef _WIN32
#include <windows.h>
#elif __linux__
#include <unistd.h>
#include <sys/time.h>
#include <fstream>
#include <vector>
#include <string>
#include <sstream>
#endif

#ifdef _WIN32
uint64_t FromFileTime(const FILETIME &ft)
{
ULARGE_INTEGER uli = {0};
uli.LowPart = ft.dwLowDateTime;
uli.HighPart = ft.dwHighDateTime;
return uli.QuadPart;
}
#elif __linux__
struct CpuTimes
{
uint64_t user, nice, system, idle, iowait, irq, softirq, steal;
uint64_t getTotalTime() const
{
return user + nice + system + idle + iowait + irq + softirq + steal;
}
uint64_t getIdleTime() const
{
return idle + iowait;
}
};

struct CPUStats
{
uint64_t ctxt;
uint64_t btime;
uint64_t processes;
uint64_t procs_running;
uint64_t procs_blocked;
};

CpuTimes getCpuTimes()
{
std::ifstream file("/proc/stat");
if (!file.is_open())
{
std::cerr << "Could not open /proc/stat" << std::endl;
return CpuTimes{0};
}
std::string line;
std::getline(file, line);

std::istringstream ss(line);
std::string cpu_label;
CpuTimes times = {0};

ss >> cpu_label >> times.user >> times.nice >> times.system >> times.idle >> times.iowait >> times.irq >> times.softirq >> times.steal;

return times;
}

CPUStats getCPUstats()
{
std::ifstream file("/proc/stat");
CPUStats stats = {0};
if (!file.is_open())
{
std::cerr << "Could not open /proc/stat" << std::endl;
return stats;
}
std::string line;
while (std::getline(file, line))
{
std::istringstream ss(line);
std::string key;
ss >> key;
if (key == "ctxt")
{
ss >> stats.ctxt;
}
else if (key == "btime")
{
ss >> stats.btime;
}
else if (key == "processes")
{
ss >> stats.processes;
}
else if (key == "procs_running")
{
ss >> stats.procs_running;
}
else if (key == "procs_blocked")
{
ss >> stats.procs_blocked;
}
}
return stats;
}
#endif

class Processor{};
class Processor
{
};

class Usage: public Processor
class Usage : public Processor
{
public:
#ifdef _WIN32
uint64_t FromFileTime(const FILETIME &ft)
{
public:
ULARGE_INTEGER uli = {0};
uli.LowPart = ft.dwLowDateTime;
uli.HighPart = ft.dwHighDateTime;
return uli.QuadPart;
}

int now(){
FILETIME i0, i1, k0, k1, u0, u1;
GetSystemTimes(&i0, &k0, &u0);
SleepEx(1000, false);
GetSystemTimes(&i1, &k1, &u1);
int now()
{
FILETIME i0, i1, k0, k1, u0, u1;
GetSystemTimes(&i0, &k0, &u0);
SleepEx(1000, false);
GetSystemTimes(&i1, &k1, &u1);

uint64_t idle0 = FromFileTime(i0);
uint64_t idle1 = FromFileTime(i1);
uint64_t kernel0 = FromFileTime(k0);
uint64_t kernel1 = FromFileTime(k1);
uint64_t user0 = FromFileTime(u0);
uint64_t user1 = FromFileTime(u1);

uint64_t idle0 = FromFileTime(i0);
uint64_t idle1 = FromFileTime(i1);
uint64_t kernel0 = FromFileTime(k0);
uint64_t kernel1 = FromFileTime(k1);
uint64_t user0 = FromFileTime(u0);
uint64_t user1 = FromFileTime(u1);
uint64_t idle = idle1 - idle0;
uint64_t kernel = kernel1 - kernel0;
uint64_t user = user1 - user0;

uint64_t idle = idle1 - idle0;
uint64_t kernel = kernel1 - kernel0;
uint64_t user = user1 - user0;
uint64_t total = (kernel + user) - idle;
double cpu = (1.0 - (double)idle / (kernel + user)) * 100.0;
return static_cast<int>(cpu);
}

double cpu = (1.0 - (double)idle / (kernel + user)) * 100.0;
#elif __linux__
int now()
{
CpuTimes times1 = getCpuTimes();
sleep(1);
CpuTimes times2 = getCpuTimes();

return static_cast<int>(cpu);
uint64_t idle1 = times1.getIdleTime();
uint64_t idle2 = times2.getIdleTime();
uint64_t total1 = times1.getTotalTime();
uint64_t total2 = times2.getTotalTime();

}
uint64_t idle_diff = idle2 - idle1;
uint64_t total_diff = total2 - total1;

if (total_diff == 0)
return 0; // Avoid division by zero

double cpu = (double)(total_diff - idle_diff) / total_diff * 100.0;
return static_cast<int>(cpu);
}
CPUStats getCPUstats()
{
return ::getCPUstats();
}

};
#endif
};
Loading