LogstashUI 0.5.5.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (762) hide show
  1. AI/__init__.py +0 -0
  2. AI/integration_factory.py +1392 -0
  3. AI/migrations/0001_initial.py +58 -0
  4. AI/migrations/0002_draftdefinition_normalizers.py +23 -0
  5. AI/migrations/0003_delete_aisettings_delete_draftdefinition.py +19 -0
  6. AI/migrations/__init__.py +0 -0
  7. AI/models.py +5 -0
  8. AI/static/js/integration_factory.js +1102 -0
  9. AI/system_prompts/dashboard_generator.md +367 -0
  10. AI/system_prompts/grok_patterns.txt +95 -0
  11. AI/system_prompts/ingest_pipeline_generator.md +331 -0
  12. AI/system_prompts/ingest_pipeline_processors.json +2851 -0
  13. AI/system_prompts/ingest_verifier.md +84 -0
  14. AI/system_prompts/integrations_list.json +2690 -0
  15. AI/system_prompts/log_classifier.md +134 -0
  16. AI/system_prompts/template_creator.md +123 -0
  17. AI/templates/integration_factory.html +200 -0
  18. AI/urls.py +16 -0
  19. AI/views.py +20 -0
  20. API/__init__.py +0 -0
  21. API/admin.py +7 -0
  22. API/api.http +784 -0
  23. API/apps.py +9 -0
  24. API/auth.py +101 -0
  25. API/connections_views.py +312 -0
  26. API/guides.py +88 -0
  27. API/mcp/__init__.py +5 -0
  28. API/mcp/dispatch.py +179 -0
  29. API/mcp/tools.py +890 -0
  30. API/mcp/views.py +215 -0
  31. API/migrations/__init__.py +0 -0
  32. API/models.py +7 -0
  33. API/pipelines_views.py +1224 -0
  34. API/policies_views.py +1015 -0
  35. API/security_views.py +488 -0
  36. API/simulation_detail.py +219 -0
  37. API/snmp_views.py +1539 -0
  38. API/urls.py +81 -0
  39. Common/__init__.py +0 -0
  40. Common/ai/agent_builder.py +690 -0
  41. Common/context_processors.py +49 -0
  42. Common/decorators.py +68 -0
  43. Common/elastic_utils.py +1154 -0
  44. Common/encryption.py +271 -0
  45. Common/error_handlers.py +65 -0
  46. Common/formatters.py +106 -0
  47. Common/logstash_config_parse.py +1469 -0
  48. Common/logstash_utils.py +34 -0
  49. Common/middleware.py +216 -0
  50. Common/product_ca.py +1124 -0
  51. Common/validators.py +66 -0
  52. Documentation/__init__.py +0 -0
  53. Documentation/admin.py +7 -0
  54. Documentation/apps.py +9 -0
  55. Documentation/content/CHANGELOG.md +890 -0
  56. Documentation/content/docs/getting_started.md +92 -0
  57. Documentation/content/docs/index.md +124 -0
  58. Documentation/content/docs/logstashagent/configuration/index.md +60 -0
  59. Documentation/content/docs/logstashagent/configuration/logstashagent.yml.md +141 -0
  60. Documentation/content/docs/logstashagent/general/build.md +217 -0
  61. Documentation/content/docs/logstashagent/general/index.md +38 -0
  62. Documentation/content/docs/logstashagent/general/roles.md +267 -0
  63. Documentation/content/docs/logstashagent/index.md +264 -0
  64. Documentation/content/docs/logstashui/SNMP/Quickstart.md +94 -0
  65. Documentation/content/docs/logstashui/SNMP/architecture.md +64 -0
  66. Documentation/content/docs/logstashui/SNMP/configuration.md +147 -0
  67. Documentation/content/docs/logstashui/SNMP/data_overview.md +59 -0
  68. Documentation/content/docs/logstashui/SNMP/deploying_changes.md +71 -0
  69. Documentation/content/docs/logstashui/SNMP/device_support.md +39 -0
  70. Documentation/content/docs/logstashui/SNMP/discovery.md +48 -0
  71. Documentation/content/docs/logstashui/SNMP/index.md +58 -0
  72. Documentation/content/docs/logstashui/SNMP/pipeline_generation.md +63 -0
  73. Documentation/content/docs/logstashui/SNMP/schema.md +595 -0
  74. Documentation/content/docs/logstashui/SNMP/testing.md +47 -0
  75. Documentation/content/docs/logstashui/SNMP/traps.md +45 -0
  76. Documentation/content/docs/logstashui/SNMP/tsds_implementation.md +82 -0
  77. Documentation/content/docs/logstashui/agent_guides/concepts.md +25 -0
  78. Documentation/content/docs/logstashui/agent_guides/deploy.md +30 -0
  79. Documentation/content/docs/logstashui/agent_guides/pipeline-review.md +24 -0
  80. Documentation/content/docs/logstashui/agent_guides/simulation.md +55 -0
  81. Documentation/content/docs/logstashui/agent_guides/snmp.md +57 -0
  82. Documentation/content/docs/logstashui/agent_guides/troubleshooting.md +21 -0
  83. Documentation/content/docs/logstashui/architecture.md +11 -0
  84. Documentation/content/docs/logstashui/compatibility.md +58 -0
  85. Documentation/content/docs/logstashui/configuration/environment.md +193 -0
  86. Documentation/content/docs/logstashui/configuration/host_mode.md +94 -0
  87. Documentation/content/docs/logstashui/configuration/index.md +72 -0
  88. Documentation/content/docs/logstashui/configuration/logstash_proxy.md +138 -0
  89. Documentation/content/docs/logstashui/configuration/logstashui.yml.md +16 -0
  90. Documentation/content/docs/logstashui/configuration/simulation.md +84 -0
  91. Documentation/content/docs/logstashui/database/examples/README.md +15 -0
  92. Documentation/content/docs/logstashui/database/examples/create-mariadb.sql +13 -0
  93. Documentation/content/docs/logstashui/database/examples/create-mysql.sql +12 -0
  94. Documentation/content/docs/logstashui/database/examples/create-postgresql.sql +13 -0
  95. Documentation/content/docs/logstashui/database/examples/schema-mysql.sql +502 -0
  96. Documentation/content/docs/logstashui/database/examples/schema-postgresql.sql +1709 -0
  97. Documentation/content/docs/logstashui/database/index.md +79 -0
  98. Documentation/content/docs/logstashui/database/migration.md +75 -0
  99. Documentation/content/docs/logstashui/general/build.md +154 -0
  100. Documentation/content/docs/logstashui/general/deploy.md +122 -0
  101. Documentation/content/docs/logstashui/general/deployment-recs.md +32 -0
  102. Documentation/content/docs/logstashui/general/index.md +62 -0
  103. Documentation/content/docs/logstashui/general/offline.md +68 -0
  104. Documentation/content/docs/logstashui/general/updating.md +50 -0
  105. Documentation/content/docs/logstashui/index.md +90 -0
  106. Documentation/content/docs/logstashui/kubernetes/cnpg.md +98 -0
  107. Documentation/content/docs/logstashui/kubernetes/envoy-gateway.md +112 -0
  108. Documentation/content/docs/logstashui/kubernetes/examples/README.md +46 -0
  109. Documentation/content/docs/logstashui/kubernetes/examples/embedded-agent.yaml +122 -0
  110. Documentation/content/docs/logstashui/kubernetes/examples/mysql/configmap.yaml +41 -0
  111. Documentation/content/docs/logstashui/kubernetes/examples/mysql/ingress.yaml +31 -0
  112. Documentation/content/docs/logstashui/kubernetes/examples/mysql/namespace.yaml +8 -0
  113. Documentation/content/docs/logstashui/kubernetes/examples/mysql/secret.yaml +19 -0
  114. Documentation/content/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml +106 -0
  115. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml +25 -0
  116. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml +42 -0
  117. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml +31 -0
  118. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml +8 -0
  119. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/secret.yaml +19 -0
  120. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml +106 -0
  121. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml +35 -0
  122. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml +31 -0
  123. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml +8 -0
  124. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/secret.yaml +18 -0
  125. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml +106 -0
  126. Documentation/content/docs/logstashui/kubernetes/index.md +121 -0
  127. Documentation/content/docs/logstashui/mcp.md +224 -0
  128. Documentation/content/docs/logstashui/mcp_scenarios.md +234 -0
  129. Documentation/content/docs/logstashui/rest_api.md +2783 -0
  130. Documentation/content/docs/logstashui/utilities/dissect_debugger.md +89 -0
  131. Documentation/content/docs/logstashui/utilities/grok_debugger.md +114 -0
  132. Documentation/content/docs/logstashui/utilities/index.md +40 -0
  133. Documentation/content/images/LogstashIcon.png +0 -0
  134. Documentation/content/images/architecture.png +0 -0
  135. Documentation/content/images/connection_manager.png +0 -0
  136. Documentation/content/images/control_plane.png +0 -0
  137. Documentation/content/images/graph.gif +0 -0
  138. Documentation/content/images/login.png +0 -0
  139. Documentation/content/images/monitoring.png +0 -0
  140. Documentation/content/images/new_connection.gif +0 -0
  141. Documentation/content/images/simulate.gif +0 -0
  142. Documentation/content/images/simulate.png +0 -0
  143. Documentation/content/images/snmp.gif +0 -0
  144. Documentation/content/images/snmp.png +0 -0
  145. Documentation/content/images/snmp_architecture.png +0 -0
  146. Documentation/migrations/__init__.py +0 -0
  147. Documentation/models.py +9 -0
  148. Documentation/static/css/markdown.css +250 -0
  149. Documentation/templates/documentation.html +225 -0
  150. Documentation/templates/nav_item.html +41 -0
  151. Documentation/urls.py +11 -0
  152. Documentation/views.py +442 -0
  153. LogstashUI/__init__.py +0 -0
  154. LogstashUI/__main__.py +10 -0
  155. LogstashUI/asgi.py +16 -0
  156. LogstashUI/cli.py +626 -0
  157. LogstashUI/config.py +116 -0
  158. LogstashUI/database.py +263 -0
  159. LogstashUI/insecure_http.py +117 -0
  160. LogstashUI/logging_config.py +99 -0
  161. LogstashUI/migrate_engine.py +282 -0
  162. LogstashUI/packaging/__init__.py +3 -0
  163. LogstashUI/packaging/logstashui.default +68 -0
  164. LogstashUI/packaging/logstashui.service.in +22 -0
  165. LogstashUI/paths.py +181 -0
  166. LogstashUI/settings.py +437 -0
  167. LogstashUI/telemetry.py +159 -0
  168. LogstashUI/urls.py +56 -0
  169. LogstashUI/wsgi.py +77 -0
  170. Management/__init__.py +0 -0
  171. Management/apps.py +10 -0
  172. Management/migrations/0001_initial.py +29 -0
  173. Management/migrations/0002_settings.py +25 -0
  174. Management/migrations/0003_settings_agent_ui_url.py +29 -0
  175. Management/migrations/0004_settings_logstash_artifact_base_url.py +29 -0
  176. Management/migrations/__init__.py +0 -0
  177. Management/models.py +92 -0
  178. Management/templates/api_tokens.html +214 -0
  179. Management/templates/components/api_token_created.html +38 -0
  180. Management/templates/components/api_token_row.html +84 -0
  181. Management/templates/components/logstash_artifact_row.html +100 -0
  182. Management/templates/components/logstash_artifact_tbody.html +26 -0
  183. Management/templates/components/user_row.html +67 -0
  184. Management/templates/logs.html +98 -0
  185. Management/templates/logstash_artifacts.html +172 -0
  186. Management/templates/management.html +80 -0
  187. Management/templates/management_settings.html +320 -0
  188. Management/templates/registration/login.html +404 -0
  189. Management/templates/users.html +304 -0
  190. Management/urls.py +23 -0
  191. Management/views.py +804 -0
  192. Monitoring/__init__.py +0 -0
  193. Monitoring/apps.py +9 -0
  194. Monitoring/migrations/__init__.py +0 -0
  195. Monitoring/static/js/monitoring.js +463 -0
  196. Monitoring/templates/components/node_metrics.html +161 -0
  197. Monitoring/templates/components/pipeline_metrics.html +189 -0
  198. Monitoring/templates/monitoring.html +271 -0
  199. Monitoring/urls.py +16 -0
  200. Monitoring/views.py +724 -0
  201. PipelineManager/__init__.py +0 -0
  202. PipelineManager/agent_api.py +1173 -0
  203. PipelineManager/agent_client.py +59 -0
  204. PipelineManager/agent_modes.py +880 -0
  205. PipelineManager/agent_policies.py +689 -0
  206. PipelineManager/agent_versions.py +151 -0
  207. PipelineManager/apps.py +10 -0
  208. PipelineManager/artifact_metrics.py +171 -0
  209. PipelineManager/artifacts.py +820 -0
  210. PipelineManager/connections_crud.py +722 -0
  211. PipelineManager/data/default_jvm.options +76 -0
  212. PipelineManager/data/default_log4j2.properties +165 -0
  213. PipelineManager/data/default_logstash.yml +405 -0
  214. PipelineManager/data/plugins.json +29109 -0
  215. PipelineManager/editor_views.py +608 -0
  216. PipelineManager/forms.py +284 -0
  217. PipelineManager/manager_views.py +490 -0
  218. PipelineManager/migrations/0001_initial.py +38 -0
  219. PipelineManager/migrations/0002_alter_connection_connection_type_and_more.py +38 -0
  220. PipelineManager/migrations/0003_policy_connection_policy.py +38 -0
  221. PipelineManager/migrations/0004_policy_current_revision_number_and_more.py +75 -0
  222. PipelineManager/migrations/0005_apikey_enrollmenttoken.py +38 -0
  223. PipelineManager/migrations/0006_enrollmenttoken_name.py +18 -0
  224. PipelineManager/migrations/0007_alter_enrollmenttoken_options_and_more.py +21 -0
  225. PipelineManager/migrations/0008_connection_agent_id.py +18 -0
  226. PipelineManager/migrations/0009_connection_last_check_in_policy_jvm_options_hash_and_more.py +33 -0
  227. PipelineManager/migrations/0010_keystore_revision_number_pipeline_revision_number.py +23 -0
  228. PipelineManager/migrations/0011_keystore_kv_hash.py +18 -0
  229. PipelineManager/migrations/0012_policy_binary_path.py +18 -0
  230. PipelineManager/migrations/0013_connection_status_blob.py +18 -0
  231. PipelineManager/migrations/0014_pipeline_pipeline_batch_delay_and_more.py +43 -0
  232. PipelineManager/migrations/0015_add_pipeline_hash.py +18 -0
  233. PipelineManager/migrations/0016_backfill_pipeline_hash.py +32 -0
  234. PipelineManager/migrations/0017_policy_keystore_password.py +31 -0
  235. PipelineManager/migrations/0018_policy_last_deployed_at.py +18 -0
  236. PipelineManager/migrations/0019_connection_restart_on_next_checkin.py +18 -0
  237. PipelineManager/migrations/0020_pipeline_no_input_pipeline_non_reloadable.py +23 -0
  238. PipelineManager/migrations/0021_connection_desired_agent_version.py +18 -0
  239. PipelineManager/migrations/0022_keystore_managed_by_pipeline_managed_by.py +23 -0
  240. PipelineManager/migrations/0023_agent_modes_policy_connection.py +89 -0
  241. PipelineManager/migrations/0024_seed_system_policies.py +173 -0
  242. PipelineManager/migrations/0025_packaged_managed_policy_types.py +166 -0
  243. PipelineManager/migrations/0026_normalize_opt_logstash_agent_paths.py +63 -0
  244. PipelineManager/migrations/0027_packaged_managed_default_ports.py +49 -0
  245. PipelineManager/migrations/0028_apikey_admin_tokens.py +80 -0
  246. PipelineManager/migrations/0029_logstash_artifacts.py +45 -0
  247. PipelineManager/migrations/0030_connection_allow_self_signed_certs.py +33 -0
  248. PipelineManager/migrations/0031_deploy_system_policies.py +93 -0
  249. PipelineManager/migrations/0032_connection_agent_inbound_key.py +30 -0
  250. PipelineManager/migrations/0033_simulation_result.py +26 -0
  251. PipelineManager/migrations/__init__.py +0 -0
  252. PipelineManager/models.py +1300 -0
  253. PipelineManager/pipelines_crud.py +738 -0
  254. PipelineManager/policies_crud.py +772 -0
  255. PipelineManager/sim_keystore.py +319 -0
  256. PipelineManager/simulation.py +1581 -0
  257. PipelineManager/static/css/codemirror.min.css +1 -0
  258. PipelineManager/static/css/graph_move.css +79 -0
  259. PipelineManager/static/css/monokai.min.css +1 -0
  260. PipelineManager/static/css/move_mode.css +144 -0
  261. PipelineManager/static/css/show-hint.min.css +1 -0
  262. PipelineManager/static/images/age.png +0 -0
  263. PipelineManager/static/images/aggregate.png +0 -0
  264. PipelineManager/static/images/alter.png +0 -0
  265. PipelineManager/static/images/azure_event_hubs.png +0 -0
  266. PipelineManager/static/images/beats.png +0 -0
  267. PipelineManager/static/images/boundary.png +0 -0
  268. PipelineManager/static/images/bytes.png +0 -0
  269. PipelineManager/static/images/cidr.png +0 -0
  270. PipelineManager/static/images/cipher.png +0 -0
  271. PipelineManager/static/images/circonus.png +0 -0
  272. PipelineManager/static/images/clone.png +0 -0
  273. PipelineManager/static/images/cloudwatch.png +0 -0
  274. PipelineManager/static/images/comment.png +0 -0
  275. PipelineManager/static/images/continue.png +0 -0
  276. PipelineManager/static/images/couchdb_changes.png +0 -0
  277. PipelineManager/static/images/csv.png +0 -0
  278. PipelineManager/static/images/datadog.png +0 -0
  279. PipelineManager/static/images/datadog_metrics.png +0 -0
  280. PipelineManager/static/images/date.png +0 -0
  281. PipelineManager/static/images/de_dot.png +0 -0
  282. PipelineManager/static/images/dead_letter_queue.png +0 -0
  283. PipelineManager/static/images/dissect.png +0 -0
  284. PipelineManager/static/images/dns.png +0 -0
  285. PipelineManager/static/images/drop.png +0 -0
  286. PipelineManager/static/images/dynatrace.png +0 -0
  287. PipelineManager/static/images/elapsed.png +0 -0
  288. PipelineManager/static/images/elastic_agent.png +0 -0
  289. PipelineManager/static/images/elastic_integration.png +0 -0
  290. PipelineManager/static/images/elastic_serverless_forwarder.png +0 -0
  291. PipelineManager/static/images/elastic_workplace_search.png +0 -0
  292. PipelineManager/static/images/elasticsearch.png +0 -0
  293. PipelineManager/static/images/else.png +0 -0
  294. PipelineManager/static/images/else_if.png +0 -0
  295. PipelineManager/static/images/email.png +0 -0
  296. PipelineManager/static/images/environment.png +0 -0
  297. PipelineManager/static/images/exec.png +0 -0
  298. PipelineManager/static/images/extractnumbers.png +0 -0
  299. PipelineManager/static/images/file.png +0 -0
  300. PipelineManager/static/images/fingerprint.png +0 -0
  301. PipelineManager/static/images/ganglia.png +0 -0
  302. PipelineManager/static/images/gelf.png +0 -0
  303. PipelineManager/static/images/generator.png +0 -0
  304. PipelineManager/static/images/geoip.png +0 -0
  305. PipelineManager/static/images/github.png +0 -0
  306. PipelineManager/static/images/google_bigquery.png +0 -0
  307. PipelineManager/static/images/google_cloud_storage.png +0 -0
  308. PipelineManager/static/images/google_pubsub.png +0 -0
  309. PipelineManager/static/images/graphite.png +0 -0
  310. PipelineManager/static/images/graphtastic.png +0 -0
  311. PipelineManager/static/images/grok.png +0 -0
  312. PipelineManager/static/images/heartbeat.png +0 -0
  313. PipelineManager/static/images/http.png +0 -0
  314. PipelineManager/static/images/http_poller.png +0 -0
  315. PipelineManager/static/images/i18n.png +0 -0
  316. PipelineManager/static/images/if.png +0 -0
  317. PipelineManager/static/images/imap.png +0 -0
  318. PipelineManager/static/images/influxdb.png +0 -0
  319. PipelineManager/static/images/irc.png +0 -0
  320. PipelineManager/static/images/java_generator.png +0 -0
  321. PipelineManager/static/images/java_stdin.png +0 -0
  322. PipelineManager/static/images/java_stdout.png +0 -0
  323. PipelineManager/static/images/java_uuid.png +0 -0
  324. PipelineManager/static/images/jdbc.png +0 -0
  325. PipelineManager/static/images/jdbc_static.png +0 -0
  326. PipelineManager/static/images/jdbc_streaming.png +0 -0
  327. PipelineManager/static/images/jms.png +0 -0
  328. PipelineManager/static/images/jmx.png +0 -0
  329. PipelineManager/static/images/json.png +0 -0
  330. PipelineManager/static/images/json_encode.png +0 -0
  331. PipelineManager/static/images/juggernaut.png +0 -0
  332. PipelineManager/static/images/kafka.png +0 -0
  333. PipelineManager/static/images/kinesis.png +0 -0
  334. PipelineManager/static/images/kv.png +0 -0
  335. PipelineManager/static/images/librato.png +0 -0
  336. PipelineManager/static/images/log4j.png +0 -0
  337. PipelineManager/static/images/loggly.png +0 -0
  338. PipelineManager/static/images/logstash.png +0 -0
  339. PipelineManager/static/images/lumberjack.png +0 -0
  340. PipelineManager/static/images/meetup.png +0 -0
  341. PipelineManager/static/images/memcached.png +0 -0
  342. PipelineManager/static/images/metriccatcher.png +0 -0
  343. PipelineManager/static/images/metricize.png +0 -0
  344. PipelineManager/static/images/metrics.png +0 -0
  345. PipelineManager/static/images/mongodb.png +0 -0
  346. PipelineManager/static/images/mutate.png +0 -0
  347. PipelineManager/static/images/nagios.png +0 -0
  348. PipelineManager/static/images/nagios_nsca.png +0 -0
  349. PipelineManager/static/images/opentsdb.png +0 -0
  350. PipelineManager/static/images/pagerduty.png +0 -0
  351. PipelineManager/static/images/pipe.png +0 -0
  352. PipelineManager/static/images/pipeline.png +0 -0
  353. PipelineManager/static/images/prune.png +0 -0
  354. PipelineManager/static/images/puppet_facter.png +0 -0
  355. PipelineManager/static/images/rabbitmq.png +0 -0
  356. PipelineManager/static/images/range.png +0 -0
  357. PipelineManager/static/images/redis.png +0 -0
  358. PipelineManager/static/images/redmine.png +0 -0
  359. PipelineManager/static/images/relp.png +0 -0
  360. PipelineManager/static/images/riak.png +0 -0
  361. PipelineManager/static/images/riemann.png +0 -0
  362. PipelineManager/static/images/rss.png +0 -0
  363. PipelineManager/static/images/ruby.png +0 -0
  364. PipelineManager/static/images/s3-sns-sqs.png +0 -0
  365. PipelineManager/static/images/s3.png +0 -0
  366. PipelineManager/static/images/salesforce.png +0 -0
  367. PipelineManager/static/images/sink.png +0 -0
  368. PipelineManager/static/images/sleep.png +0 -0
  369. PipelineManager/static/images/snmp.png +0 -0
  370. PipelineManager/static/images/snmptrap.png +0 -0
  371. PipelineManager/static/images/sns.png +0 -0
  372. PipelineManager/static/images/solr_http.png +0 -0
  373. PipelineManager/static/images/split.png +0 -0
  374. PipelineManager/static/images/sqlite.png +0 -0
  375. PipelineManager/static/images/sqs.png +0 -0
  376. PipelineManager/static/images/statsd.png +0 -0
  377. PipelineManager/static/images/stdin.png +0 -0
  378. PipelineManager/static/images/stdout.png +0 -0
  379. PipelineManager/static/images/stomp.png +0 -0
  380. PipelineManager/static/images/syslog.png +0 -0
  381. PipelineManager/static/images/syslog_pri.png +0 -0
  382. PipelineManager/static/images/tcp.png +0 -0
  383. PipelineManager/static/images/threats_classifier.png +0 -0
  384. PipelineManager/static/images/throttle.png +0 -0
  385. PipelineManager/static/images/timber.png +0 -0
  386. PipelineManager/static/images/tld.png +0 -0
  387. PipelineManager/static/images/translate.png +0 -0
  388. PipelineManager/static/images/truncate.png +0 -0
  389. PipelineManager/static/images/twitter.png +0 -0
  390. PipelineManager/static/images/udp.png +0 -0
  391. PipelineManager/static/images/unix.png +0 -0
  392. PipelineManager/static/images/urldecode.png +0 -0
  393. PipelineManager/static/images/useragent.png +0 -0
  394. PipelineManager/static/images/uuid.png +0 -0
  395. PipelineManager/static/images/varnishlog.png +0 -0
  396. PipelineManager/static/images/webhdfs.png +0 -0
  397. PipelineManager/static/images/websocket.png +0 -0
  398. PipelineManager/static/images/wmi.png +0 -0
  399. PipelineManager/static/images/wurfl_device_detection.png +0 -0
  400. PipelineManager/static/images/xml.png +0 -0
  401. PipelineManager/static/images/xmpp.png +0 -0
  402. PipelineManager/static/images/zabbix.png +0 -0
  403. PipelineManager/static/js/agent_inspect_modal.js +141 -0
  404. PipelineManager/static/js/agent_policies.js +3746 -0
  405. PipelineManager/static/js/agent_status_sse.js +166 -0
  406. PipelineManager/static/js/codemirror.min.js +1 -0
  407. PipelineManager/static/js/connections_table.js +551 -0
  408. PipelineManager/static/js/d3.v7.js +20625 -0
  409. PipelineManager/static/js/diff_modal.js +995 -0
  410. PipelineManager/static/js/expression_editor.js +291 -0
  411. PipelineManager/static/js/js-yaml.min.js +1 -0
  412. PipelineManager/static/js/logstashyml_guides.js +1063 -0
  413. PipelineManager/static/js/move_graph.js +577 -0
  414. PipelineManager/static/js/move_mode.js +559 -0
  415. PipelineManager/static/js/pipeline_editor.js +4102 -0
  416. PipelineManager/static/js/pipeline_graph_editor.js +3542 -0
  417. PipelineManager/static/js/pipeline_list.js +274 -0
  418. PipelineManager/static/js/pipeline_settings.js +121 -0
  419. PipelineManager/static/js/pipeline_text_editor.js +2088 -0
  420. PipelineManager/static/js/plugin_config_modal.js +2827 -0
  421. PipelineManager/static/js/policy_deploy_modal.js +1066 -0
  422. PipelineManager/static/js/show-hint.min.js +1 -0
  423. PipelineManager/static/js/sim_targets.js +380 -0
  424. PipelineManager/static/js/simple-comment-mode.js +56 -0
  425. PipelineManager/static/js/simulation_modal.js +1135 -0
  426. PipelineManager/static/js/simulation_results.js +2778 -0
  427. PipelineManager/static/js/stats_strip.js +231 -0
  428. PipelineManager/static/js/yaml.js +120 -0
  429. PipelineManager/system_policy_defaults.py +279 -0
  430. PipelineManager/templates/components/pipeline_editor/diff_modal.html +127 -0
  431. PipelineManager/templates/components/pipeline_editor/expression_editor.html +160 -0
  432. PipelineManager/templates/components/pipeline_editor/plugin_config_modal.html +119 -0
  433. PipelineManager/templates/components/pipeline_editor/plugin_modal.html +1016 -0
  434. PipelineManager/templates/components/pipeline_editor/simulation_modal.html +394 -0
  435. PipelineManager/templates/components/pipeline_editor/simulation_results.html +123 -0
  436. PipelineManager/templates/components/pipeline_editor/stats_strip.html +123 -0
  437. PipelineManager/templates/components/pipeline_editor/view_code_modal.html +133 -0
  438. PipelineManager/templates/components/pipeline_manager/agent_inspect_content.html +805 -0
  439. PipelineManager/templates/components/pipeline_manager/agent_inspect_modal.html +40 -0
  440. PipelineManager/templates/components/pipeline_manager/agent_policies.html +2421 -0
  441. PipelineManager/templates/components/pipeline_manager/change_policy_modal.html +210 -0
  442. PipelineManager/templates/components/pipeline_manager/collapsible_row.html +11 -0
  443. PipelineManager/templates/components/pipeline_manager/connection_modal.html +1361 -0
  444. PipelineManager/templates/components/pipeline_manager/keystore_modal.html +269 -0
  445. PipelineManager/templates/components/pipeline_manager/logstashyml_guides/centralized_pipeline_management.html +291 -0
  446. PipelineManager/templates/components/pipeline_manager/logstashyml_guides/default.html +166 -0
  447. PipelineManager/templates/components/pipeline_manager/mcp_modal.html +241 -0
  448. PipelineManager/templates/components/pipeline_manager/pipeline_list_content.html +586 -0
  449. PipelineManager/templates/components/pipeline_manager/policy_deploy_modal.html +238 -0
  450. PipelineManager/templates/pipeline_editor.html +1738 -0
  451. PipelineManager/templates/pipeline_graph_editor.html +99 -0
  452. PipelineManager/templates/pipeline_manager.html +584 -0
  453. PipelineManager/templates/pipeline_text_editor.html +350 -0
  454. PipelineManager/urls.py +99 -0
  455. SNMP/__init__.py +0 -0
  456. SNMP/ai_template_generation.py +232 -0
  457. SNMP/apps.py +9 -0
  458. SNMP/assets/device_template_generation/agents/snmp-profile-author.json +15 -0
  459. SNMP/assets/device_template_generation/skills/snmp-catalog.json +9 -0
  460. SNMP/data/authoring_instructions.md +65 -0
  461. SNMP/data/grounding/.gitignore +4 -0
  462. SNMP/data/grounding/build_grounding.py +35 -0
  463. SNMP/data/grounding/grounding.json +1 -0
  464. SNMP/data/grounding/sample_agent_payload.cisco2960x.json +2184 -0
  465. SNMP/data/mib_reference/std_bgp4_mib.json +43 -0
  466. SNMP/data/mib_reference/std_entity_sensors.json +28 -0
  467. SNMP/data/mib_reference/std_host_resources.json +32 -0
  468. SNMP/data/mib_reference/std_ospf_mib.json +55 -0
  469. SNMP/data/mib_reference/std_ucd_linux.json +27 -0
  470. SNMP/data/normalizers.json +103 -0
  471. SNMP/data/official_device_templates/arista_eos.json +24 -0
  472. SNMP/data/official_device_templates/aruba_wireless_controller.json +23 -0
  473. SNMP/data/official_device_templates/brocade_fc_switch.json +20 -0
  474. SNMP/data/official_device_templates/cisco_ios.json +21 -0
  475. SNMP/data/official_device_templates/default.json +13 -0
  476. SNMP/data/official_device_templates/dell_idrac.json +22 -0
  477. SNMP/data/official_device_templates/dell_x1026.json +16 -0
  478. SNMP/data/official_device_templates/dlink_dgs1210_switch.json +19 -0
  479. SNMP/data/official_device_templates/eastpower_ups.json +20 -0
  480. SNMP/data/official_device_templates/eaton_ups.json +22 -0
  481. SNMP/data/official_device_templates/epson_printer.json +18 -0
  482. SNMP/data/official_device_templates/geist_watchdog.json +20 -0
  483. SNMP/data/official_device_templates/generic_linux.json +18 -0
  484. SNMP/data/official_device_templates/generic_ont.json +18 -0
  485. SNMP/data/official_device_templates/generic_ups.json +16 -0
  486. SNMP/data/official_device_templates/hp_laserjet_mfp_m281cdw.json +18 -0
  487. SNMP/data/official_device_templates/hpe_nimble.json +17 -0
  488. SNMP/data/official_device_templates/huawei_ups.json +19 -0
  489. SNMP/data/official_device_templates/ingrasys_ups.json +19 -0
  490. SNMP/data/official_device_templates/isilon_onefs.json +22 -0
  491. SNMP/data/official_device_templates/mellanox_sx6036.json +20 -0
  492. SNMP/data/official_device_templates/netapp_7mode.json +22 -0
  493. SNMP/data/official_device_templates/palo_alto_firewall.json +21 -0
  494. SNMP/data/official_device_templates/phoenixtec_ups.json +18 -0
  495. SNMP/data/official_device_templates/ubiquiti_unifi_ap.json +19 -0
  496. SNMP/data/official_device_templates/ubiquiti_unifi_switch.json +18 -0
  497. SNMP/data/official_device_templates/ubiquiti_unifi_udm.json +19 -0
  498. SNMP/data/official_device_templates/versa_flexvnf_appliance.json +19 -0
  499. SNMP/data/official_profiles/arista_eos.json +16 -0
  500. SNMP/data/official_profiles/aruba_wireless_controller.json +145 -0
  501. SNMP/data/official_profiles/brocade_fibre_channel_switch_fibre_channel_ports.json +35 -0
  502. SNMP/data/official_profiles/brocade_fibre_channel_switch_name_server.json +23 -0
  503. SNMP/data/official_profiles/brocade_fibre_channel_switch_system_metrics.json +36 -0
  504. SNMP/data/official_profiles/cisco_cdp.json +26 -0
  505. SNMP/data/official_profiles/cisco_fans.json +18 -0
  506. SNMP/data/official_profiles/cisco_sensors.json +21 -0
  507. SNMP/data/official_profiles/cisco_system_metrics.json +40 -0
  508. SNMP/data/official_profiles/dell_idrac_cpu.json +19 -0
  509. SNMP/data/official_profiles/dell_idrac_fans.json +20 -0
  510. SNMP/data/official_profiles/dell_idrac_global_status.json +13 -0
  511. SNMP/data/official_profiles/dell_idrac_memory.json +20 -0
  512. SNMP/data/official_profiles/dell_idrac_power_supply.json +19 -0
  513. SNMP/data/official_profiles/dell_idrac_raid_controller.json +19 -0
  514. SNMP/data/official_profiles/dlink_dgs1210.json +15 -0
  515. SNMP/data/official_profiles/dlink_dgs1210_system_metrics.json +38 -0
  516. SNMP/data/official_profiles/eaton_ups.json +40 -0
  517. SNMP/data/official_profiles/geist_environment.json +50 -0
  518. SNMP/data/official_profiles/generic_arp.json +19 -0
  519. SNMP/data/official_profiles/generic_bgp.json +24 -0
  520. SNMP/data/official_profiles/generic_entity_psu.json +26 -0
  521. SNMP/data/official_profiles/generic_entity_sensor.json +22 -0
  522. SNMP/data/official_profiles/generic_host_system_metrics.json +68 -0
  523. SNMP/data/official_profiles/generic_interfaces.json +86 -0
  524. SNMP/data/official_profiles/generic_ip_addr.json +19 -0
  525. SNMP/data/official_profiles/generic_lldp.json +54 -0
  526. SNMP/data/official_profiles/generic_lm_sensors.json +37 -0
  527. SNMP/data/official_profiles/generic_mac_table.json +19 -0
  528. SNMP/data/official_profiles/generic_ont.json +88 -0
  529. SNMP/data/official_profiles/generic_ospf.json +21 -0
  530. SNMP/data/official_profiles/generic_printer_mib.json +48 -0
  531. SNMP/data/official_profiles/generic_rmon.json +38 -0
  532. SNMP/data/official_profiles/generic_system.json +17 -0
  533. SNMP/data/official_profiles/generic_ucd_system_metrics.json +63 -0
  534. SNMP/data/official_profiles/generic_ups_mib.json +154 -0
  535. SNMP/data/official_profiles/hpe_nimble_volumes.json +59 -0
  536. SNMP/data/official_profiles/huawei_ups.json +111 -0
  537. SNMP/data/official_profiles/isilon_performance.json +92 -0
  538. SNMP/data/official_profiles/isilon_protocols.json +77 -0
  539. SNMP/data/official_profiles/isilon_system.json +86 -0
  540. SNMP/data/official_profiles/mellanox_mlnx_os.json +15 -0
  541. SNMP/data/official_profiles/netapp_7mode_data_protection.json +106 -0
  542. SNMP/data/official_profiles/netapp_7mode_disks.json +51 -0
  543. SNMP/data/official_profiles/netapp_7mode_protocols.json +66 -0
  544. SNMP/data/official_profiles/netapp_7mode_system.json +92 -0
  545. SNMP/data/official_profiles/netapp_7mode_volumes.json +166 -0
  546. SNMP/data/official_profiles/paloalto_components.json +36 -0
  547. SNMP/data/official_profiles/paloalto_system.json +15 -0
  548. SNMP/data/official_profiles/traps.json +16 -0
  549. SNMP/data/official_profiles/ubiquiti_unifi_switch.json +18 -0
  550. SNMP/data/official_profiles/ubiquiti_unifi_switch_system.json +14 -0
  551. SNMP/data/official_profiles/ubiquiti_unifi_wireless.json +60 -0
  552. SNMP/data/official_profiles/versa_flexvnf.json +14 -0
  553. SNMP/data/schema.md +650 -0
  554. SNMP/data/schema_reference/snmp_field_schema.md +747 -0
  555. SNMP/data/snmp_template.json +629 -0
  556. SNMP/data/template_profile_context.md +3986 -0
  557. SNMP/inline_grounding.py +77 -0
  558. SNMP/management/__init__.py +1 -0
  559. SNMP/management/commands/__init__.py +1 -0
  560. SNMP/management/commands/generate_template_profile_context.py +272 -0
  561. SNMP/management/commands/load_test_snmp_data.py +240 -0
  562. SNMP/management/commands/sync_snmp_official_data.py +263 -0
  563. SNMP/management/commands/unload_test_snmp_data.py +77 -0
  564. SNMP/migrations/0001_initial.py +101 -0
  565. SNMP/migrations/0002_devicetemplate.py +34 -0
  566. SNMP/migrations/0003_remove_devicetemplate_type_remove_profile_type_and_more.py +31 -0
  567. SNMP/migrations/0004_device_device_template.py +19 -0
  568. SNMP/migrations/0005_devicetemplate_product_profile_product.py +23 -0
  569. SNMP/migrations/0006_alter_devicetemplate_model_and_more.py +28 -0
  570. SNMP/migrations/0007_remove_device_profiles.py +17 -0
  571. SNMP/migrations/0008_devicetemplate_type.py +18 -0
  572. SNMP/migrations/0009_alter_device_device_template.py +19 -0
  573. SNMP/migrations/0010_alter_device_device_template.py +19 -0
  574. SNMP/migrations/0011_network_namespace.py +18 -0
  575. SNMP/migrations/0012_profile_normalizers.py +18 -0
  576. SNMP/migrations/0013_snmpdeploymentstate.py +26 -0
  577. SNMP/migrations/0014_alter_snmpdeploymentstate_last_config_change.py +18 -0
  578. SNMP/migrations/0015_alter_snmpdeploymentstate_last_config_change.py +20 -0
  579. SNMP/migrations/0016_alter_snmpdeploymentstate_last_config_change.py +18 -0
  580. SNMP/migrations/0017_remove_network_logstash_name.py +17 -0
  581. SNMP/migrations/0018_add_official_key.py +39 -0
  582. SNMP/migrations/0019_network_namespace_from_device_template.py +18 -0
  583. SNMP/migrations/0020_device_hostname_alter_device_ip_address_and_more.py +27 -0
  584. SNMP/migrations/0021_device_building_device_latitude_device_longitude_and_more.py +43 -0
  585. SNMP/migrations/0022_alter_device_latitude_alter_device_longitude.py +23 -0
  586. SNMP/migrations/0023_network_agent_connection_network_deployment_mode_and_more.py +30 -0
  587. SNMP/migrations/0024_network_credential_mode.py +18 -0
  588. SNMP/migrations/0025_network_ssl_certificate_authorities.py +18 -0
  589. SNMP/migrations/__init__.py +0 -0
  590. SNMP/models.py +892 -0
  591. SNMP/network_map.py +660 -0
  592. SNMP/overview.py +394 -0
  593. SNMP/snmp_crud.py +6082 -0
  594. SNMP/snmp_grounding.py +146 -0
  595. SNMP/snmp_normalizers.py +594 -0
  596. SNMP/snmp_pipeline_generator.py +1658 -0
  597. SNMP/snmp_test.py +962 -0
  598. SNMP/static/css/snmp.css +33 -0
  599. SNMP/static/images/apc.png +0 -0
  600. SNMP/static/images/arista.png +0 -0
  601. SNMP/static/images/aruba.png +0 -0
  602. SNMP/static/images/brocade.png +0 -0
  603. SNMP/static/images/cisco.png +0 -0
  604. SNMP/static/images/dell.png +0 -0
  605. SNMP/static/images/dlink.png +0 -0
  606. SNMP/static/images/east.png +0 -0
  607. SNMP/static/images/eaton.png +0 -0
  608. SNMP/static/images/epson.png +0 -0
  609. SNMP/static/images/hauwei.png +0 -0
  610. SNMP/static/images/hp.png +0 -0
  611. SNMP/static/images/hpe.png +0 -0
  612. SNMP/static/images/ingrasys.png +0 -0
  613. SNMP/static/images/linux.png +0 -0
  614. SNMP/static/images/mellanox.png +0 -0
  615. SNMP/static/images/netapp.png +0 -0
  616. SNMP/static/images/paloalto.png +0 -0
  617. SNMP/static/images/phoenixtec.png +0 -0
  618. SNMP/static/images/ubiquiti.png +0 -0
  619. SNMP/static/images/unknown.png +0 -0
  620. SNMP/static/images/versa.png +0 -0
  621. SNMP/static/images/vertiv.png +0 -0
  622. SNMP/static/js/ai_device_template_modal.js +1116 -0
  623. SNMP/static/js/credentials_table.js +291 -0
  624. SNMP/static/js/devices_table.js +588 -0
  625. SNMP/static/js/discovered_devices.js +291 -0
  626. SNMP/static/js/network_map.js +1657 -0
  627. SNMP/static/js/networks_table.js +360 -0
  628. SNMP/static/js/onboarding.js +866 -0
  629. SNMP/static/js/overview.js +416 -0
  630. SNMP/static/js/snmp_changes_indicator.js +76 -0
  631. SNMP/static/js/snmp_commit_modal.js +39 -0
  632. SNMP/static/js/snmp_credentials_modal.js +217 -0
  633. SNMP/static/js/snmp_device_template_modal.js +669 -0
  634. SNMP/static/js/snmp_device_visual_preview.js +1707 -0
  635. SNMP/static/js/snmp_devices_modal.js +912 -0
  636. SNMP/static/js/snmp_diff_modal.js +1559 -0
  637. SNMP/static/js/snmp_network_modal.js +940 -0
  638. SNMP/static/js/snmp_profile_modal.js +1212 -0
  639. SNMP/static/js/snmp_profile_modal_helpers.js +17 -0
  640. SNMP/static/js/snmp_test.js +538 -0
  641. SNMP/templates/Credentials.html +325 -0
  642. SNMP/templates/DeviceTemplates.html +1059 -0
  643. SNMP/templates/Devices.html +274 -0
  644. SNMP/templates/Networks.html +469 -0
  645. SNMP/templates/Onboarding.html +521 -0
  646. SNMP/templates/Overview.html +227 -0
  647. SNMP/templates/components/ai_device_template_modal.html +46 -0
  648. SNMP/templates/components/ai_generate_template_content.html +224 -0
  649. SNMP/templates/components/device_template_profile_modal.html +60 -0
  650. SNMP/templates/components/discovered_devices_content.html +86 -0
  651. SNMP/templates/components/discovered_devices_modal.html +43 -0
  652. SNMP/templates/components/gmaps_latlon_modal.html +93 -0
  653. SNMP/templates/components/network_map.html +110 -0
  654. SNMP/templates/components/snmp_commit_modal.html +53 -0
  655. SNMP/templates/components/snmp_credentials_modal.html +189 -0
  656. SNMP/templates/components/snmp_device_modal.html +6 -0
  657. SNMP/templates/components/snmp_device_template_modal.html +129 -0
  658. SNMP/templates/components/snmp_device_visual_preview.html +347 -0
  659. SNMP/templates/components/snmp_devices_modal.html +330 -0
  660. SNMP/templates/components/snmp_diff_modal.html +148 -0
  661. SNMP/templates/components/snmp_network_modal.html +380 -0
  662. SNMP/templates/components/snmp_profile_modal.html +147 -0
  663. SNMP/templates/components/snmp_test_modal.html +398 -0
  664. SNMP/templatetags/__init__.py +0 -0
  665. SNMP/templatetags/snmp_extras.py +17 -0
  666. SNMP/urls.py +94 -0
  667. SNMP/views.py +913 -0
  668. Site/__init__.py +0 -0
  669. Site/apps.py +9 -0
  670. Site/migrations/__init__.py +0 -0
  671. Site/product_ca_views.py +41 -0
  672. Site/static/images/ElasticIcon.png +0 -0
  673. Site/static/images/LoggyIcon.png +0 -0
  674. Site/static/images/LoggyWizardIcon.png +0 -0
  675. Site/static/images/LogstashAgentIcon.png +0 -0
  676. Site/static/images/LogstashIcon.png +0 -0
  677. Site/static/js/base.js +192 -0
  678. Site/static/js/marked.min.js +69 -0
  679. Site/templates/base.html +52 -0
  680. Site/templates/error.html +65 -0
  681. Site/templates/home.html +148 -0
  682. Site/templates/navigation.html +530 -0
  683. Site/templates/popup.html +251 -0
  684. Site/templatetags/__init__.py +0 -0
  685. Site/templatetags/custom_filters.py +36 -0
  686. Site/urls.py +21 -0
  687. Site/views.py +200 -0
  688. Utilities/__init__.py +0 -0
  689. Utilities/apps.py +9 -0
  690. Utilities/data/grok-patterns/LICENSE +202 -0
  691. Utilities/data/grok-patterns/ecs-v1/aws +33 -0
  692. Utilities/data/grok-patterns/ecs-v1/bacula +53 -0
  693. Utilities/data/grok-patterns/ecs-v1/bind +13 -0
  694. Utilities/data/grok-patterns/ecs-v1/bro +30 -0
  695. Utilities/data/grok-patterns/ecs-v1/exim +26 -0
  696. Utilities/data/grok-patterns/ecs-v1/firewalls +111 -0
  697. Utilities/data/grok-patterns/ecs-v1/grok-patterns +95 -0
  698. Utilities/data/grok-patterns/ecs-v1/haproxy +40 -0
  699. Utilities/data/grok-patterns/ecs-v1/httpd +17 -0
  700. Utilities/data/grok-patterns/ecs-v1/java +34 -0
  701. Utilities/data/grok-patterns/ecs-v1/junos +13 -0
  702. Utilities/data/grok-patterns/ecs-v1/linux-syslog +16 -0
  703. Utilities/data/grok-patterns/ecs-v1/maven +1 -0
  704. Utilities/data/grok-patterns/ecs-v1/mcollective +4 -0
  705. Utilities/data/grok-patterns/ecs-v1/mongodb +7 -0
  706. Utilities/data/grok-patterns/ecs-v1/nagios +124 -0
  707. Utilities/data/grok-patterns/ecs-v1/postgresql +2 -0
  708. Utilities/data/grok-patterns/ecs-v1/rails +13 -0
  709. Utilities/data/grok-patterns/ecs-v1/redis +3 -0
  710. Utilities/data/grok-patterns/ecs-v1/ruby +2 -0
  711. Utilities/data/grok-patterns/ecs-v1/squid +6 -0
  712. Utilities/data/grok-patterns/ecs-v1/zeek +33 -0
  713. Utilities/data/grok-patterns/legacy/aws +14 -0
  714. Utilities/data/grok-patterns/legacy/bacula +50 -0
  715. Utilities/data/grok-patterns/legacy/bind +3 -0
  716. Utilities/data/grok-patterns/legacy/bro +13 -0
  717. Utilities/data/grok-patterns/legacy/exim +19 -0
  718. Utilities/data/grok-patterns/legacy/firewalls +91 -0
  719. Utilities/data/grok-patterns/legacy/grok-patterns +95 -0
  720. Utilities/data/grok-patterns/legacy/haproxy +39 -0
  721. Utilities/data/grok-patterns/legacy/httpd +15 -0
  722. Utilities/data/grok-patterns/legacy/java +17 -0
  723. Utilities/data/grok-patterns/legacy/junos +9 -0
  724. Utilities/data/grok-patterns/legacy/linux-syslog +16 -0
  725. Utilities/data/grok-patterns/legacy/maven +1 -0
  726. Utilities/data/grok-patterns/legacy/mcollective +1 -0
  727. Utilities/data/grok-patterns/legacy/mcollective-patterns +4 -0
  728. Utilities/data/grok-patterns/legacy/mongodb +7 -0
  729. Utilities/data/grok-patterns/legacy/nagios +124 -0
  730. Utilities/data/grok-patterns/legacy/postgresql +3 -0
  731. Utilities/data/grok-patterns/legacy/rails +13 -0
  732. Utilities/data/grok-patterns/legacy/redis +3 -0
  733. Utilities/data/grok-patterns/legacy/ruby +2 -0
  734. Utilities/data/grok-patterns/legacy/squid +4 -0
  735. Utilities/dissect.py +302 -0
  736. Utilities/grok.py +412 -0
  737. Utilities/migrations/__init__.py +0 -0
  738. Utilities/static/css/debugger_editor.css +88 -0
  739. Utilities/static/js/debugger_editor.js +93 -0
  740. Utilities/static/js/grok_debugger.js +131 -0
  741. Utilities/templates/dissect_debugger.html +95 -0
  742. Utilities/templates/grok_debugger.html +99 -0
  743. Utilities/urls.py +14 -0
  744. Utilities/views.py +363 -0
  745. logstashui-0.5.5.dev0.dist-info/METADATA +333 -0
  746. logstashui-0.5.5.dev0.dist-info/RECORD +762 -0
  747. logstashui-0.5.5.dev0.dist-info/WHEEL +4 -0
  748. logstashui-0.5.5.dev0.dist-info/entry_points.txt +2 -0
  749. logstashui-0.5.5.dev0.dist-info/licenses/LICENSE.txt +93 -0
  750. logstashui-0.5.5.dev0.dist-info/licenses/NOTICE.txt +2772 -0
  751. theme/__init__.py +0 -0
  752. theme/apps.py +9 -0
  753. theme/package-lock.json +6 -0
  754. theme/static/css/dist/styles.css +2 -0
  755. theme/static/images/favicon.ico +0 -0
  756. theme/static_src/.gitignore +1 -0
  757. theme/static_src/package-lock.json +1930 -0
  758. theme/static_src/package.json +26 -0
  759. theme/static_src/postcss.config.js +7 -0
  760. theme/static_src/src/styles.css +38 -0
  761. theme/static_src/tailwind.config.js +43 -0
  762. theme/templates/base.html +32 -0
