Skip to content

Instantly share code, notes, and snippets.

View paskal's full-sized avatar

Dmitry Verkhoturov paskal

View GitHub Profile
#!/usr/bin/env python
#
# imap_cleaner.py
#
# Copyright 2012 Konstantin Shcherban <k.scherban@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@paskal
paskal / zabbix_find_unused_macroses.sql
Last active July 2, 2017 02:51
Find hosts\templates macroses, unused by items and triggers (including autodiscovery)
SELECT m.hostid,
m.macro
FROM hostmacro AS m
WHERE
NOT (SELECT count(*)
FROM functions AS f
JOIN items AS i ON i.itemid = f.itemid
WHERE i.hostid = m.hostid
AND f.parameter LIKE concat('%',m.macro,'%'))
AND NOT
@paskal
paskal / expand_macro.py
Last active July 26, 2018 03:32
Recuresively resolve Zabbix user macro within string
import re
import logging
def expand_macro(zapi, itemid, hostid, macro):
"""Expand macro in passed string, recursively. Non-existent macro resolved to empty string.
Example:
# {$MACRO} resolves to "test macro in ${ENV} environment"
# {$ENV} resolves to "dev"
>>> print(expand_macro(zapi, 12345, 54321, "string with {$MACRO}"))
{
"meta": {
"theme": "kendall",
"canonical": "https://github.com/paskal/terrty/blob/master/cv/resume.json"
},
"basics": {
"name": "Dmitry Verkhoturov",
"label": "Senior Site Reliability Engineer",
"picture": "https://terrty.net/images/avatar.jpg",
"email": "paskal.07@gmail.com",
@paskal
paskal / Readme.md
Last active August 22, 2023 16:41
How to set up the Percona Monitoring and Management (PMM) v2 with docker-compose

Set up PMM Server v2

Let's start by creating entry for server in docker-compose.yaml:

version: '2'
# version 2 of docker-compose is not "old" version, it's the actual version,
# see below for explanation:
# https://stackoverflow.com/a/53636006/961092
services:
@paskal
paskal / site.conf
Last active March 22, 2024 12:26 — forked from plentz/nginx.conf
Nginx configuration for best security and modest performance. Full info on https://terrty.net/2014/ssl-tls-in-nginx/
# read more at https://terrty.net/2014/ssl-tls-in-nginx/
# latest version on https://gist.github.com/paskal/628882bee1948ef126dd/126e4d1daeb5244aacbbd847c5247c2e293f6adf
# security test score: https://www.ssllabs.com/ssltest/analyze.html?d=terrty.net
# your nginx version might not have all directives included, test this configuration before using in production against your nginx:
# $ nginx -c /etc/nginx/nginx.conf -t
server {
# public key, contains your public key and class 1 certificate, to create:
# (example for startssl)
# $ (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null