Created
January 16, 2019 00:55
-
-
Save jim-minter/58c203894459498b1c9e295e433b5ad2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/xml" | |
"os" | |
"text/template" | |
) | |
var tmpl = ` | |
<?xml version="1.0" encoding="utf-8"?> | |
<MonitoringManagement version="1.0" namespace="{{ .Namespace | Escape }}" eventVersion="1" timestamp="2017-08-01T00:00:00.000Z"> | |
<Accounts> | |
<Account moniker="{{ .Account | Escape }}" isDefault="true" autoKey="false" /> | |
</Accounts> | |
<Management eventVolume="Large" defaultRetentionInDays="90" > | |
<Identity tenantNameAlias="RPTenant" roleNameAlias="Service" roleInstanceNameAlias="Host"> | |
<IdentityComponent name="RPSector">{{ .Sector | Escape }}</IdentityComponent> | |
<IdentityComponent name="RPTenant">{{ .Region | Escape }}</IdentityComponent> | |
<IdentityComponent name="Service">OSA</IdentityComponent> | |
<IdentityComponent name="Host" useComputerName="true" /> | |
<IdentityComponent name="SubscriptionId">{{ .SubscriptionId | Escape }}</IdentityComponent> | |
<IdentityComponent name="ResourceName">{{ .ResourceName | Escape }}</IdentityComponent> | |
<IdentityComponent name="ResourceGroupName">{{ .ResourceGroupName | Escape }}</IdentityComponent> | |
</Identity> | |
<AgentResourceUsage diskQuotaInMB="50000" /> | |
</Management> | |
<Sources> | |
<Source name="journald" dynamic_schema="true" /> | |
</Sources> | |
<Events> | |
<MdsdEvents> | |
<MdsdEventSource source="journald"> | |
<RouteEvent eventName="CustomerSyslogEvents" storeType="CentralBond" priority="Normal"/> | |
</MdsdEventSource> | |
</MdsdEvents> | |
</Events> | |
</MonitoringManagement> | |
` | |
func main() { | |
t := template.Must(template.New("").Funcs(map[string]interface{}{ | |
"Escape": func(s string) (string, error) { | |
var b bytes.Buffer | |
err := xml.EscapeText(&b, []byte(s)) | |
return b.String(), err | |
}, | |
}).Parse(tmpl)) | |
err := t.Execute(os.Stdout, map[string]string{ | |
"Namespace": "", | |
"Account": "", | |
"Sector": "", | |
"Region": "", | |
"SubscriptionId": "", | |
"ResourceName": "", | |
"ResourceGroupName": "", | |
}) | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment