不可以,這屬于用戶隱私信息,再說如果可以的話,那我們的電腦你不覺得很危險嗎?隨便一個網(wǎng)頁都可以看到你的硬件信息,很危險的。我原來遇到過用戶想這樣搞,最后跟用戶談,不能實現(xiàn),修改成cookie驗證了,像韓家_四少發(fā)的代碼,只可以在特定環(huán)境下使用,還需要考慮網(wǎng)絡狀態(tài),而且nbtstat -a是windows 下面的命令,根本不可行。
創(chuàng)新互聯(lián)公司主營雄縣網(wǎng)站建設的網(wǎng)絡公司,主營網(wǎng)站建設方案,App定制開發(fā),雄縣h5微信平臺小程序開發(fā)搭建,雄縣網(wǎng)站營銷推廣歡迎雄縣等地區(qū)企業(yè)咨詢
可以的
IMonitorService接口:??
public?interface?IMonitorService?{??
public?MonitorInfoBean?getMonitorInfoBean()?throws?Exception;??
}??
MonitorInfoBean類:??
/*采集系統(tǒng)存取數(shù)據(jù)JavaBean*/??
public?class?MonitorInfoBean?implements?ComparableMonitorInfoBean?{??
/**?操作系統(tǒng).?*/??
private?String?osName;??
/**?總的物理內存.?*/??
private?float?totalMemorySize;??
/**?已使用的物理內存.?*/??
private?float?usedMemory;??
/**?cpu使用率.?*/??
private?double?cpuRatio;??
/**?主機IP地址?*/??
private?String?mIpAddress;??
/**?數(shù)據(jù)存儲時間?*/??
private?String?dDateTime;??
/**內存使用率*/??
private?float?memoryRatio;??
/**linux下Buffers內存*/??
private?float?buffersMemory;???
/**linux下Cached內存*/??
private?float?cachedMemory;??
public?float?getBuffersMemory()?{??
return?buffersMemory;??
}??
public?float?getCachedMemory()?{??
return?cachedMemory;??
}??
public?String?getDDateTime()?{??
return?dDateTime;??
}??
public?void?setDDateTime(String?dateTime)?{??
dDateTime?=?dateTime;??
}??
public?String?getMIpAddress()?{??
return?mIpAddress;??
}??
public?void?setMIpAddress(String?ipAddress)?{??
mIpAddress?=?ipAddress;??
}??
public?String?getOsName()?{??
return?osName;??
}??
public?void?setOsName(String?osName)?{??
this.osName?=?osName;??
}??
public?float?getTotalMemorySize()?{??
return?totalMemorySize;??
}??
public?void?setTotalMemorySize(float?totalMemorySize)?{??
this.totalMemorySize?=?totalMemorySize;??
}??
public?float?getUsedMemory()?{??
return?usedMemory;??
}??
public?void?setUsedMemory(long?usedMemory)?{??
this.usedMemory?=?usedMemory;??
}??
public?double?getCpuRatio()?{??
return?cpuRatio;??
}??
public?void?setCpuRatio(double?cpuRatio)?{??
this.cpuRatio?=?cpuRatio;??
}??
public?int?compareTo(MonitorInfoBean?m)?{??
String?stra?=?this.getDDateTime();??
String?strb?=?m.getDDateTime();??
Timestamp?a?=?Timestamp.valueOf(stra);??
Timestamp?b?=?Timestamp.valueOf(strb);??
if?(a.before(b))?{??
return?-1;??
}?else?if?(a.after(b))?{??
return?1;??
}?else?{??
return?0;??
}??
}??
public?float?getMemoryRatio()?{??
return?memoryRatio;??
}??
public?void?setMemoryRatio(float?memoryRatio)?{??
this.memoryRatio?=?memoryRatio;??
}??
public?void?setUsedMemory(float?usedMemory)?{??
this.usedMemory?=?usedMemory;??
}??
public?void?setBuffersMemory(float?buffersMemory)?{??
this.buffersMemory?=?buffersMemory;??
}??
public?void?setCachedMemory(float?cachedMemory)?{??
this.cachedMemory?=?cachedMemory;??
}??
}??
import?java.io.BufferedReader;??
import?java.io.File;??
import?java.io.FileInputStream;??
import?java.io.FileNotFoundException;??
import?java.io.IOException;??
import?java.io.InputStream;??
import?java.io.InputStreamReader;??
import?java.io.LineNumberReader;??
import?java.net.Inet6Address;??
import?java.net.InetAddress;??
import?java.net.NetworkInterface;??
import?java.net.SocketException;??
import?java.net.UnknownHostException;??
import?java.util.Enumeration;??
import?java.util.StringTokenizer;??
import?sun.management.ManagementFactory;??
import?com.sun.management.OperatingSystemMXBean;
public?class?Main?{
public?static?void?main(String[]?args)?{
/*?Total?number?of?processors?or?cores?available?to?the?JVM?*/
System.out.println("Available?processors?(cores):?"?+?
Runtime.getRuntime().availableProcessors());
/*?Total?amount?of?free?memory?available?to?the?JVM?*/
System.out.println("Free?memory?(bytes):?"?+?
Runtime.getRuntime().freeMemory());
/*?This?will?return?Long.MAX_VALUE?if?there?is?no?preset?limit?*/
long?maxMemory?=?Runtime.getRuntime().maxMemory();
/*?Maximum?amount?of?memory?the?JVM?will?attempt?to?use?*/
System.out.println("Maximum?memory?(bytes):?"?+?
(maxMemory?==?Long.MAX_VALUE???"no?limit"?:?maxMemory));
/*?Total?memory?currently?available?to?the?JVM?*/
System.out.println("Total?memory?available?to?JVM?(bytes):?"?+?
Runtime.getRuntime().totalMemory());
/*?Get?a?list?of?all?filesystem?roots?on?this?system?*/
File[]?roots?=?File.listRoots();
/*?For?each?filesystem?root,?print?some?info?*/
for?(File?root?:?roots)?{
System.out.println("File?system?root:?"?+?root.getAbsolutePath());
System.out.println("Total?space?(bytes):?"?+?root.getTotalSpace());
System.out.println("Free?space?(bytes):?"?+?root.getFreeSpace());
System.out.println("Usable?space?(bytes):?"?+?root.getUsableSpace());
}
}}