Skip to content

Instantly share code, notes, and snippets.

View cherts's full-sized avatar

Mikhail Grigorev cherts

View GitHub Profile
@cherts
cherts / kill_session.sh
Created June 3, 2022 13:48
Kill user session via loginctl
#!/bin/bash
#
# Program: Kill user session via loginctl <kill_session.sh>
#
# Author: Mikhail Grigorev <sleuthhound at gmail dot com>
#
# Current Version: 1.0.1
#
# License:
@cherts
cherts / change-centos8-off-repo.sh
Created February 1, 2022 17:18
Change CentOS 8 official repo (EOL)
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
@cherts
cherts / nginx_simple_http.vhost
Created January 14, 2022 11:38
Simple nginx vhost (only http and php-fpm)
server {
listen XX.XX.XX.XX:80;
server_name YYYY.ZZ;
root /var/www/NNNNNN;
index index.php index.html index.htm;
error_log /var/log/nginx/YYYY_error.log;
access_log /var/log/nginx/YYYY_access.log main;
set $fastcgipass unix:/run/php/BBBBB.sock;
@cherts
cherts / swap2ram.sh
Last active February 25, 2022 07:17
#!/bin/bash
#
# Program: Write SWAP to RAM <swap2ram.sh>
#
# Author: Mikhail Grigorev <sleuthhound at gmail dot com>
#
# Current Version: 1.0.1
#
# License:
@cherts
cherts / my.cnf_24G_200
Last active December 22, 2021 12:53
Percona Server for MySQL 5.7 (innodb_buffer_pool_size: 24G, max_connections: 200, max RAM usage: 38GB)
[mysqld]
user = mysql
bind-address = 0.0.0.0
port = 3306
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
datadir = /var/lib/mysql
connect_timeout = 600
wait_timeout = 600
@cherts
cherts / Template CPU and Memory by User.yaml
Last active September 19, 2021 18:59
Template CPU and Memory by User (required Zabbix v5.4)
zabbix_export:
version: '5.4'
date: '2021-09-19T18:59:11Z'
groups:
-
uuid: 7df96b18c230490a9a0a9e2307226338
name: Templates
templates:
-
uuid: ddfbae14f57f4aa09733fba5de867ce3
@cherts
cherts / hotplug_add_cpu_and_mem.sh
Created September 1, 2021 09:34
Hotplug add CPU and Memory
#!/bin/bash
# Bring CPUs online
for CPU_DIR in /sys/devices/system/cpu/cpu[0-9]*
do
CPU=${CPU_DIR##*/}
echo "Found cpu: '${CPU_DIR}' ..."
CPU_STATE_FILE="${CPU_DIR}/online"
if [ -f "${CPU_STATE_FILE}" ]; then
if grep -qx 1 "${CPU_STATE_FILE}"; then
@cherts
cherts / ssl_cert_expire.sh
Last active August 11, 2021 10:13
Check SSL certificate expires days
#!/usr/bin/env bash
#
# Program: Check SSL certificate expires days <ssl_cert_expire.sh>
#
# Author: Mikhail Grigorev <sleuthhound at gmail dot com>
#
# Current Version: 1.0.2
#
# License:
@cherts
cherts / whois_domain_expire.sh
Last active August 11, 2021 10:13
Check domain expires days
#!/usr/bin/env bash
#
# Program: Check domain expires days <whois_domain_expire.sh>
#
# Author: Mikhail Grigorev <sleuthhound at gmail dot com>
#
# Current Version: 1.0.2
#
# License:
@cherts
cherts / get_linux_scheduler.sh
Last active March 3, 2023 13:21
Get Linux i/o scheduler and params
for i in $(ls -1 /sys/block/ | grep -oE 'sd[a-z]|nvme.*'); do echo -n "$i: rotational: $(cat /sys/block/$i/queue/rotational) | \
scheduler: $(cat /sys/block/$i/queue/scheduler) | \
nr_requests: $(cat /sys/block/$i/queue/nr_requests) | \
rq_affinity: $(cat /sys/block/$i/queue/rq_affinity)"; [ -f "/sys/block/$i/queue/read_ahead_kb" ] && echo -n " | read_ahead_kb: $(cat /sys/block/$i/queue/read_ahead_kb)"; [ -f "/sys/block/$i/queue/iosched/writes_starved" ] && echo -n " | writes_starved: $(cat /sys/block/$i/queue/iosched/writes_starved)"; [ -f "/sys/block/$i/queue/iosched/read_expire" ] && echo -n " | read_expire: $(cat /sys/block/$i/queue/iosched/read_expire)"; echo ""; done #| awk '!(NR%2){print p "\t\t\t" $0}{p=$0}'