KDK_RTI_GE...GE_PERCENT(3)

📦 version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

✨ KDK_RTI_GE...GE_PERCENT(3) ✨

okay bestie so this is a page out of the Library Functions Manual — it's KDK_RTI_GE...GE_PERCENT(3) 💅 and it's literally all about checking how cooked your swap partition is. no cap. let's get into it 🫶


🌸 NAME 🌸

kdk_rti_get_mem_swap_usage_percent — 获取Swap分区使用率 (aka "how much of your swap is being used rn", we're getting the Swap partition usage rate)


🎀 SYNOPSIS 🎀

#include <libkyrtinfo.h>

extern float kdk_rti_get_mem_swap_usage_percent();

Link with -lkyrtinfo.

not the extern float and the empty parens 💀 she's giving old-school C energy and we respect it

🦋 Detailed Description 🦋

The main function of the interface is to obtain the Swap partition usage rate.

that's it. that's the whole vibe. this function has ONE job and it does it — it tells you the Swap partition usage rate. main character energy honestly 👑


💖 RETURN VALUE 💖

  • On success, returns the Swap partition usage rate of type float. slay ✨
  • On error, return 0. 😭 so yeah if you get a 0 back, that's your red flag bestie, not a real reading

🌈 EXAMPLES 🌈

here's the full demo, copy-paste ready, she's giving whole-system dashboard:

#include "libkyrtinfo.h"
#include <stdio.h>

int main()
{
    printf("内存总大小:%lu KiB0, kdk_rti_get_mem_res_total_KiB());
    printf("当前已用内存:%lu KiB,%f0, kdk_rti_get_mem_res_usage_KiB(), kdk_rti_get_mem_res_usage_percent());
    printf("当前空闲内存:%lu KiB0, kdk_rti_get_mem_res_free_KiB());
    printf("可用内存大小:%lu KiB0, kdk_rti_get_mem_res_available_KiB());
    printf("应用总申请虚拟内存大小:%lu KiB0, kdk_rti_get_mem_virt_alloc_KiB());
    printf("交换分区总量:%lu KiB0, kdk_rti_get_mem_swap_total_KiB());
    printf("交换分区已用量:%lu KiB, %f0, kdk_rti_get_mem_swap_usage_KiB(), kdk_rti_get_mem_swap_usage_percent());
    printf("交换分区剩余大小:%lu KiB0, kdk_rti_get_mem_swap_free_KiB());
    printf("当前CPU使用率:%f0, kdk_rti_get_cpu_current_usage());
    unsigned int day, hour, min, sec;
    kdk_rti_get_uptime(&day, &hour, &min, &sec);
    printf("开机时长:%u天%u小时%u分钟%u秒0, day, hour, min, sec);
    return 0;
}
lowkey obsessed with how this one file shows off memory, swap, cpu AND uptime all at once. it's giving "one function to rule them all" 🧚 (well, one example to call them all, technically)

👑 CONFORMING TO 👑

These functions are as per the withdrawn POSIX.1e draft specification.

The following functions are Linux extensions: kdk_rti_get_mem_res_total_KiB(), kdk_rti_get_mem_res_usage_percent(), kdk_rti_get_mem_res_usage_KiB(), kdk_rti_get_mem_res_available_KiB(), kdk_rti_get_mem_res_free_KiB(), kdk_rti_get_mem_virt_alloc_KiB(), kdk_rti_get_mem_swap_total_KiB(), kdk_rti_get_mem_swap_usage_KiB(), kdk_rti_get_mem_swap_free_KiB(), kdk_rti_get_cpu_current_usage() and kdk_rti_get_uptime().

⚠️ heads up bestie — POSIX.1e is withdrawn, so that part is a lil vintage. and everything in that list is a Linux extension, iykyk, don't go expecting it on your weird BSD setup fr fr

💜 SEE ALSO 💜

go read the whole friend group, they're all icons 🫶


and that's the page bestie!! 💖 brought to you by the Linux Programmer's Manual, dated Mon Sep 18 2023 — so like, a lil vintage but still eating. now go check your swap and hydrate 💅✨🌸

📦 where this page comes from