🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

🔧 Programmierung 🕛 kürzlich 4 Min Lesezeit
0

Dev10V2

↗ Quelle (dev.to)
🗣️ Stimme:

CODE

import java.io.*;
import java.util.*;
import java.util.regex.*;
import java.util.stream.Collectors;

public class SQLLogAnalyzer {
// Updated pattern to capture all possible thread states and include SELECT in output
private static final Pattern LOG_PATTERN = Pattern.compile(".*?\\[((?:ACTIVE|STUCK|Async-Pool-\\d+-thread-\\d+|.*?))\\].*?(?:ExecuteThread:\\s+'(\\d+)'|).*?((?i)SELECT\\s+.*)");
private final Map<String, QueryStats> queryDistribution;
private final Set<String> knownStates;

public SQLLogAnalyzer() {
this.queryDistribution = new HashMap<>();
this.knownStates = new HashSet<>();
}

private static String repeatString(String str, int count) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++) {
sb.append(str);
}
return sb.toString();
}

public static class ThreadInfo {
private final String threadId;
private int occurrences;
private final Set<Integer> lineNumbers;

public ThreadInfo(String threadId) {
this.threadId = threadId;
this.occurrences = 0;
this.lineNumbers = new HashSet<>();
}

public void addOccurrence(int lineNumber) {
occurrences++;
lineNumbers.add(lineNumber);
}

@Override
public String toString() {
return String.format("Thread %s: %d occurrences, Lines: %s",
threadId,
occurrences,
lineNumbers.stream()
.sorted()
.map(String::valueOf)
.collect(Collectors.joining(", "))
);
}
}

public static class StateInfo {
private final Map<String, ThreadInfo> threadStats;
private int totalOccurrences;

public StateInfo() {
this.threadStats = new HashMap<>();
this.totalOccurrences = 0;
}

public void addOccurrence(String threadId, int lineNumber) {
threadStats.computeIfAbsent(threadId, ThreadInfo::new)
.addOccurrence(lineNumber);
totalOccurrences++;
}

public int getTotalOccurrences() {
return totalOccurrences;
}

public Collection<ThreadInfo> getThreadStats() {
return threadStats.values();
}
}

public static class QueryStats {
private final String originalQuery;
private final String normalizedQuery;
private int occurrences;
private final Map<String, StateInfo> stateStats;

public QueryStats(String query) {
this.originalQuery = query.trim();
this.normalizedQuery = normalizeQuery(query);
this.occurrences = 0;
this.stateStats = new HashMap<>();
}

private static String normalizeQuery(String query) {
return query.replaceAll("\\s+", " ").trim();
}

public void addOccurrence(String threadId, String state, int lineNumber) {
occurrences++;
stateStats.computeIfAbsent(state, k -> new StateInfo())
.addOccurrence(threadId, lineNumber);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(String.format("Query: %s%n", originalQuery));
sb.append(String.format("Total Occurrences: %d%n", occurrences));

// State-wise breakdown
sb.append("State Distribution:\n");
stateStats.forEach((state, stateInfo) -> {
sb.append(String.format(" %s (Total: %d):%n", state, stateInfo.getTotalOccurrences()));
stateInfo.getThreadStats().forEach(threadInfo ->
sb.append(String.format(" %s%n", threadInfo))
);
});

return sb.toString();
}

public String getNormalizedQuery() {
return normalizedQuery;
}
}

public void analyzeLogs(String filePath) throws IOException {
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
String line;
int lineNumber = 0;

while ((line = reader.readLine()) != null) {
lineNumber++;
processLine(line, lineNumber);
}
}
}

private void processLine(String line, int lineNumber) {
Matcher matcher = LOG_PATTERN.matcher(line);
if (matcher.find()) {
String state = matcher.group(1);
knownStates.add(state);
String threadId = matcher.group(2) != null ? matcher.group(2) : "N/A";
String sqlStatement = matcher.group(3).trim();

String normalizedSQL = sqlStatement.replaceAll("\\s+", " ").trim();
queryDistribution
.computeIfAbsent(normalizedSQL, query -> new QueryStats(sqlStatement))
.addOccurrence(threadId, state, lineNumber);
}
}

public void printAnalysis() {
System.out.println("=== SQL Query Analysis ===\n");

queryDistribution.values().stream()
.sorted((a, b) -> Integer.compare(b.occurrences, a.occurrences))
.forEach(stats -> {
System.out.println(stats);
System.out.println(repeatString("-", 80) + "\n");
});

printSummaryStats();
}

private void printSummaryStats() {
System.out.println("=== Summary Statistics ===");

System.out.println("Total unique queries: " + queryDistribution.size());

System.out.println("\nThread states found: " +
knownStates.stream().sorted().collect(Collectors.joining(", ")));

Map<String, Integer> totalStateDistribution = new HashMap<>();
queryDistribution.values().forEach(stats ->
stats.stateStats.forEach((state, stateInfo) ->
totalStateDistribution.merge(state, stateInfo.getTotalOccurrences(), Integer::sum))
);

System.out.println("\nOverall state distribution:");
totalStateDistribution.entrySet().stream()
.sorted(Map.Entry.<String, Integer>comparingByValue().reversed())
.forEach(entry ->
System.out.printf(" %s: %d occurrences%n", entry.getKey(), entry.getValue())
);
}

public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Usage: java SQLLogAnalyzer <log-file-path>");
return;
}

SQLLogAnalyzer analyzer = new SQLLogAnalyzer();
try {
analyzer.analyzeLogs(args[0]);
analyzer.printAnalysis();
} catch (IOException e) {
System.err.println("Error processing log file: " + e.getMessage());
e.printStackTrace();
}
}
}



Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Hackers Just Poisoned the Rust Supply Chain | Threat Wire
1 Quelle
Hackers Found a Way Into Humanoid Robots | Threat Wire
1 Quelle
Bits und so #1021 (Passwort für Laufwerk)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Dev10V2

Thematisch verwandte Begriffe: Dev10V2 · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...