-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (48 loc) · 1.06 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"flag"
"fmt"
"time"
)
type job struct {
JobType string
JobData string
lastTriggered time.Time
}
var activeJobs []job
var telegramBotKey string
var probeUUID string
var hostname string
var secret string
var secretKey string
var secretIV string
var ListenAddress string
var relayTo string
var configFile string
func init() {
configFile := flag.String("config", "config.ini", "Configuration file for Probe")
flag.Parse()
hostname, secret, telegramBotKey, ListenAddress, relayTo, probeUUID, activeJobs = readConfigurationFromFile(*configFile)
secretKey, secretIV = getKeyAndIV(secret)
}
func main() {
fmt.Println(probeUUID)
if relayTo == "telegram" {
go runTelegramAPI()
}
if ListenAddress != "" {
go runTCPServer(ListenAddress)
}
time.Sleep(2 * time.Second)
for {
for i, jobItem := range activeJobs {
fmt.Println(jobItem)
if jobItem.JobType == "diskMinSpace" {
checkDiskMinSpace(&activeJobs[i])
} else if jobItem.JobType == "raidStatus" {
checkRAID(&activeJobs[i])
}
}
time.Sleep(5 * time.Second)
}
}