diff --git a/lib/towerops/snmp/poller_worker.ex b/lib/towerops/snmp/poller_worker.ex index c5e7c910..922bc936 100644 --- a/lib/towerops/snmp/poller_worker.ex +++ b/lib/towerops/snmp/poller_worker.ex @@ -246,29 +246,38 @@ defmodule Towerops.Snmp.PollerWorker do defp decode_snmp_value(value) when is_binary(value) do # Try to decode based on byte size - case byte_size(value) do - 8 -> - # Standard Counter64 (8 bytes, big-endian unsigned integer) - <> = value - counter + try do + case byte_size(value) do + 8 -> + # Standard Counter64 (8 bytes, big-endian unsigned integer) + <> = value + counter - 16 -> - # Some SNMP implementations return 16-byte values - # Try reading last 8 bytes as Counter64 - <<_prefix::binary-size(8), counter::unsigned-big-integer-size(64)>> = value - counter + 16 -> + # Some SNMP implementations return 16-byte values + # Try reading last 8 bytes as Counter64 + <<_prefix::binary-size(8), counter::unsigned-big-integer-size(64)>> = value + counter - size when size > 8 -> - # Large binary, try reading last 8 bytes - offset = size - 8 - <<_prefix::binary-size(offset), counter::unsigned-big-integer-size(64)>> = value - Logger.debug("Decoded #{size}-byte SNMP value as Counter64 from last 8 bytes: #{counter}") - counter + size when size > 8 -> + # Large binary, try reading last 8 bytes + offset = size - 8 + <<_prefix::binary-size(offset), counter::unsigned-big-integer-size(64)>> = value + Logger.debug("Decoded #{size}-byte SNMP value as Counter64 from last 8 bytes: #{counter}") + counter - _ -> - # Unknown binary format or too small - Logger.warning( - "Unknown SNMP binary value format, size: #{byte_size(value)}, bytes: #{inspect(value)}" + _ -> + # Unknown binary format or too small + Logger.warning( + "Unknown SNMP binary value format, size: #{byte_size(value)}, bytes: #{inspect(value)}" + ) + + nil + end + rescue + error -> + Logger.error( + "Failed to decode SNMP binary value (size: #{byte_size(value)}): #{inspect(error)}, bytes: #{inspect(value)}" ) nil diff --git a/lib/towerops_web/live/equipment_live/form.html.heex b/lib/towerops_web/live/equipment_live/form.html.heex index 718fb6d4..2adda04f 100644 --- a/lib/towerops_web/live/equipment_live/form.html.heex +++ b/lib/towerops_web/live/equipment_live/form.html.heex @@ -1,4 +1,18 @@ +
+ <.link + navigate={ + if @live_action == :edit, + do: ~p"/orgs/#{@organization.slug}/equipment/#{@equipment.id}", + else: ~p"/orgs/#{@organization.slug}/equipment" + } + class="inline-flex items-center gap-1 text-sm text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-100" + > + <.icon name="hero-arrow-left" class="h-4 w-4" /> + {if @live_action == :edit, do: "Back to Equipment", else: "Back to Equipment List"} + +
+ <.header> {@page_title} <:subtitle> diff --git a/lib/towerops_web/live/site_live/form.html.heex b/lib/towerops_web/live/site_live/form.html.heex index ce3fa3c6..d4da27f7 100644 --- a/lib/towerops_web/live/site_live/form.html.heex +++ b/lib/towerops_web/live/site_live/form.html.heex @@ -1,4 +1,18 @@ +
+ <.link + navigate={ + if @live_action == :edit, + do: ~p"/orgs/#{@organization.slug}/sites/#{@site.id}", + else: ~p"/orgs/#{@organization.slug}/sites" + } + class="inline-flex items-center gap-1 text-sm text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-100" + > + <.icon name="hero-arrow-left" class="h-4 w-4" /> + {if @live_action == :edit, do: "Back to Site", else: "Back to Sites"} + +
+ <.header> {@page_title} <:subtitle>