
(Monitoring, Logging and Stork)
Created: 2020-11-18 Wed 12:03






















# dnf install yum-utils pygpgme # rpm --import 'https://dl.cloudsmith.io/public/isc/stork/cfg/gpg/gpg.77F64EC28053D1FB.key' # curl -1sLf 'https://dl.cloudsmith.io/public/isc/stork/cfg/setup/config.rpm.txt?distro=fedora&codename=29' > /tmp/isc-stork.repo
# less /tmp/isc-stork.repo # dnf config-manager --add-repo '/tmp/isc-stork.repo'


# dnf makecache --enablerepo='isc-stork' CentOS-8 - AppStream 46 kB/s | 4.3 kB 00:00 CentOS-8 - Base 35 kB/s | 3.9 kB 00:00 CentOS-8 - Extras 17 kB/s | 1.5 kB 00:00 isc-stork 186 B/s | 473 B 00:02 isc-stork 3.4 kB/s | 967 B 00:00 Importing GPG key 0x8053D1FB: Userid : "Cloudsmith Package (isc/stork) <support@cloudsmith.io>" Fingerprint: 7AB5 064B 08F0 69A1 A5CC 500C 77F6 4EC2 8053 D1FB From : https://dl.cloudsmith.io/public/isc/stork/cfg/gpg/gpg.77F64EC28053D1FB.key Is this ok [y/N]: y [...]


# dnf install isc-stork-agent isc-stork-server isc-stork 446 B/s | 473 B 00:01 isc-stork-noarch 700 B/s | 473 B 00:00 isc-stork-source 694 B/s | 473 B 00:00 Dependencies resolved. ========================================================================================================================================================================== Package Architecture Version Repository Size ========================================================================================================================================================================== Installing: isc-stork-agent x86_64 0.13.0.201104144722-1 isc-stork 8.3 M isc-stork-server x86_64 0.13.0.201104144722-1 isc-stork 23 M Transaction Summary ========================================================================================================================================================================== Install 2 Packages Total download size: 31 M Installed size: 68 M Is this ok [y/N]:


[root@kea-test ~]# dnf module enable postgresql:12 isc-stork 675 B/s | 473 B 00:00 isc-stork-noarch 687 B/s | 473 B 00:00 isc-stork-source 636 B/s | 473 B 00:00 Dependencies resolved. ========================================================================================================================================================================== Package Architecture Version Repository Size ========================================================================================================================================================================== Enabling module streams: postgresql 12 Transaction Summary ========================================================================================================================================================================== Is this ok [y/N]:


# dnf module list postgresql # dnf module list postgresql Last metadata expiration check: 0:03:10 ago on Fri 13 Nov 2020 11:00:55 AM CET. CentOS-8 - AppStream Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module postgresql 10 [d] client, server [d] PostgreSQL server and client module postgresql 12 [e] client, server [d] PostgreSQL server and client module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled


# dnf install postgresql-server postgresql-contrib Last metadata expiration check: 0:04:20 ago on Fri 13 Nov 2020 11:00:55 AM CET. Dependencies resolved. ========================================================================================================================================================================== Package Architecture Version Repository Size ========================================================================================================================================================================== Installing: postgresql-server x86_64 12.1-2.module_el8.1.0+273+979c16e6 AppStream 5.5 M Installing dependencies: libicu x86_64 60.3-2.el8_1 BaseOS 8.8 M libpq x86_64 12.4-1.el8_2 AppStream 195 k postgresql x86_64 12.1-2.module_el8.1.0+273+979c16e6 AppStream 1.4 M Transaction Summary ========================================================================================================================================================================== Install 4 Packages Total download size: 16 M Installed size: 62 M Is this ok [y/N]:


# postgresql-setup --initdb * Initializing database in '/var/lib/pgsql/data' * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
# systemctl enable --now postgresql Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /usr/lib/systemd/system/postgresql.service.


stork and an empty database stork_db for Stork:# su - postgres $ psql postgres psql (12.1) Type "help" for help. postgres=# CREATE USER stork WITH PASSWORD 'secure-password'; CREATE ROLE postgres=# CREATE DATABASE stork_db; CREATE DATABASE postgres=# GRANT ALL PRIVILEGES ON DATABASE stork_db TO stork; GRANT postgres=# \c stork_db postgres=# CREATE EXTENSION pgcrypto; CREATE EXTENSION postgres=# \q


