
UUID(Universally Unique Identifier)はプログラム中でオブジェクトを一意に識別するために使用される128ビットの数値であり、記事作成時点で使用されているUUIDには乱数のみで構成される「バージョン4」とミリ秒単位のUNIX時間+乱数で構成される「バージョン7」があります。
すべてのUUIDをリストアップして検索できる「Every UUID V4」、そして直面した技術的課題とは? - GIGAZINE
ゲームプログラマーの Nolen Royalty氏はすべてのUUIDバージョン4(UUID v4)をリスト管理したいという衝動に駆られウェブアプリ化しましたが、実現までに直面した技術的課題について自身のブログにて語っていました。
すべてのUUIDをリストアップして検索できる「Every UUID V4」、そして直面した技術的課題とは? - GIGAZINE
◆検索
「UUIDを興味深さの順に並べる」という目標は達成しましたが、今度は別の問題が発生しました。UUIDが見た目上ランダムに順序付けられているため膨大なリストから目的のUUIDを見つけるのが困難になってしまいました。ミキシング関数は可逆であるため、特定のUUIDを検索する機能を追加するのであればUUIDからインデックスを逆算してインデックスが示す位置にジャンプするだけであり簡単に実装できました。しかしながら部分文字列による検索をしたいという要望にも対応するとなると話が変わってきます。表示領域に含まれるUUID程度であれば問題はないのですが、すべてのUUIDを対象にする場合は何兆件ものアイテムをメモリに置かなければならないため現実的ではありません。
すべてのUUIDをリストアップして検索できる「Every UUID V4」、そして直面した技術的課題とは? - GIGAZINE
最終的に実装された妥協策は以下のようなものとなりました。
・検索文字列パターンに基づいて有効なUUIDを複数生成する
・生成したUUIDからインデックスを得る
・インデックスをもとに現在位置から最も近いUUIDを選択する
すべてのUUIDをリストアップして検索できる「Every UUID V4」、そして直面した技術的課題とは? - GIGAZINE
⇧ まぁ、「検索」は「パフォーマンス」の問題が解決困難な領域ですからな...
とりあえず、確実に「トレードオフ」にならざるを得ないとは思うのだが、良い塩梅の妥協点を見出すのが難しい話ではあるのよね...
pmacctの対応データ、ネットワーク機器、テーブルの関係を整理したいのだが...
公式の「GitHub」のページによると、
About
pmacct is a small set of multi-purpose passive network monitoring tools [NetFlow IPFIX sFlow libpcap BGP BMP RPKI IGP Streaming Telemetry].
⇧ とあり、「ネットワーク監視ツール」であると。
⇧ ほぼほぼ「C言語」で構成されているっぽい...
で、
⇧ 上記のページによりますと、
| No | プロトコル | Supported versions | ネットワーク機器 |
|---|---|---|---|
| 1 | NETFLOW | V5/V9/V10 |
|
| 2 | IPFIX | 同上 | 同上 |
| 3 | SFLOW | V2/V4/V5 |
|
⇧ とあるのだが、
Name Last commit message Last commit date ... pmacct-create-db.pgsql Initial revision 20 years ago pmacct-create-db_bgp_v1.mysql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-db_v1.mysql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-db_v2.mysql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-db_v3.mysql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-db_v4.mysql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-db_v5.mysql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-db_v6.mysql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-db_v7.mysql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-db_v8.mysql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-db_v9.mysql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_bgp_v1.pgsql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_bgp_v1.sqlite3 Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v1.pgsql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v1.sqlite3 Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v2.pgsql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v2.sqlite3 Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v3.pgsql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v3.sqlite3 Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v4.pgsql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v4.sqlite3 Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v5.pgsql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v5.sqlite3 Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v6.pgsql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v6.sqlite3 Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v7.sqlite3 Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v7_v8.pgsql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v8.sqlite3 Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v9.pgsql Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-create-table_v9.sqlite3 Unified spacing to 4 spaces. Fixed v8 postgresql configuration section. 7 years ago pmacct-grant-db.mysql * fix, SQL: amended initial CREATE USER and GRANT commands for MySQL/… 5 years ago
⇧ 上記の「DDL」の「バージョン」と「プロトコル」の「Supported versions」が嚙み合っていない...
そもそも、「Last commit message」が全て「PostgreSQL」に関するものになっているのも解せぬ...
ちなみに、

