aboutsummaryrefslogtreecommitdiffstats
path: root/src/dma/cmd/server/agent.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/dma/cmd/server/agent.go')
-rw-r--r--src/dma/cmd/server/agent.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/dma/cmd/server/agent.go b/src/dma/cmd/server/agent.go
new file mode 100644
index 00000000..ffcb4a97
--- /dev/null
+++ b/src/dma/cmd/server/agent.go
@@ -0,0 +1,31 @@
+package main
+
+import (
+ "fmt"
+ "os/exec"
+ "strings"
+)
+
+func createCollectdConf() error {
+ outStatus, errStatus := exec.Command("ssh", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "localhost", "sudo", "systemctl", "status", "collectd").Output()
+ if errStatus != nil {
+ return fmt.Errorf("status NG")
+ }
+ if !strings.Contains(string(outStatus), "running") {
+ return fmt.Errorf("status not running")
+ }
+
+ _, errStop := exec.Command("ssh", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "localhost", "sudo", "systemctl", "stop", "collectd").Output()
+ if errStop != nil {
+ return fmt.Errorf("stop NG")
+ }
+
+ _, errStart := exec.Command("ssh", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "localhost", "sudo", "systemctl", "start", "collectd").Output()
+ if errStart != nil {
+ return fmt.Errorf("start NG")
+ }
+
+ fmt.Println("All complete!")
+
+ return nil
+}