INT 21h

Hi, I am Vladimir Smagin, SysAdmin, DevOps and barely good guy. Telegram Email / GIT / Микроблог / Thingiverse / GPG

Zabbix: monitor days before SSL expired

№ 10870 В разделе "Sysadmin" от December 30th, 2019,
В подшивках: ,

I monitor my SSL enabled domains with automatic discovery feature. On server I placed text file with new line separated domain list /etc/zabbix/scripts/ssl_list.txt, zabbix checking it every minute and creating new items with domains. No empty line at the end! Install jq tool to work with JSON.

See archive file at the end.

Create directory /etc/zabbix/scripts and place 2 files inside: ssl_get_days.sh, ssl_list.txt.
Copy configuration file for zabbix agent /etc/zabbix/zabbix_agentd.d/ssl.conf

Now import XML file with template or create discovery rule by hands:

Good! Good! Add new item prototype

And two triggers “expires” and “expired”

Now wait few minutes and you see your domains in latest data

All files you need at once, just import template data in zabbix web interface.

zabbix_ssl_check.tar

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

Zabbix calculated item and abschange (change)

№ 10168 В разделе "Sysadmin" от August 9th, 2019,
В подшивках: ,

Last time I wrote to you how monitor your Nginx instance with Zabbix. Now I tell you how to calculate rates from counters.

You looking at something like that in your template

Now create new Item handled

Ok, see at field with formula, it linked with created earlier Item “Nginx Handled”. As said in official documentation abschange shows you a difference between last and current values. Now set Interval to 60 seconds and you have “Handled per minute” value.

Of course, you want to create some Graphics. All people loves graphics!

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

Zabbix: MySQL to Postgresql migration

№ 9662 В разделе "Sysadmin" от December 28th, 2018,
В подшивках: , , ,

All services containerized by Docker, MySQL and Zabbix containers connected to network “zabbix”.

Start Postgresql container and add it to zabbix network group in Docker, set parameters as you need

docker run --name postgres -d --restart=Always \
    -e POSTGRES_USER=postgres
    -e POSTGRES_PASSWORD=postgres
    postgres
docker network connect zabbix postgres

Now create database and user

docker exec -it postgres su -c "createuser -P zabbix" postgres
docker exec -it postgres su -c "createdb -E UTF-8 -O zabbix zabbix" postgres

Ok, database online and accessible for Zabbix services.

Now you can stop old containers with Zabbix services for MySQL and run migration

docker stop zabbix-server-mysql zabbix-panel-mysql
docker run --network zabbix --rm -v /tmp/zabbix:/zabbix dimitri/pgloader:latest \
    bash -c "pgloader --debug --verbose \
    mysql://root:pa55w0rd@mariadb/zabbix \
    postgresql://zabbix:zabbix@postgres/zabbix"

Lets create script to start new Zabbix containers for Postgres DB

!/bin/bash

alertscripts="/srv/docker/zabbix/alertscripts:/usr/lib/zabbix/alertscripts"
externalscripts="/srv/docker/zabbix/externalscripts:/usr/lib/zabbix/externalscripts"

docker run --name zabbix-server-pg -p 10051:10051 \
    -v $alertscripts \
    -v $externalscripts \
    -e DB_SERVER_HOST="postgres" \
    -e DB_SERVER_PORT=5432 \
    -e POSTGRES_USER="zabbix" \
    -e POSTGRES_PASSWORD="zabbix" \
    -e POSTGRES_DB="zabbix" \
    -d --restart=always \
    --network zabbix \
    zabbix/zabbix-server-pgsql:ubuntu-latest

docker run --name zabbix-panel-pg -p 5001:80 \
    -e DB_SERVER_HOST="postgres" \
    -e POSTGRES_USER="zabbix" \
    -e POSTGRES_PASSWORD="zabbix" \
    -e POSTGRES_DB="zabbix" \
    -e ZBX_SERVER_HOST="zabbix-server-pg" \
    -e ZBX_SERVER_PORT="10051" \
    -e PHP_TZ="Asia/Novosibirsk" \
    -d --restart=always \
    --network zabbix \
    zabbix/zabbix-web-nginx-pgsql:ubuntu-latest

You did it! Take a cookie from shelf.

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

Zabbix automatic discovery and monitoring Docker containers

№ 9617. В разделе " Sysadmin " от December 2nd, 2018

В подшивках: , ,

Zabbix: notifications to Telegram

№ 9548 В разделе "Sysadmin" от November 15th, 2018,
В подшивках: , ,

To receive and forward messages to Telegram you need to install my Telegram-post-bot or use docker image. After this you can create script /usr/lib/zabbix/alertscripts/telegram.sh with this content:

#!/bin/bash
source /etc/profile

json_escape () {
    printf '%s' "$1" | python -c 'import json,sys; print(json.dumps(sys.stdin.read()).strip("\""))'
}

chat_id="-763495760089" # your channel id
post_title=$(json_escape "$1")
post_body=$(json_escape "$2")

echo "{\"chatID\":\"${chat_id}\",\"message\":\"${post_title}\n\n${post_body}\"}" | nc -U /run/telegram-GrapeBlessedBot.sock

You can get your account, group or channel id easily using @get_id_bot.

Now you ready to add new Media type (Administration -> Media types)

Add new media to your account

That’s all folks!

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

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

# 2019-12-23 09:14:01

Очень интересная концепция, docker-compose для kubernetes kompose.io/ #devops #kubernetes #docker

# 2019-12-16 17:21:18

Надо будет почитать для общего развития как оживить кластер в случае проеба сертов habr.com/ru/company/southbridg #kubernetes #devops

# 2019-12-12 17:33:46

js bootstrap с интерфейсом как в DOS github.com/kristopolous/BOOTST


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

Fortune cookie: ... I'm IMAGINING a sensuous GIRAFFE, CAVORTING in the BACK ROOM of a KOSHER DELI --