/
systemInformation.go
116 lines (98 loc) · 3.67 KB
/
systemInformation.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package commands
import (
"fmt"
"github.com/jlentink/aem/internal/aem"
"github.com/jlentink/aem/internal/aem/systeminformation"
"github.com/jlentink/aem/internal/output"
"github.com/spf13/cobra"
"os"
)
type commandSystemInformation struct {
verbose bool
instanceName string
allowRoot bool
foreground bool
forceDownload bool
ignorePid bool
}
func (c *commandSystemInformation) setup() *cobra.Command {
cmd := &cobra.Command{
Use: "system-information",
Short: "Get system information from Adobe Experience Manager instance",
Aliases: []string{"sys", "sysinfo"},
PreRun: c.preRun,
Run: c.run,
}
cmd.Flags().StringVarP(&c.instanceName, "name", "n", aem.GetDefaultInstanceName(), "Instance to start")
cmd.Flags().BoolVarP(&c.forceDownload, "download", "d", false, "Force re-download")
cmd.Flags().BoolVarP(&c.foreground, "foreground", "f", false, "on't detach aem from current tty")
cmd.Flags().BoolVarP(&c.allowRoot, "allow-root", "r", false, "Allow to start as root user (UID: 0)")
cmd.Flags().BoolVarP(&c.ignorePid, "ignore-pid", "", false, "Ignore existing PID file and start AEM")
return cmd
}
func (c *commandSystemInformation) preRun(cmd *cobra.Command, args []string) {
c.verbose, _ = cmd.Flags().GetBool("verbose")
output.SetVerbose(verbose)
ConfigCheckListProjects()
RegisterProject()
}
func (c *commandSystemInformation) run(cmd *cobra.Command, args []string) {
_, currentInstance, errorString, err := getConfigAndInstance(c.instanceName)
if err != nil {
output.Printf(output.NORMAL, errorString, err.Error())
os.Exit(ExitError)
}
sysInfo, err := systeminformation.GetSystemInformation(currentInstance)
if err != nil {
output.Printf(output.NORMAL, "Error while fetching system information (%s)", err.Error())
os.Exit(ExitError)
}
fmt.Printf("Adobe Experience manager:\n")
fmt.Printf("- Version: %s\n", sysInfo.Instance.AdobeExperienceManager)
output.PrintListing("Run mode", sysInfo.Instance.RunModes, false)
fmt.Printf("- Up since: %s\n\n", sysInfo.Instance.InstanceUpSince)
fmt.Printf("Repostitory\n")
fmt.Printf("- Version: %s\n", sysInfo.Repository.ApacheJackrabbitOak)
fmt.Printf("- Repository size: %s\n", sysInfo.Repository.RepositorySize)
fmt.Printf("- Storage location: %s\n", sysInfo.Repository.FileDataStore)
fmt.Printf("- Nodes total: %s\n", sysInfo.EstimatedNodeCounts.Total)
fmt.Printf("- Tags total: %s\n", sysInfo.EstimatedNodeCounts.Tags)
fmt.Printf("- Authorizables: %s\n", sysInfo.EstimatedNodeCounts.Authorizables)
fmt.Printf("- Pages: %s\n\n", sysInfo.EstimatedNodeCounts.Pages)
fmt.Printf("Operating system:\n")
fmt.Printf("- %s\n\n", sysInfo.SystemInformation.CurrentOS)
fmt.Printf("Maintenance Tasks:\n")
tasks := sysInfo.MaintenanceTasks.(map[string]interface{})
for key, value := range tasks {
output.PrintListing(key, value.(string), true)
}
if sysInfo.HealthChecks != nil {
warns := sysInfo.HealthChecks.(map[string]interface{})
fmt.Printf("Current health checks:\n")
if len(warns) > 0 {
for key, check := range warns {
output.PrintListing(key, check.(string), true)
}
} else {
fmt.Printf("No Warnings or errors.\n\n")
}
}
if sysInfo.ReplicationAgents != nil {
agents := sysInfo.ReplicationAgents.(map[string]interface{})
fmt.Printf("Replication Agents:\n")
if len(agents) > 0 {
for key, check := range agents {
output.PrintListing(key, check.(string), true)
}
}
}
if sysInfo.DistributionAgents != nil {
distributionAgents := sysInfo.DistributionAgents.(map[string]interface{})
fmt.Printf("Distribution Agents:\n")
if len(distributionAgents) > 0 {
for key, check := range distributionAgents {
output.PrintListing(key, check.(string), false)
}
}
}
}