Skip to content

Commit

Permalink
0.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
krystianity committed Nov 5, 2021
1 parent 11e7b48 commit 274d60b
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ilagent"
version = "0.3.0"
version = "0.3.5"
authors = ["Chris Froehlingsdorf <chris@ilert.com>"]
edition = "2018"

Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ docker run ilert/ilagent

For MacOS and Linux we also provide this one-liner to automatically install the agent:

> Note: default prebuild support stopped at version 0.3.0 if you cannot use the docker image or compile yourself and need new builds please open an issue
```shell script
curl -sL https://raw.githubusercontent.com/iLert/ilagent/master/install.sh | bash -
```

### Pre-build releases

> Note: default prebuild support stopped at version 0.3.0 if you cannot use the docker image or compile yourself and need new builds please open an issue
We provide pre compiled binaries for every major OS on the [release page of this repository](https://github.com/iLert/ilagent/releases).

Grab your version
Expand All @@ -56,7 +60,7 @@ Grab your version
Of course you can also grab the source code and compile it yourself.
Requires cross (`cargo install cross`) to be installed.

- Mac (Host): `cargo build --release`
- Mac (or your host): `cargo build --release`
- Linux: `cross build --release --target x86_64-unknown-linux-gnu`
- Windows: `cross build --release --target x86_64-pc-windows-gnu`
- ARM: `cross build --release --target arm-unknown-linux-gnueabihf`
Expand Down Expand Up @@ -85,6 +89,11 @@ You can always run `ilagent --help` or take a look at our [documentation](https:
After connecting to your MQTT broker or proxy using `-m 127.0.0.1 -q 1883 -n ilagent`
you may specify the MQTT topic that should be listen to for events with `-e 'ilert/events'`.

#### Providing credentials

In case you need to provide credentials to your MQTT broker you can do so by passing the two arguments `--mqtt_username 'my-user'`
and `--mqtt_password 'my-pass'`, there is no default provided otherwise.

### Subscribing to wildcards and filtering events

You may subscribe to wildcard topics like `-e 'ilert/+'` or `-e '#'` and filter
Expand Down Expand Up @@ -121,6 +130,7 @@ In case the property values of your eventType field do not match to iLert's API
```sh
ilagent daemon -v -v \
-m 127.0.0.1 -q 1883 -n ilagent -e '#' \
--mqtt_username 'my-user' --mqtt_password 'my-pass' \
--mqtt_event_key 'il1api112115xxx' \
--mqtt_map_key_alert_key 'mCode' \
--mqtt_map_key_summary 'comment' \
Expand Down
6 changes: 6 additions & 0 deletions src/il_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ pub struct ILConfig {
pub http_worker_count: i8,
pub db_file: String,
pub heartbeat_key: Option<String>,

pub mqtt_host: Option<String>,
pub mqtt_port: Option<u16>,
pub mqtt_name: Option<String>,
pub mqtt_username: Option<String>,
pub mqtt_password: Option<String>,

pub mqtt_event_topic: Option<String>,
pub mqtt_heartbeat_topic: Option<String>,

Expand Down Expand Up @@ -38,6 +42,8 @@ impl ILConfig {
mqtt_host: None,
mqtt_port: None,
mqtt_name: None,
mqtt_username: None,
mqtt_password: None,
mqtt_event_topic: None,
mqtt_heartbeat_topic: None,
mqtt_event_key: None,
Expand Down
6 changes: 6 additions & 0 deletions src/il_mqtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ pub fn run_mqtt_job(config: &ILConfig, are_we_running: &Arc<AtomicBool>) -> Join
.set_throttle(Duration::from_secs(1))
.set_clean_session(false);

if let Some(mqtt_username) = config.mqtt_username.clone() {
mqtt_options.set_credentials(mqtt_username.as_str(),
config.mqtt_password.clone()
.expect("mqtt_username is set, expecting mqtt_password to be set as well").as_str());
}

let (mut client, mut connection) = Client::new(mqtt_options, 10);

let event_topic = config.mqtt_event_topic.clone().expect("Missing mqtt event topic");
Expand Down
2 changes: 1 addition & 1 deletion src/il_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ struct WebContextContainer {
fn get_index(_req: HttpRequest) -> HttpResponse {
HttpResponse::Ok()
.content_type("text/plain")
.body("ilagent/0.3.0")
.body("ilagent/0.3.5")
}

fn get_heartbeat(_container: web::Data<Mutex<WebContextContainer>>, _req: HttpRequest, path: web::Path<(String,)>) -> HttpResponse {
Expand Down
27 changes: 25 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ fn main() -> () {

let matches = App::new("iLert Agent")

.version("0.3.0")
.version("0.3.5")
.author("iLert GmbH. <support@ilert.com>")
.about("The iLert Agent 🦀 📦 is a program that lets you easily integrate your monitoring system with iLert.")
.about("The iLert Agent 🦀 📦 lets you easily integrate your on premise system with iLert.")

.arg(Arg::with_name("COMMAND")
.help("The actual command that should be executed.")
Expand Down Expand Up @@ -150,6 +150,20 @@ fn main() -> () {
.takes_value(true)
)

.arg(Arg::with_name("mqtt_username")
.long("mqtt_username")
.value_name("MQTT_USERNAME")
.help("If provided under daemon command, sets mqtt client credential username (expects mqtt_password to be set as well)")
.takes_value(true)
)

.arg(Arg::with_name("mqtt_password")
.long("mqtt_password")
.value_name("MQTT_PASSWORD")
.help("If provided under daemon command, sets mqtt client credential password (only works with mqtt_username set)")
.takes_value(true)
)

.arg(Arg::with_name("mqtt_event_topic")
.short("e")
.long("mqtt_event_topic")
Expand Down Expand Up @@ -284,6 +298,15 @@ fn main() -> () {
config.mqtt_event_topic = Some(mqtt_event_topic.to_string());
config.mqtt_heartbeat_topic = Some(mqtt_heartbeat_topic.to_string());

if matches.is_present("mqtt_username") {
config.mqtt_username = Some(matches.value_of("mqtt_username").expect("failed to parse mqtt_username").to_string());

if matches.is_present("mqtt_password") {
config.mqtt_password = Some(matches.value_of("mqtt_password").expect("failed to parse mqtt_password").to_string());
info!("mqtt credentials set");
}
}

if matches.is_present("mqtt_filter_key") {
config.mqtt_filter_key = Some(matches.value_of("mqtt_filter_key").expect("failed to parse mqtt mapping key: mqtt_filter_key").to_string());
info!("Filter key is present: {:?} will be required in event payloads", config.mqtt_filter_key);
Expand Down

0 comments on commit 274d60b

Please sign in to comment.