Skip to content

Instantly share code, notes, and snippets.

@calebhailey
Last active June 25, 2019 19:47
Show Gist options
  • Save calebhailey/451126e9cf15d47b3845 to your computer and use it in GitHub Desktop.
Save calebhailey/451126e9cf15d47b3845 to your computer and use it in GitHub Desktop.

NOTE: This is an excerpt from an upcoming rewrite of the Sensu installation guide, so some references may be made to documentation contents that don't currently exist, but they are coming soonicorn.com. :shipit:

The 5-minute Sensu Install

Although Sensu’s architecture is one of its most compelling features, and the installation guide can help you get Sensu installed in a variety of configurations in any operating environment, you might not actually care about any of that until you can get Sensu up and running in a testing and/or development environment and try it out. This installation guide is intended to help you install Sensu in 5 minutes or less, or we'll give you your money back, guaranteed.

Install Sensu in 5 minutes or less, or we'll give you your money back, guaranteed.

After completing the steps in this guide, you will have a fully functional Sensu Core installation in a standalone configuration.

Installation Requirements

What will you need to complete the 5-minute Sensu install?

  • A virtual machine, or physical computer running 64-bit Ubuntu 14.04 with a minimum of 2GB of memory (4GB recommended)
  • Familiarity with a modern command-line interface
  • 5 minutes (the amount of time it should take to complete this installation guide)

Ready? Let's get started!

Install Sensu in 5-minutes or less

The following installation steps will help you get Sensu Core installed in a standalone on a system running Ubuntu 14.04, only. For installation on other platforms, and/or alternative installation configurations, please consult the installation guide.

  1. Install Redis (>= 1.3.14) from the distribution repository:

    sudo apt-get update
    sudo apt-get -y install redis-server curl jq
  2. Install the Redis init scripts using the update-rc.d utility, and start Redis:

    sudo update-rc.d redis-server defaults
    sudo /etc/init.d/redis-server start
  3. Download and install Sensu using wget and dpkg:

    wget https://core.sensuapp.com/apt/pool/sensu/main/s/sensu/sensu_0.22.1-1_amd64.deb
    sudo dpkg -i sensu_0.22.1-1_amd64.deb

    Verify that Sensu is installed by running the following command:

    /opt/sensu/bin/sensu-server --version
  4. Configure Sensu by copying the following example configuration file contents to /etc/sensu/config.json:

    {
      "redis": {
        "host": "localhost"
      },
      "transport": {
        "name": "redis"
      },
        "api": {
        "host": "localhost",
        "port": 4567
      }
    }
  5. Configure the Sensu client copying the following example configuration file contents to /etc/sensu/conf.d/client.json:

    {
      "client": {
        "name": "test",
        "address": "localhost",
        "subscriptions": [
          "test"
        ]
      }
    }
  6. Make sure that the sensu user owns all of the Sensu configuration files:

    sudo chown -R sensu:sensu /etc/sensu
  7. Start the Sensu services

    sudo /etc/init.d/sensu-server start
    sudo /etc/init.d/sensu-api start
    sudo /etc/init.d/sensu-client start
  8. Verify that your installation is ready to use by querying the Sensu API using the curl utility (and piping the result to jq):

    curl http://localhost:4567/clients | jq .

    If the Sensu API returns a JSON array of Sensu clients similar to this:

    $ curl http://localhost:4567/clients | jq .
    
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   106  100   106    0     0  14026      0 --:--:-- --:--:-- --:--:-- 15142
    [
      {
        "timestamp": 1458593707,
        "version": "0.22.1",
        "subscriptions": [
          "test"
        ],
        "address": "localhost",
        "name": "test"
      }
    ]

    ...you have successfully installed and configured Sensu!

Next Steps

Coming soon...

@viral2006
Copy link

viral2006 commented Jul 23, 2017

Hi,
I have setup sensu on ubuntu 16.04 but i am not able to start following services. KINDLY HELP
sensu-server
sensu-client
sensu-api

it gives error when i run service sensu-server start

Job for sensu-server.service failed because the control process exited with error code. See "systemctl status sensu-server.service" and "journalctl -xe" for details.

