Install Bosun
Install Bosun monitoring on Centos7 using InfluxDB
Install Java
yum install java-1.8.0-openjdk-headless
Install InfluxDB
get latest RPM from https://portal.influxdata.com/downloads
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.2.4.x86_64.rpm
yum localinstall influxdb-1.2.4.x86_64.rpm
create startup script,
vim /etc/systemd/system/influxdb.service
[Unit]
Description=InfluxDB Server
After=network.target
[Install]
WantedBy=network.target
[Service]
User=influxdb
Group=influxdb
PermissionsStartOnly=true
ExecStart=/usr/bin/influxdb -config /etc/influxdb/influxdb.conf
Restart=on-failure
check the InfluxDB conf file (should be in /etc/influxdb/influxdb.conf, check the HTTP bind port (default is 8086)
start InfluxDB service
Install Bosun
wget https://github.com/bosun-monitor/bosun/releases/download/0.6.0-beta1/bosun-linux-amd64
mv bosun-linux-amd64 bosun
mv bosun /usr/bin & chmod 755 /usr/bin/bosun
mkdir /etc/bosun
vim /etc/bosun.toml
# Note: This file is tested as part of Bosun's tests. Editing outside of comments
# may cause tests to fail
# Taken from https://github.com/bosun-monitor/bosun/blob/master/cmd/bosun/bosun.example.toml
# Hostname will be used when links are created in templates (i.e. acknowledge links)
Hostname = "devbox2"
# The HTTP IP and Port to Listen on. Default is ":8070"
HTTPListen = ":8070"
# Alert checks are run by default every CheckFrequency * DefaultRunEvery. RunEvery can be overridden
# by indivdual alerts. Defaults are "5m" and 1
CheckFrequency = "1m"
DefaultRunEvery = 5
# Path to the rule file (file that contains definitions for alerts, macros, lookups, templates, and notifications)
RuleFilePath = "/etc/bosun/rules.toml"
# timeanddate.com zones (only for use in the UI)
TimeAndDate = [ 202, 75, 179, 136 ]
# An API key for generating goo.gl shortlinks
ShortURLKey = "aKey"
# The minumum amount of alerts to create an alert group on the dashboard. Default is 5
MinGroupSize = 5
# How many unknown alerts in a check cycle are needed before a group notiofication is created
UnknownThreshold = 5
# This makes it so Bosun ping's and records a metric for every value of the "host" tag it has seen. Default is false
Ping = true
# How long before hosts stop being pinged if we haven't seen a tagset for that host.Alert. Default is 24 hours
PingDuration = "24h"
# How long certain items and metrics should be displayed in the UI if we haven't seen them. Default 3 days
SearchSince = "72h"
# Enable saving API endpoints and the ability to save the config via the UI. Default is false
# EnableSave = true
# Path to a command that will be executed on save of the rule configuration. This command is passed a filename, username, message, and vargs
# If the command does not execute save operations will be canceled and the rule file will be restored
#CommandHookPath = "/Users/kbrandt/src/hook/hook"
# Configuration for to enable to Graphite Backend
[GraphiteConf]
Host = "localhost:80"
[GraphiteConf.Headers]
X-Meow = "Mix"
# Configuration for Bosun's internal storage. Can be Ledis (Default) or Redis. Redis is recommended
# for production setups. Defaults for ledis are below but would be ignored since redis takes
# precedencea
[DBConf]
# RedisHost = "localhost:6389"
LedisDir = "ledis_data"
LedisBindAddr = "127.0.0.1:9565"
# Configuration to enable Bosun to be able to send email notifications
[SMTPConf]
EmailFrom = "bosun-alert@company.com"
Host = "localhost"
# Configuration to enable the InfluxDB backend
[InfluxConf]
URL = "https://localhost:8086"
Timeout = "5m"
UnsafeSSL = true
create bosun startup script in systemd (/etc/systemd/system/bosun.service
[Unit]
Description=Bosun Service
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/bin/bosun -c /etc/bosun/bosun.toml
Restart=on-abort
[Install]
WantedBy=multi-user.target
init.d startup script
#!/bin/sh # # /etc/rc.d/init.d/bosun # bosun # # chkconfig: - 98 02 # description: bosun ### BEGIN INIT INFO # Provides: bosun # Required-Start: networking # Required-Stop: networking # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Runs teh bosun # Description: bosun ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions base_dir="/opt/bosun" exec="/opt/bosun/bosun" prog="bosun" config="${base_dir}/config/prod.conf" [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog lockfile=/var/lock/subsys/$prog pidfile=/var/run/bosun.pid logfile=/var/log/$prog.log #These "secrets" can be used in the prod.conf using syntax like ${env.CHAT} or ${env.API_KEY} export CHAT=https://chat.company.com/rooms/123?key=123456789012345678901234567890 export API_KEY=123456789012345678901234567890 check() { $exec -t -c $config if [ $? -ne 0 ]; then echo "Errors found in configuration file, check it with '$exec -t'." exit 1 fi } start() { [ -x $exec ] || exit 5 [ -f $config ] || exit 6 check echo -n $"Starting $prog: " # if not running, start it up here, usually something like "daemon $exec" ulimit -n 65536 daemon daemonize -a -c $base_dir -e $logfile -o $logfile -p $pidfile -l $lockfile $exec -c $config $OPTS retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " # stop it here, often "killproc $prog" killproc -p $pidfile -d 5m retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { check stop start } reload() { restart } force_reload() { restart } rh_status() { # run checks to determine if the service is running or use generic status status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 restart ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit 2 esac