How to find unix/linux sytem info using java or shell script?
How to find unix/linux system info like OS version, RAM, no. of processors, hard disk, memory dedicated t开发者_开发问答o a particular process, memory utilization of java using java or shell scripts.
To find the version of the kernel, use uname -r
in a shell script. All kinds of information regarding the hardware can be retrieved from the files in /proc
.
/proc/cpuinfo
contains information about the CPU's, including their number. /proc/meminfo
shows the total physical memory, free memory, etc.
If you only want to fetch a particular field, you can filter the output like this:
cat /proc/cpuinfo | grep "model name"
df
shows you all of the mounted storage devices and their used space.
/proc/PID/status
shows the amount of virtual memory dedicated to the process, where PID
is the numeric process id.
Have a look at sysinfo.sh for a starter - it's easy to extend with your own modules.
精彩评论