Add server-initiated restart and self-update capabilities for remote agents. Restart broadcasts on the lifecycle PubSub topic causing the agent to exit cleanly for Docker to restart. Self-update fetches the latest release from GitHub, finds the matching binary for the agent's architecture, and sends the download URL with SHA256 checksum. - Add restart_agent/1 and update_agent/3 to Agents context - Handle :restart_requested and :update_requested in AgentChannel - Add superuser-only Restart and Update buttons on agent show page - Add ReleaseChecker module for GitHub Releases API with 5-min cache - Add arch field to AgentHeartbeat protobuf for architecture detection - Store arch in agent metadata from heartbeat
474 lines
13 KiB
Elixir
474 lines
13 KiB
Elixir
defmodule Towerops.Agent.JobType do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
enum: true,
|
|
full_name: "towerops.agent.JobType",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :DISCOVER, 0
|
|
field :POLL, 1
|
|
field :MIKROTIK, 2
|
|
field :TEST_CREDENTIALS, 3
|
|
field :PING, 4
|
|
end
|
|
|
|
defmodule Towerops.Agent.QueryType do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
enum: true,
|
|
full_name: "towerops.agent.QueryType",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :GET, 0
|
|
field :WALK, 1
|
|
end
|
|
|
|
defmodule Towerops.Agent.AgentConfig do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.AgentConfig",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :version, 1, type: :string
|
|
field :poll_interval_seconds, 2, type: :uint32, json_name: "pollIntervalSeconds"
|
|
field :devices, 3, repeated: true, type: Towerops.Agent.Device
|
|
end
|
|
|
|
defmodule Towerops.Agent.Device do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.Device",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :id, 1, type: :string
|
|
field :name, 2, type: :string
|
|
field :ip_address, 3, type: :string, json_name: "ipAddress"
|
|
field :snmp, 4, type: Towerops.Agent.SnmpConfig
|
|
field :poll_interval_seconds, 5, type: :uint32, json_name: "pollIntervalSeconds"
|
|
field :sensors, 6, repeated: true, type: Towerops.Agent.Sensor
|
|
field :interfaces, 7, repeated: true, type: Towerops.Agent.Interface
|
|
field :monitoring_enabled, 8, type: :bool, json_name: "monitoringEnabled"
|
|
field :check_interval_seconds, 9, type: :uint32, json_name: "checkIntervalSeconds"
|
|
end
|
|
|
|
defmodule Towerops.Agent.SnmpConfig do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.SnmpConfig",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :enabled, 1, type: :bool
|
|
field :version, 2, type: :string
|
|
field :community, 3, type: :string
|
|
field :port, 4, type: :uint32
|
|
end
|
|
|
|
defmodule Towerops.Agent.Sensor.MetadataEntry do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.Sensor.MetadataEntry",
|
|
map: true,
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :key, 1, type: :string
|
|
field :value, 2, type: :string
|
|
end
|
|
|
|
defmodule Towerops.Agent.Sensor do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.Sensor",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :id, 1, type: :string
|
|
field :type, 2, type: :string
|
|
field :oid, 3, type: :string
|
|
field :divisor, 4, type: :double
|
|
field :unit, 5, type: :string
|
|
field :metadata, 6, repeated: true, type: Towerops.Agent.Sensor.MetadataEntry, map: true
|
|
end
|
|
|
|
defmodule Towerops.Agent.Interface do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.Interface",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :id, 1, type: :string
|
|
field :if_index, 2, type: :uint32, json_name: "ifIndex"
|
|
field :if_name, 3, type: :string, json_name: "ifName"
|
|
end
|
|
|
|
defmodule Towerops.Agent.MetricBatch do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.MetricBatch",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :metrics, 1, repeated: true, type: Towerops.Agent.Metric
|
|
end
|
|
|
|
defmodule Towerops.Agent.Metric do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.Metric",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
oneof(:metric_type, 0)
|
|
|
|
field :sensor_reading, 1,
|
|
type: Towerops.Agent.SensorReading,
|
|
json_name: "sensorReading",
|
|
oneof: 0
|
|
|
|
field :interface_stat, 2,
|
|
type: Towerops.Agent.InterfaceStat,
|
|
json_name: "interfaceStat",
|
|
oneof: 0
|
|
|
|
field :neighbor_discovery, 3,
|
|
type: Towerops.Agent.NeighborDiscovery,
|
|
json_name: "neighborDiscovery",
|
|
oneof: 0
|
|
|
|
field :monitoring_check, 4,
|
|
type: Towerops.Agent.MonitoringCheck,
|
|
json_name: "monitoringCheck",
|
|
oneof: 0
|
|
end
|
|
|
|
defmodule Towerops.Agent.SensorReading do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.SensorReading",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :sensor_id, 1, type: :string, json_name: "sensorId"
|
|
field :value, 2, type: :double
|
|
field :status, 3, type: :string
|
|
field :timestamp, 4, type: :int64
|
|
end
|
|
|
|
defmodule Towerops.Agent.InterfaceStat do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.InterfaceStat",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :interface_id, 1, type: :string, json_name: "interfaceId"
|
|
field :if_in_octets, 2, type: :int64, json_name: "ifInOctets"
|
|
field :if_out_octets, 3, type: :int64, json_name: "ifOutOctets"
|
|
field :if_in_errors, 4, type: :int64, json_name: "ifInErrors"
|
|
field :if_out_errors, 5, type: :int64, json_name: "ifOutErrors"
|
|
field :if_in_discards, 6, type: :int64, json_name: "ifInDiscards"
|
|
field :if_out_discards, 7, type: :int64, json_name: "ifOutDiscards"
|
|
field :timestamp, 8, type: :int64
|
|
end
|
|
|
|
defmodule Towerops.Agent.NeighborDiscovery do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.NeighborDiscovery",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :interface_id, 1, type: :string, json_name: "interfaceId"
|
|
field :protocol, 2, type: :string
|
|
field :remote_chassis_id, 3, type: :string, json_name: "remoteChassisId"
|
|
field :remote_system_name, 4, type: :string, json_name: "remoteSystemName"
|
|
field :remote_system_description, 5, type: :string, json_name: "remoteSystemDescription"
|
|
field :remote_platform, 6, type: :string, json_name: "remotePlatform"
|
|
field :remote_port_id, 7, type: :string, json_name: "remotePortId"
|
|
field :remote_port_description, 8, type: :string, json_name: "remotePortDescription"
|
|
field :remote_address, 9, type: :string, json_name: "remoteAddress"
|
|
field :remote_capabilities, 10, repeated: true, type: :string, json_name: "remoteCapabilities"
|
|
field :timestamp, 11, type: :int64
|
|
end
|
|
|
|
defmodule Towerops.Agent.MonitoringCheck do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.MonitoringCheck",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :device_id, 1, type: :string, json_name: "deviceId"
|
|
field :status, 2, type: :string
|
|
field :response_time_ms, 3, type: :double, json_name: "responseTimeMs"
|
|
field :timestamp, 4, type: :int64
|
|
end
|
|
|
|
defmodule Towerops.Agent.HeartbeatMetadata do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.HeartbeatMetadata",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :version, 1, type: :string
|
|
field :hostname, 2, type: :string
|
|
field :uptime_seconds, 3, type: :uint64, json_name: "uptimeSeconds"
|
|
end
|
|
|
|
defmodule Towerops.Agent.HeartbeatResponse do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.HeartbeatResponse",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :status, 1, type: :string
|
|
end
|
|
|
|
defmodule Towerops.Agent.AgentJobList do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.AgentJobList",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :jobs, 1, repeated: true, type: Towerops.Agent.AgentJob
|
|
end
|
|
|
|
defmodule Towerops.Agent.AgentJob do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.AgentJob",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :job_id, 1, type: :string, json_name: "jobId"
|
|
field :job_type, 2, type: Towerops.Agent.JobType, json_name: "jobType", enum: true
|
|
field :device_id, 3, type: :string, json_name: "deviceId"
|
|
field :snmp_device, 4, type: Towerops.Agent.SnmpDevice, json_name: "snmpDevice"
|
|
field :queries, 5, repeated: true, type: Towerops.Agent.SnmpQuery
|
|
field :mikrotik_device, 6, type: Towerops.Agent.MikrotikDevice, json_name: "mikrotikDevice"
|
|
|
|
field :mikrotik_commands, 7,
|
|
repeated: true,
|
|
type: Towerops.Agent.MikrotikCommand,
|
|
json_name: "mikrotikCommands"
|
|
end
|
|
|
|
defmodule Towerops.Agent.SnmpDevice do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.SnmpDevice",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :ip, 1, type: :string
|
|
field :community, 2, type: :string
|
|
field :version, 3, type: :string
|
|
field :port, 4, type: :uint32
|
|
field :v3_security_level, 5, type: :string, json_name: "v3SecurityLevel"
|
|
field :v3_username, 6, type: :string, json_name: "v3Username"
|
|
field :v3_auth_protocol, 7, type: :string, json_name: "v3AuthProtocol"
|
|
field :v3_auth_password, 8, type: :string, json_name: "v3AuthPassword"
|
|
field :v3_priv_protocol, 9, type: :string, json_name: "v3PrivProtocol"
|
|
field :v3_priv_password, 10, type: :string, json_name: "v3PrivPassword"
|
|
end
|
|
|
|
defmodule Towerops.Agent.SnmpQuery do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.SnmpQuery",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :query_type, 1, type: Towerops.Agent.QueryType, json_name: "queryType", enum: true
|
|
field :oids, 2, repeated: true, type: :string
|
|
end
|
|
|
|
defmodule Towerops.Agent.SnmpResult.OidValuesEntry do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.SnmpResult.OidValuesEntry",
|
|
map: true,
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :key, 1, type: :string
|
|
field :value, 2, type: :string
|
|
end
|
|
|
|
defmodule Towerops.Agent.SnmpResult do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.SnmpResult",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :device_id, 1, type: :string, json_name: "deviceId"
|
|
field :job_type, 2, type: Towerops.Agent.JobType, json_name: "jobType", enum: true
|
|
|
|
field :oid_values, 3,
|
|
repeated: true,
|
|
type: Towerops.Agent.SnmpResult.OidValuesEntry,
|
|
json_name: "oidValues",
|
|
map: true
|
|
|
|
field :timestamp, 4, type: :int64
|
|
field :job_id, 5, type: :string, json_name: "jobId"
|
|
end
|
|
|
|
defmodule Towerops.Agent.AgentHeartbeat do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.AgentHeartbeat",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :version, 1, type: :string
|
|
field :hostname, 2, type: :string
|
|
field :uptime_seconds, 3, type: :uint64, json_name: "uptimeSeconds"
|
|
field :ip_address, 4, type: :string, json_name: "ipAddress"
|
|
field :arch, 5, type: :string
|
|
end
|
|
|
|
defmodule Towerops.Agent.AgentError do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.AgentError",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :device_id, 1, type: :string, json_name: "deviceId"
|
|
field :job_id, 2, type: :string, json_name: "jobId"
|
|
field :message, 3, type: :string
|
|
field :timestamp, 4, type: :int64
|
|
end
|
|
|
|
defmodule Towerops.Agent.CredentialTestResult do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.CredentialTestResult",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :test_id, 1, type: :string, json_name: "testId"
|
|
field :success, 2, type: :bool
|
|
field :error_message, 3, type: :string, json_name: "errorMessage"
|
|
field :system_description, 4, type: :string, json_name: "systemDescription"
|
|
field :timestamp, 5, type: :int64
|
|
end
|
|
|
|
defmodule Towerops.Agent.MikrotikDevice do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.MikrotikDevice",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :ip, 1, type: :string
|
|
field :port, 2, type: :uint32
|
|
field :username, 3, type: :string
|
|
field :password, 4, type: :string
|
|
field :use_ssl, 5, type: :bool, json_name: "useSsl"
|
|
field :ssh_port, 6, type: :uint32, json_name: "sshPort"
|
|
end
|
|
|
|
defmodule Towerops.Agent.MikrotikCommand.ArgsEntry do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.MikrotikCommand.ArgsEntry",
|
|
map: true,
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :key, 1, type: :string
|
|
field :value, 2, type: :string
|
|
end
|
|
|
|
defmodule Towerops.Agent.MikrotikCommand do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.MikrotikCommand",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :command, 1, type: :string
|
|
field :args, 2, repeated: true, type: Towerops.Agent.MikrotikCommand.ArgsEntry, map: true
|
|
end
|
|
|
|
defmodule Towerops.Agent.MikrotikResult do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.MikrotikResult",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :device_id, 1, type: :string, json_name: "deviceId"
|
|
field :job_id, 2, type: :string, json_name: "jobId"
|
|
field :sentences, 3, repeated: true, type: Towerops.Agent.MikrotikSentence
|
|
field :error, 4, type: :string
|
|
field :timestamp, 5, type: :int64
|
|
end
|
|
|
|
defmodule Towerops.Agent.MikrotikSentence.AttributesEntry do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.MikrotikSentence.AttributesEntry",
|
|
map: true,
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :key, 1, type: :string
|
|
field :value, 2, type: :string
|
|
end
|
|
|
|
defmodule Towerops.Agent.MikrotikSentence do
|
|
@moduledoc false
|
|
|
|
use Protobuf,
|
|
full_name: "towerops.agent.MikrotikSentence",
|
|
protoc_gen_elixir_version: "0.16.0",
|
|
syntax: :proto3
|
|
|
|
field :attributes, 1,
|
|
repeated: true,
|
|
type: Towerops.Agent.MikrotikSentence.AttributesEntry,
|
|
map: true
|
|
end
|