Having Sensu sudo

Hello folks,

I am trying to have sensu run checks as another user. So, in the check body, I am doing /usr/bin/sudo -u postgres /path/to/our/sql/check. However, this results in an error:

sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: 3 incorrect password attempts

It seems like this is a common use-case, so there must be something I am missing. I assume sensu runs checks as its own user account. So, how do we have it run checks as root or as another user?

Thanks,

Chris

The Sensu user will need passwordless sudo. You may use a /etc/sudoers.d/ file for granular* control.

···

On Thu, May 16, 2013 at 3:23 PM, Christopher Armstrong chris@chrisarmstrong.me wrote:

Hello folks,

I am trying to have sensu run checks as another user. So, in the check body, I am doing /usr/bin/sudo -u postgres /path/to/our/sql/check. However, this results in an error:

sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: 3 incorrect password attempts

It seems like this is a common use-case, so there must be something I am missing. I assume sensu runs checks as its own user account. So, how do we have it run checks as root or as another user?

Thanks,

Chris


Cheers,

Sean Porter

{ blog: “http://portertech.ca”, projects: “https://github.com/portertech” }

Thanks Sean! Is the way I am using sudo in the check the recommended sensu way? Or is there a way to tell sensu it should sudo to run a check? I assume by default it just runs as the normal user?

···

On Thu, May 16, 2013 at 3:23 PM, Christopher Armstrong chris@chrisarmstrong.me wrote:

Hello folks,

I am trying to have sensu run checks as another user. So, in the check body, I am doing /usr/bin/sudo -u postgres /path/to/our/sql/check. However, this results in an error:

sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: 3 incorrect password attempts

It seems like this is a common use-case, so there must be something I am missing. I assume sensu runs checks as its own user account. So, how do we have it run checks as root or as another user?

Thanks,

Chris

Cheers,

Sean Porter

{ blog: “http://portertech.ca”, projects: “https://github.com/portertech” }

example setup:

/etc/sudoers.d/sensu:

Defaults:sensu !requiretty

Defaults:sensu secure_path = /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

sensu ALL = NOPASSWD: /etc/sensu/plugins/check-ping-private-gateway.rb

···

On Thu, May 16, 2013 at 3:30 PM, Christopher Armstrong chris@chrisarmstrong.me wrote:

Thanks Sean! Is the way I am using sudo in the check the recommended sensu way? Or is there a way to tell sensu it should sudo to run a check? I assume by default it just runs as the normal user?

On Thu, May 16, 2013 at 3:27 PM, Sean Porter portertech@gmail.com wrote:

The Sensu user will need passwordless sudo. You may use a /etc/sudoers.d/ file for granular* control.

On Thu, May 16, 2013 at 3:23 PM, Christopher Armstrong chris@chrisarmstrong.me wrote:

Hello folks,

I am trying to have sensu run checks as another user. So, in the check body, I am doing /usr/bin/sudo -u postgres /path/to/our/sql/check. However, this results in an error:

sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: 3 incorrect password attempts

It seems like this is a common use-case, so there must be something I am missing. I assume sensu runs checks as its own user account. So, how do we have it run checks as root or as another user?

Thanks,

Chris

Cheers,

Sean Porter

{ blog: “http://portertech.ca”, projects: “https://github.com/portertech” }

Thanks Joe - I’ll be sure to add the “requiretty” part.

···

On Thu, May 16, 2013 at 3:30 PM, Christopher Armstrong chris@chrisarmstrong.me wrote:

Thanks Sean! Is the way I am using sudo in the check the recommended sensu way? Or is there a way to tell sensu it should sudo to run a check? I assume by default it just runs as the normal user?

On Thu, May 16, 2013 at 3:27 PM, Sean Porter portertech@gmail.com wrote:

The Sensu user will need passwordless sudo. You may use a /etc/sudoers.d/ file for granular* control.

On Thu, May 16, 2013 at 3:23 PM, Christopher Armstrong chris@chrisarmstrong.me wrote:

Hello folks,

I am trying to have sensu run checks as another user. So, in the check body, I am doing /usr/bin/sudo -u postgres /path/to/our/sql/check. However, this results in an error:

sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: 3 incorrect password attempts

It seems like this is a common use-case, so there must be something I am missing. I assume sensu runs checks as its own user account. So, how do we have it run checks as root or as another user?

Thanks,

Chris

Cheers,

Sean Porter

{ blog: “http://portertech.ca”, projects: “https://github.com/portertech” }