/etc/stork/agent.env and will be
read by the init-system or systemd# address to bind ie. for listening STORK_AGENT_ADDRESS=2001:db8:500::8547 STORK_AGENT_PORT=8547 # settings for exporting stats to Prometheus STORK_AGENT_PROMETHEUS_KEA_EXPORTER_ADDRESS=192.0.2.47 STORK_AGENT_PROMETHEUS_KEA_EXPORTER_PORT=9547 STORK_AGENT_PROMETHEUS_KEA_EXPORTER_INTERVAL=60


# systemctl enable --now isc-stork-agent
Created symlink /etc/systemd/system/multi-user.target.wants/isc-stork-agent.service → /usr/lib/systemd/system/isc-stork-agent.service.
[root@kea-test ~]# systemctl status isc-stork-agent
● isc-stork-agent.service - ISC Stork Agent
Loaded: loaded (/usr/lib/systemd/system/isc-stork-agent.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2020-11-13 11:23:28 CET; 9s ago
Docs: man:stork-agent(8)
Main PID: 5411 (stork-agent)
Tasks: 6 (limit: 12210)
Memory: 7.0M
CGroup: /system.slice/isc-stork-agent.service
└─5411 /usr/bin/stork-agent
Nov 13 11:23:28 kea-test systemd[1]: Started ISC Stork Agent.
Nov 13 11:23:28 kea-test stork-agent[5411]: INFO[2020-11-13 11:23:28] main.go:75 Starting Stork Agent, version 0.13.0, build date 2020-11-04 14:47
Nov 13 11:23:28 kea-test stork-agent[5411]: INFO[2020-11-13 11:23:28] promkeaexporter.go:272 Prometheus Kea Exporter listening on 0.0.0.0:9547, stats pulling interval>
Nov 13 11:23:28 kea-test stork-agent[5411]: INFO[2020-11-13 11:23:28] monitor.go:80 Started app monitor


/etc/stork/server.env and will be
read by the init-system or systemd# database settings STORK_DATABASE_HOST=192.0.2.55 STORK_DATABASE_NAME=stork_db STORK_DATABASE_USER_NAME=stork STORK_DATABASE_PASSWORD=secure-password # ReST API settings # STORK_REST_HOST= # STORK_REST_PORT= # STORK_REST_TLS_CERTIFICATE= # STORK_REST_TLS_PRIVATE_KEY= # STORK_REST_TLS_CA_CERTIFICATE= STORK_REST_STATIC_FILES_DIR=/usr/share/stork/www


# systemctl enable --now isc-stork-server
Created symlink /etc/systemd/system/multi-user.target.wants/isc-stork-server.service → /usr/lib/systemd/system/isc-stork-server.service.
# systemctl status isc-stork-server
● isc-stork-server.service - ISC Stork Server
Loaded: loaded (/usr/lib/systemd/system/isc-stork-server.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2020-11-13 12:22:13 CET; 2s ago
Docs: man:stork-server(8)
Main PID: 6984 (stork-server)
Tasks: 7 (limit: 12210)
Memory: 19.6M
CGroup: /system.slice/isc-stork-server.service
└─6984 /usr/bin/stork-server
Nov 13 12:22:13 kea-test stork-server[6984]: INFO[2020-11-13 12:22:13] puller.go:38 starting Kea Hosts Puller
Nov 13 12:22:13 kea-test stork-server[6984]: INFO[2020-11-13 12:22:13] puller.go:71 started Kea Hosts Puller
Nov 13 12:22:13 kea-test stork-server[6984]: INFO[2020-11-13 12:22:13] puller.go:38 starting Kea Status Puller
Nov 13 12:22:13 kea-test stork-server[6984]: INFO[2020-11-13 12:22:13] puller.go:71 started Kea Status Puller
Nov 13 12:22:13 kea-test stork-server[6984]: INFO[2020-11-13 12:22:13] eventcenter.go:118 event 'started Stork server'
Nov 13 12:22:13 kea-test stork-server[6984]: INFO[2020-11-13 12:22:13] main.go:25 Starting Stork Server, version 0.13.0, build date 2020-11-04 14:47
Nov 13 12:22:13 kea-test stork-server[6984]: INFO[2020-11-13 12:22:13] middleware.go:48 installed file server middleware
Nov 13 12:22:13 kea-test stork-server[6984]: INFO[2020-11-13 12:22:13] middleware.go:68 installed SSE middleware
Nov 13 12:22:13 kea-test stork-server[6984]: INFO[2020-11-13 12:22:13] middleware.go:19 installed logging middleware
Nov 13 12:22:13 kea-test stork-server[6984]: INFO[2020-11-13 12:22:13] restservice.go:241 started serving Stork Server address="http://[::]:8080"


























% kea-show-leases4.sh IPAddr HWAddr Lease Start Renew Expire Hostname State 10.20.2.7 z0:z1:d9:z5:7c:36 14400 20150905T113158 20150905T133158 20150905T153158 host1. 0 10.20.2.6 0z:1z:d9:z5:7c:35 14400 20150905T112931 20150905T132931 20150905T152931 . 0 10.20.2.234 zz:75:0z:1a:a0:98 14400 20150905T112029 20150905T132029 20150905T152029 . 0 172.20.2.222 az:z3:cz:c4:4b:00 14400 20150905T110758 20150905T130758 20150905T150758 . 0


% kea-list-leases.py DHCPv4 leases: 6 IP Address | Hostname | HW Addr | Client-ID | Subnet ID | lifetime | expire 192.0.2.23 | macbookair | 14:c2:33:fd:ba:fb | 01:14:c2:33:fd:ba:fb | 1 | 14400 | 2020-11-18T14:11:17+01:00 192.0.2.80 | phone | 00:02:13:55:5e:23 | | 1 | 14400 | 2020-11-18T14:33:32+01:00 192.0.2.120 | linux-fedora | 3c:09:14:7a:6a:67 | 01:3c:09:14:7a:6a:67 | 1 | 14400 | 2020-11-18T13:24:08+01:00 192.0.2.121 | | 80:47:23:e6:38:32 | | 1 | 14400 | 2020-11-18T14:48:28+01:00 192.0.2.122 | openbsd | a8:61:b6:d1:ee:6e | 01:a8:61:b6:d1:ee:6e | 1 | 14400 | 2020-11-18T14:48:42+01:00 192.0.2.242 | nas | 00:12:47:30:c4:de | 01:00:12:47:30:b4:de | 1 | 14400 | 2020-11-18T14:47:31+01:00


keactrl can be used to check
the status of the Kea processes$ keactrl status DHCPv4 server: active DHCPv6 server: inactive DHCP DDNS: active Control Agent: active Netconf agent: inactive Kea configuration file: /usr/local/etc/kea/kea.conf Kea DHCPv4 configuration file: /usr/local/etc/kea/kea-dhcp4.conf Kea DHCPv6 configuration file: /usr/local/etc/kea/kea-dhcp6.conf Kea DHCP DDNS configuration file: /usr/local/etc/kea/kea-dhcp-ddns.conf Kea Control Agent configuration file: /usr/local/etc/kea/kea-ctrl-agent.conf Kea Netconf configuration file: /usr/local/etc/kea/kea-netconf.conf keactrl configuration file: /usr/local/etc/kea/keactrl.conf


systemd, the status of the Kea processes
can by read from the systemd process
# systemctl status kea-dhcp6
● kea-dhcp6.service - Kea DHCPv6 Service
Loaded: loaded (/etc/systemd/system/kea-dhcp6.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-11-12 22:50:14 CET; 1 day 10h ago
Docs: man:kea-dhcp6(8)
Main PID: 244200 (kea-dhcp6)
Tasks: 1 (limit: 11784)
Memory: 5.6M
CPU: 22.572s
CGroup: /system.slice/kea-dhcp6.service
└─244200 /opt/kea/sbin/kea-dhcp6 -c /opt/kea/etc/kea/kea-dhcp6.conf
Nov 12 22:50:14 home01 systemd[1]: Started Kea DHCPv6 Service.
Nov 12 22:50:14 home01 kea-dhcp6[244200]: 2020-11-12 22:50:14.813 INFO [kea-dhcp6.dhcp6/244200.140267216668800] DHCP6_STARTING Kea DHCPv6 server version 1.9.1 (developm>
Nov 12 22:50:14 home01 kea-dhcp6[244200]: 2020-11-12 22:50:14.813 WARN [kea-dhcp6.dhcp6/244200.140267216668800] DHCP6_DEVELOPMENT_VERSION This software is a development>


systemd exposes the state of managed services via the DBUS API
systemd services
https://github.com/povilasv/systemd_exporter



dhcping is a simple tool to test if a DHCP server responds to
DHCP requests and returns a lease


% sudo ./dhcping -v -s 192.0.2.1 -h 01:02:03:04:05:05 -c 192.0.2.145 --------------------------------------------------------------------------- DHCP REQUEST packet 250 bytes nop: 1 htype: 1 hlen: 6 hops: 0 xid: ef0aaf5f secs: 0 flags: 0 ciaddr: 192.0.2.145 yiaddr: 0.0.0.0 siaddr: 0.0.0.0 giaddr: 0.0.0.0 chaddr: 01:02:03:04:05:05 sname : fname : option 53 DHCP message type DHCP message type: 3 (DHCPREQUEST) option 50 Request IP address Requested IP address: 192.0.2.145


Got answer from: 192.0.2.1 packet 300 bytes nop: 2 htype: 1 hlen: 6 hops: 0 xid: ef0aaf5f secs: 0 flags: 7f80 ciaddr: no entry found yiaddr: 0.0.0.0 siaddr: 0.0.0.0 giaddr: 0.0.0.0 chaddr: 01:02:03:04:05:05 sname : fname : option 53 DHCP message type DHCP message type: 6 (DHCPNAK) option 54 DHCP Server identifier Server identifier: 192.0.2.1 option 56 Message


DHCP RELEASE packet 250 bytes nop: 1 htype: 1 hlen: 6 hops: 0 xid: ef0aaf5f secs: 0 flags: 0 ciaddr: 192.0.2.145 yiaddr: 0.0.0.0 siaddr: 0.0.0.0 giaddr: 0.0.0.0 chaddr: 01:02:03:04:05:05 sname : fname : option 53 DHCP message type DHCP message type: 7 (DHCPRELEASE) option 54 DHCP Server identifier Server identifier: 192.0.2.1


D
% ./dhcptest --query
dhcptest v0.7 - Created by Vladimir Panteleev
https://github.com/CyberShadow/dhcptest
Run with --help for a list of command-line options.
Listening for DHCP replies on port 68.
Sending packet:
op=BOOTREQUEST chaddr=2E:78:71:CA:DA:26 hops=0 xid=8DDD0A71 secs=0 flags=8000
ciaddr=0.0.0.0 yiaddr=0.0.0.0 siaddr=0.0.0.0 giaddr=0.0.0.0 sname= file=
1 options:
53 (DHCP Message Type): discover
Received packet from 192.0.2.8:67:
op=BOOTREPLY chaddr=2E:78:71:CA:DA:26 hops=0 xid=8DDD0A71 secs=0 flags=8000
ciaddr=0.0.0.0 yiaddr=192.0.2.115 siaddr=0.0.0.0 giaddr=0.0.0.0 sname= file=
9 options:
53 (DHCP Message Type): offer
1 (Subnet Mask): 255.255.255.0
3 (Router Option): 192.0.2.1
6 (Domain Name Server Option): 192.0.2.8, 172.16.1.105
15 (Domain Name): home.example.com
51 (IP Address Lease Time): 14400 (4 hours)
54 (Server Identifier): 192.0.2.8
58 (Renewal (T1) Time Value): 3600 (1 hour)
59 (Rebinding (T2) Time Value): 7200 (2 hours)










stdout or stderr

stdout and into a file
"loggers": [{
"name": "kea-dhcp4",
"output_options": [
{
"output": "stdout",
"pattern": "%-5p %m\n"
},{
"output": "/var/log/kea/kea-dhcp4.log",
"maxsize": 1048576,
"maxver": 10
}
],
"severity": "INFO",
"debuglevel": 0
}]
[...]






output parameter of syslog will sent the log messages
of the chosen logger to the syslog daemon
syslog:name
[...]
"loggers": [{
"name": "kea-dhcp4",
"output_options": [
{ "output": "syslog:dhcp4" }
],
"severity": "WARN", "debuglevel": 0
}]
[...]


output specifies the
file name
maxsize (size of
log-file in bytes) and maxver (number of log-file generations)

pattern option
pattern used for each message is described by a string
containing one or more format components as part of a text stringpattern
format string: https://log4cplus.sourceforge.io/

{
"output": "....",
"pattern": "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i.%t] %m\n"
},
2019-08-05 14:27:45.871 DEBUG [kea-dhcp4.dhcpsrv/8475.12345] DHCPSRV_TIMERMGR_START_TIMER starting timer: reclaim-expired-leases


systemd, the
logging output written to stdout will be stored in the systemd
journal
[...]
"loggers": [{
"name": "kea-dhcp4",
"output_options": [
{
"output": "stdout",
"pattern": "%-5p %m\n"
}
],
"severity": "INFO",
"debuglevel": 0
}]
[...]


awk
and perl)systemd-journald data can be sent via an encrypted and
authenticated connection to a central systemd-journald log hostjournalctl documentation for details# journalctl --since today -u kea-dhcp4 --grep DHCP4_LEASE_ADVERT -- Logs begin at Fri 2020-09-18 11:20:45 CEST, end at Sat 2020-11-14 09:24:50 CET. -- Nov 14 00:00:00 home01 kea-dhcp4[244218]: INFO DHCP4_LEASE_ADVERT [hwtype=1 00:0d:93:29:2d:30], cid=[01:00:0d:93:29:2d:30], tid=0xfa7d9468: lease 192.0.2.114 will be a> Nov 14 00:00:04 home01 kea-dhcp4[244218]: INFO DHCP4_LEASE_ADVERT [hwtype=1 00:0d:93:29:2d:30], cid=[01:00:0d:93:29:2d:30], tid=0xe998dcab: lease 192.0.2.114 will be a> Nov 14 00:05:13 home01 kea-dhcp4[244218]: INFO DHCP4_LEASE_ADVERT [hwtype=1 2e:78:71:ca:da:26], cid=[no info], tid=0x8ddd0a71: lease 192.0.2.115 will be advertised Nov 14 02:15:06 home01 kea-dhcp4[244218]: INFO DHCP4_LEASE_ADVERT [hwtype=1 14:c2:13:ed:ba:fb], cid=[01:14:c2:13:ed:ba:fb], tid=0xda0e88bc: lease 192.0.2.23 will be ad> Nov 14 04:16:09 home01 kea-dhcp4[244218]: INFO DHCP4_LEASE_ADVERT [hwtype=1 14:c2:13:ed:ba:fb], cid=[01:14:c2:13:ed:ba:fb], tid=0xda0e88be: lease 192.0.2.23 will be ad> Nov 14 06:01:03 home01 kea-dhcp4[244218]: INFO DHCP4_LEASE_ADVERT [hwtype=1 14:c2:13:ed:ba:fb], cid=[01:14:c2:13:ed:ba:fb], tid=0xda0e88c0: lease 192.0.2.23 will be ad> Nov 14 08:04:24 home01 kea-dhcp4[244218]: INFO DHCP4_LEASE_ADVERT [hwtype=1 14:c2:13:ed:ba:fb], cid=[01:14:c2:13:ed:ba:fb], tid=0xda0e88c3: lease 192.0.2.23 will be ad>


kea-ctrl-agent.http logger:# ./kea-ctrl-agent -c simple.json 20.10.15 14:05:16.550 INFO [kea-ctrl-agent.http/174909] HTTP_CLIENT_REQUEST_AUTHORIZED received HTTP request authorized for 'admin' 20.10.15 14:05:16.550 INFO [kea-ctrl-agent.commands/174909] COMMAND_RECEIVED Received command 'list-commands'


[kea-server]# systemctl stop kea-dhcp4 [kea-server]# kea-dhcp4 -d -c /etc/kea/kea-dhcp4.conf


"loggers": [{
"name": "kea-dhcp4",
"output_options": [
{ "output": "syslog:dhcp4" }
],
"severity": "WARN", "debuglevel": 0
},{
"name": "kea-dhcp4.flex-id-hooks",
"output_options": [ {
"output": "/var/log/kea/kea-dhcp4-flex-id.log"
} ],
"severity": "DEBUG",
"debuglevel": 55
} ]
[...]




perfdhcp) that is used to do DHCP performance
testing for Kea





