Skip to content

wip: akvorado #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 103 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
9ce6c07
Create akvorado.py
SoundGoof Jun 16, 2024
0548771
Add akvorado module and service files
Jun 16, 2024
1e33c7f
Create akvorado.yaml.erb
SoundGoof Jun 16, 2024
c4f4acb
Create init.pp
SoundGoof Jun 16, 2024
881db28
Add kafka and clickhouse installation
Jun 16, 2024
fa7019a
fix cosmetic issues
Jun 16, 2024
f11d948
fix indent
Jun 16, 2024
6b567eb
Update akvorado.py
SoundGoof Jun 16, 2024
c3e200a
Update akvorado.py
SoundGoof Jun 16, 2024
c82b7bd
Update akvorado.py
SoundGoof Jun 16, 2024
b94eec3
Update akvorado.py
SoundGoof Jun 16, 2024
2ea8a88
Update akvorado.py
SoundGoof Jun 16, 2024
add344a
Update akvorado.py
SoundGoof Jun 16, 2024
f264703
add columns
Jun 16, 2024
3b5855a
add commas
Jun 16, 2024
644d284
add parameters to akvorado class
Jun 16, 2024
e1f09e4
fix typo
Jun 16, 2024
adde4b4
fix indent more
Jun 16, 2024
ee7f97f
declare kafka service
Jun 16, 2024
d99a4ec
rename duplicate service kafka
Jun 16, 2024
4698f48
fix more stuff
Jun 16, 2024
b58bc5e
give wget a bit more space
Jun 16, 2024
fc3d0f3
fix zookeeper
Jun 16, 2024
1d2b937
.
Jun 16, 2024
c321f7e
.
Jun 16, 2024
9d59ec6
.
Jun 16, 2024
23b7342
fix service file
Jun 16, 2024
5fb19cb
Update akvorado.py
SoundGoof Jun 16, 2024
2324939
fix indent in template
Jun 16, 2024
fcb8700
Merge branch 'akvorado' of ssh://github.com/dhtech/puppet-modules int…
Jun 16, 2024
390d6ef
fix yaml
Jun 16, 2024
64c362e
fix service kafka
Jun 17, 2024
a2ea3d0
fixes
Jun 17, 2024
95c733c
Fix order
Jun 17, 2024
fa969bc
Major improvements and fixes
Jun 22, 2024
7c2d41c
Fix manifest indent to make circleci happy again
Jun 22, 2024
7ab1f8d
Update init.pp
furest Jun 22, 2024
c70c64b
Fix proxy + improvements
Jun 25, 2024
70d1f60
change to not scripts
SoundGoof Oct 12, 2024
20e6aaf
Create puppet-lint.yaml (#397)
SoundGoof Oct 19, 2024
8a3b57c
Create .puppet-lint.rc (#398)
SoundGoof Oct 21, 2024
7331b59
Update .puppet-lint.rc (#399)
SoundGoof Oct 21, 2024
9d0e3dd
Update prometheus-exporter-distconfcheck.erb (#400)
tisteagle-dreamhack Oct 29, 2024
97c4f69
add logging instead of pcap (#396)
SoundGoof Oct 29, 2024
aca3bb3
Wire guard (#401)
AlexanderMalmstrom Nov 18, 2024
7dddfc0
WireGuard (#402)
AlexanderMalmstrom Nov 18, 2024
e4012a8
Update init.pp (#403)
AlexanderMalmstrom Nov 18, 2024
3443587
Wire guard (#404)
AlexanderMalmstrom Nov 18, 2024
c6022f7
Update wg0.conf.erb (#405)
AlexanderMalmstrom Nov 18, 2024
c1abd88
Path fix (#406)
AlexanderMalmstrom Nov 18, 2024
49254be
Update init.pp (#407)
AlexanderMalmstrom Nov 18, 2024
21fb129
Wireguard (#408)
AlexanderMalmstrom Nov 18, 2024
48938a5
Create akvorado.py
SoundGoof Jun 16, 2024
5924487
Add akvorado module and service files
Jun 16, 2024
0356354
Create akvorado.yaml.erb
SoundGoof Jun 16, 2024
f4f9acf
Create init.pp
SoundGoof Jun 16, 2024
a265b31
Add kafka and clickhouse installation
Jun 16, 2024
8f82300
fix cosmetic issues
Jun 16, 2024
4deb8a9
fix indent
Jun 16, 2024
708ea00
Update akvorado.py
SoundGoof Jun 16, 2024
f004e02
Update akvorado.py
SoundGoof Jun 16, 2024
abe9952
Update akvorado.py
SoundGoof Jun 16, 2024
81f2542
Update akvorado.py
SoundGoof Jun 16, 2024
de7d459
Update akvorado.py
SoundGoof Jun 16, 2024
79c0e53
Update akvorado.py
SoundGoof Jun 16, 2024
6db5de5
add columns
Jun 16, 2024
7b17770
add commas
Jun 16, 2024
9042c20
add parameters to akvorado class
Jun 16, 2024
c3d8cf4
fix typo
Jun 16, 2024
788ffa2
fix indent more
Jun 16, 2024
1639289
declare kafka service
Jun 16, 2024
5165a1b
rename duplicate service kafka
Jun 16, 2024
c0bb440
fix more stuff
Jun 16, 2024
c8a3dc6
give wget a bit more space
Jun 16, 2024
5773af8
fix zookeeper
Jun 16, 2024
fbd8acb
.
Jun 16, 2024
323f9ab
.
Jun 16, 2024
088133c
.
Jun 16, 2024
0b2360c
fix service file
Jun 16, 2024
014f0e3
fix indent in template
Jun 16, 2024
8200c6a
Update akvorado.py
SoundGoof Jun 16, 2024
558866b
fix yaml
Jun 16, 2024
c1bd203
fix service kafka
Jun 17, 2024
53c18fb
fixes
Jun 17, 2024
12cecd9
Fix order
Jun 17, 2024
ba34350
Major improvements and fixes
Jun 22, 2024
29fef7c
Fix manifest indent to make circleci happy again
Jun 22, 2024
2d97383
Update init.pp
furest Jun 22, 2024
11f450f
Fix proxy + improvements
Jun 25, 2024
5f6dd66
Merge branch 'akvorado' of ssh://github.com/dhtech/puppet-modules int…
Nov 19, 2024
b32d1b0
allow empty list
SoundGoof Nov 19, 2024
321151c
update snmp provider discovery
Nov 19, 2024
2a26ed4
Merge branch 'akvorado' of ssh://github.com/dhtech/puppet-modules int…
Nov 19, 2024
28b0b66
fix indent
Nov 19, 2024
0c5dbfe
fix ensure order
Nov 19, 2024
7acf723
fix bug
Nov 19, 2024
951cf8d
remove iterable check
Nov 19, 2024
367b2f2
return empty array instead of none
Nov 19, 2024
e218dbe
add encoded slashes support
Nov 22, 2024
d15b3c9
Remove previous encoded slashes fix
Nov 22, 2024
ddf98ea
make linter happy again
Nov 22, 2024
47a12c8
rename dh as
Nov 23, 2024
03d6fb8
change ldap template
Nov 23, 2024
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
20 changes: 0 additions & 20 deletions .circleci/config.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/puppet-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: puppet linting
on:
pull_request:
branches:
- master
- main
- production
paths-ignore:
- "**.md"

jobs:
puppet-lint:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4


- name: puppet-lint
uses: scottbrenner/[email protected]
with:
args: ./

6 changes: 6 additions & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--fail-on-warnings
--relative
--no-class_inherits_from_params_class-check
--no-documentation-check
--no-puppet_url_without_modules-check
--no-legacy_facts
138 changes: 138 additions & 0 deletions modules/akvorado.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# vim: ts=4: sts=4: sw=4: expandtab
# Copyright 2024 dhtech
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file
import lib
import os
import sqlite3
import yaml

DB_FILE = '/etc/ipplan.db'

def get_sflow_clients():
if os.path.isfile(DB_FILE):
try:
conn = sqlite3.connect(DB_FILE)
db = conn.cursor()
except sqlite3.Error as e:
print("An error occurred: {}".format(e.args[0]))
exit(2)
else:
print("No database file found: {}".format(DB_FILE))
exit(3)
db.execute(
"SELECT h.name AS hostname, h.ipv4_addr_txt AS ipv4_addr ,h.ipv6_addr_txt AS ipv6_addr, o2.value AS layer "
"FROM host h "
"INNER JOIN option o1 ON h.node_id = o1.node_id "
"INNER JOIN option o2 ON h.node_id = o2.node_id "
"WHERE o1.name='pkg' AND o1.value='sflowclient' "
"AND o2.name='layer';"
)
res = db.fetchall()
if not res:
return None

column_names = [description[0] for description in db.description]
conn.close()
rows_dict = [dict(zip(column_names, row)) for row in res]

return rows_dict

def get_snmpv2_providers():
providers = []
clients = get_sflow_clients()
if not clients:
return providers
current_event = lib.get_current_event()
for client in clients:
key = current_event+'-mgmt/snmpv2:'+client['layer']
secrets = lib.read_secret(key)
if not secrets:
return providers
if "community" in secrets:
provider = {
"ipv4": client["ipv4_addr"],
"community": secrets["community"],
}
providers.append(provider)
return providers

def get_snmpv3_providers():
providers = []
clients = get_sflow_clients()
if not clients:
return providers
current_event = lib.get_current_event()
for client in clients:
key = current_event+'-mgmt/snmpv3:'+client['layer']
secrets = lib.read_secret(key)
if not secrets:
return providers
if "user" in secrets:
provider = {
"ipv4": client["ipv4_addr"],
"authentication-passphrase": secrets["auth"],
"authentication-protocol": secrets["authtype"].replace(" ","").upper(),
"privacy-passphrase": secrets["priv"],
"privacy-protocol": secrets["privtype"].replace(" ","").replace("128","").upper(),
"user": secrets["user"],
}
providers.append(provider)
return providers

def get_prefixes(ipversion):
if os.path.isfile(DB_FILE):
try:
conn = sqlite3.connect(DB_FILE)
db = conn.cursor()
except sqlite3.Error as e:
print("An error occurred: {}".format(e.args[0]))
exit(2)
else:
print("No database file found: {}".format(DB_FILE))
exit(3)

if ipversion == "4":
db.execute(
'SELECT SUBSTR(name,1, INSTR(name, "@")-1) AS location, name, short_name, ipv4_txt'
' FROM network'
' WHERE node_id NOT IN (SELECT option.node_id FROM option WHERE name = "no-akv")'
' AND name LIKE "%@%" AND ipv4_txt IS NOT NULL'
)

elif ipversion == "6":
db.execute(
'SELECT SUBSTR(name,1, INSTR(name, "@")-1) AS location, name, short_name, ipv6_txt'
' FROM network'
' WHERE node_id NOT IN (SELECT option.node_id FROM option WHERE name = "no-akv")'
' AND name LIKE "%@%" AND ipv6_txt IS NOT NULL'
' AND NOT (name = "BOGAL@DREAMHACK" AND ipv6_txt = "2a05:2240:5000::/48")'
)
else:
raise NetworkTypeNotFoundError('network type must be 4 or 6')

res = db.fetchall()
if not res:
raise NetworkNotFoundError('network not found')

column_names = [description[0] for description in db.description]
conn.close()
rows_dict = [dict(zip(column_names, row)) for row in res]

return rows_dict


def requires(host, *args):
return ['apache(ldap)']


def generate(host, *args):

info = {}
info['snmpv3_providers'] = get_snmpv3_providers()
info['snmpv2_providers'] = get_snmpv2_providers()
info['current_event'] = lib.get_current_event()
info['ipv6_prefixes'] = get_prefixes('6')
info['ipv4_prefixes'] = get_prefixes('4')
return {'akvorado': info}
15 changes: 15 additions & 0 deletions modules/akvorado/files/akvorado-console.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Akvorado Console
After=akvorado-orch.service
Requires=akvorado-orch.service

[Service]
Type=simple
Restart=on-failure
RestartSec=15
User=akvorado
ExecStart=/usr/local/bin/akvorado console http://127.0.0.1:8080

[Install]
WantedBy=multi-user.target

15 changes: 15 additions & 0 deletions modules/akvorado/files/akvorado-inlet.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Akvorado Inlet
After=akvorado-orch.service
Requires=akvorado-orch.service

[Service]
Type=simple
Restart=on-failure
RestartSec=15
User=akvorado
ExecStart=/usr/local/bin/akvorado inlet http://127.0.0.1:8080

[Install]
WantedBy=multi-user.target

13 changes: 13 additions & 0 deletions modules/akvorado/files/akvorado-orch.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Akvorado Orchestrator
After=network.target
[Service]
Type=simple
Restart=on-failure
RestartSec=15
User=akvorado
ExecStart=/usr/local/bin/akvorado orchestrator /etc/akvorado/akvorado.yaml

[Install]
WantedBy=multi-user.target

13 changes: 13 additions & 0 deletions modules/akvorado/files/kafka.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Requires=zookeeper.service
After=zookeeper.service

[Service]
Type=simple
User=kafka
ExecStart=/bin/sh -c ' /var/lib/kafka/bin/kafka-server-start.sh /var/lib/kafka/config/server.properties > /var/log/kafka/kafka.log 2>&1'
ExecStop=/var/lib/kafka/bin/kafka-server-stop.sh
Restart=on-abnormal

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions modules/akvorado/files/zookeeper.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
Type=simple
User=kafka
ExecStart=/var/lib/kafka/bin/zookeeper-server-start.sh /var/lib/kafka/config/zookeeper.properties
ExecStop=/var/lib/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal

[Install]
WantedBy=multi-user.target
Loading