add emojis and systemctl active check test
This commit is contained in:
parent
82f553d712
commit
2fd2cda4fe
3 changed files with 25 additions and 2 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -29,6 +29,12 @@ version = "1.0.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
|
||||
|
||||
[[package]]
|
||||
name = "emojis-rs"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5c5d55d32597632ca64765dd57c1e71aaa51e69f663671fdc955950062c38ff"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.174"
|
||||
|
@ -143,6 +149,7 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
|||
name = "ssh-test"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"emojis-rs",
|
||||
"ssh2",
|
||||
]
|
||||
|
||||
|
|
|
@ -4,4 +4,5 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
emojis-rs = "0.1.3"
|
||||
ssh2 = "0.9.5"
|
||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -1,5 +1,7 @@
|
|||
use std::io::prelude::*;
|
||||
use std::net::TcpStream;
|
||||
use ssh2::Session;
|
||||
use emojis_rs::*;
|
||||
|
||||
const USER: &str = "aaronh";
|
||||
const EDI: &str = "100.94.173.5:22";
|
||||
|
@ -16,9 +18,22 @@ fn main() {
|
|||
sess.userauth_agent(USER).unwrap();
|
||||
|
||||
if sess.authenticated() {
|
||||
println!("Authentication successful!");
|
||||
println!("Authentication successful! {EMOJI_CHECK}");
|
||||
} else {
|
||||
println!("Authentication failed!");
|
||||
println!("Authentication failed! {EMOJI_CROSS}");
|
||||
}
|
||||
|
||||
let mut channel = sess.channel_session().unwrap();
|
||||
channel.exec("systemctl is-active gollum").unwrap();
|
||||
let mut s = String::new();
|
||||
channel.read_to_string(&mut s).unwrap();
|
||||
channel.wait_close().unwrap();
|
||||
|
||||
let exit_code = channel.exit_status().unwrap();
|
||||
|
||||
if exit_code == 0 {
|
||||
println!("Gollum service is active {EMOJI_CHECK}");
|
||||
} else {
|
||||
println!("Gollum service is inactive {EMOJI_CROSS}(exit code: {})", exit_code);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue