Skip to content

Commit

Permalink
Merge pull request #2395 from pqarmitage/updates
Browse files Browse the repository at this point in the history
Add use_symlink_paths and fix strict_mode skip_check_adv_addr global params.
  • Loading branch information
pqarmitage committed Mar 19, 2024
2 parents 45f6beb + ebf37b9 commit 9d4579b
Show file tree
Hide file tree
Showing 13 changed files with 351 additions and 132 deletions.
66 changes: 59 additions & 7 deletions doc/KEEPALIVED-MIB.txt
Expand Up @@ -22,12 +22,14 @@ IMPORTS
FROM SNMPv2-TC;

keepalived MODULE-IDENTITY
LAST-UPDATED "202212090001Z"
LAST-UPDATED "202403180001Z"
ORGANIZATION "Keepalived"
CONTACT-INFO "http://www.keepalived.org"
DESCRIPTION
"This MIB describes objects used by keepalived, both
for VRRP and health checker."
REVISION "202403180001Z"
DESCRIPTION "add separate path and argv[0] for scripts"
REVISION "202212090001Z"
DESCRIPTION "add VRRPv3 checksum as VRRPv2"
REVISION "202109230001Z"
Expand Down Expand Up @@ -2587,7 +2589,8 @@ VrrpScriptEntry ::= SEQUENCE {
vrrpScriptResult INTEGER,
vrrpScriptRise Unsigned32,
vrrpScriptFall Unsigned32,
vrrpScriptWgtRev Integer32
vrrpScriptWgtRev Integer32,
vrrpScriptPath DisplayString
}

vrrpScriptIndex OBJECT-TYPE
Expand Down Expand Up @@ -2668,6 +2671,14 @@ vrrpScriptWgtRev OBJECT-TYPE
"Weight reverse for the script if successful."
::= { vrrpScriptEntry 9 }

vrrpScriptPath OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Path to file to be executed when running the script."
::= { vrrpScriptEntry 10 }

-- VRRP files
-- see vrrp_track.h

Expand Down Expand Up @@ -3413,7 +3424,9 @@ VirtualServerEntry ::= SEQUENCE {
virtualServerTunnelType INTEGER,
virtualServerTunnelPort InetPortNumber,
virtualServerTunnelCsum INTEGER,
virtualServerName DisplayString
virtualServerName DisplayString,
virtualServerQuorumUpPath DisplayString,
virtualServerQuorumDownPath DisplayString
}

virtualServerIndex OBJECT-TYPE
Expand Down Expand Up @@ -4055,6 +4068,22 @@ virtualServerName OBJECT-TYPE
"Optional SNMP name of this virtual server."
::= { virtualServerEntry 71 }

virtualServerQuorumUpPath OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Path to command to execute when the quorum is met."
::= { virtualServerEntry 72 }

virtualServerQuorumDownPath OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Path to command to execute when the quorum is not met."
::= { virtualServerEntry 73 }


-- real servers

Expand Down Expand Up @@ -4130,7 +4159,9 @@ RealServerEntry ::= SEQUENCE {
realServerTunnelType INTEGER,
realServerTunnelPort InetPortNumber,
realServerTunnelCsum INTEGER,
realServerName DisplayString
realServerName DisplayString,
realServerNotifyUpPath DisplayString,
realServerNotifyDownPath DisplayString
}

realServerIndex OBJECT-TYPE
Expand Down Expand Up @@ -4619,6 +4650,22 @@ realServerName OBJECT-TYPE
"Optional SNMP name of this real server."
::= { realServerEntry 55 }

realServerNotifyUpPath OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Path to command to execute when this server becomes alive."
::= { realServerEntry 56 }

realServerNotifyDownPath OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Path to command to execute when this server becomes dead."
::= { realServerEntry 57 }

lvsSyncDaemon OBJECT IDENTIFIER ::= { check 6 }

lvsSyncDaemonEnabled OBJECT-TYPE
Expand Down Expand Up @@ -5075,7 +5122,8 @@ vrrpScriptGroup OBJECT-GROUP
vrrpScriptResult,
vrrpScriptRise,
vrrpScriptFall,
vrrpScriptWgtRev
vrrpScriptWgtRev,
vrrpScriptPath
}
STATUS current
DESCRIPTION
Expand Down Expand Up @@ -5249,7 +5297,9 @@ virtualServerGroup OBJECT-GROUP
virtualServerTunnelType,
virtualServerTunnelPort,
virtualServerTunnelCsum,
virtualServerName
virtualServerName,
virtualServerQuorumUpPath,
virtualServerQuorumDownPath
}
STATUS current
DESCRIPTION
Expand Down Expand Up @@ -5311,7 +5361,9 @@ realServerGroup OBJECT-GROUP
realServerTunnelType,
realServerTunnelPort,
realServerTunnelCsum,
realServerName
realServerName,
realServerNotifyUpPath,
realServerNotifyDownPath
}
STATUS current
DESCRIPTION
Expand Down
8 changes: 6 additions & 2 deletions doc/man/man5/keepalived.conf.5.in
Expand Up @@ -246,6 +246,10 @@ possibly following any cleanup actions needed.
\fBchecker_process_name\fR NAME
\fBbfd_process_name\fR NAME

