/**
* @throws InvalidPath
*/
public function runMonitor()
{
if (!file_exists($this->path)) {
throw InvalidPath::pathDoesNotExist($this->path);
}
$this->totalSpace = disk_total_space($this->path);
$this->freeSpace = disk_free_space($this->path);
$this->usedSpace = $this->totalSpace - $this->freeSpace;
$this->percentageUsed = sprintf('%.2f', $this->usedSpace / $this->totalSpace * 100);
if ($this->percentageUsed >= $this->alarmPercentage) {
event(new DiskUsageAlarm($this));
} else {
event(new DiskUsageHealthy($this));
}
}