use of com.emc.vipr.model.sys.healthmonitor.DataDiskStats in project coprhd-controller by CoprHD.
the class HealthMonitorService method getNodeDiskAmount.
private long getNodeDiskAmount() {
DataDiskStats dataDiskStats = ProcStats.getDataDiskStats();
long rootDiskAmount = dataDiskStats.getRootAvailKB() + dataDiskStats.getRootUsedKB();
long dataDiskAmount = dataDiskStats.getDataAvailKB() + dataDiskStats.getDataUsedKB();
return (rootDiskAmount + dataDiskAmount);
}
use of com.emc.vipr.model.sys.healthmonitor.DataDiskStats in project coprhd-controller by CoprHD.
the class BackupManager method validateDiskUsedStatus.
private void validateDiskUsedStatus() {
DataDiskStats dataDiskStatus = getDataDiskStats();
if (dataDiskStatus == null) {
log.info("Can't find disk size of /data");
return;
}
long dataTotalKB = dataDiskStatus.getDataUsedKB() + dataDiskStatus.getDataAvailKB();
int diskUsedPercentage = (int) (dataDiskStatus.getDataUsedKB() * 100 / dataTotalKB);
log.info("Disk used percentage limit: {}\tCurrent Disk used percentage: {}", getBackupDisabledDiskPercentage(), diskUsedPercentage);
if (diskUsedPercentage > getBackupDisabledDiskPercentage()) {
throw BackupException.fatals.backupDisabledAsDiskFull(diskUsedPercentage, getBackupDisabledDiskPercentage());
}
}
use of com.emc.vipr.model.sys.healthmonitor.DataDiskStats in project coprhd-controller by CoprHD.
the class BackupManager method getDataDiskStats.
private DataDiskStats getDataDiskStats() {
final String[] cmd = { DF_COMMAND };
Exec.Result result = Exec.sudo(DF_COMMAND_TIMEOUT, cmd);
if (!result.exitedNormally() || result.getExitValue() != 0) {
log.error("getDataDiskStats() is unsuccessful. Command exit value is: {}", result.getExitValue());
return null;
}
log.info("df result: {}", result.getStdOutput());
String[] lines = result.getStdOutput().split("\n");
DataDiskStats dataDiskStats = new DataDiskStats();
for (String line : lines) {
String[] v = line.split(SPACE_VALUE);
if (v != null && v.length > 5) {
if ("/data".equals(v[5].trim())) {
dataDiskStats.setDataUsedKB(Long.parseLong(v[2]));
dataDiskStats.setDataAvailKB(Long.parseLong(v[3]));
return dataDiskStats;
}
}
}
return null;
}
use of com.emc.vipr.model.sys.healthmonitor.DataDiskStats in project coprhd-controller by CoprHD.
the class ProcStats method parseDFResults.
/**
* Parses the input string and returns data disk stats object.
*/
private static DataDiskStats parseDFResults(String dfResult) {
String[] lines = dfResult.split("\n");
DataDiskStats dataDiskStats = new DataDiskStats();
for (String line : lines) {
String[] v = line.split(SPACE_VALUE);
if (v != null && v.length > 5) {
if ("/".equals(v[5].trim())) {
dataDiskStats.setRootUsedKB(Long.parseLong(v[2]));
dataDiskStats.setRootAvailKB(Long.parseLong(v[3]));
} else if ("/data".equals(v[5].trim())) {
dataDiskStats.setDataUsedKB(Long.parseLong(v[2]));
dataDiskStats.setDataAvailKB(Long.parseLong(v[3]));
}
}
}
return dataDiskStats;
}
use of com.emc.vipr.model.sys.healthmonitor.DataDiskStats in project coprhd-controller by CoprHD.
the class BackupManager method getQuotaGb.
public int getQuotaGb() {
DataDiskStats dataDiskStats = getDataDiskStats();
if (dataDiskStats == null) {
return DEFAULT_DISK_QUOTA_GB;
}
long diskTotalKB = dataDiskStats.getDataUsedKB() + dataDiskStats.getDataAvailKB();
int quotaGB = (int) ((diskTotalKB * getBackupMaxUsedDiskPercentage()) / (100 * 1024 * 1024));
log.info("Quota is {} GB", quotaGB);
return quotaGB;
}
Aggregations