# keepalived by default resolves script path names to remove symlinks.
# To keep symlinks in pathnames, specify use_syslink_paths.
\fBuse_symlink_paths \fR[<BOOL>]

# The startup and shutdown scripts are run once, when keepalived starts
# before any child processes are run, and when keepalived stops after
# all child processes have terminated, respectively.
Expand Down Expand Up @@ -2073,12 +2077,12 @@ The syntax for vrrp_instance is :

# See description of global vrrp_skip_check_adv_addr, which
# sets the default value. Defaults to vrrp_skip_check_adv_addr
\fBskip_check_adv_addr \fR[on|off|true|false|yes|no]
\fBskip_check_adv_addr \fR[<BOOL>]

# See description of global vrrp_strict
# If strict_mode is not specified, it takes the value of vrrp_strict.
# If strict_mode without a parameter is specified, it defaults to on.
\fBstrict_mode \fR[on|off|true|false|yes|no]
\fBstrict_mode \fR[<BOOL>]

# Debug level, not implemented yet.
# LEVEL is a number in the range 0 to 4
Expand Down
23 changes: 15 additions & 8 deletions keepalived/check/check_data.c
Expand Up @@ -484,6 +484,17 @@ format_decimal(unsigned long val, int dp)
return buf;
}

static void
dump_notify_vs_rs_script(FILE *fp, const notify_script_t *script, const char *type, const char *state)
{
if (script->path)
conf_write(fp, " %s %s notify script = %s, params = %s, uid:gid %u:%u", type, state,
script->path, cmd_str(script), script->uid, script->gid);
else
conf_write(fp, " %s %s notify script = %s, uid:gid %u:%u", type, state,
cmd_str(script), script->uid, script->gid);
}

