INT 21h

Hi, I am Vladimir Smagin, SysAdmin. Telegram Email GPG / Микроблог

Zabbix: monitor bash script results

№ 9533 В разделе "Администрирование" от November 10th, 2018,

Install zabbix-agent (sometimes zabbix-sender) package to your server that contains zabbix_sender. Now add some exit codes checks after every monitored command.

#!/bin/bash
source /etc/profile
cd /tmp
weekday=$(date '+%w') # 7 days history
monthday=$(date '+%d') # whole month

history=$weekday 

pg_dump postgresql://postgres@127.0.0.1:5432/mydatabase| gzip > db_backup_$history.sql.gz
if [ $? -ne 0 ]
then
    echo "pg_dump failed to dump"
    /usr/bin/zabbix_sender -z zabbix.server.ru -s pg2-server -k pgdumper.dump -o failed
    rm -f db_backup_$history.sql.gz
    exit 1
else
    /usr/bin/zabbix_sender -z zabbix.server.ru -s pg2-server -k pgdumper.dump -o successful
    curl -u ftp_login:ftp_password ftp://ftp.server.ru/postgres-backups/$history/db_backup_$history.sql.gz \
         --ftp-create-dirs -T db_backup_$history.sql.gz
    if [ $? -ne 0 ]
        then
            echo "curl failed to upload dumped file"
            /usr/bin/zabbix_sender -z zabbix.server.ru -s pg2-server -k pgdumper.upload -o failed
            rm -f db_backup_$history.sql.gz
            exit 1
        fi
    /usr/bin/zabbix_sender -z zabbix.server.ru -s pg2-server -k pgdumper.upload -o successful
    rm -f db_backup_$history.sql.gz
fi

Create template

Add your monitored items

And add triggers to raise exceptions

You can combine items in one trigger

Do not forget to activate email notices.

Нет комментариев »

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Микроблог перейти

# 2018-11-26 09:15:41

Обнаружил в kubedb код google analytics UA-62096468-20, слежка включена по умолчанию.

# 2018-11-24 23:30:12

Несложно смог контейнеризовать nginx unit с предзагрузкой конфигурации перед стартом контейнера blindage.org/?p=9575


© Vladimir Smagin, 2005-2018. Копирование материалов без разрешения запрещено. GPG 0x29AE91B1A37721C3
Яндекс.Метрика

Fortune cookie: "If a person's personal religious beliefs are sacred, they should not be peddled door-to-door like Girl Scout Cookies." [Marilyn Burge]