⇧ ほとんど、変わっていないが、
⇧ v5とv6で「テーブル」の構成が刷新されたっぽい...
そもそも、表題の件。
ネットの情報を漁っていたところ、
⇧ 上記のPDFの図を見る限り、
- インプット
- libpcap
- NetFlow
- sFlow
- 処理
- pmacct
- アウトプット
- MySQL
- PostgreSQL
- SQLite 3.x
- Memory Table
といった感じの処理の流れになりそうではある。
別のPDFによると、
⇧ 上記にありますように、処理が分かれており、「RDBMS(Relational DataBase Management System)」に対して「データ」を「INSERT」などする「SQL」の「query」は「Plugin」によって実現されていると...
とりあえず、「C言語」について門外漢なのだが、「アウトプット」先が「PostgreSQL」の場合は、
⇧ 上記にある「pmacct/src/pgsql_plugin.c」が最終的に呼び出されている感じになるんかな?
「ChatGPT」氏に質問してみたところ、以下のような回答が返ってきた。
📌 アウトプット先がPostgreSQLの場合
┌────────────────────────────────────────────┐
│ PostgreSQL schema 準備 │
└────────────────────────────────────────────┘
DBA/Admin
↓
pmacct/sql/ を確認
↓
DDL(version)選択
↓
sql_table_version 決定
↓
CREATE DATABASE
↓
CREATE USER
↓
DDL適用
↓
CREATE INDEX
↓
GRANT
DDL例:
sql/pmacct-create-table_v1.pgsql
sql/pmacct-create-table_v2.pgsql
sql/pmacct-create-table_v6.pgsql
...
※ aggregate 設定と schema を一致させる必要あり
==================================================
pmacct runtime
==================================================
+----------------+
| pmacctd |
| libpcap input |
| src/pmacctd.c |
+--------+-------+
|
v
pcap_common.c
|
v
pkt_handlers.c
|
v
+----------------+ +----------------+ +----------------+
| nfacctd | | sfacctd | | pmacctd |
| NetFlow/IPFIX | | sFlow | | raw packets |
| src/nfacctd.c | | src/sfacctd.c | | |
+--------+-------+ +--------+-------+ +--------+--------+
| | |
v v |
nfv8/nfv9/IPFIX decode sflow.c |
pkt_handlers.c read_sflow_datagram() |
nfv9_template.c |
| | |
+----------+-----------+-----------------------+
|
v
plugin_hooks.c
|
v
plugins.c
|
v
imt_plugin.c
aggregation/cache
|
v
sql_common.c
SQL column mapping
INSERT/COPY build
|
v
pgsql_plugin.c
PostgreSQL backend
|
v
libpq (PQconnectdb)
|
v
libpq (PQexec)
|
v
PostgreSQL
📌 シーケンス図

