commit ccf1ee519730171df36f2917adc9b19ede374ef3 Author: alex Date: Fri Nov 7 19:13:23 2025 +0100 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..1f6d1b6 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1841 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +dependencies = [ + "windows-sys 0.60.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.60.2", +] + +[[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core 0.3.4", + "bitflags", + "bytes", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.32", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 0.1.2", + "tower 0.4.13", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +dependencies = [ + "async-trait", + "axum-core 0.4.5", + "bytes", + "futures-util", + "http 1.3.1", + "http-body 1.0.1", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 1.0.2", + "tower 0.5.2", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.3.1", + "http-body 1.0.1", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 1.0.2", + "tower-layer", + "tower-service", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "clap" +version = "4.5.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-macro", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "h2" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap 2.12.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.3.1", + "indexmap 2.12.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.3.1", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http 1.3.1", + "http-body 1.0.1", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.3.27", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.5.10", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2 0.4.12", + "http 1.3.1", + "http-body 1.0.1", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper 0.14.32", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper 1.7.0", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http 1.3.1", + "http-body 1.0.1", + "hyper 1.7.0", + "libc", + "pin-project-lite", + "socket2 0.6.1", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +dependencies = [ + "equivalent", + "hashbrown 0.16.0", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.177" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" + +[[package]] +name = "log" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "opentelemetry" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "570074cc999d1a58184080966e5bd3bf3a9a4af650c3b05047c2621e7405cd17" +dependencies = [ + "futures-core", + "futures-sink", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", +] + +[[package]] +name = "opentelemetry-otlp" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29e1f9c8b032d4f635c730c0efcf731d5e2530ea13fa8bef7939ddc8420696bd" +dependencies = [ + "async-trait", + "futures-core", + "http 1.3.1", + "opentelemetry", + "opentelemetry-proto", + "opentelemetry_sdk", + "prost 0.13.5", + "thiserror", + "tokio", + "tonic 0.12.3", +] + +[[package]] +name = "opentelemetry-proto" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9d3968ce3aefdcca5c27e3c4ea4391b37547726a70893aab52d3de95d5f8b34" +dependencies = [ + "opentelemetry", + "opentelemetry_sdk", + "prost 0.13.5", + "tonic 0.12.3", +] + +[[package]] +name = "opentelemetry-semantic-conventions" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db945c1eaea8ac6a9677185357480d215bb6999faa9f691d0c4d4d641eab7a09" + +[[package]] +name = "opentelemetry_sdk" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c627d9f4c9cdc1f21a29ee4bfbd6028fcb8bcf2a857b43f3abdf72c9c862f3" +dependencies = [ + "async-trait", + "futures-channel", + "futures-executor", + "futures-util", + "glob", + "once_cell", + "opentelemetry", + "percent-encoding", + "rand", + "serde_json", + "thiserror", + "tokio", + "tokio-stream", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +dependencies = [ + "bytes", +] + +[[package]] +name = "prost" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "regex" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", + "serde_core", +] + +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "symon" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "opentelemetry", + "opentelemetry-otlp", + "opentelemetry-semantic-conventions", + "opentelemetry_sdk", + "regex", + "serde", + "sysinfo", + "thiserror", + "tokio", + "toml", + "tonic 0.11.0", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "syn" +version = "2.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "sysinfo" +version = "0.31.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be" +dependencies = [ + "core-foundation-sys", + "libc", + "memchr", + "ntapi", + "rayon", + "windows", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "tokio" +version = "1.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.6.1", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bd86198d9ee903fedd2f9a2e72014287c0d9167e4ae43b5853007205dda1b76" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2efa149fe76073d6e8fd97ef4f4eca7b67f599660115591483572e406e165594" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap 2.12.0", + "serde", + "serde_spanned", + "toml_datetime", + "toml_write", + "winnow", +] + +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + +[[package]] +name = "tonic" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +dependencies = [ + "async-stream", + "async-trait", + "axum 0.6.20", + "base64 0.21.7", + "bytes", + "h2 0.3.27", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.32", + "hyper-timeout 0.4.1", + "percent-encoding", + "pin-project", + "prost 0.12.6", + "tokio", + "tokio-stream", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" +dependencies = [ + "async-stream", + "async-trait", + "axum 0.7.9", + "base64 0.22.1", + "bytes", + "h2 0.4.12", + "http 1.3.1", + "http-body 1.0.1", + "http-body-util", + "hyper 1.7.0", + "hyper-timeout 0.5.2", + "hyper-util", + "percent-encoding", + "pin-project", + "prost 0.13.5", + "socket2 0.5.10", + "tokio", + "tokio-stream", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 1.0.2", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" +dependencies = [ + "windows-core", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-core" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-implement" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "winnow" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +dependencies = [ + "memchr", +] + +[[package]] +name = "zerocopy" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..4fb3456 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "symon" +version = "0.1.0" +edition = "2021" +authors = ["Alex"] +description = "Lightweight system metrics exporter for OpenTelemetry" +license = "MIT OR Apache-2.0" +repository = "https://github.com/battilo/symon" + +[dependencies] +# OpenTelemetry +opentelemetry = { version = "0.26", features = ["metrics"] } +opentelemetry-otlp = { version = "0.26", features = ["metrics", "grpc-tonic"] } +opentelemetry_sdk = { version = "0.26", features = ["metrics", "rt-tokio"] } +opentelemetry-semantic-conventions = "0.26" + +# Async runtime +tokio = { version = "1.48", features = ["rt-multi-thread", "macros", "sync", "time", "signal"] } +tonic = "0.11" + +# System metrics collection +sysinfo = "0.31" + +# Configuration +serde = { version = "1.0", features = ["derive"] } +toml = "0.8" + +# Logging and error handling +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +anyhow = "1.0" +thiserror = "1.0" + +# Process filtering +regex = "1.11" + +# CLI +clap = { version = "4.5", features = ["derive"] } + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 +strip = true diff --git a/docker-compose/METRICS.md b/docker-compose/METRICS.md new file mode 100644 index 0000000..266eafd --- /dev/null +++ b/docker-compose/METRICS.md @@ -0,0 +1,227 @@ +# Bottom OpenTelemetry Metrics Reference + +This document lists all metrics exported by Bottom when running with the `opentelemetry` feature enabled. + +## System Metrics + +### CPU + +| Metric Name | Type | Labels | Description | +|------------|------|--------|-------------| +| `system_cpu_usage_percent` | Gauge | `cpu_id` | CPU usage percentage per core | + +**Example:** +```promql +# Average CPU across all cores +avg(system_cpu_usage_percent) + +# CPU usage for core 0 +system_cpu_usage_percent{cpu_id="0"} +``` + +### Memory + +| Metric Name | Type | Labels | Description | +|------------|------|--------|-------------| +| `system_memory_usage_bytes` | Gauge | - | RAM memory currently in use | +| `system_memory_total_bytes` | Gauge | - | Total RAM memory available | +| `system_swap_usage_bytes` | Gauge | - | Swap memory currently in use | +| `system_swap_total_bytes` | Gauge | - | Total swap memory available | + +**Example:** +```promql +# Memory usage percentage +(system_memory_usage_bytes / system_memory_total_bytes) * 100 + +# Available memory +system_memory_total_bytes - system_memory_usage_bytes +``` + +### Network + +| Metric Name | Type | Labels | Description | +|------------|------|--------|-------------| +| `system_network_rx_bytes_rate` | Gauge | `interface` | Network receive rate in bytes/sec | +| `system_network_tx_bytes_rate` | Gauge | `interface` | Network transmit rate in bytes/sec | + +**Example:** +```promql +# Total network throughput +sum(system_network_rx_bytes_rate) + sum(system_network_tx_bytes_rate) + +# RX rate for specific interface +system_network_rx_bytes_rate{interface="eth0"} +``` + +### Disk + +| Metric Name | Type | Labels | Description | +|------------|------|--------|-------------| +| `system_disk_usage_bytes` | Gauge | `device`, `mount` | Disk space currently in use | +| `system_disk_total_bytes` | Gauge | `device`, `mount` | Total disk space available | + +**Example:** +```promql +# Disk usage percentage +(system_disk_usage_bytes / system_disk_total_bytes) * 100 + +# Free disk space +system_disk_total_bytes - system_disk_usage_bytes +``` + +### Temperature + +| Metric Name | Type | Labels | Description | +|------------|------|--------|-------------| +| `system_temperature_celsius` | Gauge | `sensor` | Temperature readings in Celsius | + +**Example:** +```promql +# Average temperature across all sensors +avg(system_temperature_celsius) + +# Maximum temperature +max(system_temperature_celsius) +``` + +## Process Metrics + +| Metric Name | Type | Labels | Description | +|------------|------|--------|-------------| +| `system_process_cpu_usage_percent` | Gauge | `name`, `pid` | CPU usage percentage per process | +| `system_process_memory_usage_bytes` | Gauge | `name`, `pid` | Memory usage in bytes per process | +| `system_process_count` | Gauge | - | Total number of processes | + +**Example:** +```promql +# Top 10 processes by CPU +topk(10, system_process_cpu_usage_percent) + +# Top 10 processes by memory +topk(10, system_process_memory_usage_bytes) + +# Total memory used by all Chrome processes +sum(system_process_memory_usage_bytes{name=~".*chrome.*"}) +``` + +## Recording Rules + +The following recording rules are pre-configured in Prometheus (see `rules/bottom_rules.yml`): + +| Rule Name | Expression | Description | +|-----------|------------|-------------| +| `system_process_cpu_usage_percent:recent` | Recent process CPU metrics | Filters out stale process data (>2 min old) | +| `system_process_memory_usage_bytes:recent` | Recent process memory metrics | Filters out stale process data (>2 min old) | + +**Example:** +```promql +# Query only recent process data +topk(10, system_process_cpu_usage_percent:recent) +``` + +## Common Queries + +### System Health + +```promql +# Overall system CPU usage +avg(system_cpu_usage_percent) + +# Memory pressure (>80% is high) +(system_memory_usage_bytes / system_memory_total_bytes) * 100 + +# Disk pressure (>90% is critical) +(system_disk_usage_bytes / system_disk_total_bytes) * 100 +``` + +### Resource Hogs + +```promql +# Top CPU consumers +topk(5, system_process_cpu_usage_percent) + +# Top memory consumers +topk(5, system_process_memory_usage_bytes) + +# Processes using >1GB memory +system_process_memory_usage_bytes > 1073741824 +``` + +### Network Analysis + +```promql +# Total network traffic (RX + TX) +sum(system_network_rx_bytes_rate) + sum(system_network_tx_bytes_rate) + +# Network traffic by interface +sum by (interface) (system_network_rx_bytes_rate + system_network_tx_bytes_rate) + +# Interfaces with high RX rate (>10MB/s) +system_network_rx_bytes_rate > 10485760 +``` + +## Alerting Examples + +### Sample Prometheus Alert Rules + +```yaml +groups: + - name: bottom_alerts + interval: 30s + rules: + - alert: HighCPUUsage + expr: avg(system_cpu_usage_percent) > 80 + for: 5m + labels: + severity: warning + annotations: + summary: "High CPU usage detected" + description: "Average CPU usage is {{ $value }}%" + + - alert: HighMemoryUsage + expr: (system_memory_usage_bytes / system_memory_total_bytes) * 100 > 90 + for: 5m + labels: + severity: warning + annotations: + summary: "High memory usage detected" + description: "Memory usage is {{ $value }}%" + + - alert: DiskAlmostFull + expr: (system_disk_usage_bytes / system_disk_total_bytes) * 100 > 90 + for: 10m + labels: + severity: critical + annotations: + summary: "Disk {{ $labels.mount }} almost full" + description: "Disk usage is {{ $value }}% on {{ $labels.mount }}" +``` + +## Label Reference + +| Label | Used In | Description | +|-------|---------|-------------| +| `cpu_id` | CPU metrics | CPU core identifier (0, 1, 2, ...) | +| `interface` | Network metrics | Network interface name (eth0, wlan0, ...) | +| `device` | Disk metrics | Device name (/dev/sda1, ...) | +| `mount` | Disk metrics | Mount point (/, /home, ...) | +| `sensor` | Temperature | Temperature sensor name | +| `name` | Process metrics | Process name | +| `pid` | Process metrics | Process ID | +| `exported_job` | All | Always "bottom-system-monitor" | +| `otel_scope_name` | All | Always "bottom-system-monitor" | + +## Data Retention + +By default, Prometheus stores metrics for 15 days. You can adjust this in the Prometheus configuration: + +```yaml +# In prometheus.yml +global: + retention_time: 30d # Keep data for 30 days +``` + +For long-term storage, consider using: +- **TimescaleDB** (see `docker-compose-timescale.yml.ko`) +- **Thanos** for multi-cluster metrics +- **Cortex** for horizontally scalable storage diff --git a/docker-compose/README.md b/docker-compose/README.md new file mode 100644 index 0000000..1bdc293 --- /dev/null +++ b/docker-compose/README.md @@ -0,0 +1,195 @@ +# Bottom OpenTelemetry Docker Compose Setup + +This directory contains a Docker Compose setup for running an observability stack to monitor Bottom with OpenTelemetry. + +## Architecture + +The stack includes: + +1. **OpenTelemetry Collector** - Receives metrics from Bottom via OTLP protocol +2. **Prometheus** - Scrapes and stores metrics from the OTEL Collector +3. **Grafana** - Visualizes metrics from Prometheus + +``` +Bottom (with --headless flag) + ↓ (OTLP/gRPC on port 4317) +OpenTelemetry Collector + ↓ (Prometheus scrape on port 8889) +Prometheus + ↓ (Query on port 9090) +Grafana (accessible on port 3000) +``` + +## Quick Start + +### 1. Start the observability stack + +```bash +cd docker-compose +docker-compose up -d +``` + +This will start: +- OpenTelemetry Collector on ports 4317 (gRPC), 4318 (HTTP), 8889 (metrics) +- Prometheus on port 9090 +- Grafana on port 3000 + +### 2. Build Bottom with OpenTelemetry support + +```bash +cd .. +cargo build --release --features opentelemetry +``` + +### 3. Create a configuration file + +Create a `bottom-config.toml` file: + +```toml +[opentelemetry] +enabled = true +endpoint = "http://localhost:4317" +service_name = "bottom-system-monitor" +export_interval_ms = 5000 + +[opentelemetry.metrics] +cpu = true +memory = true +network = true +disk = true +processes = true +temperature = true +gpu = true +``` + +### 4. Run Bottom in headless mode + +```bash +./target/release/btm --config bottom-config.toml --headless +``` + +Or without config file: + +```bash +OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 \ +./target/release/btm --headless +``` + +### 5. Access the dashboards + +- **Prometheus**: http://localhost:9090 +- **Grafana**: http://localhost:3000 (username: `admin`, password: `admin`) + +## Configuration Files + +### otel-collector-config.yml + +Configures the OpenTelemetry Collector to: +- Receive OTLP data on ports 4317 (gRPC) and 4318 (HTTP) +- Export metrics in Prometheus format on port 9090 +- Debug log all received data + +### prometheus.yml + +Configures Prometheus to: +- Scrape metrics from the OTEL Collector every 10 seconds +- Load alerting rules from `rules/bottom_rules.yml` + +### rules/bottom_rules.yml + +Contains Prometheus recording rules for Bottom metrics, including: +- Recent process CPU usage metrics +- Recent process memory usage metrics + +## Viewing Metrics in Prometheus + +1. Go to http://localhost:9090 +2. Click on "Graph" +3. Try these example queries: + +```promql +# CPU usage by core +system_cpu_usage_percent + +# Memory usage +system_memory_usage_bytes + +# Network RX/TX +system_network_rx_bytes +system_network_tx_bytes + +# Disk usage +system_disk_usage_bytes + +# Top processes by CPU +topk(10, system_process_cpu_usage_percent) + +# Top processes by memory +topk(10, system_process_memory_usage_bytes) +``` + +## Grafana Configuration + +Grafana is automatically configured with: +- **Prometheus data source** (http://prometheus:9090) - pre-configured +- **Bottom System Overview dashboard** - pre-loaded + +To access: +1. Go to http://localhost:3000 (username: `admin`, password: `admin`) +2. Navigate to Dashboards → Browse → "Bottom System Overview" + +The dashboard includes: +- CPU usage by core +- Memory usage (RAM/Swap) +- Network traffic +- Disk usage +- Top 10 processes by CPU +- Top 10 processes by Memory + +## Stopping the Stack + +```bash +docker-compose down +``` + +To also remove volumes: + +```bash +docker-compose down -v +``` + +## Troubleshooting + +### Bottom not sending metrics + +Check the OTEL Collector logs: +```bash +docker-compose logs -f otel-collector +``` + +You should see messages about receiving metrics. + +### Prometheus not scraping + +1. Check Prometheus targets at http://localhost:9090/targets +2. The `otel-collector` target should be UP + +### No data in Grafana + +1. Verify Prometheus data source is configured correctly +2. Check that Prometheus has data by querying directly +3. Ensure your time range in Grafana includes when Bottom was running + +## Advanced Configuration + +### Using with TimescaleDB (optional) + +A TimescaleDB configuration file is available as `docker-compose-timescale.yml.ko` for long-term storage of metrics. Rename it to include it in your stack. + +### Custom Prometheus Rules + +Edit `rules/bottom_rules.yml` to add custom recording or alerting rules. + +### OTEL Collector Sampling + +Edit `otel-collector-config.yml` to adjust the batch processor settings for different performance characteristics. diff --git a/docker-compose/docker-compose-timescale.yml.ko b/docker-compose/docker-compose-timescale.yml.ko new file mode 100644 index 0000000..05347ca --- /dev/null +++ b/docker-compose/docker-compose-timescale.yml.ko @@ -0,0 +1,61 @@ +services: + timescaledb: + image: timescale/timescaledb-ha:pg15 + environment: + POSTGRES_PASSWORD: password + POSTGRES_DB: promscale + POSTGRES_USER: postgres + ports: + - "5432:5432" + volumes: + - timescale_data:/var/lib/postgresql/data + + promscale: + image: timescale/promscale:latest + ports: + - "9201:9201" + depends_on: + - timescaledb + environment: + PROMSCALE_DB_URI: postgres://postgres:password@timescaledb:5432/promscale?sslmode=disable + PROMSCALE_STARTUP_INSTALL_EXTENSIONS: "true" + restart: on-failure + + otel-collector: + image: otel/opentelemetry-collector-contrib:latest + container_name: otel-collector + command: ["--config=/etc/otel-collector-config.yml"] + volumes: + - ./otel-collector-config.yml:/etc/otel-collector-config.yml + + ports: + - "4317:4317" + + prometheus: + image: prom/prometheus:latest + container_name: prometheus + volumes: + - ./prometheus.yml:/etc/prometheus/prometheus.yml + - ./rules:/etc/prometheus/rules + ports: + - "9090:9090" # Interfaccia Web di Prometheus + command: + - '--config.file=/etc/prometheus/prometheus.yml' + depends_on: + - otel-collector + + grafana: + image: grafana/grafana:latest + ports: + - "3000:3000" + environment: + - GF_SECURITY_ADMIN_PASSWORD=admin + - GF_SECURITY_ADMIN_USER=admin + volumes: + - grafana-storage:/var/lib/grafana + depends_on: + - prometheus + +volumes: + grafana-storage: + timescale_data: \ No newline at end of file diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml new file mode 100644 index 0000000..fb631a9 --- /dev/null +++ b/docker-compose/docker-compose.yml @@ -0,0 +1,52 @@ +services: + + otel-collector: + image: otel/opentelemetry-collector-contrib:latest + container_name: otel-collector + command: ["--config=/etc/otel-collector-config.yml"] + volumes: + - ./otel-collector-config.yml:/etc/otel-collector-config.yml + ports: + - "4317:4317" # gRPC + - "4318:4318" # HTTP + - "8889:8889" # Prometheus metrics endpoint + networks: + - observ-net + + + prometheus: + image: prom/prometheus:latest + container_name: prometheus + volumes: + - ./prometheus.yml:/etc/prometheus/prometheus.yml + - ./rules:/etc/prometheus/rules + ports: + - "9090:9090" # Interfaccia Web di Prometheus + command: + - '--config.file=/etc/prometheus/prometheus.yml' + depends_on: + - otel-collector + networks: + - observ-net + + grafana: + image: grafana/grafana:latest + ports: + - "3000:3000" + environment: + - GF_SECURITY_ADMIN_PASSWORD=admin + - GF_SECURITY_ADMIN_USER=admin + volumes: + - grafana-storage:/var/lib/grafana + - ./grafana/provisioning:/etc/grafana/provisioning + depends_on: + - prometheus + networks: + - observ-net + +volumes: + grafana-storage: + +networks: + observ-net: + driver: bridge \ No newline at end of file diff --git a/docker-compose/grafana/provisioning/dashboards/bottom-overview.json b/docker-compose/grafana/provisioning/dashboards/bottom-overview.json new file mode 100644 index 0000000..0ec600a --- /dev/null +++ b/docker-compose/grafana/provisioning/dashboards/bottom-overview.json @@ -0,0 +1,278 @@ +{ + "title": "Bottom System Overview", + "uid": "bottom-overview", + "timezone": "browser", + "schemaVersion": 16, + "refresh": "5s", + "editable": true, + "panels": [ + { + "id": 1, + "title": "CPU Usage by Core", + "type": "timeseries", + "gridPos": {"h": 8, "w": 12, "x": 0, "y": 0}, + "targets": [ + { + "expr": "system_cpu_usage_percent", + "legendFormat": "Core {{cpu_id}}", + "refId": "CPU" + } + ], + "fieldConfig": { + "defaults": { + "unit": "percent", + "min": 0, + "max": 100 + } + } + }, + { + "id": 2, + "title": "Memory Usage", + "type": "timeseries", + "gridPos": {"h": 8, "w": 12, "x": 12, "y": 0}, + "targets": [ + { + "expr": "system_memory_usage_bytes", + "legendFormat": "RAM Used", + "refId": "RAM" + }, + { + "expr": "system_memory_total_bytes", + "legendFormat": "RAM Total", + "refId": "RAM_Total" + }, + { + "expr": "system_swap_usage_bytes", + "legendFormat": "Swap Used", + "refId": "Swap" + }, + { + "expr": "system_swap_total_bytes", + "legendFormat": "Swap Total", + "refId": "Swap_Total" + } + ], + "fieldConfig": { + "defaults": { + "unit": "bytes" + } + } + }, + { + "id": 3, + "title": "Network Traffic", + "type": "timeseries", + "gridPos": {"h": 8, "w": 12, "x": 0, "y": 8}, + "targets": [ + { + "expr": "system_network_rx_bytes_rate", + "legendFormat": "RX - {{interface}}", + "refId": "RX" + }, + { + "expr": "system_network_tx_bytes_rate", + "legendFormat": "TX - {{interface}}", + "refId": "TX" + } + ], + "fieldConfig": { + "defaults": { + "unit": "Bps" + } + } + }, + { + "id": 4, + "title": "Disk Usage", + "type": "gauge", + "gridPos": {"h": 8, "w": 12, "x": 12, "y": 8}, + "targets": [ + { + "expr": "(system_disk_usage_bytes / system_disk_total_bytes) * 100", + "legendFormat": "{{mount}} ({{device}})", + "refId": "Disk" + } + ], + "fieldConfig": { + "defaults": { + "unit": "percent", + "min": 0, + "max": 100, + "thresholds": { + "mode": "absolute", + "steps": [ + {"value": 0, "color": "green"}, + {"value": 70, "color": "yellow"}, + {"value": 90, "color": "red"} + ] + } + } + } + }, + { + "id": 5, + "title": "Top 10 Processes by CPU", + "type": "table", + "gridPos": {"h": 8, "w": 12, "x": 0, "y": 16}, + "targets": [ + { + "expr": "topk(10, system_process_cpu_usage_percent and (time() - timestamp(system_process_cpu_usage_percent) < 30))", + "format": "table", + "instant": true, + "refId": "Process" + } + ], + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "job": true, + "instance": true, + "exported_job": true, + "otel_scope_name": true + }, + "indexByName": { + "name": 0, + "pid": 1, + "Value": 2 + }, + "renameByName": { + "name": "Process Name", + "pid": "PID", + "Value": "CPU %" + } + } + } + ], + "options": { + "showHeader": true, + "sortBy": [ + { + "displayName": "CPU %", + "desc": true + } + ] + }, + "fieldConfig": { + "defaults": { + "custom": { + "align": "auto", + "displayMode": "auto" + } + }, + "overrides": [ + { + "matcher": {"id": "byName", "options": "CPU %"}, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.displayMode", + "value": "color-background" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + {"value": 0, "color": "green"}, + {"value": 50, "color": "yellow"}, + {"value": 80, "color": "red"} + ] + } + } + ] + } + ] + } + }, + { + "id": 6, + "title": "Top 10 Processes by Memory", + "type": "table", + "gridPos": {"h": 8, "w": 12, "x": 12, "y": 16}, + "targets": [ + { + "expr": "topk(10, system_process_memory_usage_bytes and (time() - timestamp(system_process_memory_usage_bytes) < 30))", + "format": "table", + "instant": true, + "refId": "Process" + } + ], + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "job": true, + "instance": true, + "exported_job": true, + "otel_scope_name": true + }, + "indexByName": { + "name": 0, + "pid": 1, + "Value": 2 + }, + "renameByName": { + "name": "Process Name", + "pid": "PID", + "Value": "Memory" + } + } + } + ], + "options": { + "showHeader": true, + "sortBy": [ + { + "displayName": "Memory", + "desc": true + } + ] + }, + "fieldConfig": { + "defaults": { + "custom": { + "align": "auto", + "displayMode": "auto" + } + }, + "overrides": [ + { + "matcher": {"id": "byName", "options": "Memory"}, + "properties": [ + { + "id": "unit", + "value": "bytes" + }, + { + "id": "custom.displayMode", + "value": "color-background" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + {"value": 0, "color": "green"}, + {"value": 1073741824, "color": "yellow"}, + {"value": 2147483648, "color": "red"} + ] + } + } + ] + } + ] + } + } + ] +} diff --git a/docker-compose/grafana/provisioning/dashboards/dashboards.yml b/docker-compose/grafana/provisioning/dashboards/dashboards.yml new file mode 100644 index 0000000..2b5c0b3 --- /dev/null +++ b/docker-compose/grafana/provisioning/dashboards/dashboards.yml @@ -0,0 +1,12 @@ +apiVersion: 1 + +providers: + - name: 'Bottom Dashboards' + orgId: 1 + folder: '' + type: file + disableDeletion: false + updateIntervalSeconds: 10 + allowUiUpdates: true + options: + path: /etc/grafana/provisioning/dashboards diff --git a/docker-compose/grafana/provisioning/datasources/prometheus.yml b/docker-compose/grafana/provisioning/datasources/prometheus.yml new file mode 100644 index 0000000..e786a39 --- /dev/null +++ b/docker-compose/grafana/provisioning/datasources/prometheus.yml @@ -0,0 +1,12 @@ +apiVersion: 1 + +datasources: + - name: Prometheus + type: prometheus + access: proxy + url: http://prometheus:9090 + isDefault: true + editable: true + jsonData: + timeInterval: 10s + queryTimeout: 60s diff --git a/docker-compose/otel-collector-config.yml b/docker-compose/otel-collector-config.yml new file mode 100644 index 0000000..6a2f278 --- /dev/null +++ b/docker-compose/otel-collector-config.yml @@ -0,0 +1,31 @@ +receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + http: + endpoint: 0.0.0.0:4318 + +processors: + batch: + send_batch_size: 10000 + timeout: 10s + metricsgeneration: {} + +exporters: + prometheus: + endpoint: "0.0.0.0:8889" + debug: + verbosity: detailed + +service: + pipelines: + metrics: + receivers: [otlp] + processors: [batch] + exporters: [prometheus, debug] + + logs: + receivers: [otlp] + processors: [batch] + exporters: [debug] \ No newline at end of file diff --git a/docker-compose/processes-example.toml b/docker-compose/processes-example.toml new file mode 100644 index 0000000..1f8f6f7 --- /dev/null +++ b/docker-compose/processes-example.toml @@ -0,0 +1,67 @@ +# Example process filter configuration file +# This file can be included from the main bottom config to keep +# server-specific process lists separate. +# +# Usage in bottom-config.toml: +# [opentelemetry.metrics.process_filter] +# include = "processes.toml" + +# Filter mode: "whitelist" or "blacklist" +# - whitelist: Only export metrics for processes in the lists below +# - blacklist: Export metrics for all processes EXCEPT those in the lists +filter_mode = "whitelist" + +# Process names to monitor (case-insensitive substring match) +# Examples for common server processes: +names = [ + # Web servers + "nginx", + "apache", + "httpd", + + # Databases + "postgres", + "mysql", + "redis", + "mongodb", + + # Application servers + "java", + "node", + "python", + + # Your custom applications + # "myapp", +] + +# Regex patterns to match process names (case-sensitive) +# More powerful than simple substring matching +patterns = [ + # Match specific versions + # "^nginx-[0-9.]+$", + # "^node-v[0-9]+", + + # Match Java applications with specific main class + # "java.*MyApplication", + + # Match processes with specific format + # "^gunicorn: worker", + + # Match kernel threads (for blacklist) + # "^\\[.*\\]$", +] + +# Specific process PIDs to monitor (optional) +# Useful for monitoring specific long-running processes +pids = [] + +# Example blacklist configuration: +# filter_mode = "blacklist" +# names = [ +# "systemd", # Exclude system processes +# "kworker", +# "migration", +# ] +# patterns = [ +# "^\\[.*\\]$", # Exclude all kernel threads +# ] diff --git a/docker-compose/prometheus.yml b/docker-compose/prometheus.yml new file mode 100644 index 0000000..86f124f --- /dev/null +++ b/docker-compose/prometheus.yml @@ -0,0 +1,21 @@ +global: + scrape_interval: 10s # Quanto spesso fare lo scraping + evaluation_interval: 10s + +rule_files: + - /etc/prometheus/rules/*.yml + +scrape_configs: + # Job 1: Monitora se Prometheus stesso è attivo + - job_name: 'prometheus' + static_configs: + - targets: ['localhost:9090'] + + # Job 2: Scrape dell'OpenTelemetry Collector + - job_name: 'otel-collector' + # Il Collector espone le metriche per lo scraping sulla sua porta 8889 + metrics_path: '/metrics' + static_configs: + # Raggiunge il Collector usando il suo nome di servizio Docker + - targets: ['otel-collector:8889'] + diff --git a/docker-compose/rules/bottom_rules.yml b/docker-compose/rules/bottom_rules.yml new file mode 100644 index 0000000..4250345 --- /dev/null +++ b/docker-compose/rules/bottom_rules.yml @@ -0,0 +1,15 @@ +groups: + - name: bottom_process_metrics + interval: 30s + rules: + - record: system_process_cpu_usage_percent:recent + expr: | + system_process_cpu_usage_percent + and on(pid, name) + (time() - timestamp(system_process_cpu_usage_percent) < 120) + + - record: system_process_memory_usage_bytes:recent + expr: | + system_process_memory_usage_bytes + and on(pid, name) + (time() - timestamp(system_process_memory_usage_bytes) < 120) \ No newline at end of file diff --git a/docker-compose/symon-config-example.toml b/docker-compose/symon-config-example.toml new file mode 100644 index 0000000..c66f01c --- /dev/null +++ b/docker-compose/symon-config-example.toml @@ -0,0 +1,61 @@ +# Example Symon configuration file for OpenTelemetry export +# Copy this file and customize it for your needs + +# Collection interval in seconds +collection_interval_secs = 5 + +# OTLP configuration +[otlp] +# OTLP endpoint (gRPC) +# For local docker-compose setup: http://localhost:4317 +# For remote collector: http://your-collector-host:4317 +endpoint = "http://localhost:4317" + +# Export interval in seconds +export_interval_secs = 10 + +# Service name that will appear in metrics +service_name = "symon" + +# Service version +service_version = "0.1.0" + +# Export timeout in seconds +export_timeout_secs = 30 + +# Additional resource attributes (key-value pairs) +[otlp.resource_attributes] +environment = "production" +host = "server-01" + +# Metrics configuration - enable/disable specific metric types +[metrics] +cpu = true # CPU usage per core and average +memory = true # RAM, swap usage +network = true # Network RX/TX +disk = true # Disk usage +temperature = true # CPU/GPU temperatures +processes = true # Top 10 processes by CPU/Memory + +# Process filtering configuration +[metrics.process_filter] +# Option 1: Use an external file for server-specific process lists +# This allows different servers to monitor different processes +# Path can be relative to this config file or absolute +#include = "processes.toml" + +# Option 2: Configure inline +# Filter mode: "whitelist" (only listed processes) or "blacklist" (exclude listed) +filter_mode = "whitelist" + +# List of process names to filter (case-insensitive substring match) +# Examples: ["nginx", "postgres", "redis", "myapp"] +names = ["nginx", "postgres", "redis"] + +# List of regex patterns to match process names (case-sensitive) +# More powerful than substring matching +# Examples: ["^nginx-[0-9.]+$", "java.*MyApp", "^gunicorn: worker"] +patterns = [] + +# List of specific process PIDs to filter +pids = [] diff --git a/docker-compose/test-stack.sh b/docker-compose/test-stack.sh new file mode 100755 index 0000000..3db3037 --- /dev/null +++ b/docker-compose/test-stack.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# Test script to verify the observability stack is running correctly + +set -e + +echo "🔍 Testing Bottom OpenTelemetry Stack..." +echo "" + +# Colors +GREEN='\033[0;32m' +RED='\033[0;31m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Test OTEL Collector gRPC endpoint +echo -n "Testing OTEL Collector gRPC (port 4317)... " +if nc -zv localhost 4317 2>&1 | grep -q "succeeded\|open"; then + echo -e "${GREEN}✓ OK${NC}" +else + echo -e "${RED}✗ FAILED${NC}" + exit 1 +fi + +# Test OTEL Collector HTTP endpoint +echo -n "Testing OTEL Collector HTTP (port 4318)... " +if nc -zv localhost 4318 2>&1 | grep -q "succeeded\|open"; then + echo -e "${GREEN}✓ OK${NC}" +else + echo -e "${RED}✗ FAILED${NC}" + exit 1 +fi + +# Test OTEL Collector metrics endpoint +echo -n "Testing OTEL Collector metrics (port 8889)... " +if curl -s http://localhost:8889/metrics > /dev/null; then + echo -e "${GREEN}✓ OK${NC}" +else + echo -e "${RED}✗ FAILED${NC}" + exit 1 +fi + +# Test Prometheus +echo -n "Testing Prometheus (port 9090)... " +if curl -s http://localhost:9090/-/healthy | grep -q "Prometheus"; then + echo -e "${GREEN}✓ OK${NC}" +else + echo -e "${RED}✗ FAILED${NC}" + exit 1 +fi + +# Test Prometheus targets +echo -n "Testing Prometheus targets... " +TARGETS=$(curl -s http://localhost:9090/api/v1/targets | grep -o '"health":"up"' | wc -l) +if [ "$TARGETS" -gt 0 ]; then + echo -e "${GREEN}✓ OK${NC} (${TARGETS} targets up)" +else + echo -e "${YELLOW}⚠ WARNING${NC} (no targets up yet - this is normal if just started)" +fi + +# Test Grafana +echo -n "Testing Grafana (port 3000)... " +if curl -s http://localhost:3000/api/health | grep -q "ok"; then + echo -e "${GREEN}✓ OK${NC}" +else + echo -e "${RED}✗ FAILED${NC}" + exit 1 +fi + +echo "" +echo -e "${GREEN}✓ All tests passed!${NC}" +echo "" +echo "📊 Access points:" +echo " - Prometheus: http://localhost:9090" +echo " - Grafana: http://localhost:3000 (admin/admin)" +echo " - OTEL Collector metrics: http://localhost:8889/metrics" +echo "" +echo "💡 Next steps:" +echo " 1. Build bottom with: cargo build --release --features opentelemetry" +echo " 2. Run in headless mode: ./target/release/btm --headless" +echo " 3. Check metrics in Prometheus: http://localhost:9090/graph" diff --git a/src/collector.rs b/src/collector.rs new file mode 100644 index 0000000..6cb110a --- /dev/null +++ b/src/collector.rs @@ -0,0 +1,214 @@ +use crate::config::MetricsConfig; +use anyhow::Result; +use sysinfo::{CpuRefreshKind, Disks, Networks, RefreshKind, System}; + +/// System metrics collected at a point in time +#[derive(Debug, Clone)] +pub struct SystemMetrics { + pub cpu: Option>, + pub memory: Option, + pub network: Option>, + pub disk: Option>, + pub processes: Option>, + pub temperature: Option>, +} + +#[derive(Debug, Clone)] +pub struct CpuMetric { + pub core_index: usize, + pub usage_percent: f32, +} + +#[derive(Debug, Clone)] +pub struct MemoryMetric { + pub used_bytes: u64, + pub total_bytes: u64, + pub swap_used_bytes: u64, + pub swap_total_bytes: u64, +} + +#[derive(Debug, Clone)] +pub struct NetworkMetric { + pub interface_name: String, + pub rx_bytes_total: u64, + pub tx_bytes_total: u64, +} + +#[derive(Debug, Clone)] +pub struct DiskMetric { + pub device_name: String, + pub mount_point: String, + pub used_bytes: u64, + pub total_bytes: u64, +} + +#[derive(Debug, Clone)] +pub struct ProcessMetric { + pub pid: u32, + pub name: String, + pub cpu_usage_percent: f32, + pub memory_bytes: u64, +} + +#[derive(Debug, Clone)] +pub struct TemperatureMetric { + pub sensor_name: String, + pub temperature_celsius: f32, +} + +/// Collector for system metrics +pub struct MetricsCollector { + system: System, + networks: Networks, + disks: Disks, + config: MetricsConfig, +} + +impl MetricsCollector { + pub fn new(config: MetricsConfig) -> Self { + let refresh_kind = RefreshKind::new() + .with_cpu(CpuRefreshKind::everything()) + .with_memory(sysinfo::MemoryRefreshKind::everything()) + .with_processes(sysinfo::ProcessRefreshKind::everything()); + + Self { + system: System::new_with_specifics(refresh_kind), + networks: Networks::new_with_refreshed_list(), + disks: Disks::new_with_refreshed_list(), + config, + } + } + + /// Collect all enabled metrics + pub fn collect(&mut self) -> Result { + // Refresh system info + self.system.refresh_all(); + self.networks.refresh(); + + Ok(SystemMetrics { + cpu: if self.config.cpu { + Some(self.collect_cpu()) + } else { + None + }, + memory: if self.config.memory { + Some(self.collect_memory()) + } else { + None + }, + network: if self.config.network { + Some(self.collect_network()) + } else { + None + }, + disk: if self.config.disk { + Some(self.collect_disk()) + } else { + None + }, + processes: if self.config.processes { + Some(self.collect_processes()) + } else { + None + }, + temperature: if self.config.temperature { + Some(self.collect_temperature()) + } else { + None + }, + }) + } + + fn collect_cpu(&self) -> Vec { + self.system + .cpus() + .iter() + .enumerate() + .map(|(index, cpu)| CpuMetric { + core_index: index, + usage_percent: cpu.cpu_usage(), + }) + .collect() + } + + fn collect_memory(&self) -> MemoryMetric { + MemoryMetric { + used_bytes: self.system.used_memory(), + total_bytes: self.system.total_memory(), + swap_used_bytes: self.system.used_swap(), + swap_total_bytes: self.system.total_swap(), + } + } + + fn collect_network(&self) -> Vec { + self.networks + .iter() + .map(|(interface_name, data)| NetworkMetric { + interface_name: interface_name.to_string(), + rx_bytes_total: data.total_received(), + tx_bytes_total: data.total_transmitted(), + }) + .collect() + } + + fn collect_disk(&self) -> Vec { + self.disks + .iter() + .filter_map(|disk| { + let total_bytes = disk.total_space(); + let available_bytes = disk.available_space(); + let used_bytes = total_bytes.saturating_sub(available_bytes); + + Some(DiskMetric { + device_name: disk.name().to_string_lossy().to_string(), + mount_point: disk.mount_point().to_string_lossy().to_string(), + used_bytes, + total_bytes, + }) + }) + .collect() + } + + fn collect_processes(&self) -> Vec { + let filter = self.config.process_filter.as_ref(); + + let mut processes: Vec = self + .system + .processes() + .iter() + .filter(|(_, process)| { + if let Some(filter_config) = filter { + filter_config.should_include_process( + process.name().to_string_lossy().as_ref(), + process.pid().as_u32(), + ) + } else { + true + } + }) + .map(|(_, process)| ProcessMetric { + pid: process.pid().as_u32(), + name: process.name().to_string_lossy().to_string(), + cpu_usage_percent: process.cpu_usage(), + memory_bytes: process.memory(), + }) + .collect(); + + // Sort by CPU usage and limit to top 10 + processes.sort_by(|a, b| { + b.cpu_usage_percent + .partial_cmp(&a.cpu_usage_percent) + .unwrap_or(std::cmp::Ordering::Equal) + }); + processes.truncate(10); + + processes + } + + fn collect_temperature(&self) -> Vec { + // sysinfo doesn't have direct temperature support in 0.31 + // This would require platform-specific implementation or additional crates + // For now, return empty vector + vec![] + } +} diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..87e7493 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,347 @@ +use anyhow::{Context, Result}; +use regex::Regex; +use serde::{Deserialize, Serialize}; +use std::path::{Path, PathBuf}; +use std::time::Duration; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Config { + /// OpenTelemetry export configuration + #[serde(default)] + pub otlp: OtlpConfig, + + /// Metrics collection configuration + #[serde(default)] + pub metrics: MetricsConfig, + + /// Collection interval + #[serde(default = "default_collection_interval")] + pub collection_interval_secs: u64, +} + +impl Default for Config { + fn default() -> Self { + Self { + otlp: OtlpConfig::default(), + metrics: MetricsConfig::default(), + collection_interval_secs: default_collection_interval(), + } + } +} + +impl Config { + /// Load configuration from file + pub fn from_file(path: &Path) -> Result { + let content = std::fs::read_to_string(path) + .with_context(|| format!("Failed to read config file: {}", path.display()))?; + + let mut config: Config = toml::from_str(&content) + .with_context(|| format!("Failed to parse config file: {}", path.display()))?; + + // Load process filter includes if configured + if let Some(process_filter) = &config.metrics.process_filter { + let config_dir = path.parent(); + match process_filter.load_with_includes(config_dir) { + Ok(loaded_filter) => { + config.metrics.process_filter = Some(loaded_filter); + } + Err(e) => { + tracing::warn!("Failed to load process filter include: {}", e); + } + } + } + + config.validate()?; + Ok(config) + } + + /// Validate configuration + pub fn validate(&self) -> Result<()> { + if self.collection_interval_secs == 0 { + anyhow::bail!("Collection interval must be greater than 0"); + } + + self.otlp.validate()?; + Ok(()) + } + + pub fn collection_interval(&self) -> Duration { + Duration::from_secs(self.collection_interval_secs) + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct OtlpConfig { + /// OTLP endpoint (e.g., "http://localhost:4317") + #[serde(default = "default_endpoint")] + pub endpoint: String, + + /// Export interval in seconds + #[serde(default = "default_export_interval")] + pub export_interval_secs: u64, + + /// Service name for the metrics + #[serde(default = "default_service_name")] + pub service_name: String, + + /// Service version + #[serde(default = "default_service_version")] + pub service_version: String, + + /// Additional resource attributes + #[serde(default)] + pub resource_attributes: std::collections::HashMap, + + /// Timeout for export operations in seconds + #[serde(default = "default_timeout")] + pub export_timeout_secs: u64, +} + +impl Default for OtlpConfig { + fn default() -> Self { + Self { + endpoint: default_endpoint(), + export_interval_secs: default_export_interval(), + service_name: default_service_name(), + service_version: default_service_version(), + resource_attributes: std::collections::HashMap::new(), + export_timeout_secs: default_timeout(), + } + } +} + +impl OtlpConfig { + pub fn export_interval(&self) -> Duration { + Duration::from_secs(self.export_interval_secs) + } + + pub fn export_timeout(&self) -> Duration { + Duration::from_secs(self.export_timeout_secs) + } + + pub fn validate(&self) -> Result<()> { + if self.endpoint.is_empty() { + anyhow::bail!("OTLP endpoint cannot be empty"); + } + + if !self.endpoint.starts_with("http://") && !self.endpoint.starts_with("https://") { + anyhow::bail!("OTLP endpoint must be a valid HTTP/HTTPS URL"); + } + + if self.export_interval_secs == 0 { + anyhow::bail!("Export interval must be greater than 0"); + } + + if self.service_name.is_empty() { + anyhow::bail!("Service name cannot be empty"); + } + + Ok(()) + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct MetricsConfig { + /// Export CPU metrics + #[serde(default = "default_true")] + pub cpu: bool, + + /// Export memory metrics + #[serde(default = "default_true")] + pub memory: bool, + + /// Export network metrics + #[serde(default = "default_true")] + pub network: bool, + + /// Export disk metrics + #[serde(default = "default_true")] + pub disk: bool, + + /// Export process metrics + #[serde(default)] + pub processes: bool, + + /// Export temperature metrics + #[serde(default = "default_true")] + pub temperature: bool, + + /// Process filter configuration + #[serde(default)] + pub process_filter: Option, +} + +impl Default for MetricsConfig { + fn default() -> Self { + Self { + cpu: true, + memory: true, + network: true, + disk: true, + processes: false, + temperature: true, + process_filter: None, + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ProcessFilterConfig { + /// Path to external file containing process filter (optional) + #[serde(skip_serializing_if = "Option::is_none")] + pub include: Option, + + /// Filter mode: "whitelist" or "blacklist" + #[serde(skip_serializing_if = "Option::is_none")] + pub filter_mode: Option, + + /// List of process names to filter (case-insensitive substring match) + #[serde(default)] + pub names: Vec, + + /// List of regex patterns to match process names + #[serde(default)] + pub patterns: Vec, + + /// List of process PIDs to filter + #[serde(default)] + pub pids: Vec, + + /// Compiled regex patterns (not serialized, built at runtime) + #[serde(skip)] + compiled_patterns: Option>, +} + +impl ProcessFilterConfig { + /// Load and merge process filter from include file if specified + pub fn load_with_includes(& self, config_dir: Option<&Path>) -> Result { + if let Some(include_path) = &self.include { + // Resolve path relative to config directory if provided + let full_path = if include_path.is_absolute() { + include_path.clone() + } else if let Some(dir) = config_dir { + dir.join(include_path) + } else { + include_path.clone() + }; + + // Read and parse the included file + let content = std::fs::read_to_string(&full_path) + .with_context(|| format!("Failed to read process filter file: {}", full_path.display()))?; + + let included: ProcessFilterConfig = toml::from_str(&content) + .with_context(|| format!("Failed to parse process filter file: {}", full_path.display()))?; + + // Merge: included file takes precedence + let mut merged = Self { + include: None, + filter_mode: included.filter_mode.or(self.filter_mode), + names: if included.names.is_empty() { + self.names.clone() + } else { + included.names + }, + patterns: if included.patterns.is_empty() { + self.patterns.clone() + } else { + included.patterns + }, + pids: if included.pids.is_empty() { + self.pids.clone() + } else { + included.pids + }, + compiled_patterns: None, + }; + + merged.compile_patterns()?; + Ok(merged) + } else { + let mut result = self.clone(); + result.compile_patterns()?; + Ok(result) + } + } + + /// Compile regex patterns from strings + fn compile_patterns(&mut self) -> Result<()> { + if self.patterns.is_empty() { + self.compiled_patterns = None; + return Ok(()); + } + + let mut compiled = Vec::new(); + for pattern in &self.patterns { + let regex = Regex::new(pattern) + .with_context(|| format!("Invalid regex pattern: {}", pattern))?; + compiled.push(regex); + } + + self.compiled_patterns = Some(compiled); + Ok(()) + } + + /// Check if a process should be included based on filter configuration + pub fn should_include_process(&self, process_name: &str, process_pid: u32) -> bool { + let filter_mode = match &self.filter_mode { + Some(mode) => mode, + None => return true, + }; + + // Check if process matches the filter lists + let matches_name = self + .names + .iter() + .any(|name| process_name.to_lowercase().contains(&name.to_lowercase())); + + let matches_pattern = if let Some(patterns) = &self.compiled_patterns { + patterns.iter().any(|regex| regex.is_match(process_name)) + } else { + false + }; + + let matches_pid = self.pids.contains(&process_pid); + let matches = matches_name || matches_pattern || matches_pid; + + match filter_mode { + ProcessFilterMode::Whitelist => matches, + ProcessFilterMode::Blacklist => !matches, + } + } +} + +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "lowercase")] +pub enum ProcessFilterMode { + Whitelist, + Blacklist, +} + +// Default functions +fn default_endpoint() -> String { + "http://localhost:4317".to_string() +} + +fn default_export_interval() -> u64 { + 10 +} + +fn default_collection_interval() -> u64 { + 5 +} + +fn default_service_name() -> String { + "symon".to_string() +} + +fn default_service_version() -> String { + env!("CARGO_PKG_VERSION").to_string() +} + +fn default_timeout() -> u64 { + 30 +} + +fn default_true() -> bool { + true +} diff --git a/src/exporter.rs b/src/exporter.rs new file mode 100644 index 0000000..c36c0b5 --- /dev/null +++ b/src/exporter.rs @@ -0,0 +1,196 @@ +use crate::collector::SystemMetrics; +use crate::config::OtlpConfig; +use anyhow::{Context, Result}; +use opentelemetry::metrics::MeterProvider; +use opentelemetry::KeyValue; +use opentelemetry_otlp::WithExportConfig; +use opentelemetry_sdk::metrics::{PeriodicReader, SdkMeterProvider}; +use opentelemetry_sdk::Resource; + +pub struct MetricsExporter { + meter_provider: SdkMeterProvider, + gauges: MetricInstruments, +} + +struct MetricInstruments { + cpu_usage: opentelemetry::metrics::Gauge, + memory_usage: opentelemetry::metrics::Gauge, + memory_total: opentelemetry::metrics::Gauge, + swap_usage: opentelemetry::metrics::Gauge, + swap_total: opentelemetry::metrics::Gauge, + network_rx: opentelemetry::metrics::Counter, + network_tx: opentelemetry::metrics::Counter, + disk_usage: opentelemetry::metrics::Gauge, + disk_total: opentelemetry::metrics::Gauge, + process_cpu: opentelemetry::metrics::Gauge, + process_memory: opentelemetry::metrics::Gauge, + temperature: opentelemetry::metrics::Gauge, +} + +impl MetricsExporter { + pub async fn new(config: &OtlpConfig) -> Result { + // Build resource with service information + let mut resource_kvs = vec![ + KeyValue::new("service.name", config.service_name.clone()), + KeyValue::new("service.version", config.service_version.clone()), + ]; + + // Add custom resource attributes + for (key, value) in &config.resource_attributes { + resource_kvs.push(KeyValue::new(key.clone(), value.clone())); + } + + let resource = Resource::new(resource_kvs); + + // Build OTLP exporter using new pipeline API + let exporter = opentelemetry_otlp::new_exporter() + .tonic() + .with_endpoint(&config.endpoint) + .with_timeout(config.export_timeout()) + .build_metrics_exporter( + Box::new(opentelemetry_sdk::metrics::reader::DefaultTemporalitySelector::default()) + ) + .context("Failed to build OTLP metrics exporter")?; + + // Build meter provider + let reader = PeriodicReader::builder(exporter, opentelemetry_sdk::runtime::Tokio) + .with_interval(config.export_interval()) + .build(); + + let meter_provider = SdkMeterProvider::builder() + .with_reader(reader) + .with_resource(resource) + .build(); + + // Create meter and instruments + let meter = meter_provider.meter("symon"); + + let gauges = MetricInstruments { + cpu_usage: meter + .f64_gauge("system_cpu_usage_percent") + .with_description("CPU usage percentage per core") + .init(), + memory_usage: meter + .u64_gauge("system_memory_usage_bytes") + .with_description("Memory usage in bytes") + .init(), + memory_total: meter + .u64_gauge("system_memory_total_bytes") + .with_description("Total memory in bytes") + .init(), + swap_usage: meter + .u64_gauge("system_swap_usage_bytes") + .with_description("Swap usage in bytes") + .init(), + swap_total: meter + .u64_gauge("system_swap_total_bytes") + .with_description("Total swap in bytes") + .init(), + network_rx: meter + .u64_counter("system_network_rx_bytes_total") + .with_description("Total bytes received") + .init(), + network_tx: meter + .u64_counter("system_network_tx_bytes_total") + .with_description("Total bytes transmitted") + .init(), + disk_usage: meter + .u64_gauge("system_disk_usage_bytes") + .with_description("Disk usage in bytes") + .init(), + disk_total: meter + .u64_gauge("system_disk_total_bytes") + .with_description("Total disk space in bytes") + .init(), + process_cpu: meter + .f64_gauge("system_process_cpu_usage_percent") + .with_description("Process CPU usage percentage") + .init(), + process_memory: meter + .u64_gauge("system_process_memory_usage_bytes") + .with_description("Process memory usage in bytes") + .init(), + temperature: meter + .f64_gauge("system_temperature_celsius") + .with_description("Temperature in Celsius") + .init(), + }; + + Ok(Self { + meter_provider, + gauges, + }) + } + + pub fn export(&self, metrics: &SystemMetrics) { + // Export CPU metrics + if let Some(cpu_metrics) = &metrics.cpu { + for cpu in cpu_metrics { + self.gauges.cpu_usage.record( + cpu.usage_percent as f64, + &[KeyValue::new("cpu_id", cpu.core_index as i64)], + ); + } + } + + // Export memory metrics + if let Some(memory) = &metrics.memory { + self.gauges.memory_usage.record(memory.used_bytes, &[]); + self.gauges.memory_total.record(memory.total_bytes, &[]); + self.gauges.swap_usage.record(memory.swap_used_bytes, &[]); + self.gauges.swap_total.record(memory.swap_total_bytes, &[]); + } + + // Export network metrics + if let Some(network_metrics) = &metrics.network { + for net in network_metrics { + let attrs = &[KeyValue::new("interface", net.interface_name.clone())]; + self.gauges.network_rx.add(net.rx_bytes_total, attrs); + self.gauges.network_tx.add(net.tx_bytes_total, attrs); + } + } + + // Export disk metrics + if let Some(disk_metrics) = &metrics.disk { + for disk in disk_metrics { + let attrs = &[ + KeyValue::new("device", disk.device_name.clone()), + KeyValue::new("mount", disk.mount_point.clone()), + ]; + self.gauges.disk_usage.record(disk.used_bytes, attrs); + self.gauges.disk_total.record(disk.total_bytes, attrs); + } + } + + // Export process metrics + if let Some(process_metrics) = &metrics.processes { + for process in process_metrics { + let attrs = &[ + KeyValue::new("pid", process.pid as i64), + KeyValue::new("name", process.name.clone()), + ]; + self.gauges + .process_cpu + .record(process.cpu_usage_percent as f64, attrs); + self.gauges.process_memory.record(process.memory_bytes, attrs); + } + } + + // Export temperature metrics + if let Some(temp_metrics) = &metrics.temperature { + for temp in temp_metrics { + self.gauges.temperature.record( + temp.temperature_celsius as f64, + &[KeyValue::new("sensor", temp.sensor_name.clone())], + ); + } + } + } + + pub async fn shutdown(self) -> Result<()> { + self.meter_provider + .shutdown() + .context("Failed to shutdown meter provider")?; + Ok(()) + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..93537dc --- /dev/null +++ b/src/main.rs @@ -0,0 +1,108 @@ +mod collector; +mod config; +mod exporter; + +use anyhow::{Context, Result}; +use clap::Parser; +use collector::MetricsCollector; +use config::Config; +use exporter::MetricsExporter; +use std::path::PathBuf; +use tokio::signal; +use tokio::time::interval; +use tracing::{error, info}; + +#[derive(Parser, Debug)] +#[command(name = "symon")] +#[command(about = "Lightweight system metrics exporter for OpenTelemetry", long_about = None)] +#[command(version)] +struct Args { + /// Path to configuration file + #[arg(short, long, value_name = "FILE")] + config: Option, + + /// Log level (trace, debug, info, warn, error) + #[arg(short, long, default_value = "info")] + log_level: String, +} + +#[tokio::main] +async fn main() -> Result<()> { + let args = Args::parse(); + + // Initialize tracing + let log_level = args.log_level.parse().unwrap_or(tracing::Level::INFO); + tracing_subscriber::fmt() + .with_max_level(log_level) + .with_target(false) + .init(); + + info!("Starting symon v{}", env!("CARGO_PKG_VERSION")); + + // Load configuration + let config_path = args + .config + .or_else(find_default_config) + .context("No configuration file specified and no default config found")?; + + info!("Loading configuration from: {}", config_path.display()); + let config = Config::from_file(&config_path)?; + + info!( + "OTLP endpoint: {}, export interval: {}s, collection interval: {}s", + config.otlp.endpoint, config.otlp.export_interval_secs, config.collection_interval_secs + ); + + // Initialize metrics collector + let mut collector = MetricsCollector::new(config.metrics.clone()); + + // Initialize OTLP exporter + info!("Initializing OTLP exporter..."); + let exporter = MetricsExporter::new(&config.otlp) + .await + .context("Failed to initialize OTLP exporter")?; + + info!("Symon initialized successfully"); + info!("Press Ctrl+C to stop"); + + // Main collection loop + let mut tick_interval = interval(config.collection_interval()); + let mut shutdown = Box::pin(signal::ctrl_c()); + + loop { + tokio::select! { + _ = tick_interval.tick() => { + match collector.collect() { + Ok(metrics) => { + exporter.export(&metrics); + tracing::debug!("Metrics collected and exported"); + } + Err(e) => { + error!("Failed to collect metrics: {}", e); + } + } + } + _ = &mut shutdown => { + info!("Shutdown signal received"); + break; + } + } + } + + // Shutdown gracefully + info!("Shutting down..."); + exporter.shutdown().await?; + info!("Symon stopped"); + + Ok(()) +} + +fn find_default_config() -> Option { + let candidates = vec![ + PathBuf::from("symon.toml"), + PathBuf::from("/etc/symon/symon.toml"), + PathBuf::from("config.toml"), + ]; + + candidates.into_iter().find(|p| p.exists()) +} diff --git a/symon.toml b/symon.toml new file mode 100644 index 0000000..b7e6383 --- /dev/null +++ b/symon.toml @@ -0,0 +1,76 @@ +# Symon Configuration File +# Lightweight system metrics exporter for OpenTelemetry + +# Collection interval in seconds +# How often to collect system metrics +collection_interval_secs = 5 + +# OTLP configuration +[otlp] +# OTLP endpoint (gRPC) +endpoint = "http://localhost:4317" + +# Export interval in seconds +# How often to export metrics to OTLP collector +export_interval_secs = 10 + +# Service name that will appear in metrics +service_name = "symon" + +# Service version +service_version = "0.1.0" + +# Export timeout in seconds +export_timeout_secs = 30 + +# Additional resource attributes (key-value pairs) +[otlp.resource_attributes] +environment = "production" +# host = "server-01" +# datacenter = "us-east-1" + +# Metrics configuration - enable/disable specific metric types +[metrics] +cpu = true # CPU usage per core +memory = true # RAM and swap usage +network = true # Network RX/TX +disk = true # Disk usage +processes = false # Top 10 processes (disabled by default - can generate high cardinality) +temperature = true # System temperatures (if available) + +# Process filtering configuration +# Only used when processes = true +[metrics.process_filter] +# Option 1: Use an external file for server-specific process lists +# include = "processes.toml" + +# Option 2: Configure inline +# Filter mode: "whitelist" (only listed processes) or "blacklist" (exclude listed) +filter_mode = "whitelist" + +# List of process names to filter (case-insensitive substring match) +names = [ + # Web servers + "nginx", + "apache", + + # Databases + "postgres", + "mysql", + "redis", + + # Application servers + # "java", + # "node", + # "python", +] + +# List of regex patterns to match process names (case-sensitive) +patterns = [ + # Example: Match specific versions + # "^nginx-[0-9.]+$", + # "^node-v[0-9]+", +] + +# List of specific process PIDs to filter +pids = []