monitoring-plugins/plugins/check_dig.d/config.h
Dennis fd42290d4a
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Spellcheck / codespell (push) Has been cancelled
Tests / Running unit and integrationt tests (push) Has been cancelled
Tests / Running rpm build test on almalinux:9 (push) Has been cancelled
Tests / Running rpm build test on fedora:latest (push) Has been cancelled
Tests / Running rpm build test on rockylinux:8 (push) Has been cancelled
Tests Debian:Testing and Fedora:Rawhide / Running unit and integrationt tests (push) Has been cancelled
Tests Debian:Testing and Fedora:Rawhide / Running rpm build test on fedora:rawhide (push) Has been cancelled
check_dig: add -E/--require-flags and -X/--forbid-flags (#2165)
* check_dig: Add feature to require or forbid dig DNS flags -E, -X.
Introduced helper functions for flag parsing.

 -E, --require-flags=LIST
    Comma-separated dig flags that must be present (e.g. 'aa,qr')
 -X, --forbid-flags=LIST
    Comma-separated dig flags that must NOT be present
2025-11-29 15:24:52 +01:00

48 lines
958 B
C

#pragma once
#include "../../config.h"
#include <stddef.h>
#define UNDEFINED 0
#define DEFAULT_PORT 53
#define DEFAULT_TRIES 2
typedef struct {
char **items;
size_t count;
} flag_list;
typedef struct {
char *query_address;
char *record_type;
char *expected_address;
char *dns_server;
char *query_transport;
int server_port;
char *dig_args;
int number_tries;
double warning_interval;
double critical_interval;
flag_list require_flags;
flag_list forbid_flags;
} check_dig_config;
check_dig_config check_dig_config_init() {
check_dig_config tmp = {
.query_address = NULL,
.record_type = "A",
.expected_address = NULL,
.dns_server = NULL,
.query_transport = "",
.server_port = DEFAULT_PORT,
.dig_args = "",
.number_tries = DEFAULT_TRIES,
.warning_interval = UNDEFINED,
.critical_interval = UNDEFINED,
.require_flags = {.count = 0, .items = NULL},
.forbid_flags = {.count = 0, .items = NULL},
};
return tmp;
}