Linux System Info
This function provides some system information for Linux and returns it as a JSON block.
You may query such a block regularly and do your own decisions based on the numbers, e.g. only do something on the server if load counts are small. Or you may check how much memory is available on the computer.{
"UpTime": 708,
"Loads": [0.023873, 0.048828, 0.067382],
"TotalRAM": 4112195584,
"FreeRAM": 1589587968,
"SharedRAM": 1622016,
"BufferRAM": 20881408,
"TotalSwap": 4111462400,
"FreeSwap": 4111462400,
"Processes": 1010,
"TotalHigh": 0,
"FreeHigh": 0,
"MemoryUnit": 1,
"ConfiguredProcessors": 4,
"AvailableProcessors": 4,
"TotalPhysicalPages": 1003954,
"AvailablePhysicalPages": 388083
}
Let's look in the values. First the UpTime value shows how long the server is running already, in our example 708 seconds, which is about 11 minutes. The loads array gives you the load averages for last 1, 5 and 15 minute. The load value is how many processes had to wait for available CPU time. The load is normalized to a percentage and should not be higher than the CPU core count, e.g. 4 above for four configured processors (cores).
Memory is given as total and free values in bytes. Some memory is used by the OS for special things like sharing or for file buffering. Please note that free RAM is a bad thing as you want to be all available RAM in use and what's not needed right now should handle file buffering. If memory is needed, buffers get discarded and then you can use the memory. When your server runs well, free memory should be small, buffers should be big and most of your database files should be cached in memory.
For swap, we consider that as an emergency buffer. TotalSwap and FreeSwap should be the same value and swap should not be used, because that would be an indicator that we have not enough RAM for the machine. Except maybe for some heavy process, which temporarily needs a lot of memory for a short time and runs infrequently. But regular memory usage should not involve swap space.
The number of processes running is given with Processes value. This may normally be a thousand with all the stuff running in the background. But if you run additional scripts, shell commands to start services, a growing number here may indicate some trouble.
High memory is a concept used in 32 bit systems, so it doesn't apply to our 64-bit servers. And memory unit is 1 byte for the numbers given above. In a 32-bit system with limited integer size to report values, this may have helped to report 4 GB as 4 MB and give a memory unit of 1024 as factor to multiply in order to get the full number.
The number of configured processor cores in the system and how many are available is also given to you. The linux admin may limit the use of CPU cores for a process. For example you may limit scripting engine to 4 cores in an eight core system to keep other cores available.
The next numbers give the number of memory pages available. That should normally be the same as the memory sizes above, but divided by the page size, usually 4096 bytes per page.
Please try the new function in next pre-release 11.2pr7.
For Xojo we have similar functions in LinuxSysInfoMBS class and SystemInformationMBS module.