@@ -0,0 +1,1707 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License;
4
+ * you may not use this file except in compliance with the Elastic License.
5
+ */
6
+
7
+ // Device Visual Preview - Handle expand/collapse and data fetching
8
+
9
+ // Toggle device preview row
10
+ function toggleDevicePreview(deviceId) {
11
+ const previewRow = document.getElementById(`device-preview-${deviceId}`);
12
+ const chevron = document.getElementById(`chevron-${deviceId}`);
13
+ const contentDiv = document.getElementById(`device-preview-content-${deviceId}`);
14
+
15
+ if (previewRow.classList.contains('hidden')) {
16
+ // Expand the row
17
+ previewRow.classList.remove('hidden');
18
+ chevron.classList.add('rotate-180');
19
+
20
+ // Always fetch fresh data from Elasticsearch on every expand
21
+ const indicator = previewRow.querySelector('.htmx-indicator');
22
+ indicator.classList.remove('hidden');
23
+ contentDiv.innerHTML = '';
24
+
25
+ fetch(`/SNMP/GetDeviceVisualization/${deviceId}/`)
26
+ .then(response => response.json())
27
+ .then(data => {
28
+ indicator.classList.add('hidden');
29
+
30
+ if (data.success && !data.no_data) {
31
+ renderDevicePreview(deviceId, data.device, data.visualizations);
32
+ } else if (data.no_data) {
33
+ contentDiv.innerHTML = `
34
+ <div class="flex flex-col items-center text-center py-8 px-6 gap-3">
35
+ <div class="inline-flex items-center justify-center w-12 h-12 bg-blue-600/20 rounded-full">
36
+ <svg class="w-6 h-6 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
37
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
38
+ d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
39
+ </svg>
40
+ </div>
41
+ <p class="text-white font-medium">We aren&apos;t seeing any results in Elasticsearch yet.</p>
42
+ <p class="text-sm text-gray-400">If you have already deployed this configuration and still see no results, check your Logstash logs.</p>
43
+ </div>
44
+ `;
45
+ } else {
46
+ contentDiv.innerHTML = `
47
+ <div class="text-center text-red-400 py-4">
48
+ <p>Error loading device data: ${data.error}</p>
49
+ </div>
50
+ `;
51
+ }
52
+ })
53
+ .catch(error => {
54
+ indicator.classList.add('hidden');
55
+ contentDiv.innerHTML = `
56
+ <div class="text-center text-red-400 py-4">
57
+ <p>Error loading device data: ${error.message}</p>
58
+ </div>
59
+ `;
60
+ });
61
+ } else {
62
+ // Collapse the row
63
+ previewRow.classList.add('hidden');
64
+ chevron.classList.remove('rotate-180');
65
+ }
66
+ }
67
+
68
+ // Render device preview content
69
+ function renderDevicePreview(deviceId, device, visualizations) {
70
+ const contentDiv = document.getElementById(`device-preview-content-${deviceId}`);
71
+ const template = document.getElementById('device-preview-template');
72
+
73
+ if (!template) {
74
+ console.error('Device preview template not found');
75
+ return;
76
+ }
77
+
78
+ // Clone the template
79
+ const clone = template.content.cloneNode(true);
80
+
81
+ // Populate device configuration
82
+ clone.querySelector('.device-port').textContent = device.port;
83
+ clone.querySelector('.device-timeout').textContent = `${device.timeout}ms`;
84
+ clone.querySelector('.device-retries').textContent = device.retries;
85
+
86
+ // Populate credential info
87
+ if (device.credential) {
88
+ clone.querySelector('.credential-name').textContent = device.credential.name;
89
+ clone.querySelector('.credential-version').textContent = `SNMPv${device.credential.version}`;
90
+ } else {
91
+ clone.querySelector('.credential-name').textContent = 'None';
92
+ clone.querySelector('.credential-version').textContent = '-';
93
+ }
94
+
95
+ // Populate profiles
96
+ const profilesList = clone.querySelector('.device-profiles-list');
97
+ if (device.profiles && device.profiles.length > 0) {
98
+ device.profiles.forEach(profile => {
99
+ const profileBadge = document.createElement('div');
100
+ profileBadge.className = 'bg-blue-600/20 text-blue-300 px-3 py-1 rounded-md text-sm flex items-center gap-2 cursor-pointer hover:bg-blue-600/40 transition-colors';
101
+ profileBadge.title = 'Click to view profile';
102
+
103
+ // Check if official profile (ends with .json)
104
+ const isOfficial = profile.name.endsWith('.json');
105
+
106
+ // Create friendly display name
107
+ const displayName = profile.display_name || formatDisplayName(profile.name);
108
+
109
+ // Build metadata line with vendor and product
110
+ let metadata = '';
111
+ if (profile.vendor || profile.product) {
112
+ const parts = [];
113
+ if (profile.vendor) parts.push(escapeHtml(profile.vendor));
114
+ if (profile.product) parts.push(escapeHtml(profile.product));
115
+ metadata = `<div class="text-xs text-gray-400">${parts.join(' • ')}</div>`;
116
+ }
117
+
118
+ // Official star badge
119
+ const starBadge = isOfficial ? `
120
+ <svg class="w-3 h-3 text-yellow-400 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
121
+ <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
122
+ </svg>
123
+ ` : '';
124
+
125
+ profileBadge.innerHTML = `
126
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
127
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
128
+ </svg>
129
+ <div class="flex-1">
130
+ <div class="font-medium flex items-center gap-1.5">
131
+ ${starBadge}
132
+ ${escapeHtml(displayName)}
133
+ </div>
134
+ ${metadata}
135
+ </div>
136
+ `;
137
+
138
+ // Open the profile modal on click.
139
+ // Official profiles in the DB carry a ".json" suffix; GetOfficialProfile expects it stripped.
140
+ // Official profiles open in view-only mode; user profiles open in edit mode.
141
+ const modalName = isOfficial ? profile.name.replace(/\.json$/, '') : profile.name;
142
+ profileBadge.addEventListener('click', () => {
143
+ if (typeof openProfileModal === 'function') {
144
+ openProfileModal(modalName, isOfficial, /* viewMode= */ isOfficial);
145
+ }
146
+ });
147
+
148
+ profilesList.appendChild(profileBadge);
149
+ });
150
+ } else {
151
+ profilesList.innerHTML = '<span class="text-gray-400 italic">No profiles assigned</span>';
152
+ }
153
+
154
+ // Populate metrics if available
155
+ if (visualizations && visualizations.metrics) {
156
+ const metrics = visualizations.metrics;
157
+
158
+ // Uptime - convert from hundredths of seconds to human-readable format
159
+ if (metrics.Uptime !== undefined) {
160
+ clone.querySelector('.metric-uptime').textContent = formatUptime(metrics.Uptime);
161
+ }
162
+ } else {
163
+ // Hide metrics section if no visualization data available
164
+ const metricsSection = clone.querySelector('.device-metrics-section');
165
+ if (metricsSection) {
166
+ metricsSection.style.display = 'none';
167
+ }
168
+ }
169
+
170
+ // Clear and append the populated template
171
+ contentDiv.innerHTML = '';
172
+ contentDiv.appendChild(clone);
173
+
174
+ // Render charts after DOM insertion (charts need to be in DOM to render)
175
+ if (visualizations && visualizations.metrics) {
176
+ const metrics = visualizations.metrics;
177
+
178
+ // Render CPU chart
179
+ const cpuChartCanvas = contentDiv.querySelector('.metric-cpu-chart');
180
+ if (metrics.CPU && metrics.CPUTime && metrics.CPU.length > 0) {
181
+ renderMetricChart(
182
+ cpuChartCanvas,
183
+ metrics.CPUTime,
184
+ metrics.CPU,
185
+ 'CPU Usage (%)',
186
+ 'rgba(59, 130, 246, 1)', // Blue
187
+ 'rgba(59, 130, 246, 0.1)'
188
+ );
189
+ } else if (cpuChartCanvas) {
190
+ // Show message when CPU data is not available
191
+ const chartContainer = cpuChartCanvas.parentElement;
192
+ chartContainer.innerHTML = '<div class="flex items-center justify-center h-full text-gray-400 text-sm italic">No CPU usage data collected for this device</div>';
193
+ }
194
+
195
+ // Render Memory chart
196
+ const memoryChartCanvas = contentDiv.querySelector('.metric-memory-chart');
197
+ if (metrics.Memory && metrics.MemoryTime && metrics.Memory.length > 0) {
198
+ // hrStorageRam counts reclaimable cache/buffers, so it reads higher than the
199
+ // normalizer-derived field. Label it rather than passing it off as the same.
200
+ const memoryLabel = metrics.MemorySource === 'hrStorageRam'
201
+ ? 'Memory Usage (%) — incl. cache/buffers'
202
+ : 'Memory Usage (%)';
203
+ renderMetricChart(
204
+ memoryChartCanvas,
205
+ metrics.MemoryTime,
206
+ metrics.Memory,
207
+ memoryLabel,
208
+ 'rgba(16, 185, 129, 1)', // Green
209
+ 'rgba(16, 185, 129, 0.1)'
210
+ );
211
+ } else if (memoryChartCanvas) {
212
+ // Show message when Memory data is not available
213
+ const chartContainer = memoryChartCanvas.parentElement;
214
+ chartContainer.innerHTML = '<div class="flex items-center justify-center h-full text-gray-400 text-sm italic">No memory usage data collected for this device</div>';
215
+ }
216
+ }
217
+
218
+ // Render sensors / fans / power supplies — always show the row if any one of the
219
+ // three has data; show a "not detecting" placeholder for the others.
220
+ {
221
+ const sensorsSection = contentDiv.querySelector('.device-sensors-section');
222
+ const sensorsContainer = contentDiv.querySelector('.sensors-container');
223
+ const fansContainer = contentDiv.querySelector('.fans-container');
224
+ const psuContainer = contentDiv.querySelector('.power-supplies-container');
225
+
226
+ const sensorsArray = (visualizations && visualizations.sensors && visualizations.sensors.sensors) || [];
227
+ const fansArray = (visualizations && visualizations.fans && visualizations.fans.fans) || [];
228
+ const psuArray = (visualizations && visualizations.power_supplies && visualizations.power_supplies.power_supplies) || [];
229
+
230
+ const hasSensors = sensorsArray.length > 0;
231
+ const hasFans = fansArray.length > 0;
232
+ const hasPsu = psuArray.length > 0;
233
+
234
+ const noDataMsg = (label) =>
235
+ `<div class="col-span-full flex items-center justify-center h-24 text-gray-400 text-sm italic">No ${label} data collected for this device</div>`;
236
+
237
+ if (hasSensors || hasFans || hasPsu) {
238
+ sensorsSection.style.display = 'grid';
239
+
240
+ if (hasSensors) {
241
+ sensorsContainer.innerHTML = '';
242
+ sensorsArray.forEach(sensor => sensorsContainer.appendChild(createSensorCard(sensor)));
243
+ } else {
244
+ sensorsContainer.innerHTML = noDataMsg('temperature sensor');
245
+ }
246
+
247
+ if (hasFans) {
248
+ fansContainer.innerHTML = '';
249
+ fansArray.forEach(fan => fansContainer.appendChild(createFanCard(fan)));
250
+ } else {
251
+ fansContainer.innerHTML = noDataMsg('fan');
252
+ }
253
+
254
+ if (hasPsu) {
255
+ psuContainer.innerHTML = '';
256
+ psuArray.forEach(psu => psuContainer.appendChild(createPowerSupplyCard(psu)));
257
+ } else {
258
+ psuContainer.innerHTML = noDataMsg('power supply');
259
+ }
260
+ }
261
+ }
262
+
263
+ // Render interfaces if available
264
+ if (visualizations && visualizations.interfaces) {
265
+ const interfacesSection = contentDiv.querySelector('.device-interfaces-section');
266
+ const interfacesContainer = contentDiv.querySelector('.interfaces-container');
267
+
268
+ const interfacesArray = visualizations.interfaces.interfaces || [];
269
+
270
+ if (interfacesArray.length > 0 && interfacesSection && interfacesContainer) {
271
+ interfacesSection.style.display = 'block';
272
+ interfacesContainer.innerHTML = '';
273
+
274
+ // Sort interfaces by index
275
+ const sortedInterfaces = interfacesArray.sort((a, b) => {
276
+ const indexA = parseInt(a.index) || 0;
277
+ const indexB = parseInt(b.index) || 0;
278
+ return indexA - indexB;
279
+ });
280
+
281
+ sortedInterfaces.forEach(iface => {
282
+ const interfaceCard = createInterfaceCard(iface);
283
+ interfacesContainer.appendChild(interfaceCard);
284
+ });
285
+ }
286
+ }
287
+
288
+ // Render printer supplies if available
289
+ if (visualizations && visualizations.printer_supplies) {
290
+ const suppliesSection = contentDiv.querySelector('.device-printer-supplies-section');
291
+ const suppliesContainer = contentDiv.querySelector('.printer-supplies-container');
292
+ const suppliesArray = visualizations.printer_supplies.supplies || [];
293
+
294
+ if (suppliesArray.length > 0 && suppliesSection && suppliesContainer) {
295
+ suppliesSection.style.display = 'block';
296
+ suppliesContainer.innerHTML = '';
297
+
298
+ suppliesArray.forEach(supply => {
299
+ const supplyCard = createPrinterSupplyCard(supply);
300
+ suppliesContainer.appendChild(supplyCard);
301
+ });
302
+ }
303
+ }
304
+
305
+ // Render filesystems if available
306
+ if (visualizations && visualizations.filesystems) {
307
+ const fsSection = contentDiv.querySelector('.device-filesystems-section');
308
+ const fsContainer = contentDiv.querySelector('.filesystems-container');
309
+ const fsArray = visualizations.filesystems.filesystems || [];
310
+
311
+ if (fsArray.length > 0 && fsSection && fsContainer) {
312
+ fsSection.style.display = 'block';
313
+ fsContainer.innerHTML = '';
314
+
315
+ fsArray.forEach(fs => {
316
+ const fsCard = createFilesystemCard(fs);
317
+ fsContainer.appendChild(fsCard);
318
+ });
319
+ }
320
+ }
321
+
322
+ // Render wireless radios if available
323
+ if (visualizations && visualizations.wireless_radios) {
324
+ const radiosSection = contentDiv.querySelector('.device-wireless-radios-section');
325
+ const radiosContainer = contentDiv.querySelector('.wireless-radios-container');
326
+ const radiosArray = visualizations.wireless_radios.radios || [];
327
+
328
+ if (radiosArray.length > 0 && radiosSection && radiosContainer) {
329
+ radiosSection.style.display = 'block';
330
+ radiosContainer.innerHTML = '';
331
+
332
+ radiosArray.forEach(radio => {
333
+ const radioCard = createWirelessRadioCard(radio);
334
+ radiosContainer.appendChild(radioCard);
335
+ });
336
+ }
337
+ }
338
+
339
+ // Render wireless APs if available
340
+ if (visualizations && visualizations.wireless_aps) {
341
+ const apsSection = contentDiv.querySelector('.device-wireless-aps-section');
342
+ const apsContainer = contentDiv.querySelector('.wireless-aps-container');
343
+ const apsSummary = contentDiv.querySelector('.wireless-aps-summary');
344
+ const apsArray = visualizations.wireless_aps.aps || [];
345
+ const upCount = visualizations.wireless_aps.up_count || 0;
346
+ const downCount = visualizations.wireless_aps.down_count || 0;
347
+
348
+ if (apsArray.length > 0 && apsSection && apsContainer) {
349
+ apsSection.style.display = 'block';
350
+ apsContainer.innerHTML = '';
351
+
352
+ if (apsSummary) {
353
+ const parts = [];
354
+ if (upCount > 0) parts.push(`<span class="text-emerald-400">${upCount} up</span>`);
355
+ if (downCount > 0) parts.push(`<span class="text-red-400">${downCount} down</span>`);
356
+ const clientCount = visualizations.wireless_aps.client_count;
357
+ if (clientCount != null) parts.push(`${clientCount} clients`);
358
+ apsSummary.innerHTML = parts.length ? `— ${parts.join(', ')}` : `— ${apsArray.length} total`;
359
+ }
360
+
361
+ apsArray.forEach(ap => {
362
+ apsContainer.appendChild(createAPCard(ap));
363
+ });
364
+ }
365
+ }
366
+
367
+ // Render RAID volumes if available
368
+ if (visualizations && visualizations.raid_volumes) {
369
+ const raidSection = contentDiv.querySelector('.device-raid-volumes-section');
370
+ const raidContainer = contentDiv.querySelector('.raid-volumes-container');
371
+ const raidArray = visualizations.raid_volumes.raid_volumes || [];
372
+
373
+ if (raidArray.length > 0 && raidSection && raidContainer) {
374
+ raidSection.style.display = 'block';
375
+ raidContainer.innerHTML = '';
376
+
377
+ raidArray.forEach(vol => {
378
+ raidContainer.appendChild(createRaidVolumeCard(vol));
379
+ });
380
+ }
381
+ }
382
+
383
+ // Render disk grid if available
384
+ if (visualizations && visualizations.disks) {
385
+ const disksSection = contentDiv.querySelector('.device-disks-section');
386
+ const disksContainer = contentDiv.querySelector('.disks-container');
387
+ const disksSummary = contentDiv.querySelector('.device-disks-summary');
388
+ const disksArray = visualizations.disks.disks || [];
389
+
390
+ if (disksArray.length > 0 && disksSection && disksContainer) {
391
+ disksSection.style.display = 'block';
392
+ disksContainer.innerHTML = '';
393
+
394
+ if (disksSummary) {
395
+ const stateCount = {};
396
+ disksArray.forEach(d => {
397
+ const s = d.state || 'UNKNOWN';
398
+ stateCount[s] = (stateCount[s] || 0) + 1;
399
+ });
400
+ const parts = [];
401
+ if (stateCount['ACTIVE']) parts.push(`<span class="text-emerald-400">${stateCount['ACTIVE']} active</span>`);
402
+ if (stateCount['SPARE']) parts.push(`<span class="text-blue-400">${stateCount['SPARE']} spare</span>`);
403
+ if (stateCount['RECONSTRUCTING'])parts.push(`<span class="text-yellow-400">${stateCount['RECONSTRUCTING']} rebuilding</span>`);
404
+ if (stateCount['FAILED']) parts.push(`<span class="text-red-400">${stateCount['FAILED']} failed</span>`);
405
+ disksSummary.innerHTML = parts.length ? `— ${parts.join(', ')}` : `— ${disksArray.length} total`;
406
+ }
407
+
408
+ disksArray.forEach(disk => {
409
+ disksContainer.appendChild(createDiskCard(disk));
410
+ });
411
+ }
412
+ }
413
+
414
+ // Render neighbors if available
415
+ if (visualizations && visualizations.neighbors) {
416
+ const neighborsSection = contentDiv.querySelector('.device-neighbors-section');
417
+ const neighborsContainer = contentDiv.querySelector('.neighbors-container');
418
+ const neighborsArray = visualizations.neighbors.neighbors || [];
419
+
420
+ if (neighborsArray.length > 0 && neighborsSection && neighborsContainer) {
421
+ neighborsSection.style.display = 'block';
422
+ neighborsContainer.innerHTML = '';
423
+
424
+ neighborsArray.forEach(neighbor => {
425
+ const neighborCard = createNeighborCard(neighbor);
426
+ neighborsContainer.appendChild(neighborCard);
427
+ });
428
+ }
429
+ }
430
+
431
+ // Render CPU cores if available
432
+ if (visualizations && visualizations.cpu_cores) {
433
+ const cpuCoresSection = contentDiv.querySelector('.device-cpu-cores-section');
434
+ const cpuCoresContainer = contentDiv.querySelector('.cpu-cores-container');
435
+ const coresArray = visualizations.cpu_cores.cores || [];
436
+
437
+ if (coresArray.length > 0 && cpuCoresSection && cpuCoresContainer) {
438
+ cpuCoresSection.style.display = 'block';
439
+ cpuCoresContainer.innerHTML = '';
440
+
441
+ coresArray.forEach((core, i) => {
442
+ const coreCard = createCpuCoreCard(core, i);
443
+ cpuCoresContainer.appendChild(coreCard);
444
+ });
445
+ }
446
+ }
447
+
448
+ // Render UPS battery health row if data is present.
449
+ // Show the section when any meaningful field is available — battery_status or
450
+ // output_source alone are enough; capacity_pct may be null/unsupported on some
451
+ // firmware (e.g. Huawei UPS5000 via generic UPS-MIB returns -1, sanitized to
452
+ // null by the backend) and individual tiles will show "--" in that case.
453
+ if (visualizations && visualizations.ups) {
454
+ const ups = visualizations.ups;
455
+ const hasUpsData = ups.battery_status != null
456
+ || ups.output_source != null
457
+ || (ups.battery_capacity_pct != null && ups.battery_capacity_pct >= 0);
458
+
459
+ if (hasUpsData) {
460
+ const upsSection = contentDiv.querySelector('.device-ups-section');
461
+ const upsTrendSection = contentDiv.querySelector('.device-ups-trend-section');
462
+ if (upsSection) upsSection.style.display = 'grid';
463
+
464
+ // --- Output Source ---
465
+ const sourceEl = contentDiv.querySelector('.ups-output-source');
466
+ if (sourceEl && ups.output_source != null) {
467
+ const { label, cls } = upsOutputSourceInfo(ups.output_source);
468
+ sourceEl.textContent = label;
469
+ sourceEl.className = `ups-output-source text-sm font-bold text-center ${cls}`;
470
+ }
471
+
472
+ // --- Battery Status ---
473
+ const statusEl = contentDiv.querySelector('.ups-battery-status');
474
+ if (statusEl && ups.battery_status != null) {
475
+ const { label, cls } = upsBatteryStatusInfo(ups.battery_status);
476
+ statusEl.textContent = label;
477
+ statusEl.className = `ups-battery-status text-sm font-bold text-center ${cls}`;
478
+ }
479
+
480
+ // --- Battery Capacity gauge ---
481
+ // null means the device doesn't report it (e.g. UPS-MIB returns -1, sanitized
482
+ // by the backend); show "--" rather than a misleading "0%".
483
+ const capacityPct = ups.battery_capacity_pct; // may be null
484
+ const capacityEl = contentDiv.querySelector('.ups-battery-capacity-pct');
485
+ const capacityBar = contentDiv.querySelector('.ups-battery-capacity-bar');
486
+ if (capacityEl) capacityEl.textContent = capacityPct != null ? `${capacityPct}%` : '--';
487
+ if (capacityBar) {
488
+ if (capacityPct != null) {
489
+ const barColor = capacityPct <= 20 ? 'bg-red-500'
490
+ : capacityPct <= 40 ? 'bg-yellow-500'
491
+ : 'bg-green-500';
492
+ capacityBar.className = `ups-battery-capacity-bar h-full ${barColor} rounded-full transition-all duration-500`;
493
+ capacityBar.style.width = `${capacityPct}%`;
494
+ } else {
495
+ capacityBar.className = 'ups-battery-capacity-bar h-full bg-base-300 rounded-full';
496
+ capacityBar.style.width = '0%';
497
+ }
498
+ }
499
+
500
+ // --- Runtime Remaining ---
501
+ // Some UPS firmware (e.g. Eastpower iStars) reports 0 for
502
+ // upsEstimatedMinutesRemaining when on AC normal power — the runtime
503
+ // estimate is only computed while actually running on battery.
504
+ // Show "N/A" in that case rather than a misleading red "0m".
505
+ const runtimeEl = contentDiv.querySelector('.ups-runtime');
506
+ if (runtimeEl && ups.battery_time_remaining_minutes != null) {
507
+ const mins = ups.battery_time_remaining_minutes;
508
+ if (mins === 0 && ups.output_source === 'normal') {
509
+ runtimeEl.textContent = 'N/A';
510
+ runtimeEl.className = 'ups-runtime text-xl font-bold text-center text-base-content/40';
511
+ } else {
512
+ const runtimeText = mins >= 60
513
+ ? `${Math.floor(mins / 60)}h ${mins % 60}m`
514
+ : `${mins}m`;
515
+ const runtimeColor = mins < 15 ? 'text-red-400'
516
+ : mins < 30 ? 'text-yellow-400'
517
+ : 'text-green-400';
518
+ runtimeEl.textContent = runtimeText;
519
+ runtimeEl.className = `ups-runtime text-xl font-bold text-center ${runtimeColor}`;
520
+ }
521
+ }
522
+
523
+ // --- Active Alarms ---
524
+ const alarmsEl = contentDiv.querySelector('.ups-alarms');
525
+ if (alarmsEl && ups.alarms_present != null) {
526
+ const count = ups.alarms_present;
527
+ alarmsEl.textContent = String(count);
528
+ const alarmColor = count > 0 ? 'text-red-400' : 'text-green-400';
529
+ alarmsEl.className = `ups-alarms text-3xl font-bold text-center ${alarmColor}`;
530
+ }
531
+
532
+ // --- Capacity Trend chart ---
533
+ if (upsTrendSection && ups.CapacityTrend && ups.CapacityTrend.length > 0) {
534
+ upsTrendSection.style.display = 'block';
535
+ // renderMetricChart multiplies values by 100 (expects 0-1 fractions)
536
+ const scaledTrend = ups.CapacityTrend.map(v => v / 100);
537
+ const chartDiv = contentDiv.querySelector('.ups-capacity-chart');
538
+ if (chartDiv) {
539
+ renderMetricChart(
540
+ chartDiv,
541
+ ups.CapacityTrendTime,
542
+ scaledTrend,
543
+ 'Battery Capacity (%)',
544
+ 'rgba(16, 185, 129, 1)', // emerald
545
+ 'rgba(16, 185, 129, 0.1)'
546
+ );
547
+ }
548
+ }
549
+ }
550
+ }
551
+ }
552
+
553
+ // Abbreviate common interface name prefixes so port numbers are visible in compact cards.
554
+ // The full name is always shown in the hover tooltip.
555
+ function abbreviateIfaceName(name) {
556
+ if (!name) return name;
557
+ const prefixes = [
558
+ // Longest/most-specific matches first to avoid partial replacements
559
+ [/^TenGigabitEthernet/i, 'Te'],
560
+ [/^HundredGigE/i, 'Hu'],
561
+ [/^TwentyFiveGigE/i, '25G'],
562
+ [/^FortyGigabitEthernet/i,'Fo'],
563
+ [/^GigabitEthernet/i, 'Gi'],
564
+ [/^FastEthernet/i, 'Fa'],
565
+ [/^Ethernet/i, 'Eth'],
566
+ [/^Port-channel/i, 'Po'],
567
+ [/^Bundle-Ether/i, 'BE'],
568
+ [/^Loopback/i, 'Lo'],
569
+ [/^Tunnel/i, 'Tu'],
570
+ [/^Serial/i, 'Se'],
571
+ [/^Management/i, 'Mg'],
572
+ [/^Vlan/i, 'Vl'],
573
+ [/^StackSub-St/i, 'StSub'],
574
+ [/^StackPort/i, 'StPo'],
575
+ ];
576
+ for (const [pattern, abbr] of prefixes) {
577
+ if (pattern.test(name)) {
578
+ return name.replace(pattern, abbr);
579
+ }
580
+ }
581
+ return name;
582
+ }
583
+
584
+ // Create an interface card with status indicators and hover details
585
+ function createInterfaceCard(iface) {
586
+ const card = document.createElement('div');
587
+
588
+ // admin_status / oper_status are stored as strings (UP/DOWN/TESTING/...)
589
+ const adminStatus = iface.admin_status;
590
+ const operStatus = iface.oper_status;
591
+
592
+ let borderClass = 'border-gray-600';
593
+ let statusText = 'Unknown';
594
+ let statusColor = 'bg-gray-500';
595
+
596
+ if (adminStatus === 'UP' && operStatus === 'UP') {
597
+ // Admin up / oper up — enabled and active
598
+ borderClass = 'border-green-500';
599
+ statusText = 'Up';
600
+ statusColor = 'bg-green-500';
601
+ } else if (adminStatus === 'DOWN' && operStatus === 'UP') {
602
+ // Admin down / oper up — inconsistent, worth investigating
603
+ borderClass = 'border-yellow-500';
604
+ statusText = 'Admin Down / Link Up';
605
+ statusColor = 'bg-yellow-500';
606
+ } else if (adminStatus === 'UP' && operStatus === 'DORMANT') {
607
+ // Admin up / oper dormant — link enabled but dormant
608
+ borderClass = 'border-yellow-500';
609
+ statusText = 'Dormant';
610
+ statusColor = 'bg-yellow-500';
611
+ } else if (adminStatus === 'TESTING' || operStatus === 'TESTING') {
612
+ // Testing state
613
+ borderClass = 'border-blue-500';
614
+ statusText = 'Testing';
615
+ statusColor = 'bg-blue-500';
616
+ } else {
617
+ // Admin down / oper down, admin up / oper down, or unknown — gray (disabled/no link)
618
+ borderClass = 'border-gray-500';
619
+ statusText = adminStatus === 'DOWN' ? 'Admin Down' : operStatus === 'DOWN' ? 'No Link' : 'Unknown';
620
+ statusColor = 'bg-gray-500';
621
+ }
622
+
623
+ const speedMbps = iface.speed_high_mbps ?? (iface.speed ? iface.speed / 1_000_000 : 0);
624
+ const speedText = speedMbps >= 1000 ? `${speedMbps / 1000}G` : `${speedMbps}M`;
625
+
626
+ const macAddress = iface.mac ?? 'N/A';
627
+
628
+ const ifaceName = iface.name ?? iface.alt_name ?? '';
629
+ const ifaceAlias = iface.alias ?? '';
630
+
631
+ const inBytes = iface.in_octets ?? 0;
632
+ const outBytes = iface.out_octets ?? 0;
633
+
634
+ const inErrors = iface.in_errors ?? 0;
635
+ const outErrors = iface.out_errors ?? 0;
636
+
637
+ const mtu = iface.mtu ?? 'N/A';
638
+ const type = iface.type ?? 'N/A';
639
+ const index = iface.index ?? 'N/A';
640
+
641
+ const adminStatusText = adminStatus === 'UP' ? '<span class="text-green-400">Up</span>'
642
+ : adminStatus === 'DOWN' ? '<span class="text-gray-400">Down</span>'
643
+ : '<span class="text-blue-400">Testing</span>';
644
+ const operStatusHtml = operStatus === 'UP' ? '<span class="text-green-400">Up</span>'
645
+ : operStatus === 'DOWN' ? '<span class="text-gray-400">Down</span>'
646
+ : operStatus === 'LOWER_LAYER_DOWN' ? '<span class="text-orange-400">Lower Layer Down</span>'
647
+ : operStatus === 'DORMANT' ? '<span class="text-yellow-400">Dormant</span>'
648
+ : operStatus === 'NOT_PRESENT' ? '<span class="text-gray-500">Not Present</span>'
649
+ : `<span class="text-yellow-400">${escapeHtml(statusText)}</span>`;
650
+
651
+ const tooltipContent = `
652
+ <div class="font-semibold text-sm mb-2 pb-2 border-b border-gray-700">${escapeHtml(ifaceName)}</div>
653
+ ${ifaceAlias ? `<div class="text-xs text-gray-400 mb-2 italic">${escapeHtml(ifaceAlias)}</div>` : ''}
654
+
655
+ <div class="grid grid-cols-2 gap-x-3 gap-y-1 text-xs mb-2">
656
+ <div><span class="text-gray-400">Admin:</span> ${adminStatusText}</div>
657
+ <div><span class="text-gray-400">Oper:</span> ${operStatusHtml}</div>
658
+ <div><span class="text-gray-400">Speed:</span> <span class="text-white">${speedText}</span></div>
659
+ <div><span class="text-gray-400">MTU:</span> <span class="text-white">${mtu}</span></div>
660
+ <div class="col-span-2"><span class="text-gray-400">MAC:</span> <span class="text-white font-mono text-xs">${escapeHtml(macAddress)}</span></div>
661
+ </div>
662
+
663
+ <div class="border-t border-gray-700 pt-2 mt-2">
664
+ <div class="grid grid-cols-2 gap-x-3 gap-y-1 text-xs">
665
+ <div><span class="text-gray-400">Type:</span> <span class="text-white">${type}</span></div>
666
+ <div><span class="text-gray-400">Index:</span> <span class="text-white">${index}</span></div>
667
+ <div><span class="text-gray-400">In:</span> <span class="text-green-400">${formatBytes(inBytes)}</span></div>
668
+ <div><span class="text-gray-400">Out:</span> <span class="text-blue-400">${formatBytes(outBytes)}</span></div>
669
+ <div><span class="text-gray-400">In Err:</span> <span class="${inErrors > 0 ? 'text-red-400' : 'text-white'}">${inErrors}</span></div>
670
+ <div><span class="text-gray-400">Out Err:</span> <span class="${outErrors > 0 ? 'text-red-400' : 'text-white'}">${outErrors}</span></div>
671
+ </div>
672
+ </div>
673
+ `;
674
+
675
+ const displayName = abbreviateIfaceName(ifaceName);
676
+
677
+ card.className = `relative bg-gray-800 rounded-lg p-1.5 border-2 ${borderClass} hover:shadow-lg transition-all cursor-pointer group`;
678
+ card.innerHTML = `
679
+ <div class="flex flex-col items-center justify-center h-12">
680
+ <div class="w-2.5 h-2.5 rounded-full ${statusColor} mb-1"></div>
681
+ <div class="text-xs font-medium text-white text-center truncate w-full px-0.5">${escapeHtml(displayName)}</div>
682
+ <div class="text-xs text-gray-400 text-xs">${speedText}</div>
683
+ </div>
684
+
685
+ <!-- Tooltip -->
686
+ <div class="interface-tooltip absolute bottom-full left-0 mb-2 hidden group-hover:block z-50 w-80 pointer-events-none">
687
+ <div class="bg-gray-900 text-white rounded-lg p-3 shadow-2xl border-2 border-gray-600">
688
+ ${tooltipContent}
689
+ <div class="tooltip-arrow absolute top-full left-6 -mt-0.5">
690
+ <div class="border-8 border-transparent border-t-gray-600"></div>
691
+ </div>
692
+ </div>
693
+ </div>
694
+ `;
695
+
696
+ // Add hover event to dynamically position tooltip
697
+ card.addEventListener('mouseenter', function() {
698
+ const tooltip = this.querySelector('.interface-tooltip');
699
+ const arrow = this.querySelector('.tooltip-arrow');
700
+ if (tooltip) {
701
+ // Small delay to ensure tooltip is rendered
702
+ setTimeout(() => {
703
+ const tooltipRect = tooltip.getBoundingClientRect();
704
+ const viewportWidth = window.innerWidth;
705
+
706
+ // Check if tooltip goes off the right edge
707
+ if (tooltipRect.right > viewportWidth) {
708
+ // Switch to right-aligned
709
+ tooltip.classList.remove('left-0');
710
+ tooltip.classList.add('right-0');
711
+ arrow.classList.remove('left-6');
712
+ arrow.classList.add('right-6');
713
+ } else {
714
+ // Keep left-aligned
715
+ tooltip.classList.remove('right-0');
716
+ tooltip.classList.add('left-0');
717
+ arrow.classList.remove('right-6');
718
+ arrow.classList.add('left-6');
719
+ }
720
+ }, 10);
721
+ }
722
+ });
723
+
724
+ return card;
725
+ }
726
+
727
+ // Format bytes to human-readable format
728
+ function formatBytes(bytes) {
729
+ if (bytes === 0) return '0 B';
730
+ const k = 1024;
731
+ const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
732
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
733
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
734
+ }
735
+
736
+ // Render a metric line chart using D3.js
737
+ function renderMetricChart(chartDiv, timeData, metricData, label, borderColor, backgroundColor) {
738
+ if (!chartDiv || !timeData || !metricData) return;
739
+
740
+ // Parse ISO timestamp strings to Date objects and create paired data
741
+ const data = timeData.map((timestamp, index) => ({
742
+ time: new Date(timestamp),
743
+ value: metricData[index] * 100 // Convert to percentage
744
+ }));
745
+
746
+ // Sort by time (chronological order)
747
+ data.sort((a, b) => a.time - b.time);
748
+
749
+ // Clear any existing content and get container dimensions
750
+ const container = chartDiv.parentElement;
751
+ chartDiv.innerHTML = '';
752
+
753
+ const margin = { top: 10, right: 10, bottom: 40, left: 45 };
754
+ const width = container.clientWidth - margin.left - margin.right;
755
+ const height = container.clientHeight - margin.top - margin.bottom;
756
+
757
+ // Create SVG
758
+ const svg = d3.select(chartDiv)
759
+ .append('svg')
760
+ .attr('width', width + margin.left + margin.right)
761
+ .attr('height', height + margin.top + margin.bottom)
762
+ .append('g')
763
+ .attr('transform', `translate(${margin.left},${margin.top})`);
764
+
765
+ // Create scales
766
+ const xScale = d3.scaleTime()
767
+ .domain(d3.extent(data, d => d.time))
768
+ .range([0, width]);
769
+
770
+ const yScale = d3.scaleLinear()
771
+ .domain([0, 100])
772
+ .range([height, 0]);
773
+
774
+ // Create line generator with curve
775
+ const line = d3.line()
776
+ .x(d => xScale(d.time))
777
+ .y(d => yScale(d.value))
778
+ .curve(d3.curveMonotoneX);
779
+
780
+ // Create area generator for fill
781
+ const area = d3.area()
782
+ .x(d => xScale(d.time))
783
+ .y0(height)
784
+ .y1(d => yScale(d.value))
785
+ .curve(d3.curveMonotoneX);
786
+
787
+ // Add gradient for area fill with unique ID
788
+ const gradientId = `gradient-${Math.random().toString(36).substr(2, 9)}`;
789
+ const defs = svg.append('defs');
790
+
791
+ const gradient = defs.append('linearGradient')
792
+ .attr('id', gradientId)
793
+ .attr('x1', '0%')
794
+ .attr('y1', '0%')
795
+ .attr('x2', '0%')
796
+ .attr('y2', '100%');
797
+
798
+ gradient.append('stop')
799
+ .attr('offset', '0%')
800
+ .attr('stop-color', borderColor)
801
+ .attr('stop-opacity', 0.4);
802
+
803
+ gradient.append('stop')
804
+ .attr('offset', '100%')
805
+ .attr('stop-color', borderColor)
806
+ .attr('stop-opacity', 0.05);
807
+
808
+ // Add grid lines
809
+ svg.append('g')
810
+ .attr('class', 'grid')
811
+ .attr('opacity', 0.1)
812
+ .call(d3.axisLeft(yScale)
813
+ .tickSize(-width)
814
+ .tickFormat(''));
815
+
816
+ // Add area
817
+ svg.append('path')
818
+ .datum(data)
819
+ .attr('fill', `url(#${gradientId})`)
820
+ .attr('d', area);
821
+
822
+ // Add line
823
+ svg.append('path')
824
+ .datum(data)
825
+ .attr('fill', 'none')
826
+ .attr('stroke', borderColor)
827
+ .attr('stroke-width', 2)
828
+ .attr('d', line);
829
+
830
+ // Add X axis
831
+ const xAxis = d3.axisBottom(xScale)
832
+ .ticks(d3.timeMinute.every(30))
833
+ .tickFormat(d => {
834
+ const hours = d.getHours().toString().padStart(2, '0');
835
+ const mins = d.getMinutes().toString().padStart(2, '0');
836
+ return `${hours}:${mins}`;
837
+ });
838
+
839
+ svg.append('g')
840
+ .attr('transform', `translate(0,${height})`)
841
+ .call(xAxis)
842
+ .selectAll('text')
843
+ .style('fill', '#9CA3AF')
844
+ .style('text-anchor', 'end')
845
+ .attr('dx', '-.8em')
846
+ .attr('dy', '.15em')
847
+ .attr('transform', 'rotate(-45)');
848
+
849
+ svg.selectAll('.domain, .tick line')
850
+ .style('stroke', 'rgba(75, 85, 99, 0.3)');
851
+
852
+ // Add Y axis
853
+ const yAxis = d3.axisLeft(yScale)
854
+ .ticks(5)
855
+ .tickFormat(d => d + '%');
856
+
857
+ svg.append('g')
858
+ .call(yAxis)
859
+ .selectAll('text')
860
+ .style('fill', '#9CA3AF');
861
+
862
+ svg.selectAll('.domain, .tick line')
863
+ .style('stroke', 'rgba(75, 85, 99, 0.3)');
864
+
865
+ // Add tooltip with chart color theme
866
+ const tooltip = d3.select(chartDiv)
867
+ .append('div')
868
+ .style('position', 'absolute')
869
+ .style('background-color', borderColor)
870
+ .style('color', '#fff')
871
+ .style('padding', '8px 12px')
872
+ .style('border-radius', '6px')
873
+ .style('pointer-events', 'none')
874
+ .style('opacity', 0)
875
+ .style('font-size', '12px')
876
+ .style('box-shadow', '0 4px 6px rgba(0, 0, 0, 0.3)')
877
+ .style('z-index', 1000);
878
+
879
+ // Add invisible overlay for mouse tracking
880
+ const bisect = d3.bisector(d => d.time).left;
881
+
882
+ svg.append('rect')
883
+ .attr('width', width)
884
+ .attr('height', height)
885
+ .style('fill', 'none')
886
+ .style('pointer-events', 'all')
887
+ .on('mousemove', function(event) {
888
+ const [mouseX] = d3.pointer(event);
889
+ const x0 = xScale.invert(mouseX);
890
+ const i = bisect(data, x0, 1);
891
+ const d0 = data[i - 1];
892
+ const d1 = data[i];
893
+ const d = d1 && (x0 - d0.time > d1.time - x0) ? d1 : d0;
894
+
895
+ if (d) {
896
+ const containerRect = chartDiv.getBoundingClientRect();
897
+ tooltip
898
+ .style('opacity', 0.95)
899
+ .html(`
900
+ <div style="font-weight: bold; margin-bottom: 4px;">${d.time.toLocaleString()}</div>
901
+ <div style="font-size: 14px; font-weight: bold;">${d.value.toFixed(2)}%</div>
902
+ `)
903
+ .style('left', (event.pageX - containerRect.left + 15) + 'px')
904
+ .style('top', (event.pageY - containerRect.top - 10) + 'px');
905
+ }
906
+ })
907
+ .on('mouseout', function() {
908
+ tooltip.style('opacity', 0);
909
+ });
910
+ }
911
+
912
+ // Create a sensor card with temperature gauge
913
+ function createSensorCard(sensor) {
914
+ const card = document.createElement('div');
915
+
916
+ const tempC = Number(sensor.temp_celsius);
917
+ const hasTemp = sensor.temp_celsius != null && sensor.temp_celsius !== '' && !Number.isNaN(tempC);
918
+ const threshold = Number(sensor.temp_threshold);
919
+ const hasThreshold = sensor.temp_threshold != null && sensor.temp_threshold !== '' && !Number.isNaN(threshold) && threshold > 0;
920
+
921
+ const tempF = hasTemp ? (tempC * 9 / 5) + 32 : null;
922
+ const thresholdF = hasThreshold ? (threshold * 9 / 5) + 32 : null;
923
+ // When state is absent (e.g. lm-sensors has no status field) but we have a
924
+ // reading, show a neutral blue "Reading" style instead of gray "Unknown".
925
+ const stateInfo = (sensor.state == null || sensor.state === '') && hasTemp
926
+ ? { label: 'Reading', borderClass: 'border-blue-500', badgeClass: 'bg-blue-900/40 text-blue-300', textClass: 'text-blue-400', gaugeClass: 'bg-blue-500' }
927
+ : getSensorStateInfo(sensor.state);
928
+ const gaugeMax = hasThreshold ? threshold : 100;
929
+ const percentage = hasTemp ? Math.min((tempC / gaugeMax) * 100, 100) : 0;
930
+ const tempDisplay = hasTemp ? `${tempF.toFixed(1)}°F` : '—';
931
+ const tempCDisplay = hasTemp ? `${tempC}°C` : '—';
932
+ // Compact inline threshold string (e.g. "/ 85°F")
933
+ const thresholdInline = hasThreshold
934
+ ? `<span class="text-xs text-gray-500 ml-1">/ ${thresholdF.toFixed(0)}°F</span>`
935
+ : '';
936
+ const thresholdCInline = hasThreshold
937
+ ? `<span class="text-xs text-gray-500 ml-1">/ ${threshold}°C</span>`
938
+ : '';
939
+
940
+ card.className = 'bg-gray-800 rounded-lg p-2 border-l-4 ' + stateInfo.borderClass;
941
+ card.innerHTML = `
942
+ <!-- Header row: label + badge -->
943
+ <div class="flex items-center justify-between gap-2 mb-1.5">
944
+ <h4 class="text-xs font-medium text-white truncate" title="${escapeHtml(sensor.description)}">${escapeHtml(sensor.description)}</h4>
945
+ <span class="text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${stateInfo.badgeClass}">${stateInfo.label}</span>
946
+ </div>
947
+
948
+ <!-- Temp value + gauge on one compact block -->
949
+ <div class="flex items-center gap-3">
950
+ <!-- Primary temp -->
951
+ <div class="flex-shrink-0">
952
+ <span class="text-lg font-bold leading-none ${stateInfo.textClass}">${tempDisplay}</span>${thresholdInline}
953
+ <div class="text-xs text-gray-400 mt-0.5">${tempCDisplay}${thresholdCInline}</div>
954
+ </div>
955
+ <!-- Gauge fills remaining width -->
956
+ <div class="flex-1">
957
+ <div class="relative w-full h-1.5 bg-gray-700 rounded-full overflow-hidden">
958
+ <div class="absolute h-full ${stateInfo.gaugeClass} transition-all duration-300"
959
+ style="width: ${percentage}%"></div>
960
+ </div>
961
+ </div>
962
+ </div>
963
+ `;
964
+
965
+ return card;
966
+ }
967
+
968
+ // Create a fan card with state display
969
+ function createFanCard(fan) {
970
+ const card = document.createElement('div');
971
+
972
+ // Determine state color and label, with RPM-based inference when state is absent
973
+ const hasState = fan.state != null && fan.state !== '' && !Number.isNaN(parseInt(fan.state));
974
+ const hasRpm = fan.rpm != null && fan.rpm !== '';
975
+ const rpm = hasRpm ? Number(fan.rpm) : null;
976
+
977
+ let stateInfo;
978
+ if (hasState) {
979
+ stateInfo = getSensorStateInfo(fan.state);
980
+ } else if (hasRpm) {
981
+ // lm-sensors: infer from RPM
982
+ stateInfo = rpm > 0
983
+ ? { label: 'Spinning', borderClass: 'border-green-500', badgeClass: 'bg-green-900/40 text-green-300', textClass: 'text-green-400' }
984
+ : { label: 'Idle', borderClass: 'border-gray-500', badgeClass: 'bg-gray-700 text-gray-400', textClass: 'text-gray-400' };
985
+ } else {
986
+ stateInfo = getSensorStateInfo(null);
987
+ }
988
+
989
+ // Sub-label line under the RPM — only shown when we have an explicit state
990
+ const isOperational = hasState && (parseInt(fan.state) === 1 || parseInt(fan.state) === 2);
991
+ const showSubLabel = hasState;
992
+ const subLabel = showSubLabel ? (isOperational ? 'Operational' : 'Not Running') : '';
993
+
994
+ card.className = 'bg-gray-800 rounded-lg p-2 border-l-4 flex flex-col items-center justify-center gap-1 ' + stateInfo.borderClass;
995
+ card.innerHTML = `
996
+ <!-- Fan icon -->
997
+ <svg class="w-8 h-8 ${stateInfo.textClass}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
998
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
999
+ </svg>
1000
+
1001
+ <!-- RPM -->
1002
+ ${hasRpm ? `<div class="text-sm font-semibold ${stateInfo.textClass} leading-none">${escapeHtml(String(fan.rpm))} RPM</div>` : ''}
1003
+ ${showSubLabel ? `<div class="text-xs text-gray-400 text-center leading-none">${subLabel}</div>` : ''}
1004
+
1005
+ <!-- Description -->
1006
+ <h4 class="text-xs text-gray-400 text-center truncate w-full px-1 mt-0.5" title="${escapeHtml(fan.description)}">${escapeHtml(fan.description)}</h4>
1007
+ `;
1008
+
1009
+ return card;
1010
+ }
1011
+
1012
+ // Decode prtMarkerSuppliesSupplyUnit values to labels
1013
+ function decodePrinterSupplyUnit(unit) {
1014
+ const map = {
1015
+ 3: 'tenths of inches', 4: 'micrometers', 7: 'impressions',
1016
+ 8: 'sheets', 11: 'hours', 12: 'thousandths of oz',
1017
+ 13: 'tenths of grams', 14: 'hundredths fl oz', 15: 'tenths of mL',
1018
+ 16: 'feet', 17: 'meters', 18: 'items',
1019
+ 19: '%',
1020
+ };
1021
+ return map[parseInt(unit)] || '';
1022
+ }
1023
+
1024
+ // Infer toner/ink swatch color from the supply description string
1025
+ function inferSupplyColor(description) {
1026
+ if (!description) return null;
1027
+ const d = description.toLowerCase();
1028
+
1029
+ if (d.includes('yellow')) return { swatch: 'bg-yellow-400', label: 'Yellow', bar: 'bg-yellow-400', text: 'text-yellow-400', border: 'border-yellow-500' };
1030
+ if (d.includes('cyan')) return { swatch: 'bg-cyan-400', label: 'Cyan', bar: 'bg-cyan-400', text: 'text-cyan-400', border: 'border-cyan-500' };
1031
+ if (d.includes('magenta')) return { swatch: 'bg-pink-500', label: 'Magenta', bar: 'bg-pink-500', text: 'text-pink-400', border: 'border-pink-500' };
1032
+ if (d.includes('black') || d.includes('toner k')) {
1033
+ return { swatch: 'bg-gray-300', label: 'Black', bar: 'bg-gray-400', text: 'text-gray-300', border: 'border-gray-400' };
1034
+ }
1035
+ if (d.includes('waste')) return { swatch: 'bg-orange-500', label: 'Waste', bar: 'bg-orange-500', text: 'text-orange-400', border: 'border-orange-500' };
1036
+ if (d.includes('fuser')) return { swatch: 'bg-purple-500', label: 'Fuser', bar: 'bg-purple-500', text: 'text-purple-400', border: 'border-purple-500' };
1037
+ if (d.includes('drum')) return { swatch: 'bg-indigo-500', label: 'Drum', bar: 'bg-indigo-500', text: 'text-indigo-400', border: 'border-indigo-500' };
1038
+ return null;
1039
+ }
1040
+
1041
+ // Decode component power-supply state integer → display metadata
1042
+ function getPsuStateInfo(state) {
1043
+ const s = parseInt(state);
1044
+ if (isNaN(s)) {
1045
+ // Inventory-only record (ENTITY-MIB has no state sensor)
1046
+ return { label: 'Unknown', borderClass: 'border-gray-500', badgeClass: 'bg-gray-700 text-gray-300', textClass: 'text-gray-400' };
1047
+ }
1048
+ const map = {
1049
+ 1: { label: 'Present', borderClass: 'border-green-500', badgeClass: 'bg-green-900/50 text-green-300', textClass: 'text-green-400' },
1050
+ 2: { label: 'Not Present', borderClass: 'border-gray-500', badgeClass: 'bg-gray-700 text-gray-400', textClass: 'text-gray-500' },
1051
+ 3: { label: 'Present', borderClass: 'border-green-500', badgeClass: 'bg-green-900/50 text-green-300', textClass: 'text-green-400' },
1052
+ 4: { label: 'Powered Off', borderClass: 'border-yellow-500', badgeClass: 'bg-yellow-900/50 text-yellow-300', textClass: 'text-yellow-400' },
1053
+ 5: { label: 'Warning', borderClass: 'border-yellow-500', badgeClass: 'bg-yellow-900/50 text-yellow-300', textClass: 'text-yellow-400' },
1054
+ 6: { label: 'Critical', borderClass: 'border-orange-500', badgeClass: 'bg-orange-900/50 text-orange-300', textClass: 'text-orange-400' },
1055
+ 7: { label: 'Failed', borderClass: 'border-red-500', badgeClass: 'bg-red-900/50 text-red-300', textClass: 'text-red-400' },
1056
+ };
1057
+ return map[s] || { label: `State ${s}`, borderClass: 'border-gray-500', badgeClass: 'bg-gray-700 text-gray-300', textClass: 'text-gray-400' };
1058
+ }
1059
+
1060
+ // Create a power supply card (inventory or state-bearing)
1061
+ function createPowerSupplyCard(psu) {
1062
+ const card = document.createElement('div');
1063
+
1064
+ const stateInfo = getPsuStateInfo(psu.state);
1065
+ const location = psu.location ? escapeHtml(String(psu.location)) : '—';
1066
+ const description = psu.description ? escapeHtml(String(psu.description)) : null;
1067
+ const serialNo = psu.serial_no ? escapeHtml(String(psu.serial_no)) : null;
1068
+
1069
+ card.className = 'bg-gray-800 rounded-lg p-2 border-l-4 flex flex-col items-center justify-center gap-1 ' + stateInfo.borderClass;
1070
+ card.innerHTML = `
1071
+ <!-- PSU icon -->
1072
+ <svg class="w-7 h-7 ${stateInfo.textClass}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1073
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
1074
+ d="M3 7h18M3 7a2 2 0 00-2 2v8a2 2 0 002 2h18a2 2 0 002-2V9a2 2 0 00-2-2M3 7V5a2 2 0 012-2h14a2 2 0 012 2v2" />
1075
+ </svg>
1076
+
1077
+ <!-- Label (description if set, otherwise location) -->
1078
+ <h4 class="text-xs font-medium text-white text-center truncate w-full px-1 leading-none mt-0.5"
1079
+ title="${description || location}">${description || location}</h4>
1080
+ ${serialNo ? `<div class="text-xs text-gray-500 text-center truncate w-full px-1 leading-none" title="S/N: ${serialNo}">S/N: ${serialNo}</div>` : ''}
1081
+ `;
1082
+
1083
+ return card;
1084
+ }
1085
+
1086
+ // Create a printer supply card with a level gauge and toner-color awareness
1087
+ function createPrinterSupplyCard(supply) {
1088
+ const card = document.createElement('div');
1089
+
1090
+ const level = typeof supply.level === 'number' ? supply.level : 0;
1091
+ const capacityMax = supply.capacity_max || 100;
1092
+ const pct = Math.min(Math.max((level / capacityMax) * 100, 0), 100);
1093
+ const pctText = pct.toFixed(0);
1094
+ const unitLabel = decodePrinterSupplyUnit(supply.unit);
1095
+
1096
+ // Level display: if unit is %, show as %; otherwise show raw level + unit label
1097
+ const levelDisplay = unitLabel === '%'
1098
+ ? `${pctText}%`
1099
+ : `${level}${unitLabel ? ' ' + unitLabel : ''}`;
1100
+
1101
+ const colorInfo = inferSupplyColor(supply.description);
1102
+
1103
+ // If we know the toner color, use it for the bar and border; otherwise fall back to level thresholds
1104
+ let barColor, textColor, borderColor;
1105
+ if (colorInfo) {
1106
+ barColor = colorInfo.bar;
1107
+ textColor = colorInfo.text;
1108
+ borderColor = colorInfo.border;
1109
+ } else if (pct <= 10) {
1110
+ barColor = 'bg-red-500'; textColor = 'text-red-400'; borderColor = 'border-red-500';
1111
+ } else if (pct <= 25) {
1112
+ barColor = 'bg-yellow-500'; textColor = 'text-yellow-400'; borderColor = 'border-yellow-500';
1113
+ } else {
1114
+ barColor = 'bg-emerald-500'; textColor = 'text-emerald-400'; borderColor = 'border-emerald-500';
1115
+ }
1116
+
1117
+ // Low-level warning badge regardless of color type
1118
+ let warningBadge = '';
1119
+ if (pct <= 10) {
1120
+ warningBadge = `<span class="text-xs px-1.5 py-0.5 rounded bg-red-600/20 text-red-300 flex-shrink-0">Low</span>`;
1121
+ } else if (pct <= 25) {
1122
+ warningBadge = `<span class="text-xs px-1.5 py-0.5 rounded bg-yellow-600/20 text-yellow-300 flex-shrink-0">Low</span>`;
1123
+ }
1124
+
1125
+ const swatchHtml = colorInfo
1126
+ ? `<span class="inline-block w-3 h-3 rounded-sm ${colorInfo.swatch} flex-shrink-0 border border-gray-600"></span>`
1127
+ : '';
1128
+
1129
+ card.className = `bg-gray-800 rounded-lg p-3 border-l-4 ${borderColor} w-52 flex-shrink-0`;
1130
+ card.innerHTML = `
1131
+ <div class="flex items-start justify-between gap-1 mb-2">
1132
+ <div class="flex items-center gap-1.5 min-w-0">
1133
+ ${swatchHtml}
1134
+ <span class="text-xs font-medium text-white truncate" title="${escapeHtml(supply.description)}">${escapeHtml(supply.description)}</span>
1135
+ </div>
1136
+ ${warningBadge}
1137
+ </div>
1138
+
1139
+ <div class="${textColor} text-2xl font-bold leading-none mb-2">${escapeHtml(levelDisplay)}</div>
1140
+
1141
+ <!-- Level gauge -->
1142
+ <div class="relative w-full h-2 bg-gray-700 rounded-full overflow-hidden mb-1">
1143
+ <div class="absolute h-full ${barColor} transition-all duration-300 rounded-full" style="width: ${pct}%"></div>
1144
+ </div>
1145
+ <div class="flex justify-between text-xs text-gray-500">
1146
+ <span>Empty</span>
1147
+ <span>Full</span>
1148
+ </div>
1149
+ `;
1150
+
1151
+ return card;
1152
+ }
1153
+
1154
+ // Decode HR Storage type OIDs to human-readable labels
1155
+ function decodeFilesystemType(typeOid) {
1156
+ const map = {
1157
+ '1.3.6.1.2.1.25.2.1.1': 'Other',
1158
+ '1.3.6.1.2.1.25.2.1.2': 'RAM',
1159
+ '1.3.6.1.2.1.25.2.1.3': 'Virtual Memory',
1160
+ '1.3.6.1.2.1.25.2.1.4': 'Fixed Disk',
1161
+ '1.3.6.1.2.1.25.2.1.5': 'Removable Disk',
1162
+ '1.3.6.1.2.1.25.2.1.6': 'Floppy Disk',
1163
+ '1.3.6.1.2.1.25.2.1.7': 'Compact Disc',
1164
+ '1.3.6.1.2.1.25.2.1.8': 'RAM Disk',
1165
+ '1.3.6.1.2.1.25.2.1.9': 'Flash Memory',
1166
+ '1.3.6.1.2.1.25.2.1.10': 'Network Disk',
1167
+ // Vendor-specific types injected by the backend
1168
+ 'aggregate': 'Aggregate',
1169
+ };
1170
+ return map[typeOid] || typeOid || 'Unknown';
1171
+ }
1172
+
1173
+ // Create a filesystem card with a capacity gauge
1174
+ function createFilesystemCard(fs) {
1175
+ const card = document.createElement('div');
1176
+
1177
+ const usedPct = typeof fs.used_pct === 'number' ? fs.used_pct : 0;
1178
+ const pct = Math.min(Math.max(usedPct * 100, 0), 100);
1179
+ const pctText = pct.toFixed(1);
1180
+ const freePct = (100 - pct).toFixed(1);
1181
+
1182
+ const usedBytes = fs.used_bytes || 0;
1183
+ const totalBytes = fs.total_bytes || 0;
1184
+ const freeBytes = Math.max(totalBytes - usedBytes, 0);
1185
+
1186
+ // Colour thresholds mirroring CPU cores
1187
+ let barColor, textColor, borderColor;
1188
+ if (pct >= 90) {
1189
+ barColor = 'bg-red-500'; textColor = 'text-red-400'; borderColor = 'border-red-500';
1190
+ } else if (pct >= 75) {
1191
+ barColor = 'bg-yellow-500'; textColor = 'text-yellow-400'; borderColor = 'border-yellow-500';
1192
+ } else {
1193
+ barColor = 'bg-emerald-500'; textColor = 'text-emerald-400'; borderColor = 'border-emerald-500';
1194
+ }
1195
+
1196
+ const typeLabel = decodeFilesystemType(fs.type);
1197
+
1198
+ card.className = `bg-gray-800 rounded-lg p-3 border-l-4 ${borderColor}`;
1199
+ card.innerHTML = `
1200
+ <div class="flex items-start justify-between gap-2 mb-1.5">
1201
+ <span class="text-sm font-semibold text-white font-mono truncate" title="${escapeHtml(fs.mount_point || '/')}">${escapeHtml(fs.mount_point || '/')}</span>
1202
+ <span class="text-xs px-1.5 py-0.5 rounded bg-gray-700 text-gray-300 whitespace-nowrap flex-shrink-0">${escapeHtml(typeLabel)}</span>
1203
+ </div>
1204
+
1205
+ <!-- Inline percent + gauge -->
1206
+ <div class="flex items-center gap-2 mb-2">
1207
+ <span class="${textColor} text-sm font-bold w-12 flex-shrink-0">${pctText}%</span>
1208
+ <div class="flex-1 relative h-2 bg-gray-700 rounded-full overflow-hidden">
1209
+ <div class="absolute h-full ${barColor} transition-all duration-300 rounded-full" style="width: ${pct}%"></div>
1210
+ </div>
1211
+ </div>
1212
+
1213
+ <div class="grid grid-cols-3 gap-1 text-xs">
1214
+ <div>
1215
+ <span class="text-gray-500 block">Used</span>
1216
+ <span class="${textColor} font-mono">${formatBytes(usedBytes)}</span>
1217
+ </div>
1218
+ <div>
1219
+ <span class="text-gray-500 block">Free</span>
1220
+ <span class="text-gray-300 font-mono">${formatBytes(freeBytes)}</span>
1221
+ </div>
1222
+ <div>
1223
+ <span class="text-gray-500 block">Total</span>
1224
+ <span class="text-gray-300 font-mono">${formatBytes(totalBytes)}</span>
1225
+ </div>
1226
+ </div>
1227
+ `;
1228
+
1229
+ return card;
1230
+ }
1231
+
1232
+ // Map short band codes to human-readable 802.11 standard + frequency labels
1233
+ function decodeWirelessBand(band) {
1234
+ if (!band) return { label: 'Unknown', freq: '', color: 'text-gray-400', badge: 'bg-gray-600/20 text-gray-300' };
1235
+ const b = band.toLowerCase();
1236
+ const map = {
1237
+ 'b': { label: '802.11b', freq: '2.4 GHz', color: 'text-gray-400', badge: 'bg-gray-600/20 text-gray-300' },
1238
+ 'g': { label: '802.11g', freq: '2.4 GHz', color: 'text-blue-400', badge: 'bg-blue-600/20 text-blue-300' },
1239
+ 'ng': { label: '802.11n', freq: '2.4 GHz', color: 'text-blue-400', badge: 'bg-blue-600/20 text-blue-300' },
1240
+ 'na': { label: '802.11n', freq: '5 GHz', color: 'text-violet-400', badge: 'bg-violet-600/20 text-violet-300' },
1241
+ 'a': { label: '802.11a', freq: '5 GHz', color: 'text-violet-400', badge: 'bg-violet-600/20 text-violet-300' },
1242
+ 'ac': { label: '802.11ac', freq: '5 GHz', color: 'text-violet-400', badge: 'bg-violet-600/20 text-violet-300' },
1243
+ 'ax': { label: 'Wi-Fi 6', freq: '6 GHz', color: 'text-emerald-400','badge': 'bg-emerald-600/20 text-emerald-300' },
1244
+ 'ax6': { label: 'Wi-Fi 6E', freq: '6 GHz', color: 'text-emerald-400','badge': 'bg-emerald-600/20 text-emerald-300' },
1245
+ 'be': { label: 'Wi-Fi 7', freq: '6 GHz', color: 'text-pink-400', badge: 'bg-pink-600/20 text-pink-300' },
1246
+ };
1247
+ return map[b] || { label: band.toUpperCase(), freq: '', color: 'text-blue-400', badge: 'bg-blue-600/20 text-blue-300' };
1248
+ }
1249
+
1250
+ // Create a wireless radio card
1251
+ function createWirelessRadioCard(radio) {
1252
+ const card = document.createElement('div');
1253
+
1254
+ const bandInfo = decodeWirelessBand(radio.band);
1255
+ const inBytes = radio.in_bytes || 0;
1256
+ const outBytes = radio.out_bytes || 0;
1257
+ const outDiscards = radio.out_discards || 0;
1258
+ const outErrors = radio.out_errors || 0;
1259
+ const hasErrors = outDiscards > 0 || outErrors > 0;
1260
+
1261
+ card.className = 'bg-gray-800 rounded-lg p-4 border border-gray-600 hover:border-blue-500 transition-colors w-64 flex-shrink-0';
1262
+ card.innerHTML = `
1263
+ <div class="flex items-center justify-between mb-3">
1264
+ <div class="flex items-center gap-2">
1265
+ <svg class="w-4 h-4 ${bandInfo.color} flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1266
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0" />
1267
+ </svg>
1268
+ <span class="text-sm font-semibold text-white font-mono">${escapeHtml(radio.name || `Radio ${radio.index}`)}</span>
1269
+ </div>
1270
+ <span class="text-xs px-2 py-0.5 rounded ${bandInfo.badge}">${bandInfo.label}</span>
1271
+ </div>
1272
+
1273
+ <div class="grid grid-cols-2 gap-x-3 gap-y-1.5 text-xs mb-3">
1274
+ ${bandInfo.freq ? `
1275
+ <div>
1276
+ <span class="text-gray-500 block">Frequency</span>
1277
+ <span class="${bandInfo.color} font-medium">${bandInfo.freq}</span>
1278
+ </div>` : ''}
1279
+ ${radio.channel !== '' && radio.channel !== null && radio.channel !== undefined ? `
1280
+ <div>
1281
+ <span class="text-gray-500 block">Channel</span>
1282
+ <span class="text-white font-medium">${escapeHtml(String(radio.channel))}</span>
1283
+ </div>` : ''}
1284
+ </div>
1285
+
1286
+ <div class="border-t border-gray-700 pt-2 space-y-1 text-xs">
1287
+ <div class="flex justify-between">
1288
+ <span class="text-gray-500">Rx</span>
1289
+ <span class="text-green-400 font-mono">${formatBytes(inBytes)}</span>
1290
+ </div>
1291
+ <div class="flex justify-between">
1292
+ <span class="text-gray-500">Tx</span>
1293
+ <span class="text-blue-400 font-mono">${formatBytes(outBytes)}</span>
1294
+ </div>
1295
+ ${hasErrors ? `
1296
+ <div class="flex justify-between">
1297
+ <span class="text-gray-500">Tx Discards</span>
1298
+ <span class="${outDiscards > 0 ? 'text-yellow-400' : 'text-gray-400'} font-mono">${outDiscards}</span>
1299
+ </div>
1300
+ <div class="flex justify-between">
1301
+ <span class="text-gray-500">Tx Errors</span>
1302
+ <span class="${outErrors > 0 ? 'text-red-400' : 'text-gray-400'} font-mono">${outErrors}</span>
1303
+ </div>` : ''}
1304
+ </div>
1305
+ `;
1306
+
1307
+ return card;
1308
+ }
1309
+
1310
+ // Decode CDP/LLDP capabilities hex string (e.g. "00:00:00:28") into human-readable labels
1311
+ function decodeCdpCapabilities(capHex) {
1312
+ if (!capHex) return [];
1313
+ // Strip colons and parse as a 32-bit integer
1314
+ const hex = capHex.replace(/:/g, '');
1315
+ const bits = parseInt(hex, 16);
1316
+ if (isNaN(bits)) return [];
1317
+
1318
+ const capMap = [
1319
+ [0x0001, 'Router'],
1320
+ [0x0002, 'Bridge'],
1321
+ [0x0004, 'SR Bridge'],
1322
+ [0x0008, 'Switch'],
1323
+ [0x0010, 'Host'],
1324
+ [0x0020, 'IGMP'],
1325
+ [0x0040, 'Repeater'],
1326
+ [0x0080, 'VoIP Phone'],
1327
+ [0x0100, 'Remotely Managed'],
1328
+ [0x0200, 'CVTA'],
1329
+ [0x0400, 'Two-Port MAC Relay'],
1330
+ ];
1331
+
1332
+ return capMap.filter(([mask]) => bits & mask).map(([, label]) => label);
1333
+ }
1334
+
1335
+ // Create a neighbor card showing CDP/LLDP adjacency details
1336
+ function createAPCard(ap) {
1337
+ const card = document.createElement('div');
1338
+
1339
+ const status = String(ap.status ?? '').toLowerCase();
1340
+
1341
+ let borderColor, dotColor, statusLabel;
1342
+ if (status === 'up' || status === '1') {
1343
+ borderColor = 'border-emerald-500';
1344
+ dotColor = 'bg-emerald-400';
1345
+ statusLabel = 'Up';
1346
+ } else if (status === 'down' || status === '2') {
1347
+ borderColor = 'border-red-500';
1348
+ dotColor = 'bg-red-500';
1349
+ statusLabel = 'Down';
1350
+ } else {
1351
+ borderColor = 'border-gray-600';
1352
+ dotColor = 'bg-gray-500';
1353
+ statusLabel = 'Unknown';
1354
+ }
1355
+
1356
+ const name = ap.name || ap.index || '?';
1357
+ const ip = ap.ip || '';
1358
+ const serial = ap.serial || '';
1359
+
1360
+ // Shorten name for the card face — drop common AP prefix patterns
1361
+ const shortName = name.replace(/^(AP[-_]?|access[-_]?point[-_]?)/i, '').trim() || name;
1362
+
1363
+ const tooltipContent = `
1364
+ <div class="font-semibold text-sm mb-2 pb-2 border-b border-gray-700 truncate" title="${escapeHtml(name)}">${escapeHtml(name)}</div>
1365
+ <div class="space-y-1 text-xs">
1366
+ <div class="flex justify-between gap-2">
1367
+ <span class="text-gray-400">Status</span>
1368
+ <span class="${status === 'up' || status === '1' ? 'text-emerald-400' : status === 'down' || status === '2' ? 'text-red-400' : 'text-gray-400'}">${escapeHtml(statusLabel)}</span>
1369
+ </div>
1370
+ ${ip ? `<div class="flex justify-between gap-2"><span class="text-gray-400">IP</span><span class="text-white font-mono">${escapeHtml(ip)}</span></div>` : ''}
1371
+ ${serial ? `<div class="flex justify-between gap-2"><span class="text-gray-400">Serial</span><span class="text-white font-mono">${escapeHtml(serial)}</span></div>` : ''}
1372
+ </div>
1373
+ `;
1374
+
1375
+ card.className = `relative bg-gray-800 rounded-lg p-1.5 border-2 ${borderColor} hover:shadow-lg transition-all cursor-pointer group`;
1376
+ card.innerHTML = `
1377
+ <div class="flex flex-col items-center justify-center h-12">
1378
+ <div class="w-2.5 h-2.5 rounded-full ${dotColor} mb-1 flex-shrink-0"></div>
1379
+ <div class="text-xs font-medium text-white text-center truncate w-full px-0.5" title="${escapeHtml(name)}">${escapeHtml(shortName)}</div>
1380
+ ${ip ? `<div class="text-xs text-gray-400 truncate w-full text-center px-0.5">${escapeHtml(ip)}</div>` : ''}
1381
+ </div>
1382
+
1383
+ <!-- Tooltip -->
1384
+ <div class="interface-tooltip absolute bottom-full left-0 mb-2 hidden group-hover:block z-50 w-64 pointer-events-none">
1385
+ <div class="bg-gray-900 text-white rounded-lg p-3 shadow-2xl border-2 border-gray-600">
1386
+ ${tooltipContent}
1387
+ <div class="tooltip-arrow absolute top-full left-6 -mt-0.5">
1388
+ <div class="border-8 border-transparent border-t-gray-600"></div>
1389
+ </div>
1390
+ </div>
1391
+ </div>
1392
+ `;
1393
+
1394
+ // Reuse same tooltip repositioning logic as interface cards
1395
+ card.addEventListener('mouseenter', function() {
1396
+ const tooltip = this.querySelector('.interface-tooltip');
1397
+ const arrow = this.querySelector('.tooltip-arrow');
1398
+ if (tooltip) {
1399
+ setTimeout(() => {
1400
+ const rect = tooltip.getBoundingClientRect();
1401
+ if (rect.right > window.innerWidth) {
1402
+ tooltip.classList.replace('left-0', 'right-0');
1403
+ arrow.classList.replace('left-6', 'right-6');
1404
+ } else {
1405
+ tooltip.classList.replace('right-0', 'left-0');
1406
+ arrow.classList.replace('right-6', 'left-6');
1407
+ }
1408
+ }, 10);
1409
+ }
1410
+ });
1411
+
1412
+ return card;
1413
+ }
1414
+
1415
+ function createNeighborCard(neighbor) {
1416
+ const card = document.createElement('div');
1417
+
1418
+ const caps = decodeCdpCapabilities(neighbor.capabilities);
1419
+ const capsBadges = caps.map(c =>
1420
+ `<span class="text-xs px-1.5 py-0.5 rounded bg-indigo-600/20 text-indigo-300">${escapeHtml(c)}</span>`
1421
+ ).join('');
1422
+
1423
+ // Shorten platform — strip leading vendor word if it duplicates common prefixes
1424
+ const platform = neighbor.platform || '';
1425
+
1426
+ // Extract a short OS version line from the multi-line version string
1427
+ let versionShort = '';
1428
+ if (neighbor.version) {
1429
+ const firstLine = neighbor.version.split('\n')[0].trim();
1430
+ // Try to pull just the "Version X.Y(Z)" fragment
1431
+ const versionMatch = firstLine.match(/Version\s+[\w().]+/i);
1432
+ versionShort = versionMatch ? versionMatch[0] : firstLine.slice(0, 60);
1433
+ }
1434
+
1435
+ card.className = 'bg-gray-800 rounded-lg p-3 border border-gray-600 hover:border-indigo-500 transition-colors';
1436
+ card.innerHTML = `
1437
+ <div class="flex items-start justify-between gap-2 mb-2">
1438
+ <div class="flex items-center gap-2 min-w-0">
1439
+ <svg class="w-4 h-4 text-indigo-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1440
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01" />
1441
+ </svg>
1442
+ <span class="text-sm font-semibold text-white truncate" title="${escapeHtml(neighbor.device_id || 'Unknown')}">${escapeHtml(neighbor.device_id || 'Unknown')}</span>
1443
+ </div>
1444
+ ${neighbor.address ? `<span class="text-xs text-gray-400 font-mono flex-shrink-0" title="${escapeHtml(neighbor.address)}">${escapeHtml(neighbor.address)}</span>` : ''}
1445
+ </div>
1446
+
1447
+ <div class="space-y-1 text-xs mb-2">
1448
+ ${neighbor.port ? `
1449
+ <div class="flex items-center gap-1.5">
1450
+ <span class="text-gray-500 w-16 flex-shrink-0">Remote Port</span>
1451
+ <span class="text-gray-200 font-mono truncate" title="${escapeHtml(neighbor.port)}">${escapeHtml(neighbor.port)}</span>
1452
+ </div>` : ''}
1453
+ ${platform ? `
1454
+ <div class="flex items-center gap-1.5">
1455
+ <span class="text-gray-500 w-16 flex-shrink-0">Platform</span>
1456
+ <span class="text-gray-200 truncate" title="${escapeHtml(platform)}">${escapeHtml(platform)}</span>
1457
+ </div>` : ''}
1458
+ ${versionShort ? `
1459
+ <div class="flex items-center gap-1.5">
1460
+ <span class="text-gray-500 w-16 flex-shrink-0">Version</span>
1461
+ <span class="text-gray-400 truncate italic" title="${escapeHtml(versionShort)}">${escapeHtml(versionShort)}</span>
1462
+ </div>` : ''}
1463
+ </div>
1464
+
1465
+ ${caps.length > 0 ? `
1466
+ <div class="flex flex-wrap gap-1 pt-2 border-t border-gray-700">
1467
+ ${capsBadges}
1468
+ </div>` : ''}
1469
+ `;
1470
+
1471
+ return card;
1472
+ }
1473
+
1474
+ // Create a CPU core card with a load percentage gauge and colour-coded utilisation
1475
+ function createCpuCoreCard(core, displayIndex) {
1476
+ const card = document.createElement('div');
1477
+
1478
+ const loadPct = typeof core.load_pct === 'number' ? core.load_pct : 0;
1479
+ // load_pct arrives as a fraction (e.g. 0.06 = 6%)
1480
+ const pct = Math.min(Math.max(loadPct * 100, 0), 100);
1481
+ const pctRounded = pct.toFixed(1);
1482
+
1483
+ // Colour thresholds: green < 60 %, yellow 60–85 %, red > 85 %
1484
+ let barColor, textColor, borderColor;
1485
+ if (pct >= 85) {
1486
+ barColor = 'bg-red-500';
1487
+ textColor = 'text-red-400';
1488
+ borderColor = 'border-red-500';
1489
+ } else if (pct >= 60) {
1490
+ barColor = 'bg-yellow-500';
1491
+ textColor = 'text-yellow-400';
1492
+ borderColor = 'border-yellow-500';
1493
+ } else {
1494
+ barColor = 'bg-blue-500';
1495
+ textColor = 'text-blue-400';
1496
+ borderColor = 'border-blue-500';
1497
+ }
1498
+
1499
+ card.className = `bg-gray-800 rounded-lg p-3 border-l-4 ${borderColor} w-36 flex-shrink-0`;
1500
+ card.innerHTML = `
1501
+ <div class="flex items-center justify-between mb-2">
1502
+ <span class="text-xs font-semibold text-gray-300 uppercase">Core ${displayIndex}</span>
1503
+ <span class="text-xs text-gray-500 font-mono">#${escapeHtml(String(core.index))}</span>
1504
+ </div>
1505
+
1506
+ <div class="${textColor} text-2xl font-bold leading-none mb-2">${pctRounded}%</div>
1507
+
1508
+ <!-- Load gauge -->
1509
+ <div class="relative w-full h-2 bg-gray-700 rounded-full overflow-hidden">
1510
+ <div class="absolute h-full ${barColor} transition-all duration-300" style="width: ${pct}%"></div>
1511
+ </div>
1512
+ <div class="flex justify-between text-xs text-gray-500 mt-1">
1513
+ <span>0%</span>
1514
+ <span>100%</span>
1515
+ </div>
1516
+ `;
1517
+
1518
+ return card;
1519
+ }
1520
+
1521
+ // Get sensor/fan state information (color, label, etc.)
1522
+ function getSensorStateInfo(state) {
1523
+ switch (parseInt(state)) {
1524
+ case 1: // Normal
1525
+ return {
1526
+ label: 'Normal',
1527
+ borderClass: 'border-green-500',
1528
+ badgeClass: 'bg-green-600/20 text-green-300',
1529
+ textClass: 'text-green-400',
1530
+ gaugeClass: 'bg-green-500'
1531
+ };
1532
+ case 2: // Warning
1533
+ return {
1534
+ label: 'Warning',
1535
+ borderClass: 'border-yellow-500',
1536
+ badgeClass: 'bg-yellow-600/20 text-yellow-300',
1537
+ textClass: 'text-yellow-400',
1538
+ gaugeClass: 'bg-yellow-500'
1539
+ };
1540
+ case 3: // Critical
1541
+ return {
1542
+ label: 'Critical',
1543
+ borderClass: 'border-red-500',
1544
+ badgeClass: 'bg-red-600/20 text-red-300',
1545
+ textClass: 'text-red-400',
1546
+ gaugeClass: 'bg-red-500'
1547
+ };
1548
+ case 4: // Shutdown
1549
+ return {
1550
+ label: 'Shutdown',
1551
+ borderClass: 'border-red-700',
1552
+ badgeClass: 'bg-red-700/20 text-red-400',
1553
+ textClass: 'text-red-500',
1554
+ gaugeClass: 'bg-red-700'
1555
+ };
1556
+ case 5: // Not Present
1557
+ return {
1558
+ label: 'Not Present',
1559
+ borderClass: 'border-gray-500',
1560
+ badgeClass: 'bg-gray-600/20 text-gray-300',
1561
+ textClass: 'text-gray-400',
1562
+ gaugeClass: 'bg-gray-500'
1563
+ };
1564
+ case 6: // Not Functioning
1565
+ return {
1566
+ label: 'Not Functioning',
1567
+ borderClass: 'border-orange-500',
1568
+ badgeClass: 'bg-orange-600/20 text-orange-300',
1569
+ textClass: 'text-orange-400',
1570
+ gaugeClass: 'bg-orange-500'
1571
+ };
1572
+ default:
1573
+ return {
1574
+ label: 'Unknown',
1575
+ borderClass: 'border-gray-500',
1576
+ badgeClass: 'bg-gray-600/20 text-gray-300',
1577
+ textClass: 'text-gray-400',
1578
+ gaugeClass: 'bg-gray-500'
1579
+ };
1580
+ }
1581
+ }
1582
+
1583
+ // Format uptime from hundredths of seconds to human-readable format
1584
+ function formatUptime(hundredthsOfSeconds) {
1585
+ // Convert hundredths of seconds to total seconds
1586
+ const totalSeconds = Math.floor(hundredthsOfSeconds / 100);
1587
+
1588
+ // Calculate days, hours, minutes
1589
+ const days = Math.floor(totalSeconds / 86400);
1590
+ const hours = Math.floor((totalSeconds % 86400) / 3600);
1591
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
1592
+
1593
+ // Build the formatted string
1594
+ const parts = [];
1595
+ if (days > 0) parts.push(`${days}d`);
1596
+ if (hours > 0) parts.push(`${hours}h`);
1597
+ if (minutes > 0) parts.push(`${minutes}m`);
1598
+
1599
+ return parts.length > 0 ? parts.join(' ') : '0m';
1600
+ }
1601
+
1602
+ // Create a compact RAID volume card for the grid
1603
+ function createRaidVolumeCard(vol) {
1604
+ const card = document.createElement('div');
1605
+
1606
+ const name = vol.name || 'Unknown';
1607
+ const plex = vol.plex_num != null ? vol.plex_num : '—';
1608
+ const rg = vol.rg_index != null ? vol.rg_index : '—';
1609
+
1610
+ const plexTitle = 'A plex is one full copy of the volume\'s data. Plex 0 is the primary copy; Plex 1 exists only on mirrored (SyncMirror) aggregates.';
1611
+ const rgTitle = 'A RAID group is the set of drives that share parity within this volume. Large volumes span multiple RAID groups.';
1612
+
1613
+ card.className = 'bg-gray-800 rounded-lg p-2.5 border border-gray-600 hover:border-blue-500 transition-colors w-36 flex-shrink-0';
1614
+ card.innerHTML = `
1615
+ <div class="flex items-center gap-1.5 mb-1.5">
1616
+ <svg class="w-3.5 h-3.5 text-blue-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1617
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
1618
+ d="M4 7v10c0 2 1 3 3 3h10c2 0 3-1 3-3V7c0-2-1-3-3-3H7C5 4 4 5 4 7zm4 0h8M8 12h8M8 17h5" />
1619
+ </svg>
1620
+ <span class="text-xs font-mono font-semibold text-white truncate" title="${escapeHtml(name)}">${escapeHtml(name)}</span>
1621
+ </div>
1622
+ <div class="text-xs text-gray-400" title="${escapeHtml(plexTitle)} ${escapeHtml(rgTitle)}">Plex ${escapeHtml(String(plex))} &middot; RG ${escapeHtml(String(rg))}</div>
1623
+ `;
1624
+
1625
+ return card;
1626
+ }
1627
+
1628
+ // Create a disk-slot card for the disk grid — no hover, all info visible inline
1629
+ function createDiskCard(disk) {
1630
+ const card = document.createElement('div');
1631
+
1632
+ const state = disk.state || '';
1633
+ const usedPct = typeof disk.used_pct === 'number' ? disk.used_pct : 0;
1634
+ const pct = Math.min(Math.max(usedPct * 100, 0), 100);
1635
+
1636
+ // Strip "data disk " / "spare disk " prefix — keep just the slot address
1637
+ const rawDesc = disk.description || `Disk ${disk.index}`;
1638
+ const shortDesc = rawDesc.replace(/^(data disk\s+|spare disk\s+)/i, '').trim() || rawDesc;
1639
+
1640
+ let borderClass, stateColor, stateLabel;
1641
+ switch (state) {
1642
+ case 'ACTIVE':
1643
+ borderClass = 'border-emerald-500'; stateColor = 'text-emerald-400'; stateLabel = 'Active'; break;
1644
+ case 'SPARE':
1645
+ borderClass = 'border-blue-500'; stateColor = 'text-blue-400'; stateLabel = 'Spare'; break;
1646
+ case 'RECONSTRUCTING':
1647
+ borderClass = 'border-yellow-500'; stateColor = 'text-yellow-400'; stateLabel = 'Rebuilding'; break;
1648
+ case 'FAILED':
1649
+ borderClass = 'border-red-500'; stateColor = 'text-red-400'; stateLabel = 'Failed'; break;
1650
+ default:
1651
+ borderClass = 'border-gray-600'; stateColor = 'text-gray-400'; stateLabel = state || 'Unknown';
1652
+ }
1653
+
1654
+ const barColor = state === 'FAILED' ? 'bg-red-500'
1655
+ : state === 'RECONSTRUCTING' ? 'bg-yellow-500'
1656
+ : state === 'SPARE' ? 'bg-blue-500'
1657
+ : 'bg-emerald-500';
1658
+
1659
+ const totalKb = disk.total_kb || 0;
1660
+ const totalStr = totalKb >= 1048576 ? `${(totalKb / 1048576).toFixed(0)} GB`
1661
+ : totalKb >= 1024 ? `${(totalKb / 1024).toFixed(0)} MB`
1662
+ : totalKb > 0 ? `${totalKb} KB`
1663
+ : '—';
1664
+
1665
+ card.className = `bg-gray-800 rounded-lg p-2 border-2 ${borderClass}`;
1666
+ card.innerHTML = `
1667
+ <div class="text-xs font-mono font-semibold text-white truncate mb-1 leading-tight"
1668
+ title="${escapeHtml(rawDesc)}">${escapeHtml(shortDesc)}</div>
1669
+ <div class="flex items-center justify-between mb-1.5 leading-tight">
1670
+ <span class="${stateColor} text-xs font-medium">${escapeHtml(stateLabel)}</span>
1671
+ <span class="text-gray-400 text-xs">${escapeHtml(totalStr)}</span>
1672
+ </div>
1673
+ <div class="flex items-center gap-1">
1674
+ <div class="flex-1 h-1.5 bg-gray-700 rounded-full overflow-hidden">
1675
+ <div class="h-full ${barColor} rounded-full transition-all duration-300" style="width: ${pct}%"></div>
1676
+ </div>
1677
+ <span class="${stateColor} text-xs font-mono flex-shrink-0 w-7 text-right">${pct.toFixed(0)}%</span>
1678
+ </div>
1679
+ `;
1680
+
1681
+ return card;
1682
+ }
1683
+
1684
+ // Decode ups.output.source string → { label, cls } for display
1685
+ function upsOutputSourceInfo(source) {
1686
+ switch (source) {
1687
+ case 'normal': return { label: 'AC Normal', cls: 'text-green-400' };
1688
+ case 'battery': return { label: 'On Battery', cls: 'text-yellow-400' };
1689
+ case 'bypass': return { label: 'Bypass', cls: 'text-blue-400' };
1690
+ case 'booster': return { label: 'Booster', cls: 'text-yellow-400' };
1691
+ case 'reducer': return { label: 'Reducer', cls: 'text-yellow-400' };
1692
+ case 'none': return { label: 'None', cls: 'text-gray-400' };
1693
+ default: return { label: source || 'Unknown', cls: 'text-gray-400' };
1694
+ }
1695
+ }
1696
+
1697
+ // Decode ups.battery.status string → { label, cls } for display
1698
+ function upsBatteryStatusInfo(status) {
1699
+ switch (status) {
1700
+ case 'normal': return { label: 'Normal', cls: 'text-green-400' };
1701
+ case 'low_battery':return { label: 'Low Battery', cls: 'text-yellow-400' };
1702
+ case 'depleted': return { label: 'Depleted', cls: 'text-red-400' };
1703
+ case 'discharging':return { label: 'Discharging', cls: 'text-yellow-400' };
1704
+ case 'bypass': return { label: 'Bypass', cls: 'text-blue-400' };
1705
+ default: return { label: status || 'Unknown', cls: 'text-gray-400' };
1706
+ }
1707
+ }