Passing Variables to an external command.

Hi guys

I’m writing a script that automatically generates an issue in Atlassian Jira and I need to , or I’d like to, to pass some information to the script I’m executing from the handler.
It would be nice if I can pass for example which is the issue, let’s say, server down or whatever the problem is, is that possible?

An example of what I’d like to do:
{
“handlers”: {
“jira_test_issue”: {
“type”: “pipe”,
“command”: “/etc/sensu/handlers/create-issue.sh $SENSU_VAR1 $SENSU_VAR2”
}
}
}

Them from the script I could take those variables and generate the Ticket with some extra information.

Thank you for your time and support
Regards

Hey,

Basically you want to add a variable to your client definition then you can access it in your command there like ::my_sensu_var:::

Read up on it here: https://sensuapp.org/docs/latest/reference/checks.html#check-token-substitution

Thanks,

Josh

···

On Mon, Nov 14, 2016 at 9:37 AM, Kernel Panic netwarrior863@gmail.com wrote:

Hi guys

I’m writing a script that automatically generates an issue in Atlassian Jira and I need to , or I’d like to, to pass some information to the script I’m executing from the handler.
It would be nice if I can pass for example which is the issue, let’s say, server down or whatever the problem is, is that possible?

An example of what I’d like to do:
{
“handlers”: {
“jira_test_issue”: {
“type”: “pipe”,
“command”: “/etc/sensu/handlers/create-issue.sh $SENSU_VAR1 $SENSU_VAR2”
}
}
}

Them from the script I could take those variables and generate the Ticket with some extra information.

Thank you for your time and support
Regards

Hi Joshua
Maybe I did not myself clearn, for example in nagios I have a variable call $HOSTNAME$ which contains the name of the hostname of the client being checked, what I want is
to pass as an argument to may script that information… is that possible?

For example reading /vol2/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-mailer-1.0.0/bin/handler-mailer.rb I found this:

headers = {

‘X-Sensu-Host’ => (@event[‘client’][‘name’]).to_s,

‘X-Sensu-Timestamp’ => Time.at(@event[‘check’][‘issued’]).to_s,

‘X-Sensu-Address’ => (@event[‘client’][‘address’]).to_s,

‘X-Sensu-Check-Name’ => (@event[‘check’][‘name’]).to_s,

‘X-Sensu-Status’ => status_to_string.to_s,

‘X-Sensu-Occurrences’ => (@event[‘occurrences’]).to_s

}

So the mailer takes the client name from somewhere, maybe from the sensu-handler include files, with this information, the mail is sent with all the information , hostname having the problem,
the state of the alert and so on, I want to do something similiar with my script, where is or from where can I get the variable that tells me which node is being executed?

Thanks
Regards

···

El lunes, 14 de noviembre de 2016, 16:32:39 (UTC-3), Joshua Pasqualetto escribió:

Hey,

Basically you want to add a variable to your client definition then you can access it in your command there like ::my_sensu_var:::

Read up on it here: https://sensuapp.org/docs/latest/reference/checks.html#check-token-substitution

Thanks,

Josh

On Mon, Nov 14, 2016 at 9:37 AM, Kernel Panic netwar...@gmail.com wrote:

Hi guys

I’m writing a script that automatically generates an issue in Atlassian Jira and I need to , or I’d like to, to pass some information to the script I’m executing from the handler.
It would be nice if I can pass for example which is the issue, let’s say, server down or whatever the problem is, is that possible?

An example of what I’d like to do:
{
“handlers”: {
“jira_test_issue”: {
“type”: “pipe”,
“command”: “/etc/sensu/handlers/create-issue.sh $SENSU_VAR1 $SENSU_VAR2”
}
}
}

Them from the script I could take those variables and generate the Ticket with some extra information.

Thank you for your time and support
Regards

By the way, anyone using this?

Thanks
Regards

···

El miércoles, 16 de noviembre de 2016, 13:27:31 (UTC-3), Kernel Panic escribió:

