operating system - How do I get OS properties in java program? -
hi need details operating system physical memory , cpu usage , other details. cannot pay amount available apis. can use free apis or can write own api.
i need details in below image.
in above picture have following values
- total
- cached
- available
- free
like values need. have searched lot , got hint. got first value total physical memory value using below code.
public class mbeanserverdemo { public mbeanserverdemo() { super(); } public static void main(string... a) throws exception { mbeanserver mbeanserver = managementfactory.getplatformmbeanserver(); object attribute = mbeanserver.getattribute(new objectname("java.lang", "type", "operatingsystem"), "totalphysicalmemorysize"); long l = long.parselong(attribute.tostring()); system.out.println("total memory: " + (l / (1024*1024))); } }
the below output above program
total memory: 3293
please me . how achieve this.
edit: have searched lot on google solution , found lot of posts in stackoverflow.com. in these posts people discussed memory details. need details kernal(paged , non-paged) etc. please refer post...
thanks lot.
can please @ below api:
sigar api - system information gatherer , reporter https://support.hyperic.com/display/sigar/home
some examples usage : http://www.programcreek.com/java-api-examples/index.php?api=org.hyperic.sigar.sigar
Comments
Post a Comment