Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev.icinga.com #5933] command argument conditionals #1414

Closed
icinga-migration opened this issue Apr 3, 2014 · 15 comments

Comments

@icinga-migration
Copy link
Member

commented Apr 3, 2014

This issue has been migrated from Redmine: https://dev.icinga.com/issues/5933

Created by mfriedrich on 2014-04-03 18:33:29 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2014-05-11 11:10:03 +00:00)
Target Version: 0.0.11
Last Update: 2014-05-11 11:10:03 +00:00 (in Redmine)


If variable is set, add entries to command line.

object CheckCommand "ping4" {
  import "plugin-check-command"

  command = [ PluginDir, "/check_ping",
              "-H", "$address"
            ]

  command += { "-t", "$host.var.timeout$" } if isset host.var.timeout
}

Changesets

2014-04-26 11:16:08 +00:00 by (unknown) c21817376df43e080ecf3e8cb4cd469a21a1a709

Implement support for optional command arguments.

Fixes #5933

2014-04-26 13:03:38 +00:00 by (unknown) d617c7b

Implement support for optional command arguments.

Fixes #5933

2014-04-26 14:40:30 +00:00 by (unknown) 1631d79

Add missing $ sign in a macro.

Refs #5933

2014-04-26 16:31:49 +00:00 by (unknown) 9b9ee5c

Add ssh_port parameter for the ssh check command.

Refs #5933

2014-04-29 08:33:09 +00:00 by gbeutner 17d277f

Implement the "order" attribute for command arguments.

Refs #5933

2014-05-11 11:05:32 +00:00 by (unknown) f499d93

Documentation: Add command arguments.

Fixes #5933

Relations:

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 6, 2014

Updated by gbeutner on 2014-04-06 08:50:05 +00:00

How about this:

object CheckCommand "http" {
  import "plugin-check-command"

  methods.getcmd = function(resolved_env) {
    cmd = [ PluginDir + "/check_http" ]

    if (resolved_env.vhost) {
      cmd += [ "-H", resolved_env.vhost ]
    } else {
      cmd += [ "-I", resolved_env.address ]
    }

    if (resolved_env.port) {
      cmd += [ "-p", resolved_env.port ]
    }

    return cmd
  }

  env = {
    address = "$address$"
    vhost = "$vhost$"
    port = "$port$"
  }
}
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 6, 2014

Updated by gvegidy on 2014-04-06 12:17:03 +00:00

I like the more C-like syntax proposed by Gunnar better than the postfix-if. I think it is more easy to read and probably the users are more familiar with this syntax as most programming languages (except maybe perl) don't support the postfix if.

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 15, 2014

Updated by tgelf on 2014-04-15 12:25:24 +00:00

I don't like the ideo to have powerful language constructs like function() and if/else in 2.0.x. What about something like this:

object CheckCommand "http" {
  import "plugin-check-command"
  command = "check_snmp"

  arguments = {
     H = host.name,
     C = host.vars.community,
     oid = "1.3...."
  }

  optional = {
     c = "$host.vars.some_threshold$%"
  }
}

Cheers,
Thomas

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 15, 2014

Updated by tgelf on 2014-04-15 12:28:27 +00:00

I added a relation to #5926: this feature should also play fine with existing backends visualizing command information.

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 25, 2014

Updated by gbeutner on 2014-04-25 13:18:48 +00:00

  • Assigned to set to gbeutner
  • Priority changed from Normal to High
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 25, 2014

Updated by mfriedrich on 2014-04-25 13:53:39 +00:00

object CheckCommand "snmp" {
  import "plugin-check-command" 
  command = [ PluginDir + "/check_snmp" ]

  arguments = {
     "-H" = {
        value = "$host.name$"
        description = "keks"
     }
     "-C" = "$snmp_community$"
     "--oid" = "1.3...." 
     "-c" = {
        value = "$snmp_threshold$%"
        optional = true
     }
  }
}
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 26, 2014

Updated by gbeutner on 2014-04-26 11:18:14 +00:00

This is how it's currently implemented:

object CheckCommand "http" {
    import "plugin-check-command",

    command = PluginDir + "/check_http"

    arguments = {
        "-H" = {
            value = "$http_vhost$"
            optional = true
        }
        "-I" = "$http_address$"
        "-u" = {
            value = "$http_uri$"
            optional = true
        }
        "-p" = {
            value = "$http_port$"
            optional = true
        }
        "-S" = {
            set_if = "$http_ssl$"
        }
        "-w" = {
            value = "$http_warn_time$"
            optional = true
        }
        "-c" = {
            value = "$http_critical_time$"
            optional = true
        }
    }

    vars.http_address = "$address$"
    vars.http_ssl = false
}
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 26, 2014

Updated by Anonymous on 2014-04-26 11:18:22 +00:00

  • Status changed from New to Resolved
  • Done % changed from 0 to 100

Applied in changeset c21817376df43e080ecf3e8cb4cd469a21a1a709.

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 28, 2014

Updated by mfriedrich on 2014-04-28 08:25:01 +00:00

  • Status changed from Resolved to Feedback
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 28, 2014

Updated by mfriedrich on 2014-04-28 08:48:25 +00:00

  • Subject changed from evaluate command conditionals to command argument conditionals
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Apr 29, 2014

Updated by mfriedrich on 2014-04-29 12:12:41 +00:00

  • Target Version changed from 0.0.10 to 0.0.11
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented May 2, 2014

Updated by mfriedrich on 2014-05-02 22:51:48 +00:00

  • Assigned to changed from gbeutner to mfriedrich
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented May 11, 2014

Updated by gbeutner on 2014-05-11 03:16:03 +00:00

What's missing here?

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented May 11, 2014

Updated by mfriedrich on 2014-05-11 09:00:46 +00:00

Documentation. Should be somewhere in the basics section when introducing commands, or in detail on the *command object type docs. Your opinion?

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented May 11, 2014

Updated by Anonymous on 2014-05-11 11:10:03 +00:00

  • Status changed from Feedback to Resolved

Applied in changeset f499d93.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.