We have a LibreNMS with daily.sh script enabled for auto updates. We would like to receive Slack notifications every time it got updated or failed to update. We would like to generate syslog messages from daily.sh script to local syslog and based on these syslogs we can generate alerts and send them to Slack.
Here is a code that we would like to propose:
# Check if we need to revert (Must be in post pull so we can update it) if [[ "$old_version" != "$new_version" ]]; then check_dependencies # check php and python version and switch branches # Add timestamp and hostname to the status message timestamp=$(date +"%Y-%m-%dT%H:%M:%S.%N%z") hostname=$(hostname) status_message="$timestamp $hostname daily.sh: %LIBRENMS_UPGRADE_SUCCESS: LibreNMS Updated from $old_version to $new_version on $hostname" # Output status message to syslog and standard output logger -t "LibreNMS" "$status_message" status_run "$status_message" '' set_notifiable_result update 1 # only clear the error if update was a success fi
Please let us know if it works and we can submit PR.