Nik
Nik

Reputation: 695

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 to a particular process, memory utilization of java using java or shell scripts.

Upvotes: 1

Views: 1129

Answers (2)

symcbean
symcbean

Reputation: 48367

Have a look at sysinfo.sh for a starter - it's easy to extend with your own modules.

Upvotes: 0

Blagovest Buyukliev
Blagovest Buyukliev

Reputation: 43548

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.

Upvotes: 1

Related Questions