commit 0f8cfc34e7d5548e285395d3c1091fb3ad1d8ee0 Author: Graham McIntire Date: Fri Jan 9 13:22:15 2026 -0600 init diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..117d5f9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +target/ +.git/ +.gitignore +Dockerfile +.dockerignore +README.md +*.db +*.db-shm +*.db-wal diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e467c7c --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# Created by https://gitignore.org +# Rust.gitignore + +# Generated by Cargo +# will have compiled files and executables +debug +target + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Generated by cargo mutants +# Contains mutation testing data +**/mutants.out*/ + +# RustRover +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d2139e1 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1952 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + +[[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 = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" + +[[package]] +name = "bumpalo" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" + +[[package]] +name = "bytes" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" + +[[package]] +name = "cc" +version = "1.2.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chrono" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.5.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" +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 = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + +[[package]] +name = "find-msvc-tools" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[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-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-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasip2", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hostname" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd" +dependencies = [ + "cfg-if", + "libc", + "windows-link", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[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", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "js-sys" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" +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.180" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[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 = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[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 = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[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 = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[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.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quinn" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.17", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" +dependencies = [ + "bytes", + "getrandom 0.3.4", + "lru-slab", + "rand", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.17", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.60.2", +] + +[[package]] +name = "quote" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[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 = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64", + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rusqlite" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e" +dependencies = [ + "bitflags", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustls" +version = "0.23.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21e6f2ab2928ca4291b86736a8bd920a277a399bba1589409d72154ff87c1282" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[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.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[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.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "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 = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "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 = "snmp" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2a575449a5c487091e541c0cb4ccd83620167fd52363f816fe28f6f357fc00" + +[[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 = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +dependencies = [ + "thiserror-impl 2.0.17", +] + +[[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 = "thiserror-impl" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +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 = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[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-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[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", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "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 = "towerops-agent" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "clap", + "hostname", + "reqwest", + "rusqlite", + "serde", + "serde_json", + "snmp", + "thiserror 1.0.69", + "tokio", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +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.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" +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 = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[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 = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[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 = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12bed680863276c63889429bfd6cab3b99943659923822de1c8a39c49e4d722c" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +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.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[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 = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fc5a66a20078bf1251bde995aa2fdcc4b800c70b5d92dd2c62abc5c60f679f8" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..8388d97 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "towerops-agent" +version = "0.1.0" +edition = "2021" + +[dependencies] +snmp = "0.2" +reqwest = { version = "0.12", features = ["json", "rustls-tls"], default-features = false } +tokio = { version = "1", features = ["full"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +rusqlite = { version = "0.32", features = ["bundled"] } +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +anyhow = "1.0" +thiserror = "1.0" +chrono = { version = "0.4", features = ["serde"] } +clap = { version = "4.0", features = ["derive", "env"] } +hostname = "0.4" + +[profile.release] +opt-level = "z" +lto = true +codegen-units = 1 +strip = true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..90c0d44 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# Build stage +FROM rust:1.75-alpine AS builder + +WORKDIR /app + +# Install build dependencies +RUN apk add --no-cache musl-dev + +# Copy manifests +COPY Cargo.toml Cargo.lock ./ + +# Create a dummy main.rs to build dependencies +RUN mkdir src && echo "fn main() {}" > src/main.rs + +# Build dependencies (cached layer) +RUN cargo build --release --target x86_64-unknown-linux-musl + +# Remove dummy src +RUN rm -rf src + +# Copy actual source code +COPY src ./src + +# Build the actual application +RUN touch src/main.rs && cargo build --release --target x86_64-unknown-linux-musl + +# Runtime stage +FROM alpine:3.19 + +# Install runtime dependencies +RUN apk add --no-cache ca-certificates + +# Create data directory +RUN mkdir -p /data + +# Copy binary from builder +COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/towerops-agent /usr/local/bin/ + +# Volume for database +VOLUME ["/data"] + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ + CMD test -f /data/towerops-agent.db || exit 1 + +# Run as non-root user +RUN addgroup -g 1000 towerops && \ + adduser -D -u 1000 -G towerops towerops && \ + chown -R towerops:towerops /data + +USER towerops + +ENTRYPOINT ["towerops-agent"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6b45a9 --- /dev/null +++ b/README.md @@ -0,0 +1,142 @@ +# Towerops Agent + +A lightweight Rust-based remote polling agent for Towerops SNMP monitoring. + +## Overview + +The Towerops agent enables customers to deploy SNMP polling infrastructure on their internal networks. The agent polls SNMP devices locally and reports metrics to the Towerops API using token-based authentication. + +## Features + +- **Local SNMP Polling**: Poll devices on your internal network without exposing them to the internet +- **Secure Communication**: All communication with Towerops API uses HTTPS with token authentication +- **Metric Buffering**: Stores up to 24 hours of metrics in SQLite when API is unavailable +- **Automatic Configuration**: Fetches polling configuration from the Towerops API +- **Low Resource Usage**: Built in Rust for minimal memory and CPU footprint (< 256 MB RAM typical) +- **Docker Ready**: Pre-built Docker images for easy deployment + +## Quick Start + +### Using Docker Compose + +1. Create a `docker-compose.yml` file: + +```yaml +version: '3.8' +services: + towerops-agent: + image: towerops/agent:latest + restart: unless-stopped + environment: + - TOWEROPS_API_URL=https://app.towerops.com + - TOWEROPS_AGENT_TOKEN=your-agent-token-here + volumes: + - ./data:/data +``` + +2. Start the agent: + +```bash +docker-compose up -d +``` + +### Configuration + +The agent is configured via environment variables: + +| Variable | Description | Default | +|----------|-------------|---------| +| `TOWEROPS_API_URL` | Towerops API endpoint | Required | +| `TOWEROPS_AGENT_TOKEN` | Agent authentication token | Required | +| `CONFIG_REFRESH_SECONDS` | How often to refresh configuration | 300 (5 minutes) | +| `DATABASE_PATH` | SQLite database path for buffering | `/data/towerops-agent.db` | + +### Obtaining an Agent Token + +1. Log in to your Towerops account +2. Navigate to your organization's Agents page +3. Click "Create New Agent" +4. Copy the token (it will only be shown once) + +## Architecture + +The agent consists of several components: + +- **API Client**: Communicates with Towerops API to fetch configuration and submit metrics +- **SNMP Poller**: Polls configured devices for sensor readings and interface statistics +- **Storage Buffer**: SQLite database that buffers metrics during API outages +- **Scheduler**: Coordinates polling intervals and metric submission + +### Polling Flow + +1. Agent fetches configuration from API every 5 minutes (configurable) +2. For each equipment item, polls sensors and interfaces at configured intervals +3. Metrics are stored locally in SQLite +4. Every 30 seconds, pending metrics are submitted to the API +5. Successfully submitted metrics are marked as sent and cleaned up after 24 hours + +### Buffering + +If the API is unreachable, metrics are stored locally for up to 24 hours. When connectivity is restored, the agent automatically submits all buffered metrics. + +## Building from Source + +### Prerequisites + +- Rust 1.75 or later +- SQLite development libraries + +### Build + +```bash +cargo build --release +``` + +The binary will be in `target/release/towerops-agent`. + +### Docker Build + +```bash +docker build -t towerops-agent . +``` + +## Troubleshooting + +### Agent Not Connecting + +- Verify the API URL is correct +- Check that the agent token is valid and hasn't been revoked +- Ensure network connectivity to the Towerops API + +### No Metrics Appearing + +- Check that equipment is assigned to this agent in Towerops +- Verify SNMP credentials are correct in Towerops equipment settings +- Review agent logs for SNMP polling errors + +### High Memory Usage + +- Check the size of the SQLite database (`/data/towerops-agent.db`) +- Verify metrics are being submitted successfully (check API connectivity) + +## Resource Requirements + +- **Memory**: 128-256 MB typical, 512 MB maximum +- **CPU**: 0.1-0.5 cores typical +- **Disk**: ~100 MB for 24 hours of buffered metrics +- **Network**: Minimal (metrics are small JSON payloads) + +## Security + +- Agent token should be kept secret (treat like a password) +- All API communication uses HTTPS with certificate verification +- Agent requires no inbound network connections +- SNMP community strings are only used locally and never logged + +## Development Status + +**NOTE**: SNMP library integration is incomplete. The current implementation compiles but requires proper SNMP library integration for production use. This will be completed in the next development phase. + +## License + +Copyright © 2026 Towerops diff --git a/src/api_client.rs b/src/api_client.rs new file mode 100644 index 0000000..435a200 --- /dev/null +++ b/src/api_client.rs @@ -0,0 +1,107 @@ +use crate::config::{AgentConfig, HeartbeatMetadata}; +use crate::metrics::Metric; +use anyhow::{Context, Result}; +use reqwest::Client; +use serde_json::json; +use std::time::Duration; + +/// API client for communicating with the Towerops server +#[derive(Clone)] +pub struct ApiClient { + client: Client, + base_url: String, + token: String, +} + +impl ApiClient { + /// Create a new API client + pub fn new(base_url: String, token: String) -> Result { + let client = Client::builder() + .timeout(Duration::from_secs(30)) + .build() + .context("Failed to create HTTP client")?; + + Ok(Self { + client, + base_url, + token, + }) + } + + /// Fetch configuration from the API + pub async fn fetch_config(&self) -> Result { + let url = format!("{}/api/v1/agent/config", self.base_url); + + let response = self + .client + .get(&url) + .header("Authorization", format!("Bearer {}", self.token)) + .send() + .await + .context("Failed to send config request")?; + + if !response.status().is_success() { + anyhow::bail!( + "Config request failed with status: {}", + response.status() + ); + } + + let config: AgentConfig = response + .json() + .await + .context("Failed to parse config response")?; + + Ok(config) + } + + /// Submit metrics to the API + pub async fn submit_metrics(&self, metrics: Vec) -> Result<()> { + if metrics.is_empty() { + return Ok(()); + } + + let url = format!("{}/api/v1/agent/metrics", self.base_url); + + let response = self + .client + .post(&url) + .header("Authorization", format!("Bearer {}", self.token)) + .json(&json!({ "metrics": metrics })) + .send() + .await + .context("Failed to send metrics request")?; + + if !response.status().is_success() { + anyhow::bail!( + "Metrics submission failed with status: {}", + response.status() + ); + } + + Ok(()) + } + + /// Send heartbeat to the API + pub async fn heartbeat(&self, metadata: HeartbeatMetadata) -> Result<()> { + let url = format!("{}/api/v1/agent/heartbeat", self.base_url); + + let response = self + .client + .post(&url) + .header("Authorization", format!("Bearer {}", self.token)) + .json(&metadata) + .send() + .await + .context("Failed to send heartbeat request")?; + + if !response.status().is_success() { + anyhow::bail!( + "Heartbeat failed with status: {}", + response.status() + ); + } + + Ok(()) + } +} diff --git a/src/buffer/mod.rs b/src/buffer/mod.rs new file mode 100644 index 0000000..851d8a6 --- /dev/null +++ b/src/buffer/mod.rs @@ -0,0 +1,3 @@ +mod storage; + +pub use storage::Storage; diff --git a/src/buffer/storage.rs b/src/buffer/storage.rs new file mode 100644 index 0000000..f2f73c4 --- /dev/null +++ b/src/buffer/storage.rs @@ -0,0 +1,188 @@ +use crate::metrics::Metric; +use anyhow::{Context, Result}; +use chrono::{DateTime, Utc}; +use rusqlite::{params, Connection}; +use std::collections::HashMap; +use std::path::Path; +use std::sync::{Arc, Mutex}; + +/// SQLite storage for buffering metrics when API is unavailable +#[derive(Clone)] +pub struct Storage { + conn: Arc>, +} + +impl Storage { + /// Create a new storage instance + pub fn new>(path: P) -> Result { + let conn = Connection::open(path).context("Failed to open database")?; + + conn.execute( + "CREATE TABLE IF NOT EXISTS metrics ( + id INTEGER PRIMARY KEY, + metric_type TEXT NOT NULL, + data TEXT NOT NULL, + timestamp TEXT NOT NULL, + sent INTEGER DEFAULT 0, + created_at TEXT DEFAULT CURRENT_TIMESTAMP + )", + [], + ) + .context("Failed to create metrics table")?; + + conn.execute( + "CREATE INDEX IF NOT EXISTS idx_metrics_sent ON metrics(sent, created_at)", + [], + ) + .context("Failed to create index")?; + + conn.execute( + "CREATE TABLE IF NOT EXISTS last_poll_times ( + equipment_id TEXT PRIMARY KEY, + last_poll_time TEXT NOT NULL + )", + [], + ) + .context("Failed to create last_poll_times table")?; + + Ok(Self { + conn: Arc::new(Mutex::new(conn)), + }) + } + + /// Store a metric in the buffer + pub fn store_metric(&self, metric: &Metric) -> Result<()> { + let data = serde_json::to_string(metric).context("Failed to serialize metric")?; + let conn = self.conn.lock().unwrap(); + + conn.execute( + "INSERT INTO metrics (metric_type, data, timestamp) VALUES (?1, ?2, ?3)", + params![ + metric.metric_type(), + data, + metric.timestamp().to_rfc3339() + ], + ) + .context("Failed to insert metric")?; + + Ok(()) + } + + /// Get pending metrics that haven't been sent yet + pub fn get_pending_metrics(&self, limit: usize) -> Result> { + let conn = self.conn.lock().unwrap(); + + let mut stmt = conn + .prepare("SELECT id, data FROM metrics WHERE sent = 0 ORDER BY created_at LIMIT ?1") + .context("Failed to prepare statement")?; + + let metrics = stmt + .query_map([limit], |row| { + let id: i64 = row.get(0)?; + let data: String = row.get(1)?; + Ok((id, data)) + }) + .context("Failed to query metrics")? + .filter_map(|r| r.ok()) + .filter_map(|(id, data)| { + serde_json::from_str::(&data) + .ok() + .map(|metric| (id, metric)) + }) + .collect(); + + Ok(metrics) + } + + /// Mark metrics as sent + pub fn mark_metrics_sent(&self, ids: &[i64]) -> Result<()> { + if ids.is_empty() { + return Ok(()); + } + + let conn = self.conn.lock().unwrap(); + let placeholders = ids.iter().map(|_| "?").collect::>().join(","); + let query = format!("UPDATE metrics SET sent = 1 WHERE id IN ({})", placeholders); + + let params: Vec<_> = ids.iter().map(|id| id as &dyn rusqlite::ToSql).collect(); + conn.execute(&query, params.as_slice()) + .context("Failed to mark metrics as sent")?; + + Ok(()) + } + + /// Clean up old metrics that have been sent + pub fn cleanup_old_metrics(&self) -> Result<()> { + let conn = self.conn.lock().unwrap(); + + conn.execute( + "DELETE FROM metrics WHERE sent = 1 AND created_at < datetime('now', '-24 hours')", + [], + ) + .context("Failed to cleanup old metrics")?; + + Ok(()) + } + + /// Get the last poll time for equipment + pub fn get_last_poll_time(&self, equipment_id: &str) -> Result>> { + let conn = self.conn.lock().unwrap(); + + let result: Result = conn.query_row( + "SELECT last_poll_time FROM last_poll_times WHERE equipment_id = ?1", + params![equipment_id], + |row| row.get(0), + ); + + match result { + Ok(timestamp_str) => { + let dt = DateTime::parse_from_rfc3339(×tamp_str) + .context("Failed to parse timestamp")? + .with_timezone(&Utc); + Ok(Some(dt)) + } + Err(rusqlite::Error::QueryReturnedNoRows) => Ok(None), + Err(e) => Err(e).context("Failed to query last poll time"), + } + } + + /// Update the last poll time for equipment + pub fn update_last_poll_time(&self, equipment_id: &str) -> Result<()> { + let conn = self.conn.lock().unwrap(); + let now = Utc::now().to_rfc3339(); + + conn.execute( + "INSERT OR REPLACE INTO last_poll_times (equipment_id, last_poll_time) VALUES (?1, ?2)", + params![equipment_id, now], + ) + .context("Failed to update last poll time")?; + + Ok(()) + } + + /// Get all last poll times + pub fn get_all_last_poll_times(&self) -> Result>> { + let conn = self.conn.lock().unwrap(); + + let mut stmt = conn + .prepare("SELECT equipment_id, last_poll_time FROM last_poll_times") + .context("Failed to prepare statement")?; + + let times: HashMap> = stmt + .query_map([], |row| { + let equipment_id: String = row.get(0)?; + let timestamp_str: String = row.get(1)?; + Ok((equipment_id, timestamp_str)) + }) + .context("Failed to query poll times")? + .filter_map(|r| r.ok()) + .filter_map(|(id, ts)| { + DateTime::parse_from_rfc3339(&ts) + .ok() + .map(|dt| (id, dt.with_timezone(&Utc))) + }) + .collect(); + + Ok(times) + } +} diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..a46c8ba --- /dev/null +++ b/src/config.rs @@ -0,0 +1,58 @@ +use serde::{Deserialize, Serialize}; + +/// Configuration received from the API +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct AgentConfig { + pub version: String, + pub poll_interval_seconds: u64, + pub equipment: Vec, +} + +/// Configuration for a single piece of equipment +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct EquipmentConfig { + pub id: String, + pub name: String, + pub ip_address: String, + pub snmp: SnmpConfig, + pub poll_interval_seconds: u64, + pub sensors: Vec, + pub interfaces: Vec, +} + +/// SNMP configuration +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct SnmpConfig { + pub enabled: bool, + pub version: String, + pub community: String, + pub port: u16, +} + +/// Sensor configuration +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct SensorConfig { + pub id: String, + #[serde(rename = "type")] + pub sensor_type: String, + pub oid: String, + pub divisor: Option, + pub unit: Option, + pub metadata: Option, +} + +/// Interface configuration +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct InterfaceConfig { + pub id: String, + pub if_index: i32, + pub if_name: String, +} + +/// Heartbeat metadata sent to the API +#[derive(Debug, Serialize)] +pub struct HeartbeatMetadata { + pub version: String, + pub hostname: String, + pub uptime_seconds: u64, +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..3fb5f1b --- /dev/null +++ b/src/main.rs @@ -0,0 +1,68 @@ +mod api_client; +mod buffer; +mod config; +mod metrics; +mod poller; +mod snmp; + +use anyhow::Result; +use clap::Parser; +use poller::Scheduler; +use tracing::info; + +#[derive(Parser)] +#[command(name = "towerops-agent")] +#[command(about = "Towerops remote SNMP polling agent", long_about = None)] +struct Args { + /// API URL (e.g., https://app.towerops.com) + #[arg(long, env = "TOWEROPS_API_URL")] + api_url: String, + + /// Agent authentication token + #[arg(long, env = "TOWEROPS_AGENT_TOKEN")] + token: String, + + /// Configuration refresh interval in seconds + #[arg(long, env = "CONFIG_REFRESH_SECONDS", default_value = "300")] + config_refresh_seconds: u64, + + /// Database path for metrics buffering + #[arg(long, env = "DATABASE_PATH", default_value = "/data/towerops-agent.db")] + database_path: String, +} + +#[tokio::main] +async fn main() -> Result<()> { + // Initialize logging + tracing_subscriber::fmt() + .with_env_filter( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")), + ) + .init(); + + let args = Args::parse(); + + info!("Towerops agent starting"); + info!("API URL: {}", args.api_url); + info!( + "Config refresh interval: {} seconds", + args.config_refresh_seconds + ); + info!("Database path: {}", args.database_path); + + // Initialize components + let api_client = api_client::ApiClient::new(args.api_url, args.token)?; + let storage = buffer::Storage::new(args.database_path)?; + let snmp_client = snmp::SnmpClient::new(); + + // Create and run scheduler + let mut scheduler = Scheduler::new( + api_client, + storage, + snmp_client, + args.config_refresh_seconds, + ); + + scheduler.run().await +} diff --git a/src/metrics/mod.rs b/src/metrics/mod.rs new file mode 100644 index 0000000..441da44 --- /dev/null +++ b/src/metrics/mod.rs @@ -0,0 +1,50 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; + +/// Metric types that can be submitted to the API +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(tag = "type")] +pub enum Metric { + #[serde(rename = "sensor_reading")] + SensorReading(SensorReading), + #[serde(rename = "interface_stat")] + InterfaceStat(InterfaceStat), +} + +impl Metric { + pub fn metric_type(&self) -> &str { + match self { + Metric::SensorReading(_) => "sensor_reading", + Metric::InterfaceStat(_) => "interface_stat", + } + } + + pub fn timestamp(&self) -> &DateTime { + match self { + Metric::SensorReading(sr) => &sr.timestamp, + Metric::InterfaceStat(is) => &is.timestamp, + } + } +} + +/// Sensor reading metric +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct SensorReading { + pub sensor_id: String, + pub value: f64, + pub status: String, + pub timestamp: DateTime, +} + +/// Interface statistics metric +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct InterfaceStat { + pub interface_id: String, + pub if_in_octets: i64, + pub if_out_octets: i64, + pub if_in_errors: i64, + pub if_out_errors: i64, + pub if_in_discards: i64, + pub if_out_discards: i64, + pub timestamp: DateTime, +} diff --git a/src/poller/executor.rs b/src/poller/executor.rs new file mode 100644 index 0000000..b8945d1 --- /dev/null +++ b/src/poller/executor.rs @@ -0,0 +1,217 @@ +use crate::buffer::Storage; +use crate::config::EquipmentConfig; +use crate::metrics::{InterfaceStat, Metric, SensorReading}; +use crate::snmp::SnmpClient; +use anyhow::Result; +use chrono::Utc; +use tracing::{error, info, warn}; + +/// Executor handles polling individual pieces of equipment +pub struct Executor { + snmp_client: SnmpClient, + storage: Storage, +} + +impl Executor { + pub fn new(snmp_client: SnmpClient, storage: Storage) -> Self { + Self { + snmp_client, + storage, + } + } + + /// Poll sensors for a piece of equipment + pub async fn poll_sensors(&self, equipment: &EquipmentConfig) -> Result<()> { + if !equipment.snmp.enabled || equipment.sensors.is_empty() { + return Ok(()); + } + + info!( + "Polling {} sensors for equipment: {}", + equipment.sensors.len(), + equipment.name + ); + + for sensor in &equipment.sensors { + match self + .snmp_client + .get( + &equipment.ip_address, + &equipment.snmp.community, + &equipment.snmp.version, + equipment.snmp.port, + &sensor.oid, + ) + .await + { + Ok(value) => { + let raw_value = match value.as_f64() { + Some(v) => v, + None => { + warn!( + "Could not convert sensor value to number for sensor {}", + sensor.id + ); + continue; + } + }; + + // Apply divisor if specified + let final_value = if let Some(divisor) = sensor.divisor { + if divisor != 0 { + raw_value / divisor as f64 + } else { + raw_value + } + } else { + raw_value + }; + + let reading = SensorReading { + sensor_id: sensor.id.clone(), + value: final_value, + status: "ok".to_string(), + timestamp: Utc::now(), + }; + + if let Err(e) = self.storage.store_metric(&Metric::SensorReading(reading)) { + error!("Failed to store sensor reading: {}", e); + } + } + Err(e) => { + warn!( + "Failed to poll sensor {} for {}: {}", + sensor.oid, equipment.name, e + ); + } + } + } + + Ok(()) + } + + /// Poll interfaces for a piece of equipment + pub async fn poll_interfaces(&self, equipment: &EquipmentConfig) -> Result<()> { + if !equipment.snmp.enabled || equipment.interfaces.is_empty() { + return Ok(()); + } + + info!( + "Polling {} interfaces for equipment: {}", + equipment.interfaces.len(), + equipment.name + ); + + for interface in &equipment.interfaces { + // OIDs for interface statistics (from IF-MIB) + let if_in_octets_oid = format!("1.3.6.1.2.1.2.2.1.10.{}", interface.if_index); + let if_out_octets_oid = format!("1.3.6.1.2.1.2.2.1.16.{}", interface.if_index); + let if_in_errors_oid = format!("1.3.6.1.2.1.2.2.1.14.{}", interface.if_index); + let if_out_errors_oid = format!("1.3.6.1.2.1.2.2.1.20.{}", interface.if_index); + let if_in_discards_oid = format!("1.3.6.1.2.1.2.2.1.13.{}", interface.if_index); + let if_out_discards_oid = format!("1.3.6.1.2.1.2.2.1.19.{}", interface.if_index); + + // Poll each counter + let in_octets = self + .get_counter( + &equipment.ip_address, + &equipment.snmp.community, + &equipment.snmp.version, + equipment.snmp.port, + &if_in_octets_oid, + ) + .await + .unwrap_or(0); + + let out_octets = self + .get_counter( + &equipment.ip_address, + &equipment.snmp.community, + &equipment.snmp.version, + equipment.snmp.port, + &if_out_octets_oid, + ) + .await + .unwrap_or(0); + + let in_errors = self + .get_counter( + &equipment.ip_address, + &equipment.snmp.community, + &equipment.snmp.version, + equipment.snmp.port, + &if_in_errors_oid, + ) + .await + .unwrap_or(0); + + let out_errors = self + .get_counter( + &equipment.ip_address, + &equipment.snmp.community, + &equipment.snmp.version, + equipment.snmp.port, + &if_out_errors_oid, + ) + .await + .unwrap_or(0); + + let in_discards = self + .get_counter( + &equipment.ip_address, + &equipment.snmp.community, + &equipment.snmp.version, + equipment.snmp.port, + &if_in_discards_oid, + ) + .await + .unwrap_or(0); + + let out_discards = self + .get_counter( + &equipment.ip_address, + &equipment.snmp.community, + &equipment.snmp.version, + equipment.snmp.port, + &if_out_discards_oid, + ) + .await + .unwrap_or(0); + + let stat = InterfaceStat { + interface_id: interface.id.clone(), + if_in_octets: in_octets, + if_out_octets: out_octets, + if_in_errors: in_errors, + if_out_errors: out_errors, + if_in_discards: in_discards, + if_out_discards: out_discards, + timestamp: Utc::now(), + }; + + if let Err(e) = self.storage.store_metric(&Metric::InterfaceStat(stat)) { + error!("Failed to store interface stat: {}", e); + } + } + + Ok(()) + } + + async fn get_counter( + &self, + ip_address: &str, + community: &str, + version: &str, + port: u16, + oid: &str, + ) -> Result { + let value = self + .snmp_client + .get(ip_address, community, version, port, oid) + .await?; + + value + .as_i64() + .ok_or_else(|| anyhow::anyhow!("Could not convert value to i64")) + } +} diff --git a/src/poller/mod.rs b/src/poller/mod.rs new file mode 100644 index 0000000..8c7e04d --- /dev/null +++ b/src/poller/mod.rs @@ -0,0 +1,5 @@ +mod executor; +mod scheduler; + +pub use executor::Executor; +pub use scheduler::Scheduler; diff --git a/src/poller/scheduler.rs b/src/poller/scheduler.rs new file mode 100644 index 0000000..90e9165 --- /dev/null +++ b/src/poller/scheduler.rs @@ -0,0 +1,205 @@ +use crate::api_client::ApiClient; +use crate::buffer::Storage; +use crate::config::{AgentConfig, HeartbeatMetadata}; +use crate::poller::Executor; +use crate::snmp::SnmpClient; +use anyhow::Result; +use chrono::Utc; +use std::time::Duration; +use tokio::time::interval; +use tracing::{error, info, warn}; + +/// Main scheduler that orchestrates polling, config refresh, and metrics submission +pub struct Scheduler { + api_client: ApiClient, + storage: Storage, + executor: Executor, + config_refresh_seconds: u64, + current_config: Option, + start_time: chrono::DateTime, +} + +impl Scheduler { + pub fn new( + api_client: ApiClient, + storage: Storage, + snmp_client: SnmpClient, + config_refresh_seconds: u64, + ) -> Self { + let executor = Executor::new(snmp_client, storage.clone()); + + Self { + api_client, + storage, + executor, + config_refresh_seconds, + current_config: None, + start_time: Utc::now(), + } + } + + /// Run the main event loop + pub async fn run(&mut self) -> Result<()> { + info!("Starting Towerops agent scheduler"); + + // Fetch initial configuration + if let Err(e) = self.refresh_config().await { + error!("Failed to fetch initial config: {}", e); + } + + let mut config_ticker = interval(Duration::from_secs(self.config_refresh_seconds)); + let mut metrics_ticker = interval(Duration::from_secs(30)); + let mut heartbeat_ticker = interval(Duration::from_secs(60)); + let mut cleanup_ticker = interval(Duration::from_secs(3600)); // Cleanup every hour + let mut poll_ticker = interval(Duration::from_secs(5)); // Check if polling needed every 5s + + loop { + tokio::select! { + _ = config_ticker.tick() => { + if let Err(e) = self.refresh_config().await { + error!("Failed to refresh config: {}", e); + } + } + + _ = metrics_ticker.tick() => { + if let Err(e) = self.flush_metrics().await { + error!("Failed to flush metrics: {}", e); + } + } + + _ = heartbeat_ticker.tick() => { + if let Err(e) = self.send_heartbeat().await { + warn!("Failed to send heartbeat: {}", e); + } + } + + _ = cleanup_ticker.tick() => { + if let Err(e) = self.storage.cleanup_old_metrics() { + error!("Failed to cleanup old metrics: {}", e); + } + } + + _ = poll_ticker.tick() => { + if let Err(e) = self.poll_equipment().await { + error!("Polling error: {}", e); + } + } + } + } + } + + async fn refresh_config(&mut self) -> Result<()> { + info!("Refreshing configuration from API"); + + match self.api_client.fetch_config().await { + Ok(config) => { + info!( + "Configuration updated: {} equipment items", + config.equipment.len() + ); + self.current_config = Some(config); + Ok(()) + } + Err(e) => { + warn!("Failed to fetch config, continuing with cached config: {}", e); + Err(e) + } + } + } + + async fn flush_metrics(&self) -> Result<()> { + let pending = self.storage.get_pending_metrics(100)?; + + if pending.is_empty() { + return Ok(()); + } + + info!("Flushing {} pending metrics to API", pending.len()); + + let ids: Vec = pending.iter().map(|(id, _)| *id).collect(); + let metrics: Vec<_> = pending.into_iter().map(|(_, m)| m).collect(); + + match self.api_client.submit_metrics(metrics).await { + Ok(_) => { + self.storage.mark_metrics_sent(&ids)?; + info!("Successfully submitted {} metrics", ids.len()); + Ok(()) + } + Err(e) => { + warn!("Failed to submit metrics, will retry later: {}", e); + Err(e) + } + } + } + + async fn send_heartbeat(&self) -> Result<()> { + let uptime = Utc::now() + .signed_duration_since(self.start_time) + .num_seconds() as u64; + + let hostname = hostname::get() + .ok() + .and_then(|h| h.into_string().ok()) + .unwrap_or_else(|| "unknown".to_string()); + + let metadata = HeartbeatMetadata { + version: env!("CARGO_PKG_VERSION").to_string(), + hostname, + uptime_seconds: uptime, + }; + + self.api_client.heartbeat(metadata).await?; + Ok(()) + } + + async fn poll_equipment(&self) -> Result<()> { + let config = match &self.current_config { + Some(c) => c, + None => return Ok(()), + }; + + let poll_times = self.storage.get_all_last_poll_times()?; + + for equipment in &config.equipment { + if !equipment.snmp.enabled { + continue; + } + + // Check if it's time to poll this equipment + let should_poll = match poll_times.get(&equipment.id) { + Some(last_poll) => { + let elapsed = Utc::now() + .signed_duration_since(*last_poll) + .num_seconds() as u64; + elapsed >= equipment.poll_interval_seconds + } + None => true, // Never polled before + }; + + if should_poll { + info!("Polling equipment: {}", equipment.name); + + // Poll sensors and interfaces in parallel + let (sensor_result, interface_result) = tokio::join!( + self.executor.poll_sensors(equipment), + self.executor.poll_interfaces(equipment) + ); + + if let Err(e) = sensor_result { + error!("Failed to poll sensors for {}: {}", equipment.name, e); + } + + if let Err(e) = interface_result { + error!("Failed to poll interfaces for {}: {}", equipment.name, e); + } + + // Update last poll time + if let Err(e) = self.storage.update_last_poll_time(&equipment.id) { + error!("Failed to update last poll time: {}", e); + } + } + } + + Ok(()) + } +} diff --git a/src/snmp/client.rs b/src/snmp/client.rs new file mode 100644 index 0000000..de60508 --- /dev/null +++ b/src/snmp/client.rs @@ -0,0 +1,64 @@ +use super::types::{SnmpError, SnmpResult, SnmpValue}; +use std::net::IpAddr; +use std::str::FromStr; + +/// SNMP client for polling devices +/// +/// NOTE: This is a simplified implementation. Full SNMP integration +/// requires proper SNMP library integration with correct error handling. +#[derive(Debug)] +pub struct SnmpClient; + +impl SnmpClient { + pub fn new() -> Self { + Self + } + + /// Perform an SNMP GET operation + /// + /// TODO: Complete SNMP library integration with proper session management + pub async fn get( + &self, + ip_address: &str, + _community: &str, + _version: &str, + _port: u16, + _oid: &str, + ) -> SnmpResult { + // Validate IP address + IpAddr::from_str(ip_address) + .map_err(|e| SnmpError::InvalidOid(format!("Invalid IP: {}", e)))?; + + // TODO: Implement actual SNMP GET using snmp library + // For now, return an error indicating incomplete implementation + Err(SnmpError::RequestFailed( + "SNMP implementation incomplete - requires library integration".into(), + )) + } + + /// Perform an SNMP WALK operation to get multiple values + /// + /// TODO: Complete SNMP library integration with proper walk implementation + pub async fn walk( + &self, + ip_address: &str, + _community: &str, + _version: &str, + _port: u16, + _base_oid: &str, + ) -> SnmpResult> { + // Validate IP address + IpAddr::from_str(ip_address) + .map_err(|e| SnmpError::InvalidOid(format!("Invalid IP: {}", e)))?; + + // TODO: Implement actual SNMP WALK using snmp library + // For now, return an empty result + Ok(Vec::new()) + } +} + +impl Default for SnmpClient { + fn default() -> Self { + Self::new() + } +} diff --git a/src/snmp/mod.rs b/src/snmp/mod.rs new file mode 100644 index 0000000..4cff113 --- /dev/null +++ b/src/snmp/mod.rs @@ -0,0 +1,5 @@ +mod client; +mod types; + +pub use client::SnmpClient; +pub use types::*; diff --git a/src/snmp/types.rs b/src/snmp/types.rs new file mode 100644 index 0000000..7e6dfa8 --- /dev/null +++ b/src/snmp/types.rs @@ -0,0 +1,50 @@ +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum SnmpError { + #[error("SNMP request failed: {0}")] + RequestFailed(String), + + #[error("Invalid OID: {0}")] + InvalidOid(String), + + #[error("Timeout")] + Timeout, + + #[error("Authentication failure")] + AuthFailure, + + #[error("Network unreachable")] + NetworkUnreachable, +} + +pub type SnmpResult = Result; + +/// SNMP value returned from a GET operation +#[derive(Debug, Clone)] +pub enum SnmpValue { + Integer(i64), + String(String), + Counter32(u32), + Counter64(u64), + Gauge32(u32), + TimeTicks(u32), + IpAddress(String), +} + +impl SnmpValue { + pub fn as_i64(&self) -> Option { + match self { + SnmpValue::Integer(v) => Some(*v), + SnmpValue::Counter32(v) => Some(*v as i64), + SnmpValue::Counter64(v) => Some(*v as i64), + SnmpValue::Gauge32(v) => Some(*v as i64), + SnmpValue::TimeTicks(v) => Some(*v as i64), + _ => None, + } + } + + pub fn as_f64(&self) -> Option { + self.as_i64().map(|v| v as f64) + } +}