Initial commit

This commit is contained in:
2023-05-03 21:18:47 +02:00
commit 64702636e6
23 changed files with 2116 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
package executor
import "time"
// Service is a service that handles executing commands on the main host and does a first processing of the raw data it gets from the system
type Service interface {
SlurmQueue() []string
SlurmJobs() []string
NodeUptime(hostname string) time.Time
Temperature(hostname string) float64
MemoryUsage(hostname string) int64
StorageUsage(hostname string) int64
NetworkUploadDownload(hostname string) (int64, int64)
}
+43
View File
@@ -0,0 +1,43 @@
package executor
import "time"
var _ Service = &Mock{}
type Mock struct {
SlurmQueueFunc func() []string
SlurmJobsFunc func() []string
NodeUptimeFunc func(hostname string) time.Time
TemperatureFunc func(hostname string) float64
MemoryUsageFunc func(hostname string) int64
StorageUsageFunc func(hostname string) int64
NetworkUploadDownloadFunc func(hostname string) (int64, int64)
}
func (ex *Mock) SlurmQueue() []string {
return ex.SlurmQueueFunc()
}
func (ex *Mock) SlurmJobs() []string {
return ex.SlurmJobsFunc()
}
func (ex *Mock) NodeUptime(hostname string) time.Time {
return ex.NodeUptimeFunc(hostname)
}
func (ex *Mock) Temperature(hostname string) float64 {
return ex.TemperatureFunc(hostname)
}
func (ex *Mock) MemoryUsage(hostname string) int64 {
return ex.MemoryUsageFunc(hostname)
}
func (ex *Mock) StorageUsage(hostname string) int64 {
return ex.StorageUsageFunc(hostname)
}
func (ex *Mock) NetworkUploadDownload(hostname string) (int64, int64) {
return ex.NetworkUploadDownloadFunc(hostname)
}