forked from davetayl/vagrant_sensu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision-agent1.sh
134 lines (113 loc) · 3.14 KB
/
provision-agent1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/env bash
# Configure script
set -e # Stop script execution on any error
echo ""; echo "-----------------------------------------"
# Configure variables
MYHOST=agent1
MYHOSTIP="10.0.0.33"
echo "- Variables set -"
# Set system name
hostnamectl set-hostname $MYHOST
cat >> /etc/hosts <<EOF
$MYHOSTIP $MYHOST $MYHOST.localdomain
EOF
echo "- Name set -"
# Install tools
curl -s http://download.opensuse.org/repositories/home:/kayhayen/CentOS_8/home:kayhayen.repo > /etc/yum.repos.d/nuitka.repo
dnf -yqe 3 install net-tools python3 epel-release
dnf -yqe 3 install nuitka
pip3 install icmplib > /dev/null 2>&1
echo "- Tools installed -"
# Install Application
curl -s https://packagecloud.io/install/repositories/sensu/stable/script.rpm.sh | sudo bash > /dev/null 2>&1
dnf -yqe 3 install sensu-go-agent sensu-go-cli
cat <<EOF > /etc/sensu/agent.yml
---
# Sensu agent configuration
##
# agent overview
##
name: "$MYHOST"
namespace: "default"
subscriptions:
- sla-sub
##
# agent configuration
##
backend-url:
- "ws://10.0.0.17:8081"
cache-dir: "/var/cache/sensu/sensu-agent"
config-file: "/etc/sensu/agent.yml"
disable-assets: false
log-level: "debug" # available log levels: panic, fatal, error, warn, info, debug
# Everything below this line is configuring the agent itself, IPs should be 127.0.0.1
##
# api configuration
##
api-host: "127.0.0.1"
api-port: 3031
disable-api: false
events-burst-limit: 10
events-rate-limit: 10.0
##
# authentication configuration
##
user: "admin"
password: "password"
##
# monitoring configuration
##
deregister: false
deregistration-handler: "example_handler"
keepalive-warning-timeout: 120
keepalive-interval: 20
##
# security configuration
##
insecure-skip-tls-verify: false
redact:
- password
- passwd
- pass
- api_key
- api_token
- access_key
- secret_key
- private_key
- secret
#trusted-ca-file: "/path/to/trusted-certificate-authorities.pem"
##
# socket configuration
##
disable-sockets: false
socket-host: "127.0.0.1"
socket-port: 3030
##
# statsd configuration
##
statsd-disable: false
statsd-event-handlers:
- example_handler
statsd-flush-interval: 10
statsd-metrics-host: "127.0.0.1"
statsd-metrics-port: 8125
EOF
cat <<EOF > /etc/sudoers.d/sensu
sensu ALL=NOPASSWD:/usr/bin/check-path.py ALL
EOF
echo "- Sensu installed -"
# Install check-path.py
curl -s "https://raw.githubusercontent.com/davetayl/Nagios-Plugins/master/check-path/check-path.py" -o /tmp/check-path.py > /dev/null 2>&1
nuitka3 --recurse-all /tmp/check-path.py -o /usr/bin/check-path.bin > /dev/null 2>&1
chmod +s /usr/bin/check-path.bin > /dev/null 2>&1
echo "- check-path.py Installed -"
# Install check-path-inf.py
curl -s "https://raw.githubusercontent.com/davetayl/influxdb-plugins/main/check-path/check-path-inf.py" -o /tmp/check-path-inf.py > /dev/null 2>&1
nuitka3 --recurse-all /tmp/check-path-inf.py -o /usr/bin/check-path-inf.bin > /dev/null 2>&1
chmod +s /usr/bin/check-path-inf.bin > /dev/null 2>&1
echo "- check-path-inf.py Installed -"
systemctl enable --now sensu-agent
echo "- Sensu started -"
echo "-----------------------------------------"
echo "With great power comes great opportunity!"
echo "-----------------------------------------"