Skip to content
Snippets Groups Projects
Select Git revision
  • 74f14b2d4a6c7d548310f2625a209741d89c19ec
  • master default protected
  • simple-task/7248-eol-check-add-node-22
  • 6877_check_iml_deployment
4 results

inc_pluginfunctions

Blame
  • show_ttls.sh 1.56 KiB
    #!/usr/bin/bash
    # ======================================================================
    #
    # INFOBLOX HELPER
    # show all hosts that override the default TTL
    #
    # ----------------------------------------------------------------------
    # 2022-09-14  v1.0  <axel.hahn@iml.unibe.ch>  initial version
    # 2022-09-15  v1.1  <axel.hahn@iml.unibe.ch>  check required jq
    # ======================================================================
    
    _version="1.1"
    
    # ----------------------------------------------------------------------
    # HELP
    # ----------------------------------------------------------------------
    if [ -z "$1" ] || [ "$1" = "-h" ]; then
    cat <<EOH
    
    >>>>>>>>>> INFOBLOX DNS HELPER: TTL v$_version
    
    Search for hostnames in Infoblox API and show all hosts that have an
    activated custom ttl value.
    
    It uses dns-api.sh and adds the return field for aliases.
    The filter functionality of json data requires jq.
    
    SYNTAX: dns-search.sh REGEX
    
    REGEX  string  search string for a hostname.
                   Use a dot . to scan all hosts you are allowed to access
    
    EOH
    exit 0
    fi
    
    # ----------------------------------------------------------------------
    # MAIN
    # ----------------------------------------------------------------------
    
    mysearch=$1
    
    >&2 echo ";"
    >&2 echo "; >>>>>>>>>> INFOBLOX DNS HELPER TTL v$_version"
    >&2 echo ";"
    
    which jq >/dev/null || exit
    
    "$( dirname $0 )"/dns-api.sh GET "/record:host?name~=${mysearch}&_return_fields%2B=ttl,use_ttl" \
        | jq -r '.[]  | select ( .use_ttl == true and .ttl != null ) | .name,.ttl'
    
    # ----------------------------------------------------------------------