diff --git a/files/netbox-reporter.sh b/files/netbox-reporter.sh index 883dc67..60e9495 100644 --- a/files/netbox-reporter.sh +++ b/files/netbox-reporter.sh @@ -23,6 +23,7 @@ NB_TOKEN="${NB_TOKEN:-}" # --- Optional performance knobs --- # NB_PREREAD=1 enables extra GETs to print pre-change values (more load on NetBox). NB_PREREAD="${NB_PREREAD:-0}" +USE_TAGS="${USE_TAGS:-yes}" # Device ID cache (per worker process) # Cache entries are considered fresh for 60 minutes. After that, they may be used up to an @@ -544,6 +545,9 @@ handle_payload() { ;; tag_add) # add a tag to the device using task_result as slug + if [[ "$USE_TAGS" != "yes" ]]; then + return 0 + fi if [[ -z "$task_result" ]]; then warn "tag_add: task_result (tag slug) is empty; skipping." return 0 @@ -555,15 +559,19 @@ handle_payload() { ;; update_cleanup_success) # cleanup after successful update - nb_remove_tag_by_slug "$dev_id" "update-in-progress" || true - nb_remove_tag_by_slug "$dev_id" "update-auto-restarted" || true - nb_add_tag_by_slug "$dev_id" "update-successful" || true + if [[ "$USE_TAGS" == "yes" ]]; then + nb_remove_tag_by_slug "$dev_id" "update-in-progress" || true + nb_remove_tag_by_slug "$dev_id" "update-auto-restarted" || true + nb_add_tag_by_slug "$dev_id" "update-successful" || true + fi nb_clear_update_progress "$dev_id" || true echo ">>> Device '$device' (id=$dev_id) cleanup done:" - echo " - tag removed: update-in-progress" - echo " - tag removed: update-auto-restarted" - echo " - tag added: update-successful" + if [[ "$USE_TAGS" == "yes" ]]; then + echo " - tag removed: update-in-progress" + echo " - tag removed: update-auto-restarted" + echo " - tag added: update-successful" + fi echo " - custom field cleared: update_progress" ;; custom_field_set) @@ -580,6 +588,9 @@ handle_payload() { ;; tag_remove) # remove a tag from the device using task_result as slug + if [[ "$USE_TAGS" != "yes" ]]; then + return 0 + fi if [[ -z "$task_result" ]]; then warn "tag_remove: task_result (tag slug) is empty; skipping." return 0