headers = {

‘X-Sensu-Host’ => (@event[‘client’][‘name’]).to_s,

‘X-Sensu-Timestamp’ => Time.at(@event[‘check’][‘issued’]).to_s,

‘X-Sensu-Address’ => (@event[‘client’][‘address’]).to_s,

‘X-Sensu-Check-Name’ => (@event[‘check’][‘name’]).to_s,

‘X-Sensu-Status’ => status_to_string.to_s,

‘X-Sensu-Occurrences’ => (@event[‘occurrences’]).to_s

Hey,

Basically you want to add a variable to your client definition then you can access it in your command there like ::my_sensu_var:::

Read up on it here: https://sensuapp.org/docs/latest/reference/checks.html#check-token-substitution

Thanks,

Josh

On Mon, Nov 14, 2016 at 9:37 AM, Kernel Panic netwar...@gmail.com wrote:

Hi guys

I’m writing a script that automatically generates an issue in Atlassian Jira and I need to , or I’d like to, to pass some information to the script I’m executing from the handler.
It would be nice if I can pass for example which is the issue, let’s say, server down or whatever the problem is, is that possible?

An example of what I’d like to do:
{
“handlers”: {
“jira_test_issue”: {
“type”: “pipe”,
“command”: “/etc/sensu/handlers/create-issue.sh $SENSU_VAR1 $SENSU_VAR2”
}
}
}

Them from the script I could take those variables and generate the Ticket with some extra information.

Thank you for your time and support
Regards

Hi Joshua
Maybe I did not myself clearn, for example in nagios I have a variable call $HOSTNAME$ which contains the name of the hostname of the client being checked, what I want is
to pass as an argument to may script that information… is that possible?

For example reading /vol2/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-mailer-1.0.0/bin/handler-mailer.rb I found this:

}

So the mailer takes the client name from somewhere, maybe from the sensu-handler include files, with this information, the mail is sent with all the information , hostname having the problem,
the state of the alert and so on, I want to do something similiar with my script, where is or from where can I get the variable that tells me which node is being executed?

Thanks
Regards

El lunes, 14 de noviembre de 2016, 16:32:39 (UTC-3), Joshua Pasqualetto escribió:

Me :slight_smile:

···

On Thu, Nov 17, 2016 at 8:09 AM, Kernel Panic netwarrior863@gmail.com wrote:

By the way, anyone using this?

https://github.com/Yelp/sensu_handlers

Thanks
Regards

El miércoles, 16 de noviembre de 2016, 13:27:31 (UTC-3), Kernel Panic escribió:

headers = {

‘X-Sensu-Host’ => (@event[‘client’][‘name’]).to_s,

‘X-Sensu-Timestamp’ => Time.at(@event[‘check’][‘issued’]).to_s,

‘X-Sensu-Address’ => (@event[‘client’][‘address’]).to_s,

‘X-Sensu-Check-Name’ => (@event[‘check’][‘name’]).to_s,

‘X-Sensu-Status’ => status_to_string.to_s,

‘X-Sensu-Occurrences’ => (@event[‘occurrences’]).to_s

Hey,

Basically you want to add a variable to your client definition then you can access it in your command there like ::my_sensu_var:::

Read up on it here: https://sensuapp.org/docs/latest/reference/checks.html#check-token-substitution

Thanks,

Josh

On Mon, Nov 14, 2016 at 9:37 AM, Kernel Panic netwar...@gmail.com wrote:

Hi guys

I’m writing a script that automatically generates an issue in Atlassian Jira and I need to , or I’d like to, to pass some information to the script I’m executing from the handler.
It would be nice if I can pass for example which is the issue, let’s say, server down or whatever the problem is, is that possible?

An example of what I’d like to do:
{
“handlers”: {
“jira_test_issue”: {
“type”: “pipe”,
“command”: “/etc/sensu/handlers/create-issue.sh $SENSU_VAR1 $SENSU_VAR2”
}
}
}

Them from the script I could take those variables and generate the Ticket with some extra information.

Thank you for your time and support
Regards

Hi Joshua
Maybe I did not myself clearn, for example in nagios I have a variable call $HOSTNAME$ which contains the name of the hostname of the client being checked, what I want is
to pass as an argument to may script that information… is that possible?

For example reading /vol2/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-mailer-1.0.0/bin/handler-mailer.rb I found this:

}

