Skip to content

Instantly share code, notes, and snippets.

@zouzias
Last active April 5, 2016 06:36
Show Gist options
  • Save zouzias/c1a40d9dbcf42d80e86d3a6c80a47cfe to your computer and use it in GitHub Desktop.
Save zouzias/c1a40d9dbcf42d80e86d3a6c80a47cfe to your computer and use it in GitHub Desktop.
Install Sensu on Ubuntu
{
"checks": {
"cron": {
"command": "check-process.rb -p cron",
"standalone": true,
"interval": 60,
"handlers": ["default", "debug"]
}
}
}
# Run sensu-install -p process-checks to install process checks
# Put it under /etc/sensu/conf.d/
{
"client": {
"name": "client-01",
"address": "localhost",
"environment": "development",
"subscriptions": [
"dev"
],
"socket": {
"bind": "127.0.0.1",
"port": 3030
}
}
}
{
"redis": {
"host": "localhost"
},
"transport": {
"name": "redis"
},
"api": {
"host": "localhost",
"port": 4567
}
}
{
"sensu": [
{
"name": "sensu",
"host": "localhost",
"port": 4567
}
],
"dashboard": {
"host": "0.0.0.0",
"port": 3000
}
}
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run with sudo, or as root"
exit 1
fi
grep -i 'ubuntu\|debian' /etc/issue > /dev/null 2>&1
issue=$?
if [ $issue -ne 0 ]; then
echo "This script must be run on Ubuntu or Debian only"
exit 1
fi
# update apt, install depenedencies
echo "Installing dependencies..."
apt-get install -y curl > /dev/null
echo "...installing the Sensu Core software repository..."
wget -q http://repositories.sensuapp.org/apt/pubkey.gpg -O- | apt-key add - > /dev/null 2>&1
echo "deb http://repositories.sensuapp.org/apt sensu main" | tee /etc/apt/sources.list.d/sensu.list > /dev/null 2>&1
echo "SUCCESS!"
success=1
sudo apt-get update
# Install Redis, CURL and JQ
sudo apt-get -y install redis-server curl jq
# Redis setup:( Bind on every IP, Disable DB synchronization)
sed -i.bak 's/^bind/#bind/g' /etc/redis/redis.conf
sed -i.bak 's/^save/#save/g' /etc/redis/redis.conf
sudo update-rc.d redis-server defaults
sudo /etc/init.d/redis-server start
# Install sensu
sudo apt-get install sensu
# COPY FILES HERE (/etc/sensu/dashboard.json, /etc/sensu/conf.d/client.json, /etc/sensu/config.json)
CONFIG_JSON="{
\"redis\": {
\"host\": \"localhost\"
},
\"transport\": {
\"name\": \"redis\"
},
\"api\": {
\"host\": \"localhost\",
\"port\": 4567
}
}"
DASHBOARD_JSON= "{
\"sensu\": [
{
\"name\": \"sensu\",
\"host\": \"0.0.0.0\",
\"port\": 4567
}
],
\"dashboard\": {
\"host\": \"0.0.0.0\",
\"port\": 3000
}
}"
CLIENT_JSON="{
\"client\": {
\"name\": \"client-01\",
\"address\": \"localhost\",
\"environment\": \"development\",
\"subscriptions\": [
\"dev\"
],
\"socket\": {
\"bind\": \"0.0.0.0\",
\"port\": 3030
}
}
}"
echo $DASHBOARD_JSON > /etc/sensu/dashboard.json
echo $CONFIG_JSON > /etc/sensu/config.json
echo $CLIENT_JSON > /etc/sensu/conf.d/client.json
# Change owner
sudo chown -R sensu:sensu /etc/sensu
sudo /etc/init.d/sensu-server start
sudo /etc/init.d/sensu-api start
sudo /etc/init.d/sensu-client start
# Install Uchiwa
UCHIWA_JSON="{
\"sensu\": [
{
\"name\": \"Localhost\",
\"host\": \"localhost\",
\"port\": 4567,
\"timeout\": 5
}
],
\"uchiwa\": {
\"host\": \"0.0.0.0\",
\"port\": 3000,
\"interval\": 5
}
}"
sudo apt-get install -y uchiwa
echo $UCHIWA_JSON > /etc/sensu/uchiwa.json
sudo service sensu_api restart
sudo service uchiwa restart
curl -s http://localhost:4567/clients | jq .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment