From 9029531894318f67bc8e5c410960113c75894067 Mon Sep 17 00:00:00 2001 From: KZ Date: Wed, 19 Apr 2023 22:14:22 -0400 Subject: [PATCH] Update plugin from 2023.02.19 to 2023.04.20 to fix a regression introduced in SNMP 5.9.3 causing additional log output --- packages/unraid-snmp-2023.04.20-x86_64-1.txz | Bin 0 -> 12100 bytes snmp.plg | 17 +++++++--- source/install/doinst.sh | 32 ++++++------------ .../usr/local/emhttp/plugins/snmp/cpu_mhz.sh | 2 +- .../emhttp/plugins/snmp/disk_free_space.sh | 4 +-- .../local/emhttp/plugins/snmp/disk_temps.sh | 10 +++--- .../emhttp/plugins/snmp/share_free_space.sh | 2 +- .../usr/local/emhttp/plugins/snmp/snmp.page | 2 +- 8 files changed, 34 insertions(+), 35 deletions(-) create mode 100644 packages/unraid-snmp-2023.04.20-x86_64-1.txz diff --git a/packages/unraid-snmp-2023.04.20-x86_64-1.txz b/packages/unraid-snmp-2023.04.20-x86_64-1.txz new file mode 100644 index 0000000000000000000000000000000000000000..45d05d237ff04f8e697c85503cd0dc896b53fcff GIT binary patch literal 12100 zcmV-KFT2qFH+ooF000E$*0e?hz=2+XkOLtB8~^|S0000o{9pRu$Nw(*T>uvgyc~T2 zmB1ZJK6w?w%qF8=6)owlAVZj?D!(PFv_t~+eir5#(bv6z^^Of)JUCa2SCWcY!I3N% zX~wn^AQ5byanG1r4>>n{ImttRLI${?OhA+OTfo+3XiZh+`l<4z@@9%H{?K#Ml#iv0 zjpWtBYd?D;+TBmCZlp134|-QGuTB(ptH8bM=VTyDtk+$mcK)!&^PLlAcv5m&X$ybS z1{^VMcH-h#`$RSNV)R9f6PrGk>g>|bZJ#ho7xRBNo|SkoKpxgiaUZa-W?JVGi+ej{ zL$=f`kgWg{Fgmkmw}P>rFtZjfq1STA`4HR^gSij6 zW&ULL%0r!9hrEw#mA@a!f?$k#>gG@N+=L*UoO?SE66q@5m<>wB^>DZh0E%rLgqimo zM;x%|@b1RB&4pcLx3I;+m(;A}m5 zw~l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URdfE_IR8rh4^*bX=p)GLp@wD-$}{-SQonA$Gv; - + @@ -26,7 +26,7 @@ - + ]> ## SNMP +### 2023.04.20 +- Fixed a regression in unraid-snmp that prevented the `/etc/rc.d/rc.snmpd` file from being updated correctly. + - This regression caused extra logs in `/var/log/snmpd.log` + - This regression is caused by the update from `net-snmp-5.9` to `net-snmp-5.9.3` + - NOTE: `ps -ef | grep snmp` can be used to confirm the flags were set correctly. They should be `/usr/sbin/snmpd -A -p /var/run/snmpd -LF 0-5 /var/log/snmpd.log -c /etc/snmp/snmpd.conf` + - Thanks @irishjd and @Uncore for the help! + ### 2023.02.19 - Adjusted CPU MHz script to more succinctly retrieve data - Adjusted plugin PLG install script to read the `rocommunity` string from the `/etc/snmp/snmpd.conf` SNMP daemon config file when testing install success/failure. Thanks @cjhammel for the suggestion! @@ -189,7 +196,7 @@ # NOTE: Modified bash for embedding in XML with ampersand-semicolon placeholders # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ -# Exit script early if we encounter an error +# Exit script early if an error is encountered set -e echo "" @@ -201,6 +208,7 @@ echo "" # Get the Read-Only Community string from the config file community=$(grep "rocommunity" --max-count 1 "/etc/snmp/snmpd.conf" | awk '{print $2}') # Clean newlines, carriage returns, spaces, and tabs +# https://stackoverflow.com/questions/19345872/how-to-remove-a-newline-from-a-string-in-bash community=${community//[$'\t\r\n ']} # If the Community cannot be read, default to "public" @@ -255,7 +263,7 @@ exit 0 # NOTE: Modified bash for embedding in XML with ampersand-semicolon placeholders # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ -# Exit script early if we encounter an error +# Exit script early if an error is encountered set -e echo "" @@ -283,6 +291,7 @@ dirs_files_to_remove=" /etc/snmp/ /var/lib/net-snmp/ /var/log/snmpd.log +/etc/default/snmpd " echo "Starting TXZ package removal" diff --git a/source/install/doinst.sh b/source/install/doinst.sh index 42d31bc..97aaac9 100755 --- a/source/install/doinst.sh +++ b/source/install/doinst.sh @@ -52,34 +52,24 @@ if [[ -f /etc/rc.d/rc.snmpd ]]; then fi - # Define the additional flags we want to add into the SNMP daemon startup - # Spaces at end of string to separate from other flags + echo "Writing extra SNMPD_OPTIONS into /etc/default/snmpd to configure logging" + # Define the additional flags to be added into the SNMP daemon startup # 1=a=alert, 2=c=crit, 3=e=err, 4=w=warn, 5=n=notice, 6=i=info, 7=d=debug - new_flags="-LF 0-5 /var/log/snmpd.log " + # Write these flags into /etc/default/snmpd. As of SNMP 5.9.3, this file + # is sourced and merged with the default flags inside /etc/rc.d/rc.snmpd upon startup. + # -A appends rather than truncates the log file + # -p /var/run/snmpd creates a PID file, used later on to determine if it's running + # https://tldp.org/LDP/abs/html/internal.html#SOURCEREF + # https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash + echo 'SNMPD_OPTIONS="-A -p /var/run/snmpd -LF 0-5 /var/log/snmpd.log"' > /etc/default/snmpd - # Get existing OPTIONS from file, keeping only what's in double quotes - # https://stackoverflow.com/questions/35636323/extracting-a-string-between-two-quotes-in-bash - options=$(grep "OPTIONS=" /etc/rc.d/rc.snmpd | cut -d'"' -f 2) - # Check that new flags haven't already been added - if [[ $options != *"-L"* ]]; then - # Concatenate the new flags with the old - options=$new_flags$options - echo "Editing SNMP startup options in rc.snmpd to be [$options]" - # Replace the line beginning with OPTIONS= with a custom set - # Use a custom delimiter | to avoid collisions of sed and variable use of / - # Escape the start quote and end quote when we recreate the line - # https://stackoverflow.com/questions/9366816/sed-fails-with-unknown-option-to-s-error - sed --in-place=.bak --expression "s|^OPTIONS=.*|OPTIONS=\"$options\"|" /etc/rc.d/rc.snmpd - else - echo "SNMP logging flag already present in rc.snmpd, skipping modification" - fi - - echo "Restart SNMP daemon now that we've adjusted how rc.snmpd starts it" + echo "Start SNMP daemon back up now that snmpd.conf and /etc/default/snmpd modifications are done" # Make sure error logging is going to STDOUT so it prints in install logs bash /etc/rc.d/rc.snmpd start 2>&1 # Wait for daemon startup to complete by watching for PID file # Send error output of "No such file or directory" to /dev/null + # NOTE: ps -ef | grep snmp can be used to confirm the flags were set correctly count=0 sleep 2 while [[ -z "$(cat /var/run/snmpd 2> /dev/null)" ]]; do diff --git a/source/usr/local/emhttp/plugins/snmp/cpu_mhz.sh b/source/usr/local/emhttp/plugins/snmp/cpu_mhz.sh index 503a8fe..cbfeb66 100755 --- a/source/usr/local/emhttp/plugins/snmp/cpu_mhz.sh +++ b/source/usr/local/emhttp/plugins/snmp/cpu_mhz.sh @@ -26,5 +26,5 @@ else fi fi -# Exit with an error, as we only get here if there was an issue +# Exit with an error, as this can only be reached in the event of an issue exit 1 \ No newline at end of file diff --git a/source/usr/local/emhttp/plugins/snmp/disk_free_space.sh b/source/usr/local/emhttp/plugins/snmp/disk_free_space.sh index ebc70fa..2169b51 100755 --- a/source/usr/local/emhttp/plugins/snmp/disk_free_space.sh +++ b/source/usr/local/emhttp/plugins/snmp/disk_free_space.sh @@ -6,10 +6,10 @@ # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ set -euo pipefail -# Run df with only the columns we want, mount point and available kibibytes +# Run df with only the desired columns, mount point and available kibibytes df_output=$(df --output=target --output=avail) -# Filter the output to only the lines we want, those with /boot or /mnt/disk* or /mnt/cache +# Filter the output to only the desired lines, those with /boot or /mnt/disk* or /mnt/cache # https://phoenixnap.com/kb/grep-multiple-strings filtered_df_lines=$(grep -e '/mnt/disk[0-9]' -e '/mnt/cache' -e '/boot' <<< "$df_output") diff --git a/source/usr/local/emhttp/plugins/snmp/disk_temps.sh b/source/usr/local/emhttp/plugins/snmp/disk_temps.sh index f74d537..3ae907c 100755 --- a/source/usr/local/emhttp/plugins/snmp/disk_temps.sh +++ b/source/usr/local/emhttp/plugins/snmp/disk_temps.sh @@ -28,7 +28,7 @@ mkdir -p "$working_dir" # Check if cache file has been modified in the last five minutes if [[ -n $(find $working_dir -name $cache_file_name -mmin -5) ]] then - # Output to the log file that we used cached values + # Output to the log file that cached values were used in place of fresh values echo "Valid cached values served at $(date)" >> "$cache_log_full_path" # Output the cached information cat "$cache_file_full_path" @@ -39,7 +39,7 @@ fi # Define the function which will poll the disks' state in another PID function update_cache_file { # Attempt to get lock file handle/descriptor 200. - # -n ensures we fail immediately if we can't immediately lock + # -n ensures an immediate exit/failure if a lock can't be immediately acquired if ! flock -n 200 then echo "PID $$ couldn't acquire lock on $cache_lock_full_path at $(date)" @@ -77,7 +77,7 @@ function update_cache_file { if [[ "${UNSAFETEMP:-}" -eq "1" ]] then echo "Disk temp retrieval may wake disks from STANDBY" - # Set the command-modifying var we'll use later to an empty string + # Set the command-modifying var to an empty string. It will be used later # NOTE: WD disks need to be spun up for attributes to show # NOTE: Disks may be forced out of STANDBY to report attributes standby_check="" @@ -86,7 +86,7 @@ function update_cache_file { standby_check="--nocheck standby" fi - # Remove the cache file before we start writing to it + # Remove the cache file before it gets written to rm -f "$cache_file_full_path" # Iterate through each model/address pair @@ -156,7 +156,7 @@ function update_cache_file { } # Call the function defined above. -# >$cache_log_full_path redirects all STDOUT to a file # 2>&1 redirects STDERR (2) into STDOUT (1) # 200>$filename I think executes the function under file handle 200 on the given filename diff --git a/source/usr/local/emhttp/plugins/snmp/share_free_space.sh b/source/usr/local/emhttp/plugins/snmp/share_free_space.sh index c755712..d1c554f 100755 --- a/source/usr/local/emhttp/plugins/snmp/share_free_space.sh +++ b/source/usr/local/emhttp/plugins/snmp/share_free_space.sh @@ -5,7 +5,7 @@ # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ set -euo pipefail -# Define the input file from which we will read Share name and free KB +# Define the input file from which Share name and free KB will be read shares_ini=/var/local/emhttp/shares.ini # Check that the file exists and is non-empty and exit otherwise diff --git a/source/usr/local/emhttp/plugins/snmp/snmp.page b/source/usr/local/emhttp/plugins/snmp/snmp.page index 3b37bdb..8663d1c 100644 --- a/source/usr/local/emhttp/plugins/snmp/snmp.page +++ b/source/usr/local/emhttp/plugins/snmp/snmp.page @@ -81,7 +81,7 @@ Custom snmpd.conf contents: - +