So the mailer takes the client name from somewhere, maybe from the sensu-handler include files, with this information, the mail is sent with all the information , hostname having the problem,
the state of the alert and so on, I want to do something similiar with my script, where is or from where can I get the variable that tells me which node is being executed?

Thanks
Regards

El lunes, 14 de noviembre de 2016, 16:32:39 (UTC-3), Joshua Pasqualetto escribió:

Hehe, Thank you Kyle.

Regards

···

On 11/19/2016 12:17 AM, Kyle Anderson wrote:

Me :slight_smile:

On Thu, Nov 17, 2016 at 8:09 AM, Kernel Panic <netwarrior863@gmail.com > <mailto:netwarrior863@gmail.com>> wrote:

    By the way, anyone using this?

    GitHub - Yelp/sensu_handlers: Custom Sensu Handlers to support a multi-tenant environment, allowing checks themselves to emit the type of handler behavior they need in the event json
    <https://github.com/Yelp/sensu_handlers&gt;

    Thanks
    Regards

    El miércoles, 16 de noviembre de 2016, 13:27:31 (UTC-3), Kernel > Panic escribió:

        Hi Joshua
        Maybe I did not myself clearn, for example in nagios I have a
        variable call $HOSTNAME$ which contains the name of the
        hostname of the client being checked, what I want is
        to pass as an argument to may script that information.. is
        that possible?

        For example reading
        /vol2/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-mailer-1.0.0/bin/handler-mailer.rb
        I found this:

        headers = {

        'X-Sensu-Host' => (@event['client']['name']).to_s,
        'X-Sensu-Timestamp' => Time.at(@event['check']['issued']).to_s,
        'X-Sensu-Address' => (@event['client']['address']).to_s,
        'X-Sensu-Check-Name' => (@event['check']['name']).to_s,
        'X-Sensu-Status' => status_to_string.to_s,
        'X-Sensu-Occurrences' => (@event['occurrences']).to_s
        }

        So the mailer takes the client name from somewhere, maybe
        from the sensu-handler include files, with this information,
        the mail is sent with all the information , hostname having
        the problem,
        the state of the alert and so on, I want to do something
        similiar with my script, where is or from where can I get the
        variable that tells me which node is being executed?

        Thanks
        Regards

        El lunes, 14 de noviembre de 2016, 16:32:39 (UTC-3), Joshua > Pasqualetto escribió:

            Hey,

            Basically you want to add a variable to your client
            definition then you can access it in your command there
            like ::my_sensu_var:::

            Read up on it here:
            https://sensuapp.org/docs/latest/reference/checks.html#check-token-substitution
            <https://sensuapp.org/docs/latest/reference/checks.html#check-token-substitution&gt;

            Thanks,
            Josh

            On Mon, Nov 14, 2016 at 9:37 AM, Kernel Panic > <netwar...@gmail.com> wrote:

                Hi guys

                I'm writing a script that automatically generates an
                issue in Atlassian Jira and I need to , or I'd like
                to, to pass some information to the script I'm
                executing from the handler.
                It would be nice if I can pass for example which is
                the issue, let's say, server down or whatever the
                problem is, is that possible?

                An example of what I'd like to do:
                {
                  "handlers": {
                        "jira_test_issue": {
                          "type": "pipe",
                          "command":
                "/etc/sensu/handlers/create-issue.sh $SENSU_VAR1
                $SENSU_VAR2"
                        }
                  }
                }

                Them from the script I could take those variables and
                generate the Ticket with some extra information.

                Thank you for your time and support
                Regards