Things that gave the simulator away (#40): - hosts were fleet-0000 to fleet-0119. Now they're named for their site and what they do: phx1-gw01, phx1-lb01, phx1-app05, phx1-db03, phx1-cache02, iad1-lb02, lon1-kvm01 (collectors.go); - fleet-0041 was a Redis cache, a KVM host, the IBM i collector and the HMC reader at once, so IBM i alerts read as if PROD2 ran on it. The agents that read storage, IBM i and virtualization are small hosts of their own now: phx1-stor01 (the Pure arrays), phx1-ibmi01 (the partitions and the HMC), phx1-virt01 (vCenter, Proxmox, Nutanix). fleet config writes their agents; - libvirt runs only on app servers, not on a load balancer or a cache; - RHEL hosts' units are sshd and chronyd, as RHEL names them; - Akamai's CP codes no longer have round counts. Varied disks and jittered readings came with #39 (load.go).
70 lines
3.5 KiB
Go
70 lines
3.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/cairnobs/cairnobs/internal/report"
|
|
)
|
|
|
|
// A Prism Central, as a host agent with a nutanix: section sends it
|
|
// (docs/cluster-watcher.md, step 9): phx1-virt01's agent reads it.
|
|
const (
|
|
prismCentral = "pc-01.example.org"
|
|
ntnxClusters = 3
|
|
ahvPerPE = 6 // AHV hosts in each cluster
|
|
// nutanixGuestEvery: host 11 in every 20 is Prism Central's VM number i/20.
|
|
nutanixGuestEvery = 20
|
|
)
|
|
|
|
var ahvRoles = []string{"epic-app", "epic-db", "citrix-vda", "mssql", "oracle", "web", "ad", "backup-proxy", "k8s-worker", "elastic"}
|
|
|
|
func peName(c int) string { return fmt.Sprintf("pe-%s", []string{"phx-01", "phx-02", "tus-01"}[c]) }
|
|
|
|
func newNutanix(name, token string, vms int) *fakeCluster {
|
|
c := &fakeCluster{name: name, token: token, recs: map[string]report.Workload{}, changed: map[string]bool{}, noUsage: true, source: prismCentral}
|
|
now := time.Now()
|
|
put := func(w report.Workload) { c.recs[w.ID] = w }
|
|
put(report.Workload{Kind: report.KindCluster, ID: report.ClusterSelf, Name: prismCentral, State: report.StateOK, Word: "API answering",
|
|
Since: now.Add(-45 * 24 * time.Hour), Facts: map[string]any{"distribution": "Prism Central", "version": "pc.2024.3.1",
|
|
"hosts": ntnxClusters * ahvPerPE, "clusters": "pe-phx-01, pe-phx-02, pe-tus-01", "alerts": "pe-tus-01: NTP Not Synchronized (warning)"}})
|
|
host := func(cl, n int) string { return fmt.Sprintf("ahv-%s-%02d", []string{"phx1", "phx2", "tus1"}[cl], n) }
|
|
for cl := range ntnxClusters {
|
|
for n := 1; n <= ahvPerPE; n++ {
|
|
r := report.Workload{Kind: report.KindNode, ID: fmt.Sprintf("a1b2c3d4-%04d-4000-8000-%012d", cl, n), Name: host(cl, n),
|
|
State: report.StateOK, Word: "Connected", Since: now.Add(-time.Duration(20+n) * 24 * time.Hour),
|
|
Facts: map[string]any{"cluster": peName(cl), "cpus": 64, "memory_gib": 1024.0, "version": "AHV 10.0.1", "model": "NX-8170-G9"}}
|
|
put(r)
|
|
}
|
|
for k, ct := range []string{"default-container", "vdi-images", "db-data"} {
|
|
r := report.Workload{Kind: report.KindPVC, ID: fmt.Sprintf("c0ffee00-%04d-4000-8000-%012d", cl, k), Name: ct,
|
|
State: report.StateOK, Word: "Available", Since: now.Add(-200 * 24 * time.Hour),
|
|
Facts: map[string]any{"type": "storage container", "cluster": peName(cl), "capacity_gib": 81920.0, "replication_factor": 2}}
|
|
put(r)
|
|
}
|
|
}
|
|
for k := range vms {
|
|
cl, n := k%ntnxClusters, (k/ntnxClusters)%ahvPerPE+1
|
|
if cl == 1 && n == 4 { // in maintenance: its VMs moved off
|
|
n = 5
|
|
}
|
|
r := report.Workload{Kind: report.KindVM, ID: fmt.Sprintf("5f0e1d2c-%04d-4000-8000-%012d", cl, k), Name: fmt.Sprintf("%s-%02d", ahvRoles[k%len(ahvRoles)], k/len(ahvRoles)),
|
|
Node: host(cl, n), State: report.StateOK, Word: "Running", Since: now.Add(-time.Duration(1+k%60) * 24 * time.Hour),
|
|
Facts: map[string]any{"hypervisor": "AHV", "cluster": peName(cl), "firmware_uuid": vmUUID("nutanix-"+prismCentral, k), "vcpus": 4 << (k % 2),
|
|
"memory_gib": float64(int(16) << (k % 3)), "guest_os": []string{"Red Hat Enterprise Linux 9.4", "Windows Server 2022 Datacenter"}[k%2]}}
|
|
switch {
|
|
case k%23 == 22:
|
|
r.State, r.Word, r.Node = report.StateStopped, "Powered off", ""
|
|
case k == 41:
|
|
r.Facts["alerts"] = "VM Snapshot Is Old (warning)"
|
|
case k%50 == 13:
|
|
r.Facts["guest_tools"] = "not reachable"
|
|
}
|
|
put(r)
|
|
}
|
|
c.flap(fmt.Sprintf("a1b2c3d4-%04d-4000-8000-%012d", 1, 4), spellAHVUpdate, func(r *report.Workload, since time.Time) { // an AOS upgrade's rolling restart (scenario.go)
|
|
r.State, r.Word, r.Since = report.StateUpdating, "In maintenance mode", since
|
|
})
|
|
return c
|
|
}
|