```mermaid
sequenceDiagram
autonumber
participant DBA as DBA/Admin
participant SQLDIR as sql/*.pgsql
participant DB as PostgreSQL
participant EXP as Exporter<br/>(Router/Switch)
participant NF as nfacctd.c
participant SF as sfacctd.c
participant DEC as Decoder Layer
participant PLG as plugin_hooks.c
participant IMT as imt_plugin.c
participant SQL as sql_common.c
participant PG as pgsql_plugin.c
participant LIBPQ as libpq
rect rgb(240,240,240)
Note over DBA,DB: PostgreSQL schema preparation
DBA->>SQLDIR: DDL version選択
Note right of SQLDIR: pmacct-create-table_vX.pgsql
DBA->>DB: CREATE DATABASE
DBA->>DB: CREATE USER
DBA->>DB: DDL適用
DBA->>DB: CREATE INDEX
DBA->>DB: GRANT
Note over DBA,DB: aggregate設定とDDL schemaを一致させる必要あり
end
rect rgb(235,245,255)
Note over EXP,DEC: Input / Decode layer
alt NetFlow/IPFIX
EXP->>NF: UDP NetFlow/IPFIX
NF->>DEC: pkt_handlers.c
DEC->>DEC: nfv9_template.c
DEC->>DEC: Flow decode
else sFlow
EXP->>SF: UDP sFlow Datagram
SF->>DEC: sflow.c
DEC->>DEC: read_sflow_datagram()
DEC->>DEC: sample type判定
DEC->>DEC: Flow sample decode
end
end
rect rgb(245,255,245)
Note over PLG,PG: Aggregation / SQL backend layer
DEC->>PLG: normalized flow record
PLG->>IMT: aggregate/cache
IMT->>IMT: flow aggregation
IMT->>IMT: cache accumulation
IMT->>SQL: purge trigger
SQL->>SQL: aggregate → SQL column mapping
SQL->>SQL: INSERT/COPY build
SQL->>PG: SQL execution request
PG->>LIBPQ: PQconnectdb()
PG->>LIBPQ: PQexec()
LIBPQ->>DB: INSERT INTO acct(...)
DB-->>LIBPQ: result
LIBPQ-->>PG: success/failure
end
```
⇧ う~む...
「C言語」が門外漢なので、「AI」の回答にある処理の流れが正しいのか皆目見当が付かない...
ちなみに、
⇧ 上記の「Dockerfile」によると、「/etc/pmacct/pmacctd.conf」の設定を読み込んでいるらしく、
int main(int argc,char **argv, char **envp)
{
/* pcap library stuff */
struct pcap_pkthdr pkt_hdr;
const u_char *pkt_body;
pcap_if_t *pm_pcap_ifs = NULL;
int index, index_rr = 0, logf, ret;
int pm_pcap_savefile_round = 0;
struct plugins_list_entry *list;
struct plugin_requests req;
char config_file[SRVBUFLEN];
int psize = DEFAULT_SNAPLEN;
struct id_table bpas_table;
struct id_table blp_table;
struct id_table bmed_table;
struct id_table biss_table;
struct id_table bta_table;
struct pm_pcap_device *dev_ptr;
struct pm_pcap_callback_data cb_data;
/* select() stuff */
fd_set read_descs, bkp_read_descs;
int select_fd, bkp_select_fd;
/* getopt() stuff */
extern char *optarg;
extern int optind, opterr, optopt;
int errflag, cp;
struct sockaddr_storage client;
⇧ 上記の「int main(int argc,char **argv, char **envp)」の「引数」として「設定ファイル(/etc/pmacct/pmacctd.conf)」を受け取っていて、
/* getting commandline values */
while (!errflag && ((cp = getopt(argc, argv, ARGS_PMACCTD)) != -1)) {
if (!cfg_cmdline[rows]) cfg_cmdline[rows] = malloc(SRVBUFLEN);
memset(cfg_cmdline[rows], 0, SRVBUFLEN);
switch (cp) {
case 'P':
strlcpy(cfg_cmdline[rows], "plugins: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'D':
strlcpy(cfg_cmdline[rows], "daemonize: true", SRVBUFLEN);
rows++;
break;
case 'z':
strlcpy(cfg_cmdline[rows], "pmacctd_nonroot: true", SRVBUFLEN);
rows++;
break;
case 'd':
debug = TRUE;
strlcpy(cfg_cmdline[rows], "debug: true", SRVBUFLEN);
rows++;
break;
case 'n':
strlcpy(cfg_cmdline[rows], "networks_file: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 't':
strlcpy(cfg_cmdline[rows], "ports_file: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'O':
strlcpy(cfg_cmdline[rows], "print_output: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'o':
strlcpy(cfg_cmdline[rows], "print_output_file: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'M':
strlcpy(cfg_cmdline[rows], "print_markers: true", SRVBUFLEN);
rows++;
break;
case 'A':
strlcpy(cfg_cmdline[rows], "print_output_file_append: true", SRVBUFLEN);
rows++;
break;
case 'E':
strlcpy(cfg_cmdline[rows], "print_output_separator: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'u':
strlcpy(cfg_cmdline[rows], "print_num_protos: true", SRVBUFLEN);
rows++;
break;
case 'N':
strlcpy(cfg_cmdline[rows], "promisc: false", SRVBUFLEN);
rows++;
break;
case 'f':
strlcpy(config_file, optarg, sizeof(config_file));
free(cfg_cmdline[rows]);
cfg_cmdline[rows] = NULL;
break;
case 'F':
strlcpy(cfg_cmdline[rows], "pidfile: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'c':
strlcpy(cfg_cmdline[rows], "aggregate: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'b':
strlcpy(cfg_cmdline[rows], "imt_buckets: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'm':
strlcpy(cfg_cmdline[rows], "imt_mem_pools_number: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'p':
strlcpy(cfg_cmdline[rows], "imt_path: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'r':
strlcpy(cfg_cmdline[rows], "sql_refresh_time: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 's':
strlcpy(cfg_cmdline[rows], "imt_mem_pools_size: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'S':
strlcpy(cfg_cmdline[rows], "syslog: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'i':
strlcpy(cfg_cmdline[rows], "pcap_interface: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'I':
strlcpy(cfg_cmdline[rows], "pcap_savefile: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'w':
strlcpy(cfg_cmdline[rows], "pcap_interface_wait: true", SRVBUFLEN);
rows++;
break;
case 'W':
strlcpy(cfg_cmdline[rows], "pcap_savefile_wait: true", SRVBUFLEN);
rows++;
break;
case 'Z':
strlcpy(cfg_cmdline[rows], "pcap_savefile_delay: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'Y':
strlcpy(cfg_cmdline[rows], "pcap_savefile_replay: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'L':
strlcpy(cfg_cmdline[rows], "snaplen: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'R':
strlcpy(cfg_cmdline[rows], "sfacctd_renormalize: true", SRVBUFLEN);
rows++;
break;
case 'T':
strlcpy(cfg_cmdline[rows], "dry_run: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
break;
case 'h':
usage_daemon(argv[0]);
exit(0);
break;
case 'V':
version_daemon(config.acct_type, PMACCTD_USAGE_HEADER);
exit(0);
break;
case 'a':
print_primitives(config.acct_type, PMACCTD_USAGE_HEADER);
exit(0);
break;
default:
usage_daemon(argv[0]);
exit(1);
break;
}
}
⇧ 上記で「変数」に格納されると。
で、「変数」に格納された「設定ファイル(/etc/pmacct/pmacctd.conf)」は、
/* post-checks and resolving conflicts */
if (strlen(config_file)) {
if (parse_configuration_file(config_file) != SUCCESS)
exit(1);
}
else {
if (parse_configuration_file(NULL) != SUCCESS)
exit(1);
}
⇧ 上記で処理されるのだが、
/* parse_configuration_file() reads configuration file
and stores its content in an array; then creates
plugin structures and parses supported config keys */
int parse_configuration_file(char *filename)
{
struct stat st;
char localbuf[10240];
char cmdline [] = "cmdline";
FILE *file;
int num = 0, cmdlineflag = FALSE, rows_cmdline = rows, idx, ret;
rows = 0;
/* NULL filename means we don't have a configuration file; 1st stage: read from
file and store lines into a first char* array; merge commandline options, if
required, placing them at the tail - in order to override directives placed
in the configuration file */
if (filename) {
ret = stat(filename, &st);
if (ret < 0) {
Log(LOG_ERR, "ERROR: [%s] file not found.\n", filename);
return ERR;
}
else {
if (!S_ISREG(st.st_mode)) {
Log(LOG_ERR, "ERROR: [%s] path is not a regular file.\n", filename);
return ERR;
}
}
if ((file = fopen(filename, "r"))) {
while (!feof(file)) {
if (rows == LARGEBUFLEN) {
Log(LOG_ERR, "ERROR: [%s] maximum number of %d lines reached.\n", filename, LARGEBUFLEN);
break;
}
memset(localbuf, 0, sizeof(localbuf));
if (fgets(localbuf, sizeof(localbuf), file) == NULL) break;
else {
localbuf[sizeof(localbuf)-1] = '\0';
cfg[rows] = malloc(strlen(localbuf)+2);
if (!cfg[rows]) {
Log(LOG_ERR, "ERROR: [%s] malloc() failed (parse_configuration_file). Exiting.\n", filename);
exit(1);
}
strcpy(cfg[rows], localbuf);
cfg[rows][strlen(localbuf)+1] = '\0';
rows++;
}
}
}
fclose(file);
}
else {
filename = cmdline;
cmdlineflag = TRUE;
}
if (rows_cmdline) {
for (idx = 0; idx < rows_cmdline && (rows+idx) < LARGEBUFLEN; idx++) {
cfg[rows+idx] = cfg_cmdline[idx];
}
rows += idx;
}
/* 2nd stage: sanitize lines */
sanitize_cfg(rows, filename);
/* 3rd stage: plugin structures creation; we discard
plugin names if 'pmacctd' has been invoked commandline;
if any plugin has been activated we default to a single
'imt' plugin */
if (!cmdlineflag) parse_core_process_name(filename, rows, FALSE);
else parse_core_process_name(filename, rows, TRUE);
if (!cmdlineflag) num = parse_plugin_names(filename, rows, FALSE);
else num = parse_plugin_names(filename, rows, TRUE);
if (!num && config.acct_type < ACCT_FWDPLANE_MAX) {
Log(LOG_WARNING, "WARN: [%s] No plugin has been activated; defaulting to in-memory table.\n", filename);
num = create_plugin(filename, "default_memory", "memory");
}
if (debug) {
struct plugins_list_entry *list = plugins_list;
while (list) {
Log(LOG_DEBUG, "DEBUG: [%s] plugin name/type: '%s'/'%s'.\n", filename, list->name, list->type.string);
list = list->next;
}
}
/* 4th stage: setting some default value */
set_default_values();
/* 5th stage: parsing keys and building configurations */
evaluate_configuration(filename, rows);
return SUCCESS;
}
⇧ 上記の「pmacct/src/cfg.c」の「メソッド」に処理が委譲されている。
ので、「PostgreSQL」の「接続情報」は、「設定ファイル(/etc/pmacct/pmacctd.conf)」から参照できる状態にしておく必要がありますと...
ちなみに、
⇧ 上記にあるように、「設定ファイル」の内容は実際に、「Dockerイメージ」から「Dockerコンテナ」を作成・起動して、「Dockerコンテナ」にログインして確認するしか無さそうなのよね...
「pmacct」の「Configuration files」の設計思想について、「ChatGPT」氏に質問してみたところ、以下のような回答が返ってきた。
■ この記述の意味
All daemons expect a pmacct configuration file in
/etc/pmacct/<name_of_daemon>.conf
これはつまり:
/etc/pmacct/nfacctd.conf/etc/pmacct/sfacctd.conf/etc/pmacct/pmacctd.conf
のように daemon名で1対1対応する固定パス設計です。
■ 重要なポイント(設計的意味)
① include機構ではない
この仕様はこういう意味です:
「設定は1ファイル完結が前提」
つまり:
- ❌ 分割読み込み(include)は基本想定なし
- ❌ PostgreSQL設定だけ別ファイルロードも非対応
- ⭕ daemon単位で完全に独立
■ なぜこの設計なのか
pmacctはかなり古典的なUNIX daemon設計なので:
✅ 理由① シンプルさ
- 1 daemon = 1 config file
✅ 理由② cfg.cが単純
実装は基本これだけ:
fopen(config_file)while (fgets)
✅ 理由③ runtime reload前提
複雑なinclude依存関係を避けている
■ ここから本質(あなたの元質問への結論)
あなたの疑問:
PostgreSQL接続情報だけ別ファイルにできる?
このドキュメントを踏まえると結論は明確で:
- ❌ pmacctの設計思想的に不可
理由:
config file = daemon単位の完全構成
- ⭕ ただし「運用で分離」は可能
ただし実務的には:
方法1(現実的)
- common pgsql.conf をコピー or マージ
方法2(Docker)
- 同一ボリュームに共通config配置
■ まとめ
この仕様の本質
- pmacctは「単一configファイルモデル」
- daemon名でファイルが固定
- includeや分割ロードは設計外
- PostgreSQL設定もその中に含める
■ 結論(重要)
あなたの問いに対して一言でいうと:
PostgreSQL接続情報だけ別ファイルにする仕組みは「設計上存在しない」
⇧ なるへそ…
1ファイルに全ての設定を集約しないといけないのは辛いっすな...
毎度モヤモヤ感が半端ない…
今回はこのへんで。












