generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from amosproj/vis_metrics_updated
Vis metrics updated
- Loading branch information
Showing
23 changed files
with
1,010 additions
and
146 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
15 changes: 15 additions & 0 deletions
15
frontend/app/src/main/java/de/amosproj3/ziofa/api/DataStreamProvider.kt
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,15 @@ | ||
// SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
package de.amosproj3.ziofa.api | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface DataStreamProvider { | ||
suspend fun counter(ebpfProgramName: String): Flow<UInt> | ||
|
||
suspend fun vfsWriteEvents(pids: List<UInt>): Flow<WriteEvent.VfsWriteEvent> | ||
|
||
suspend fun sendMessageEvents(pids: List<UInt>): Flow<WriteEvent.SendMessageEvent> | ||
} |
28 changes: 28 additions & 0 deletions
28
frontend/app/src/main/java/de/amosproj3/ziofa/api/WriteEvent.kt
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,28 @@ | ||
// SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
package de.amosproj3.ziofa.api | ||
|
||
sealed class WriteEvent( | ||
val fileDescriptor: ULong, | ||
val processId: UInt, | ||
val startTimestamp: ULong, | ||
val durationOrSize: ULong, | ||
) { | ||
|
||
data class VfsWriteEvent( | ||
val fd: ULong, | ||
val pid: UInt, | ||
val size: ULong, | ||
val timestampMillis: ULong, // unix time | ||
) : WriteEvent(fd, pid, timestampMillis, size) | ||
|
||
data class SendMessageEvent( | ||
val fd: ULong, | ||
val pid: UInt, | ||
val tid: UInt, | ||
val beginTimestamp: ULong, | ||
val durationMicros: ULong, | ||
) : WriteEvent(fd, pid, beginTimestamp, durationMicros) | ||
} |
68 changes: 68 additions & 0 deletions
68
frontend/app/src/main/java/de/amosproj3/ziofa/bl/DataStreamManager.kt
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,68 @@ | ||
// SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
package de.amosproj3.ziofa.bl | ||
|
||
import de.amosproj3.ziofa.api.DataStreamProvider | ||
import de.amosproj3.ziofa.api.WriteEvent | ||
import de.amosproj3.ziofa.client.ClientFactory | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.filter | ||
import kotlinx.coroutines.flow.map | ||
import timber.log.Timber | ||
import uniffi.shared.EventData | ||
|
||
class DataStreamManager(private val clientFactory: ClientFactory) : DataStreamProvider { | ||
|
||
override suspend fun counter(ebpfProgramName: String): Flow<UInt> { | ||
return clientFactory | ||
.connect() | ||
.also { | ||
try { | ||
it.load() | ||
// default wifi interface on android, now configurable | ||
it.attach("wlan0") | ||
it.startCollecting() | ||
} catch (e: Exception) { | ||
Timber.e(e.stackTraceToString()) | ||
} | ||
} | ||
.serverCount() | ||
} | ||
|
||
override suspend fun vfsWriteEvents(pids: List<UInt>): Flow<WriteEvent.VfsWriteEvent> = | ||
clientFactory | ||
.connect() | ||
.initStream() | ||
.map { it.eventData } | ||
.filter { it is EventData.VfsWrite } | ||
.map { | ||
if (it is EventData.VfsWrite) { | ||
WriteEvent.VfsWriteEvent( | ||
it.v1.fp, | ||
it.v1.pid, | ||
it.v1.bytesWritten, | ||
it.v1.beginTimeStamp, | ||
) | ||
} else throw Exception("only for the compiler") | ||
} | ||
|
||
override suspend fun sendMessageEvents(pids: List<UInt>): Flow<WriteEvent.SendMessageEvent> = | ||
clientFactory | ||
.connect() | ||
.initStream() | ||
.map { it.eventData } | ||
.filter { it is EventData.SysSendmsg } | ||
.map { | ||
if (it is EventData.SysSendmsg) { | ||
WriteEvent.SendMessageEvent( | ||
it.v1.fd.toULong(), | ||
it.v1.pid, | ||
it.v1.tid, | ||
it.v1.beginTimeStamp, | ||
it.v1.durationMicroSec, | ||
) | ||
} else throw Exception("only for the compiler") | ||
} | ||
} |
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
Oops, something went wrong.