MonkeybreadSoftware Posted February 8 Posted February 8 For the 15.1 version of MBS FileMaker Plugin, we made a little change to Text.ReadTextFile to be able to read from /proc directory on Linux. This way you can read various system things. There are hundreds of things you can read there, so let us show you a few useful picks: Memory Information The meminfo entry provides information about memory utilization. This varies for different linux versions, but you should be able to query the text and find the entries you like. Set Variable [ $meminfo ; Value: MBS("Text.ReadTextFile"; "/proc/meminfo") ] The MemTotal is the total memory in the system. MemFree would be the free memory, but on a Linux system free memory is a waste as every free page could be used for file caching. So MemAvailable defines how much memory is available for use, which includes the free memory, but also memory that could be freed dirctely like file caches. Unevictable shows how much memory can't be moved to swap. You may use these values to calculate some memory statistics and watch it over time. MemTotal: 2013676 kB MemFree: 94388 kB MemAvailable: 797316 kB Buffers: 11584 kB Cached: 822488 kB SwapCached: 46672 kB Active: 389888 kB Inactive: 1149180 kB Active(anon): 162308 kB Inactive(anon): 657372 kB Active(file): 227580 kB Inactive(file): 491808 kB Unevictable: 124760 kB Mlocked: 26648 kB SwapTotal: 2097148 kB SwapFree: 561844 kB Dirty: 64 kB Writeback: 0 kB AnonPages: 788252 kB Mapped: 255136 kB Shmem: 107300 kB KReclaimable: 73652 kB Slab: 167248 kB SReclaimable: 73652 kB SUnreclaim: 93596 kB KernelStack: 12944 kB PageTables: 26132 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 3103984 kB Committed_AS: 7162784 kB VmallocTotal: 133143592960 kB VmallocUsed: 30956 kB VmallocChunk: 0 kB Percpu: 1528 kB HardwareCorrupted: 0 kB AnonHugePages: 0 kB ShmemHugePages: 0 kB ShmemPmdMapped: 0 kB FileHugePages: 0 kB FilePmdMapped: 0 kB CmaTotal: 32768 kB CmaFree: 1968 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB Hugetlb: 0 kB CPU Information You can query various CPU information with the cpuinfo entry. Our example below shows 2 CPUs and a lot of flags what the CPU can do. Set Variable [ $cpuinfo ; Value: MBS("Text.ReadTextFile"; "/proc/cpuinfo") ] Interesting to see that this CPU can do various SHA functions in hardware! processor : 0 BogoMIPS : 48.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp flagm2 frint CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0x000 CPU revision : 0 processor : 1 BogoMIPS : 48.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp flagm2 frint CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0x000 CPU revision : 0 Load Average The load average provides how much CPU usage you ave for the last 1, 5 & 15 minutes. Set Variable [ $loadavg ; Value: MBS("Text.ReadTextFile"; "/proc/loadavg") ] The output below shows a very low load on this machine. 3 processes are runnable, 808 processes are there in total and the last PID is 29022. 0.04 0.05 0.08 3/808 29022 Stats You can get various information about kernel activity here. All the numbers are counted and increase. So you may need to query this from time to time in order to calculate differences. Set Variable [ $stat ; Value: MBS("Text.ReadTextFile"; "/proc/stat") ] First line sums the individual CPU cores below. First number is user, then nice, then system and then idle time. You would need to sum up all four numbers and then calculate the percentage. e.g. 10175 + 591 + 7497 + 1465294 = 1483557. Now we divide 1465294 / 1.483.557 and get 98.8% idle. cpu 10175 591 7497 1465294 2431 0 640 0 0 0 cpu0 4854 225 3636 733182 930 0 453 0 0 0 cpu1 5321 366 3860 732112 1501 0 186 0 0 0 intr 1748953 0 64184 488692 0 0 0 5 0 0 0 742674 0 0 0 0 325920 0 0 0 0 5462 0 28627 28044 3 64431 0 0 0 911 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ctxt 3160661 btime 1738684164 processes 29023 procs_running 2 procs_blocked 0 softirq 1337672 4763 186019 5 75927 322371 0 2619 372912 0 373056 My Process Status You can query information about each process. You refer to the current process with self, so we can use /proc/self/status to query information about our process. Set Variable [ $MyProcessStatus ; Value: MBS("Text.ReadTextFile"; "/proc/self/status") ] Intersting is here to see the process name and that the process is sleeping while we request the information. The kernel produces this output, our scripts waits. We see a lot of IDs and memory statistics. The VmSize field is the current used memory by the application: Name: fmsased Umask: 0002 State: S (sleeping) Tgid: 27012 Ngid: 0 Pid: 27012 PPid: 25821 TracerPid: 0 Uid: 999 999 999 999 Gid: 1001 1001 1001 1001 FDSize: 64 Groups: NStgid: 27012 NSpid: 27012 NSpgid: 25821 NSsid: 25821 VmPeak: 1616320 kB VmSize: 1616320 kB VmLck: 0 kB VmPin: 0 kB VmHWM: 344800 kB VmRSS: 344800 kB RssAnon: 239232 kB RssFile: 105568 kB RssShmem: 0 kB VmData: 332592 kB VmStk: 132 kB VmExe: 4968 kB VmLib: 298524 kB VmPTE: 1180 kB VmSwap: 0 kB HugetlbPages: 0 kB CoreDumping: 0 THP_enabled: 1 Threads: 24 SigQ: 0/7305 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000080001000 SigCgt: 0000000100004006 CapInh: 0000000000000000 CapPrm: 0000000000000000 CapEff: 0000000000000000 CapBnd: 000001ffffffffff CapAmb: 0000000000000000 NoNewPrivs: 0 Seccomp: 0 Seccomp_filters: 0 Speculation_Store_Bypass: vulnerable SpeculationIndirectBranch: unknown Cpus_allowed: 3 Cpus_allowed_list: 0-1 Mems_allowed: 00000000,00000001 Mems_allowed_list: 0 voluntary_ctxt_switches: 276 nonvoluntary_ctxt_switches: 206 My Process Mappings This long list of file mappings can show you all the file paths for the various libraries loaded into the process. Set Variable [ $maps ; Value: MBS("Text.ReadTextFile"; "/proc/self/maps") ] We shorted the list here, but you can find over 280 libraries here with their file paths: aaaaea440000-aaaaea91a000 r-xp 00000000 08:02 1441897 /opt/FileMaker/FileMaker Server/Database Server/bin/fmsased aaaaea92a000-aaaaea97d000 r--p 004da000 08:02 1441897 /opt/FileMaker/FileMaker Server/Database Server/bin/fmsased aaaaea97d000-aaaaea983000 rw-p 0052d000 08:02 1441897 /opt/FileMaker/FileMaker Server/Database Server/bin/fmsased aaaaea983000-aaaaea992000 rw-p 00000000 00:00 0 aaab1fb23000-aaab2c891000 rw-p 00000000 00:00 0 [heap] ffff34000000-ffff34115000 rw-p 00000000 00:00 0 ffff34115000-ffff38000000 ---p 00000000 00:00 0 ffff38000000-ffff38503000 rw-p 00000000 00:00 0 ffff38503000-ffff3c000000 ---p 00000000 00:00 0 ffff3c000000-ffff3c25b000 rw-p 00000000 00:00 0 ffff3c25b000-ffff40000000 ---p 00000000 00:00 0 ffff41e40000-ffff43d34000 r-xp 00000000 08:02 3023583 /opt/FileMaker/FileMaker Server/Database Server/Extensions/MBS.arm.fmx ffff43d34000-ffff43d43000 ---p 01ef4000 08:02 3023583 /opt/FileMaker/FileMaker Server/Database Server/Extensions/MBS.arm.fmx ffff43d43000-ffff43dfb000 r--p 01ef3000 08:02 3023583 /opt/FileMaker/FileMaker Server/Database Server/Extensions/MBS.arm.fmx ffff43dfb000-ffff43e68000 rw-p 01fab000 08:02 3023583 /opt/FileMaker/FileMaker Server/Database Server/Extensions/MBS.arm.fmx ffff43e68000-ffff43ff5000 rw-p 00000000 00:00 0 ffff44000000-ffff44301000 rw-p 00000000 00:00 0 ffff44301000-ffff48000000 ---p 00000000 00:00 0 ... ffff8c3a6000-ffff8c3b0000 rw-p 00000000 00:00 0 ffff8c3b0000-ffff8cce4000 r-xp 00000000 08:02 1453733 /opt/FileMaker/lib/libFMSLib.so ffff8cce4000-ffff8ccf4000 ---p 00934000 08:02 1453733 /opt/FileMaker/lib/libFMSLib.so ffff8ccf4000-ffff8cd24000 r--p 00934000 08:02 1453733 /opt/FileMaker/lib/libFMSLib.so ffff8cd24000-ffff8cd2d000 rw-p 00964000 08:02 1453733 /opt/FileMaker/lib/libFMSLib.so ffff8cd2d000-ffff8cdc0000 rw-p 00000000 00:00 0 ffff8cdc0000-ffff8cdeb000 r-xp 00000000 08:02 2372008 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ffff8cdeb000-ffff8cdf7000 rw-p 00000000 00:00 0 ffff8cdf7000-ffff8cdf9000 r--p 00000000 00:00 0 [vvar] ffff8cdf9000-ffff8cdfa000 r-xp 00000000 00:00 0 [vdso] ffff8cdfa000-ffff8cdfc000 r--p 0002a000 08:02 2372008 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ffff8cdfc000-ffff8cdfe000 rw-p 0002c000 08:02 2372008 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ffffe6cfd000-ffffe6d1e000 rw-p 00000000 00:00 0 [stack] What other entries would you be interested to read? Read more here: The /proc Filesystem on the Linux Kernel website.
Recommended Posts