-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #897 from ywc689/new-tools
new-tools: dpvs-agent & healthcheck
- Loading branch information
Showing
292 changed files
with
38,610 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# configs | ||
export CONFIG_DPVS_MAX_SOCKET=2 | ||
export CONFIG_DPVS_MAX_LCORE=64 | ||
|
||
## modules | ||
export CONFIG_DPVS_AGENT=n | ||
export CONFIG_IXGEB_PMD=y | ||
export CONFIG_DPVS_LOG=y | ||
export CONFIG_PDUMP=y | ||
export CONFIG_ICMP_REDIRECT_CORE=n | ||
|
||
# debugging and logging | ||
export CONFIG_DEBUG=n | ||
export CONFIG_DPVS_NEIGH_DEBUG=n | ||
export CONFIG_RECORD_BIG_LOOP=n | ||
export CONFIG_DPVS_SAPOOL_DEBUG=n | ||
export CONFIG_DPVS_IPVS_DEBUG=n | ||
export CONFIG_DPVS_SERVICE_DEBUG=n | ||
export CONFIG_SYNPROXY_DEBUG=n | ||
export CONFIG_TIMER_MEASURE=n | ||
export CONFIG_TIMER_DEBUG=n | ||
export CONFIG_DPVS_CFG_PARSER_DEBUG=n | ||
export CONFIG_NETIF_BONDING_DEBUG=n | ||
export CONFIG_TC_DEBUG=n | ||
export CONFIG_DPVS_IPVS_STATS_DEBUG=n | ||
export CONFIG_DPVS_IP_HEADER_DEBUG=n | ||
export CONFIG_DPVS_MBUF_DEBUG=n | ||
export CONFIG_DPVS_IPSET_DEBUG=n | ||
export CONFIG_NDISC_DEBUG=n | ||
export CONFIG_MSG_DEBUG=n | ||
export CONFIG_DPVS_MP_DEBUG=n | ||
export CONFIG_DPVS_NETIF_DEBUG=n | ||
export CONFIG_DPVS_ICMP_DEBUG=n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#!/bin/env bash | ||
|
||
# Set target directory for cleaning | ||
TARGET_DIR="/var/log/healthcheck" | ||
|
||
# Set log file name pattern | ||
LOG_FILENAME_PATTERN="*\.log\.*" | ||
|
||
# Set the maximum usage percentage and the target usage percentage | ||
MAX_USAGE=80 | ||
TARGET_USAGE=40 | ||
|
||
# Set the minimum number of log files to keep | ||
MIN_FILES=12 | ||
|
||
# Set the maximum number of files to delete in one run | ||
MAX_DELETE=10000 | ||
|
||
OPTS=`getopt -o d:p:u:l:K:D:h --long \ | ||
log-directory:,filename-pattern:,disk-usage-high:,\ | ||
disk-usage-low:,min-files-kept:,max-deletions:,help,\ | ||
-n "$0" -- "$@"` | ||
eval set -- "$OPTS" | ||
while true | ||
do | ||
case "$1" in | ||
-d|--log-directory) | ||
TARGET_DIR="$2" | ||
shift 2 | ||
;; | ||
-p|--filename-pattern) | ||
LOG_FILENAME_PATTERN="$2" | ||
shift 2 | ||
;; | ||
-u|--disk-usage-high) | ||
MAX_USAGE="$2" | ||
shift 2 | ||
;; | ||
-l|--disk-usage-low) | ||
TARGET_USAGE="$2" | ||
shift 2 | ||
;; | ||
-K|--min-files-kept) | ||
MIN_FILES="$2" | ||
shift 2 | ||
;; | ||
-D|--max-deletions) | ||
MAX_DELETE="$2" | ||
shift 2 | ||
;; | ||
-h|--help) | ||
echo "[usage] $0 [ OPTS ]" | ||
echo "OPTS:" | ||
echo " -d|--log-directory DIRECTORY" | ||
echo " -p|--filename-pattern REGEXPR" | ||
echo " -u|--disk-usage-high 0-100" | ||
echo " -l|--disk-usage-low 0-100" | ||
echo " -K|--min-files-kept NUM" | ||
echo " -D|--max-deletions NUM" | ||
echo " -h|--help" | ||
exit 0 | ||
;; | ||
--) | ||
shift | ||
break | ||
;; | ||
*) | ||
echo "Param Error!" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
NotRecognized=$(for arg do printf "$arg " ; done) | ||
[ ! -z "$NotRecognized" ] && echo "Unrecognized Opts: ${NotRecognized}" && exit 1 | ||
|
||
echo "CONFIGS:" | ||
echo " log-directory: ${TARGET_DIR}" | ||
echo " filename-pattern: ${LOG_FILENAME_PATTERN}" | ||
echo " disk-usage-high: ${MAX_USAGE}" | ||
echo " disk-usage-low: ${TARGET_USAGE}" | ||
echo " min-files-kept: ${MIN_FILES}" | ||
echo " max-deletions: ${MAX_DELETE}" | ||
|
||
[ ! -d ${TARGET_DIR} ] && echo "invalid --log-directory \"${TARGET_DIR}\", not found!" && exit 1 | ||
echo ${MAX_USAGE} | egrep ^[0-9]+$ >/dev/null; [ $? -ne 0 ] && echo "invalid --disk-usage-high" && exit 1 | ||
echo ${TARGET_USAGE} | egrep ^[0-9]+$ >/dev/null; [ $? -ne 0 ] && echo "invalid --disk-usage-low" && exit 1 | ||
echo ${MIN_FILES} | egrep ^[0-9]+$ >/dev/null; [ $? -ne 0 ] && echo "invalid --min-files-kept" && exit 1 | ||
echo ${MAX_DELETE} | egrep ^[0-9]+$ >/dev/null; [ $? -ne 0 ] && echo "invalid --max-deletions" && exit 1 | ||
res=$(echo "${MAX_USAGE} < 100" | bc); [ "$res" -ne 1 ] && echo "--disk-usage-high must less than 100" && exit 1 | ||
res=$(echo "${MAX_USAGE} > ${TARGET_USAGE}" | bc); [ "$res" -ne 1 ] && echo "--disk-usage-high must greater than --disk-usage-low" && exit 1 | ||
|
||
# Get the current disk usage | ||
CURRENT_USAGE=$(df -P ${TARGET_DIR} | awk 'NR==2 {printf "%d", $5}') | ||
|
||
# Initialize a counter for deleted files | ||
DELETED_FILES=0 | ||
|
||
# Start the cleaning process if the disk usage is higher than the defined MAX_USAGE | ||
if [ "${CURRENT_USAGE}" -gt "${MAX_USAGE}" ]; then | ||
echo "Disk usage is ${CURRENT_USAGE}%, starting cleaning process." | ||
|
||
# Find and delete logs until disk usage reaches TARGET_USAGE or MAX_DELETE files are deleted | ||
while [ "${CURRENT_USAGE}" -gt "${TARGET_USAGE}" ] && [ "${DELETED_FILES}" -lt "${MAX_DELETE}" ]; do | ||
# Check the number of log files | ||
NUM_FILES=$(find ${TARGET_DIR} -type f -name ${LOG_FILENAME_PATTERN} | wc -l) | ||
|
||
# Ensure that at least MIN_FILES log files remain | ||
if [ "${NUM_FILES}" -le "${MIN_FILES}" ]; then | ||
echo "Reached minimum number of log files (${MIN_FILES}), aborting." | ||
exit 1 | ||
fi | ||
|
||
# Find the oldest log file | ||
OLDEST_LOG=$(find ${TARGET_DIR} -type f -name ${LOG_FILENAME_PATTERN} -printf '%T+ %p\n' | sort | head -n1 | cut -d' ' -f2) | ||
|
||
echo "Deleting ${OLDEST_LOG}..." | ||
rm -f "${OLDEST_LOG}" | ||
DELETED_FILES=$((DELETED_FILES+1)) | ||
|
||
# Update current disk usage | ||
CURRENT_USAGE=$(df -P ${TARGET_DIR} | awk 'NR==2 {printf "%d", $5}') | ||
done | ||
|
||
if [ "${DELETED_FILES}" -eq "${MAX_DELETE}" ]; then | ||
echo "Reached the maximum number of deletions (${MAX_DELETE}), aborting." | ||
else | ||
echo "Cleaning process completed. Disk usage is now ${CURRENT_USAGE}%." | ||
fi | ||
|
||
else | ||
echo "Disk usage is ${CURRENT_USAGE}%, no cleaning needed." | ||
fi | ||
|
||
echo "Remaining Files in ${TARGET_DIR} (only show 30 entries):" | ||
ls -lh ${TARGET_DIR} | head -n 30 | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
#!/bin/sh | ||
# program: dpvs | ||
# Apr 20, 2023 | ||
# Jul 13, 2023 | ||
# | ||
# Features | ||
# - Dpvs: Multiple instance deployment support. | ||
# - Dpvs: IPC improvements between keepalived/ipvsadm and dpvs by combining data structs. | ||
# - Add new tools: dpvs-agent and healthcheck. | ||
# | ||
# Bugfixes | ||
# - Dpvs: Fix memory problem when setting MATCH service. | ||
# - Ipvsadm: Fix service list problem when dpvs lcore ids are not continuous. | ||
# - Ipvsadm: Fix the problem that service/dest/laddr cannot be listed per-lcore. | ||
# - Ipvsadm: Support version info. | ||
# - Fix several spelling mistakes. | ||
# - Fix compiling errors on RHEL 9, Ubuntu 22.04 and microsoft standard WSL2. | ||
# - Keepalived: Fix service deletion by mistake problem caused by uninitialized local variable. | ||
# - Dpvs: Do not increase service num unless it's hashed sucessfully. | ||
# - Dpvs: Fix sa_entry leak when flushing snat connections. | ||
# - Keepalived: Fix ipvs allow/deny list config problem caused by incorrect parameters. | ||
# - Dpvs: Fix dead lock problem of eal-mem show and rte_free. | ||
# - Dpvs: Fix crash problem caused by msg_destroy when msg->refcnt==0. | ||
# - Dpvs: Fix eal-mem module uninitialized problem. | ||
# - Dpvs: Fix memory leak problem in ipvs allow list. | ||
# - Dpvs: Improve config of adding/removing multicast ether addresses. | ||
# - Dpvs: Fix synproxy config problems. | ||
# - Keepalived: Fix session disturbance problem when vs/rs updated and reloaded. | ||
# | ||
|
||
export VERSION=1.9 | ||
export RELEASE=4 | ||
export RELEASE=5 | ||
|
||
echo $VERSION-$RELEASE |
Oops, something went wrong.