How does VBulletin get the system information without the use of exec
? Is there any other information I can get about the server without exec? I am interested in:
- bandwidth used
- system type
- CPU speed/usage/count
- RAM usage
How does VBulletin get the system information without the use of exec
? Is there any other information I can get about the server without exec? I am interested in:
The psutil library gives you information about CPU, RAM, etc., on a variety of platforms:
psutil is a module providing an interface for retrieving information on running processes and system utilization (CPU, memory) in a portable way by using Python, implementing many functionalities offered by tools like ps, top and Windows task manager.
It currently supports Linux, Windows, OSX, Sun Solaris, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures, with Python versions from 2.6 to 3.5 (users of Python 2.4 and 2.5 may use 2.1.3 version).
Some examples:
#!/usr/bin/env python
import psutil
# gives a single float value
psutil.cpu_percent()
# gives an object with many fields
psutil.virtual_memory()
# you can convert that object to a dictionary
dict(psutil.virtual_memory()._asdict())
# you can have the percentage of used RAM
psutil.virtual_memory().percent
79.2
# you can calculate percentage of available memory
psutil.virtual_memory().available * 100 / psutil.virtual_memory().total
20.8
Here's other documentation that provides more concepts and interest concepts:
There is an open source library that gives these (and more system info stuff) across many platforms: SIGAR API
I've used it in fairly large projects and it works fine (except for certain corner cases on OS X etc.)
You could always utilise the systeminfo
command, but then would be forced to go through a brief loading screen
set totalMem=
set availableMem=
set usedMem=
REM You need to make a loop
for /f "tokens=4" %%a in ('systeminfo ^| findstr Physical') do if defined totalMem (set availableMem=%%a) else (set totalMem=%%a)
set totalMem=%totalMem:,=%
set availableMem=%availableMem:,=%
set /a usedMem=totalMem-availableMem
Echo Total Memory: %totalMem%
Echo Used Memory: %usedMem%
And that should do exactly what you want. This code can easily be modified to show Virtual Memory as well. (The use of set totalMem=%totalMem:,=%
and set availableMem=%availableMem:,=%
gets rid of commas in the variables.)
Mona
Use PHPSysInfo library
phpSysInfo is a open source PHP script that displays information about the host being accessed. It will displays things like:
It directly parsed parses
/proc
and does not useexec
.Another way is to use Linfo. It is a very fast cross-platform php script that describes the host server in extreme detail, giving information such as ram usage, disk space, raid arrays, hardware, network cards, kernel, os, samba/cups/truecrypt status, temps, disks, and much more.