root@ip-172-31-25-171:# service sensu-server start
Job for sensu-server.service failed because the control process exited with error code. See "systemctl status sensu-server.service" and "journalctl -xe" for details.
root@ip-172-31-25-171:
# service sensu-server status
● sensu-server.service - LSB: Sensu monitoring framework server
Loaded: loaded (/etc/init.d/sensu-server; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2017-07-23 06:13:04 UTC; 47s ago
Docs: man:systemd-sysv-generator(8)
Process: 2771 ExecStart=/etc/init.d/sensu-server start (code=exited, status=1/FAILURE)

Jul 23 06:13:02 ip-172-31-25-171 systemd[1]: Starting LSB: Sensu monitoring framework server...
Jul 23 06:13:02 ip-172-31-25-171 sensu-server[2771]: * Starting sensu-server
Jul 23 06:13:04 ip-172-31-25-171 sensu-server[2771]: ...fail!
Jul 23 06:13:04 ip-172-31-25-171 systemd[1]: sensu-server.service: Control process exited, code=exited status=1
Jul 23 06:13:04 ip-172-31-25-171 systemd[1]: Failed to start LSB: Sensu monitoring framework server.
Jul 23 06:13:04 ip-172-31-25-171 systemd[1]: sensu-server.service: Unit entered failed state.
Jul 23 06:13:04 ip-172-31-25-171 systemd[1]: sensu-server.service: Failed with result 'exit-code'.

root@ip-172-31-25-171:~# tail -f /var/log/sensu/sensu-server.log
{"timestamp":"2017-07-22T18:16:51.732061+0000","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/transport.json"}
{"timestamp":"2017-07-22T18:16:51.732098+0000","level":"warn","message":"config file applied changes","file":"/etc/sensu/conf.d/transport.json","changes":{}}
{"timestamp":"2017-07-22T18:16:51.732185+0000","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/client.json"}
{"timestamp":"2017-07-22T18:16:51.732239+0000","level":"warn","message":"config file applied changes","file":"/etc/sensu/conf.d/client.json","changes":{"client":{"name":[null,"server"],"address":[null,"localhost"],"subscriptions":[null,["ALL"]]}}}
{"timestamp":"2017-07-22T18:16:51.732276+0000","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/uchiwa.json"}
{"timestamp":"2017-07-22T18:16:51.732333+0000","level":"warn","message":"config file applied changes","file":"/etc/sensu/conf.d/uchiwa.json","changes":{"sensu":[{"spawn":{"limit":12}},[{"name":"Sensu","host":"localhost","ssl":false,"port":4567,"path":"","timeout":5000}]],"uchiwa":[null,{"port":3000,"stats":10,"refresh":10000}]}}
{"timestamp":"2017-07-22T18:16:51.732384+0000","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/redis.json"}
{"timestamp":"2017-07-22T18:16:51.732432+0000","level":"warn","message":"config file applied changes","file":"/etc/sensu/conf.d/redis.json","changes":{"redis":[null,{"host":"localhost","port":6379}]}}
{"timestamp":"2017-07-22T18:16:51.732482+0000","level":"fatal","message":"sensu must be a hash","object":[{"name":"Sensu","host":"localhost","ssl":false,"port":4567,"path":"","timeout":5000}]}
{"timestamp":"2017-07-22T18:16:51.732513+0000","level":"fatal","message":"SENSU NOT RUNNING!"}

@denisgolius
Copy link

denisgolius commented Oct 24, 2017

I have the same errors!

/etc/sensu/conf.d/api.json

{
  "api": {
    "host": "localhost",
    "port": 4567
  }
}

/etc/sensu/conf.d/check_apache.json

{
  "checks": {
    "apache_check": {
      "command": "/etc/sensu/plugins/check-apache.rb",
      "interval": 60,
      "handlers": ["default", "email"],
      "subscribers": [ "ALL" ]
    }
  }
}

**/etc/sensu/conf.d/client.json **

{
  "client": {
    "name": "client1",
    "address": "localhost",
    "environment": "development",
    "subscriptions": [ "ALL" ]
  }
}

/etc/sensu/conf.d/handler_email.json

{
  "handlers": {
    "email": {
      "type": "pipe",
      "command": "mail -s 'sensu event' [email protected]"
    }
  }
}

/etc/sensu/conf.d/rabbitmq.json

{
  "rabbitmq": {
    "host": "192.168.1.40",
    "port": 5671,
    "vhost": "/sensu",
    "user": "sensu",
    "password": "mypass"
  }
}

/etc/sensu/conf.d/redis.json

{
  "redis": {
    "host": "localhost",
    "port": 6379
  }
}

/etc/sensu/conf.d/transport.json

{
  "transport": {
    "name": "rabbitmq",
    "reconnect_on_error": true
  }
}

/etc/sensu/conf.d/uchiwa.json

{
  "sensu": [
    {
      "name": "Sensu",
      "host": "localhost",
      "ssl": "false",
      "port": 4567,
      "path": "",
      "timeout": 5000
    }
  ],
  "uchiwa": {
    "port": 3000,
    "stats": 10,
    "refresh": 10000
  }

Copy link

ghost commented Feb 8, 2018

Remove uchiwa.json from conf.d. That's it. it works like charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment