Skip to content
Merged

#186 #188

Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion autogole-api/packaging/files/etc/rtmon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ grafana_dev:
# image_flask_port:
# Default image debug is False (mainly used for development)
#image_debug:


# Default debug is False (mainly used for development), If set to True Dashboard will be generated with Memaid and Debug Info
# Debug:

# Default topdiagrams is Diagrams (mainly used for development)
#topdiagrams:
# Choices -> Diagrams | Mermaid
# ==================================

# Template path and tags. If tag updated - it will force update all templates
Expand Down Expand Up @@ -65,4 +73,3 @@ external_service:
# HostCert and HostKey location (needed for SiteRM communications). Cert mush be authorized in all Frontends.
hostcert: '/etc/grid-security/hostcert.pem'
hostkey: '/etc/grid-security/hostkey.pem'

25 changes: 14 additions & 11 deletions autogole-api/src/python/RTMonLibs/Template.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def t_createDashboard(self, *args, **kwargs):
out["uid"] = args[0]["intents"][0]["id"]
return out

def t_createHostFlow(self, sitehost, *args):
def t_createHostFlow(self, sitehost, num, *args):
"""Create Host Flow Template"""
out = []
interfaces = self.m_groups['Hosts'].get(sitehost, "")
Expand All @@ -464,7 +464,7 @@ def t_createHostFlow(self, sitehost, *args):
sitename = sitehost.split(":")[0]
hostname = sitehost.split(":")[1]
intfline = "|".join(interfaces.keys())
row = self.t_addRow(*args, title=f"Host Flow Summary: {sitehost}")
row = self.t_addRow(*args, title=f"{num}. Host Flow Summary: {sitehost}")
panels = dumpJson(self._t_loadTemplate("hostflow.json"), self.logger)
panels = panels.replace("REPLACEME_DATASOURCE", str(self.t_dsourceuid))
panels = panels.replace("REPLACEME_SITENAME", sitename)
Expand All @@ -474,7 +474,7 @@ def t_createHostFlow(self, sitehost, *args):
out += self.addRowPanel(row, panels, True)
return out

def t_createSwitchFlow(self, sitehost, *args):
def t_createSwitchFlow(self, sitehost, num, *args):
"""Create Switch Flow Template"""
def findIntf(interfaces):
"""Find Interface"""
Expand Down Expand Up @@ -519,7 +519,7 @@ def findIntf(interfaces):
sitename = sitehost.split(":")[0]
hostname = sitehost.split(":")[1]
intfline = findIntf(interfaces)
row = self.t_addRow(*args, title=f"Switch Flow Summary: {sitehost}")
row = self.t_addRow(*args, title=f"{num}. Switch Flow Summary: {sitehost}")
panels = dumpJson(self._t_loadTemplate("switchflow.json"), self.logger)
panels = panels.replace("REPLACEME_DATASOURCE", str(self.t_dsourceuid))
panels = panels.replace("REPLACEME_SITENAME", sitename)
Expand Down Expand Up @@ -721,21 +721,24 @@ def t_createTemplate(self, *args, **kwargs):

# Add Links on top of the page
self.generated['links'] = self.t_addLinks(*args, **kwargs)
# Add Debug Info (manifest, instance)
self.generated['panels'] += self.t_addDebug(*args)
added = []
hostnum, switchnum = 1, 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look at enumerate and use only 1 index from a list. No need separate numbers for hostnum, switchnum

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets say I have [host, host, host, switch] will it not create
host1
host2
host3
and switch4?

but we want hostt1, host2, host3, switch1 right?

Copy link
Collaborator

@juztas juztas Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want it in a flow:
host1, switch2, switch3, switch4, host5

for item in self.orderlist:
if item['Type'] == 'Host' and item['Name'] not in added:
self.generated['panels'] += self.t_createHostFlow(item["Name"], *args)
self.generated['panels'] += self.t_createHostFlow(item["Name"], hostnum, *args)
added.append(item['Name'])
hostnum += 1
elif item['Type'] == 'Switch' and item['Node'] not in added:
self.generated['panels'] += self.t_createSwitchFlow(item["Node"], *args)
self.generated['panels'] += self.t_createSwitchFlow(item["Node"], switchnum, *args)
added.append(item['Node'])
switchnum += 1
else:
self.logger.error(f"Unknown Type: {item['Type']}. Skipping... {item}")
# Add L2 Debugging
self.generated['panels'] += self.t_addL2Debugging(*args)

if len(diagrams) > 1:
self.generated['panels'] += diagrams[1]
if self.config.get('Debug', True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need documentation inside config file

if len(diagrams) > 1:
self.generated['panels'] += diagrams[1]
# Add Debug Info (manifest, instance)
self.generated['panels'] += self.t_addDebug(*args)
return {"dashboard": self.generated}, {"uid": self.generated['uid'], "annotation_panels": self.annotationids}
61 changes: 0 additions & 61 deletions autogole-api/src/templates/hostflow.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,4 @@
[
{
"datasource": {
"type": "prometheus",
"uid": "REPLACEME_DATASOURCE"
},
"description": "Network Address Information indicates what address is visible on interface (this comes out from Prometheus output)",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"options": {
"displayMode": "gradient",
"minVizHeight": 10,
"minVizWidth": 0,
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showUnfilled": true
},
"pluginVersion": "8.5.27",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "REPLACEME_DATASOURCE"
},
"editorMode": "code",
"expr": "node_network_address_info{instance=~\"REPLACEME_HOSTNAME.*\",sitename=\"REPLACEME_SITENAME\", device=~\"REPLACEME_INTERFACE\"}",
"interval": "",
"legendFormat": "{{address}} {{device}}",
"range": true,
"refId": "A"
}
],
"title": "Network Address Information",
"transformations": [],
"type": "bargauge"
},
{
"datasource": {
"type": "prometheus",
Expand Down
2 changes: 1 addition & 1 deletion autogole-api/src/templates/row.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"collapsed": false,
"collapsed": true,
"datasource": {
"type": "prometheus",
"uid": "bdlb788gxxcsge"
Expand Down