static void
dump_rs(FILE *fp, const real_server_t *rs)
{
Expand Down Expand Up @@ -511,11 +522,9 @@ dump_rs(FILE *fp, const real_server_t *rs)
conf_write(fp, " Inhibit on failure is %s", rs->inhibit ? "ON" : "OFF");

if (rs->notify_up)
conf_write(fp, " RS up notify script = %s, uid:gid %u:%u",
cmd_str(rs->notify_up), rs->notify_up->uid, rs->notify_up->gid);
dump_notify_vs_rs_script(fp, rs->notify_up, "RS", "up");
if (rs->notify_down)
conf_write(fp, " RS down notify script = %s, uid:gid %u:%u",
cmd_str(rs->notify_down), rs->notify_down->uid, rs->notify_down->gid);
dump_notify_vs_rs_script(fp, rs->notify_down, "RS", "down");
if (rs->virtualhost)
conf_write(fp, " VirtualHost = '%s'", rs->virtualhost);
#ifdef _WITH_SNMP_CHECKER_
Expand Down Expand Up @@ -730,11 +739,9 @@ dump_vs(FILE *fp, const virtual_server_t *vs)
conf_write(fp, " Inhibit on failure is %s", vs->inhibit ? "ON" : "OFF");
conf_write(fp, " quorum = %u, hysteresis = %u", vs->quorum, vs->hysteresis);
if (vs->notify_quorum_up)
conf_write(fp, " Quorum up notify script = %s, uid:gid %u:%u",
cmd_str(vs->notify_quorum_up), vs->notify_quorum_up->uid, vs->notify_quorum_up->gid);
dump_notify_vs_rs_script(fp, vs->notify_quorum_up, "Quorum", "up");
if (vs->notify_quorum_down)
conf_write(fp, " Quorum down notify script = %s, uid:gid %u:%u",
cmd_str(vs->notify_quorum_down), vs->notify_quorum_down->uid, vs->notify_quorum_down->gid);
dump_notify_vs_rs_script(fp, vs->notify_quorum_down, "Quorum", "down");
if (vs->ha_suspend)
conf_write(fp, " Using HA suspend");
conf_write(fp, " Using smtp notification = %s", vs->smtp_alert ? "yes" : "no");
Expand Down
5 changes: 3 additions & 2 deletions keepalived/check/check_misc.c
Expand Up @@ -57,8 +57,7 @@ free_misc_check(checker_t *checker)
{
misc_checker_t *misck_checker = checker->data;

if (misck_checker->script.args)
FREE(misck_checker->script.args);
notify_free_script(&misck_checker->script);
FREE(misck_checker);
FREE(checker);
}
Expand All @@ -70,6 +69,8 @@ dump_misc_check(FILE *fp, const checker_t *checker)
char time_str[26];

conf_write(fp, " Keepalive method = MISC_CHECK");
if (misck_checker->script.path)
conf_write(fp, " path = %s", misck_checker->script.path);
conf_write(fp, " script = %s", cmd_str(&misck_checker->script));
conf_write(fp, " timeout = %lu", misck_checker->timeout/TIMER_HZ);
conf_write(fp, " dynamic = %s", misck_checker->dynamic ? "YES" : "NO");
Expand Down
34 changes: 34 additions & 0 deletions keepalived/check/check_snmp.c
Expand Up @@ -125,6 +125,8 @@ enum check_snmp_virtualserver_magic {
#endif
#endif
CHECK_SNMP_VSNAME,
CHECK_SNMP_VSQUORUMUPPATH,
CHECK_SNMP_VSQUORUMDOWNPATH,
};

enum check_snmp_realserver_magic {
Expand Down Expand Up @@ -188,6 +190,8 @@ enum check_snmp_realserver_magic {
#endif
#endif
CHECK_SNMP_RSNAME,
CHECK_SNMP_RSNOTIFYUPPATH,
CHECK_SNMP_RSNOTIFYDOWNPATH,
};

#define STATE_VSGM_FWMARK 1
Expand Down Expand Up @@ -756,6 +760,16 @@ check_snmp_virtualserver(struct variable *vp, oid *name, size_t *length,
*var_len = strlen(v->snmp_name);
ret.cp = v->snmp_name;
return ret.p;
case CHECK_SNMP_VSQUORUMUPPATH:
if (!v->notify_quorum_up) break;
ret.cp = v->notify_quorum_up->path ? v->notify_quorum_up->path : v->notify_quorum_up->args[0] ;
*var_len = strlen(ret.cp);
return ret.p;
case CHECK_SNMP_VSQUORUMDOWNPATH:
if (!v->notify_quorum_down) break;
ret.cp = v->notify_quorum_down->path ? v->notify_quorum_down->path : v->notify_quorum_down->args[0];
*var_len = strlen(ret.cp);
return ret.p;
default:
return NULL;
}
Expand Down Expand Up @@ -1178,6 +1192,18 @@ check_snmp_realserver(struct variable *vp, oid *name, size_t *length,
*var_len = strlen(be->snmp_name);
ret.cp = be->snmp_name;
return ret.p;
case CHECK_SNMP_RSNOTIFYUPPATH:
if (type == STATE_RS_SORRY) break;
if (!be->notify_up) break;
ret.cp = be->notify_up->path ? be->notify_up->path : be->notify_up->args[0];
*var_len = strlen(ret.cp);
return ret.p;
case CHECK_SNMP_RSNOTIFYDOWNPATH:
if (type == STATE_RS_SORRY) break;
if (!be->notify_down) break;
ret.cp = be->notify_down->path ? be->notify_down->path : be->notify_down->args[0];
*var_len = strlen(ret.cp);
return ret.p;
default:
return NULL;
}
Expand Down Expand Up @@ -1456,6 +1482,10 @@ static struct variable8 check_vars[] = {
#endif
{CHECK_SNMP_VSNAME, ASN_OCTET_STR, RONLY,
check_snmp_virtualserver, 3, {3, 1, 71}},
{CHECK_SNMP_VSQUORUMUPPATH, ASN_OCTET_STR, RONLY,
check_snmp_virtualserver, 3, {3, 1, 72}},
{CHECK_SNMP_VSQUORUMDOWNPATH, ASN_OCTET_STR, RONLY,
check_snmp_virtualserver, 3, {3, 1, 73}},

/* realServerTable */
{CHECK_SNMP_RSTYPE, ASN_INTEGER, RONLY,
Expand Down Expand Up @@ -1572,6 +1602,10 @@ static struct variable8 check_vars[] = {
#endif
{CHECK_SNMP_RSNAME, ASN_OCTET_STR, RONLY,
check_snmp_realserver, 3, {4, 1, 55}},
{CHECK_SNMP_RSNOTIFYUPPATH, ASN_OCTET_STR, RONLY,
check_snmp_realserver, 3, {4, 1, 56}},
{CHECK_SNMP_RSNOTIFYDOWNPATH, ASN_OCTET_STR, RONLY,
check_snmp_realserver, 3, {4, 1, 57}},

#ifdef _WITH_VRRP_
/* LVS sync daemon configuration */
Expand Down

0 comments on commit 9d4579b

Please sign in to comment.