Some progress on service configuration

This commit is contained in:
Ziver Koc 2015-06-03 15:08:41 +00:00
parent 29def452b6
commit ab7296198a
10 changed files with 138 additions and 84 deletions

View file

@ -60,35 +60,41 @@ public class HDDStatus implements WAStatus {
@Override
public void jsonUpdate(Map<String, String> request, DataNode root) {
DataNode hdd_root = new DataNode(DataNode.DataType.List);
root.set("hdd", hdd_root);
Sigar sigar = new Shell().getSigar();
try {
FileSystem[] hdds = sigar.getFileSystemList();
for (FileSystem hdd : hdds) {
if (hdd.getType() != FileSystem.TYPE_LOCAL_DISK)
continue;
DataNode node = new DataNode(DataNode.DataType.Map);
if (request.containsKey("hdd")) {
DataNode hdd_root = new DataNode(DataNode.DataType.List);
root.set("hdd", hdd_root);
Sigar sigar = new Shell().getSigar();
try {
FileSystem[] hdds = sigar.getFileSystemList();
for (FileSystem hdd : hdds) {
if (hdd.getType() != FileSystem.TYPE_LOCAL_DISK)
continue;
DataNode node = new DataNode(DataNode.DataType.Map);
String device = new String(hdd.getDevName().getBytes(), "UTF-8");
node.set("device", device);
node.set("filesystem", hdd.getSysTypeName());
node.set("mount", hdd.getDirName());
String device = new String(hdd.getDevName().getBytes(), "UTF-8");
node.set("device", device);
node.set("filesystem", hdd.getSysTypeName());
node.set("mount", hdd.getDirName());
if(idMap.containsKey(device))
node.set("id", idMap.get(device));
else{
idMap.put(device, nextId);
node.set("id", nextId++);
if (idMap.containsKey(device))
node.set("id", idMap.get(device));
else {
idMap.put(device, nextId);
node.set("id", nextId++);
}
FileSystemUsage hdd_use = sigar.getFileSystemUsage(hdd.getDirName());
node.set("size_total", hdd_use.getTotal() * 1000);
node.set("size_used", (hdd_use.getTotal() - hdd_use.getFree()) * 1000);
node.set("size_free", hdd_use.getFree() * 1000);
hdd_root.add(node);
}
FileSystemUsage hdd_use = sigar.getFileSystemUsage(hdd.getDirName());
node.set("size_total", hdd_use.getTotal() * 1000);
node.set("size_used", (hdd_use.getTotal() - hdd_use.getFree())*1000);
node.set("size_free", hdd_use.getFree() * 1000);
hdd_root.add(node);
} catch (SigarException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}catch(SigarException e){} catch (UnsupportedEncodingException e) {}
}
}
}