~serjei_mikailov/zbfetch

0a37734258984ee5ecdaaecafedf703e57fea5db — SerjeiMikailov 25 days ago 8bf989e master
fetch
3 files changed, 52 insertions(+), 2 deletions(-)

M README.md
A src/cmem.sh
M src/main.zig
M README.md => README.md +1 -1
@@ 1,3 1,3 @@
# zbfetch

### ZIG fetch
### Advanced FreeBSD Zig fetch tool

A src/cmem.sh => src/cmem.sh +27 -0
@@ 0,0 1,27 @@
# Total pages
total_pages=$(sysctl -n vm.stats.vm.v_page_count)
# Free pages
free_pages=$(sysctl -n vm.stats.vm.v_free_count)
# Active pages
active_pages=$(sysctl -n vm.stats.vm.v_active_count)
# Inactive pages
inactive_pages=$(sysctl -n vm.stats.vm.v_inactive_count)
# Wired pages
wired_pages=$(sysctl -n vm.stats.vm.v_wire_count)
# Page size
page_size=$(sysctl -n hw.pagesize)

# Calculate memory usage in bytes
total_mem=$((total_pages * page_size))
free_mem=$((free_pages * page_size))
active_mem=$((active_pages * page_size))
inactive_mem=$((inactive_pages * page_size))
wired_mem=$((wired_pages * page_size))

# Print memory usage
echo "Total Memory: $((total_mem / 1024 / 1024)) MB"
echo "Free Memory: $((free_mem / 1024 / 1024)) MB"
echo "Active Memory: $((active_mem / 1024 / 1024)) MB"
echo "Inactive Memory: $((inactive_mem / 1024 / 1024)) MB"
echo "Wired Memory: $((wired_mem / 1024 / 1024)) MB"


M src/main.zig => src/main.zig +24 -1
@@ 1,5 1,28 @@
const std = @import("std");
const c = @cImport(@cInclude("stdlib.h"));

pub fn main() !void {
    std.debug.print("gg", .{});
    std.debug.print(" \n", .{});
    std.debug.print("USER: ", .{});
    _ = c.system("who");

    std.debug.print("OS: ", .{});
    _ = c.system("uname -o -r");

    std.debug.print(" \n", .{});
    std.debug.print("PROCESSOR: \n", .{});
    _ = c.system("sysctl hw.model hw.machine hw.ncpu");

    std.debug.print(" \n", .{});
    std.debug.print("MEMORY: \n", .{});
    _ = c.system("dmesg | grep memory");
    _ = c.system("cd ~/projects/zbfetch/src && sh cmem.sh");

    std.debug.print(" \n", .{});
    std.debug.print("DISK: \n", .{});
    _ = c.system("df -h");

    std.debug.print(" \n", .{});
    std.debug.print("GRAPHICS: \n", .{});
    _ = c.system("pciconf -lv | grep -A4 -i vga");
}