diff --git a/README.md b/README.md index f7c66ae5..86cd94bf 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,29 @@ INFO:root:Create new IP 42.42.42.43/24 on enp1s0f1 INFO:root:Creating Disk Samsung SSD 850 S2RBNX0K101698D ``` +## Debug Mode + +The `--debug` flag prints detailed information about the device before attempting to create or update it in Netbox. This is useful for troubleshooting issues or verifying what data will be sent to Netbox. + +``` +# netbox_agent -c /etc/netbox_agent.yaml --debug --register +Datacenter: dc-1 +Netbox Datacenter: dc-1 +Rack: rack-01 +Netbox Rack: rack-01 +Is blade: False +Got expansion: False +Product Name: ProLiant DL380 Gen10 +Platform: x86-64 +Chassis: Default string +Chassis service tag: 2M25XX0020 +Service tag: 2M25XX0020 +NIC: +[{'name': 'eno1', 'mac': 'a8:1e:84:f2:9e:69', ...}, ...] +INFO:root:Creating chassis blade (serial: QTFCQ574502EF) +... +``` + # Configuration ``` diff --git a/netbox_agent.yaml.example b/netbox_agent.yaml.example index a1a8e028..609b2532 100644 --- a/netbox_agent.yaml.example +++ b/netbox_agent.yaml.example @@ -51,3 +51,8 @@ rack_location: # regex: '.*-(\d+)' inventory: true + +# Enable debug mode to print detailed device information +# This is useful for troubleshooting before registration or updates +# Same as using the --debug or -d command line flag +# debug: true diff --git a/netbox_agent/cli.py b/netbox_agent/cli.py index f277533e..3455b0de 100644 --- a/netbox_agent/cli.py +++ b/netbox_agent/cli.py @@ -45,6 +45,8 @@ def run(config): print("netbox-agent is not compatible with Netbox prior to version 3.7") return 1 + if config.debug: + server.print_debug() if ( config.register or config.update_all @@ -54,8 +56,6 @@ def run(config): or config.update_psu ): server.netbox_create_or_update(config) - if config.debug: - server.print_debug() return 0