Skip to content

Commit

Permalink
Merge pull request #18 from 12urenloop/snmp-monitoring2
Browse files Browse the repository at this point in the history
add snmp monitor
  • Loading branch information
mcbloch authored Apr 26, 2023
2 parents bb29e42 + 0bdda3c commit 60db053
Show file tree
Hide file tree
Showing 5 changed files with 265 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config_prod.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ MANUALCOUNT_PORT=3000
CLIENT1_IP=172.12.50.21

CLIENT2_IP=172.12.50.22

ROUTER_IP=172.12.50.1
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ services:
- "--web.console.templates=/usr/share/prometheus/consoles"
network_mode: host
depends_on:
depends_on:
- blackbox
- snmp
# ports:
# - "9090:9090"
snmp:
build:
context: snmp/
dockerfile: Dockerfile
network_mode: host
blackbox:
build:
context: blackbox/
Expand Down
237 changes: 237 additions & 0 deletions grafana/provisioning/dashboards/snmp-network.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 15,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFA97CFB590B2093"
},
"description": "Traffic on the mikrotik router per bridge network",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "binBps"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 24,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "9.3.6",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFA97CFB590B2093"
},
"editorMode": "code",
"expr": "rate(ifHCInOctets{ifName!~\"ether.*\"}[$__rate_interval])",
"legendFormat": "{{ifName}}",
"range": true,
"refId": "A"
}
],
"title": "Router traffic IN",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "PBFA97CFB590B2093"
},
"description": "Traffic on the mikrotik router per bridge network",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "binBps"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 24,
"x": 0,
"y": 9
},
"id": 3,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "9.3.6",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFA97CFB590B2093"
},
"editorMode": "code",
"expr": "rate(ifHCOutOctets{ifName!~\"ether.*\"}[$__rate_interval])",
"legendFormat": "{{ifName}}",
"range": true,
"refId": "A"
}
],
"title": "Router traffic OUT",
"type": "timeseries"
}
],
"refresh": "5s",
"schemaVersion": 37,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Network Traffic",
"uid": "N80PqzyVk",
"version": 4,
"weekStart": ""
}
15 changes: 14 additions & 1 deletion prometheus/prometheus.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ scrape_configs:
metrics_path: /metrics
static_configs:
- targets: [ "$TELRAAM_IP:9187" ]

- job_name: snmp
static_configs:
- targets:
- $ROUTER_IP # SNMP device
metrics_path: /snmp
params:
module: [if_mib]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9116 # The SNMP exporter's real hostname:port.
- job_name: blackbox
metrics_path: /probe
params:
Expand Down
5 changes: 5 additions & 0 deletions snmp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM prom/snmp-exporter

EXPOSE 9116
ENTRYPOINT [ "/bin/snmp_exporter" ]
CMD [ "--config.file=/etc/snmp_exporter/snmp.yml" ]

0 comments on commit 60db053

Please sign in to comment.