-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dmytro Galushko
committed
Jul 1, 2024
1 parent
9c61d17
commit c7a641c
Showing
9 changed files
with
117 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.halushko.kinocat.file; | ||
|
||
import com.halushko.kinocat.core.Queues; | ||
import com.halushko.kinocat.core.handlers.input.CliCommandExecutor; | ||
import com.halushko.kinocat.core.rabbit.SmartJson; | ||
import lombok.extern.slf4j.Slf4j; | ||
import lombok.val; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
public class CheckDiskFreeSpace extends CliCommandExecutor { | ||
@Override | ||
protected String getResultString(List<String> lines, SmartJson rabbitMessage) { | ||
log.debug(String.format("[CheckDiskFreeSpace] [%s]", String.join(", ", lines))); | ||
StringBuilder sb = new StringBuilder("Вільного місця у сховищі:"); | ||
for (val device : Constants.FOLDERS.entrySet()) { | ||
val key = device.getKey(); | ||
if (Constants.DEVICES.containsKey(key)) { | ||
val value = Constants.DEVICES.get(key); | ||
for (String line : lines) { | ||
if (line.matches(value + ".*")) { | ||
sb.append("\n") | ||
.append(key) | ||
.append(": ") | ||
.append( | ||
line.replaceAll("^\\S+\\s+\\S+\\s+\\S+\\s+", "") | ||
.replaceAll("\\S+\\s+\\S+\\s*$", "") | ||
); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return sb.toString(); | ||
} | ||
|
||
@Override | ||
protected String getQueue() { | ||
return Queues.File.CHOOSE_THE_DESTINATION; | ||
} | ||
|
||
@Override | ||
protected String[] getScript(SmartJson rabbitMessage) { | ||
return new String[]{ | ||
"/usr/bin/df", | ||
"-h" | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
file/src/main/java/com/halushko/kinocat/file/DevicesProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.halushko.kinocat.file; | ||
|
||
import com.halushko.kinocat.core.JsonConstants; | ||
import com.halushko.kinocat.core.prcessors.ServicesInfoProcessor; | ||
import com.halushko.kinocat.core.prcessors.ValueProcessor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class DevicesProcessor extends ServicesInfoProcessor { | ||
|
||
public DevicesProcessor(String json) { | ||
super(json); | ||
} | ||
|
||
@Override | ||
public ValueProcessor getNameProcessor() { | ||
return new ValueProcessor(JsonConstants.WebKeys.KEY_NAME, Constants.EMPTY_SERVICE_DEFAULT_NAME); | ||
} | ||
|
||
@Override | ||
public List<ValueProcessor> getServiceProcessors() { | ||
return new ArrayList<>() {{ | ||
this.add(new ValueProcessor("folder", "")); | ||
}}; | ||
} | ||
|
||
@Override | ||
public String getUrlTemplate() { | ||
return ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters