- move scripts from folder to git-repo

- install script manual only
This commit is contained in:
Vassiliy Yegorov
2019-07-13 11:10:56 +07:00
parent 941b13aa49
commit 14e6ae1973
9 changed files with 11 additions and 145 deletions

17
main.tf
View File

@@ -51,21 +51,18 @@ resource "google_compute_instance" "zabbix" {
private_key = "${file("~/.ssh/id_rsa")}" private_key = "${file("~/.ssh/id_rsa")}"
} }
# provisioner "file" {
# source = "scripts/setupzabbix.sh"
# destination = "~/setupzabbix.sh"
# }
metadata_startup_script = "${file("scripts/setupzabbix.sh")}"
provisioner "file" { provisioner "file" {
source = "scripts/zabscripts" source = "scripts/setupzabbix.sh"
destination = "/usr/lib/zabbix/alertscripts " destination = "~/setupzabbix.sh"
} }
# provisioner "remote-exec" {
# inline = ["${file("scripts/setupzabbix.sh")}"]
# }
provisioner "file" { provisioner "file" {
source = "scripts/zabconf" source = "scripts/zabconf"
destination = "/etc/zabbix" destination = "~/"
} }
} }

View File

@@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
cd ~
sudo wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-2+bionic_all.deb sudo wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-2+bionic_all.deb
sudo dpkg -i zabbix-release_4.0-2+bionic_all.deb sudo dpkg -i zabbix-release_4.0-2+bionic_all.deb
sudo apt-get update sudo apt-get update

View File

@@ -6,6 +6,7 @@ sudo apt update
sudo apt install zabbix-server-mysql -y sudo apt install zabbix-server-mysql -y
sudo apt install zabbix-frontend-php -y sudo apt install zabbix-frontend-php -y
sudo apt install git -y
sudo mysql -uroot -e "create database zabbix character set utf8 collate utf8_bin;" sudo mysql -uroot -e "create database zabbix character set utf8 collate utf8_bin;"
sudo mysql -uroot -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'V7F4Uj12dcn5WAu';" sudo mysql -uroot -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'V7F4Uj12dcn5WAu';"
@@ -14,6 +15,8 @@ sudo mysql -uroot -e "quit"
sudo zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | sudo mysql -uzabbix zabbix -pV7F4Uj12dcn5WAu sudo zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | sudo mysql -uzabbix zabbix -pV7F4Uj12dcn5WAu
git clone https://github.com/vasyakrg/zabbix-alert-scripts.git /usr/lib/zabbix/alertscripts
sudo service apache2 restart sudo service apache2 restart
sudo service zabbix-server start sudo service zabbix-server start
sudo update-rc.d zabbix-server enable sudo update-rc.d zabbix-server enable

View File

@@ -1,23 +0,0 @@
#!/bin/bash
KEY="https://hooks.slack.com/services/"
TO="$1"
SUB="$2"
MESS="$3"
if [[ $SUB == 'PROBLEM' ]]
then
ICON=":scream:"
elif [[ $SUB == 'OK' ]]
then
ICON=":ok_hand:"
else
ICON=":point_up_2:"
fi
/usr/local/bin/curl -X POST --data-urlencode "payload={\"channel\": \"$TO\", \"username\": \"TradeNarK\", \"text\": \"$ICON $SUB\n$MESS\"}" $KEY
# settings to zabbix-server
# {ALERT.SENDTO}
# {ALERT.SUBJECT}
# {ALERT.MESSAGE}

View File

@@ -1,52 +0,0 @@
#!/bin/bash
# Slack incoming web-hook URL and user name
url='https://hooks.slack.com/services/' # example: url='https://hooks.slack.com/services/QW3R7Y/D34DC0D3/BCADFGabcDEF123'
username='zabbix-server'
## Values received by this script:
# To = $1 / Slack channel or user to send the message to, specified in the Zabbix web interface; "@username" or "#channel"
# Subject = $2 / subject of the message sent by Zabbix; by default, it is usually something like "(Problem|Resolved): Lack of free swap space on Zabbix server"
# Message = $3 / message body sent by Zabbix; by default, it is usually approximately 4 lines detailing the specific trigger involved
# Alternate URL = $4 (optional) / alternative Slack.com web-hook URL to replace the above hard-coded one; useful when multiple groups have seperate Slack teams
# Proxy = $5 (optional) / proxy host including port (such as "example.com:8080")
# Get the user/channel ($1), subject ($2), and message ($3)
to="$1"
subject="$2"
message="$3"
# Change message emoji and notification color depending on the subject indicating whether it is a trigger going in to problem state or recovering
#recoversub='^RECOVER(Y|ED)?$|^OK$|^Resolved*'
recoversub='Resolved'
problemsub='Problem'
#problemsub='^Беда*'
updatesub='Update'
if [[ "$subject" =~ $recoversub ]]; then
emoji=':smile:'
color='#0C7BDC'
elif [[ "$subject" =~ $problemsub ]]; then
emoji=':face_palm:'
color='#FFC20A'
elif [[ "$subject" =~ $updatesub ]]; then
emoji=':scream:'
color='#FFC20A'
else
emoji=':pager:'
color='#CCCCCC'
fi
# Replace the above hard-coded Slack.com web-hook URL entirely, if one was passed via the optional 4th parameter
url=${4-$url}
# Use optional 5th parameter as proxy server for curl
proxy=${5-""}
if [[ "$proxy" != '' ]]; then
proxy="-x $proxy"
fi
# Build JSON payload which will be HTTP POST'ed to the Slack.com web-hook URL
payload="payload={\"channel\": \"${to//\"/\\\"}\", \
\"username\": \"${username//\"/\\\"}\", \
\"attachments\": [{\"fallback\": \"${subject//\"/\\\"}\", \"title\": \"${subject//\"/\\\"}\", \"text\": \"${message//\"/\\\"}\", \"color\": \"${color}\"}], \

View File

@@ -1,4 +0,0 @@
PATH=/bin:/usr/bin:/usr/local/bin
USER_ID=X
PASSWORD=X

View File

@@ -1,31 +0,0 @@
#!/bin/bash
TO_NUMBER="$1"
SUBJECT="$2"
MESSAGE="$3"
echo ${TO_NUMBER} >> /tmp/out.txt
echo ${SUBJECT} >> /tmp/out.txt
echo ${MESSAGE} >> /tmp/out.txt
. smsc.conf
SMSC_URL=${SMSC_URL:-"https://smsc.ru/sys/send.php"}
TO_NUMBER=$(echo "${TO_NUMBER}" | sed 's/[^0123456789]//g')
NL=''
RESULT=$(curl --get --silent --show-error \
--data-urlencode "login=${USER_ID}" \
--data-urlencode "psw=${PASSWORD}" \
--data-urlencode "phones=${TO_NUMBER}" \
--data-urlencode "mes=${SUBJECT}:${MESSAGE}" \
"${SMSC_URL}" 2>&1
)
STATUS=$?
echo ${RESULT}
echo ${RESULT} >> /tmp/smsc.txt
exit ${STATUS}

View File

@@ -1,15 +0,0 @@
#!/bin/bash
TOKEN=''
which curl &>/dev/null
if [ $? -ne 0 ] ; then echo 'FAIL: curl not found.' && exit 1 ; fi
if [ $# -ne 3 ] ; then echo 'FAIL: Params not defined.' && echo 'Usage: zabbix-to-telegram-notify.sh TelegramID Subject Message' && exit 1 ; fi
CHAT_ID="$1"
SUBJECT="$2"
MESSAGE="$3"
curl -s --header 'Content-Type: application/json' --request 'POST' --data "{\"chat_id\":\"${CHAT_ID}\",\"text\":\"${SUBJECT}\n${MESSAGE}\"}" "https://
api.telegram.org/bot${TOKEN}/sendMessage" | grep -q '"ok":false,'
if [ $? -eq 0 ] ; then exit 1 ; fi

View File

@@ -1,10 +0,0 @@
#/bin/bash
if [ $# -eq 0 ] ; then echo 'FAIL: Params not defined.' && echo 'Usage: zbxviewer.sh Token Subject Message' && exit 1 ; fi
if wget -V >/dev/null 2>&1 ; then
#use wget
wget -q "https://zbx.vovanys.com/push/sendPush.php?token=$1&title=$2&desc=$3"
else
#if wget not found, use curl
curl -kdG "https://zbx.vovanys.com/push/sendPush.php?token=$1&title=$2&desc=$3"
fi