Skip to content

Commit

Permalink
Replace device_name with a hard coded meraki_controller_name to make …
Browse files Browse the repository at this point in the history
…NR side easier
  • Loading branch information
i3149 committed Sep 4, 2023
1 parent da6ef67 commit 3738823
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/inputs/snmp/x/meraki/meraki.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ type networkDesc struct {
org *organizations.GetOrganizationsOKBodyItems0
}

const (
MerakiDeviceName = "meraki_controller_name"
)

func NewMerakiClient(jchfChan chan []*kt.JCHF, gconf *kt.SnmpGlobalConfig, conf *kt.SnmpDeviceConfig, metrics *kt.SnmpDeviceMetric, log logger.ContextL) (*MerakiClient, error) {
c := MerakiClient{
log: log,
Expand Down Expand Up @@ -628,9 +632,9 @@ func (c *MerakiClient) parseClients(cs []*client) ([]*kt.JCHF, error) {
dst.CustomBigInt = map[string]int64{}
dst.EventType = kt.KENTIK_EVENT_SNMP_DEV_METRIC
dst.Provider = kt.ProviderMerakiCloud
dst.DeviceName = MerakiDeviceName

if client.device.Serial != "" {
dst.DeviceName = client.device.Name // Here, device is this device's name.
dst.SrcAddr = client.device.LanIP
dst.CustomStr["device_serial"] = client.device.Serial
dst.CustomStr["device_firmware"] = client.device.Firmware
Expand All @@ -644,7 +648,6 @@ func (c *MerakiClient) parseClients(cs []*client) ([]*kt.JCHF, error) {
dst.CustomStr["org_id"] = client.device.network.org.ID
}
} else {
dst.DeviceName = client.network // Here, device is this network's name.
dst.SrcAddr = c.conf.DeviceIP
}

Expand Down Expand Up @@ -928,7 +931,7 @@ func (c *MerakiClient) parseUplinks(uplinkMap map[string]deviceUplink) ([]*kt.JC
for _, uplink := range device.Uplinks {
dst := kt.NewJCHF()
dst.SrcAddr = uplink.IP
dst.DeviceName = strings.Join([]string{device.network.Name, uplink.Interface}, ".")
dst.DeviceName = MerakiDeviceName

dst.CustomStr = map[string]string{
"network": device.network.Name,
Expand Down Expand Up @@ -1090,7 +1093,7 @@ func (c *MerakiClient) parseVpnStatus(vpns []*vpnStatus) ([]*kt.JCHF, error) {
makeChf := func(vpn *vpnStatus) *kt.JCHF {
dst := kt.NewJCHF()
//dst.SrcAddr = uplink.PublicIP
dst.DeviceName = vpn.DeviceSerial
dst.DeviceName = MerakiDeviceName

dst.CustomStr = map[string]string{
"network": vpn.NetworkName,
Expand Down Expand Up @@ -1256,14 +1259,15 @@ func (c *MerakiClient) parseDeviceStatus(devices []*deviceStatusWrapper) ([]*kt.
makeChf := func(wrap *deviceStatusWrapper) *kt.JCHF {
dst := kt.NewJCHF()
dst.SrcAddr = wrap.device.PublicIP
dst.DeviceName = wrap.device.Name
dst.DeviceName = MerakiDeviceName

dst.CustomStr = map[string]string{
"network": wrap.NetworkName,
"network_id": wrap.device.NetworkID,
"serial": wrap.device.Serial,
"status": wrap.device.Status,
"tags": strings.Join(wrap.device.Tags, ","),
"name": wrap.device.Name,
"org_name": wrap.org.Name,
"org_id": wrap.org.ID,
"mac": wrap.device.Mac,
Expand Down

0 comments on commit 3738823

Please sign in to comment.