Skip to content

Instantly share code, notes, and snippets.

View stoyanovgeorge's full-sized avatar
🎯
Focusing

Georgi Stoyanov stoyanovgeorge

🎯
Focusing
  • Techtriq GmbH
  • Germany
View GitHub Profile
@stoyanovgeorge
stoyanovgeorge / check_running_status.sh
Created February 11, 2019 13:01
Check if a PID (process ID is running and return True in case it does.
#!/bin/bash
if [[ $(ps -o pid= -p 2310) -ne 0 ]]; then
echo "True"
else
echo "False"
fi
@stoyanovgeorge
stoyanovgeorge / sshd_config
Created February 15, 2019 11:40
Hardened SSH configuration file for modern Linux servers
# $OpenBSD: sshd_config,v 1.102 2018/02/16 02:32:40 djm Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
@stoyanovgeorge
stoyanovgeorge / proc_monitor.sh
Created February 15, 2019 12:52
Python3 script monitoring if a process is running and logging the time when the process has stopped. It works for one or multiple instances of the same process.
#!/usr/bin/env python3
''' Script checking if a pre-defined process is running '''
import subprocess
import shlex
import time
import datetime
import psutil
import os
@stoyanovgeorge
stoyanovgeorge / process_checker.sh
Created March 27, 2019 13:10
Checks and records in a CSV file how many processes with a <process_name> are running every 10 seconds.
#!/usr/bin/env python3
import subprocess
import csv
import os
import time
from datetime import datetime
from pathlib import Path
#### Variables definition
@stoyanovgeorge
stoyanovgeorge / avg_speed.sh
Last active November 3, 2024 19:13
An one line command to get the average RX and TX speed of a particular interface (eth0) over $INT seconds in bytes per second. You need to divide by 128 to get it in Kbps or by 131072 (128*1024) for Mbps.
#!/bin/bash
INT=2; RXDIR=/sys/class/net/eth0/statistics/rx_bytes; TXDIR=/sys/class/net/eth0/statistics/tx_bytes; RXSTART=$(cat $RXDIR); TXSTART=$(cat $TXDIR); sleep $INT; RXEND=$(cat $RXDIR); TXEND=$(cat $TXDIR); RXBPS="$(((RXEND-RXSTART)/INT))"; TXBPS="$(((TXEND-TXSTART)/INT))"; echo "$RXBPS" "$TXBPS"
@stoyanovgeorge
stoyanovgeorge / mc_join
Created July 17, 2019 12:49
Join Multicast addresses over IGMP
The join command requires smcroute package to be installed
You can install it by executing:
sudo apt install smcroute
sudo smcroutectl join <interface> <mc_address>
where:
1. <interface> is the interface on which the MC traffic should be present
@stoyanovgeorge
stoyanovgeorge / cpu_usage.sh
Created August 21, 2019 14:49
Print the total CPU usage in the terminal and updates its value every second.
#!/bin/bash
# Created by Paul Colby (http://colby.id.au)
# Further edited by Georgi Stoyanov (http://gstoyanov.com), no rights reserved ;)
PREV_TOTAL=0
PREV_IDLE=0
# Determinining the number of CPU cores
CPU_CORES=$(nproc --all)
@stoyanovgeorge
stoyanovgeorge / fullscreen_rofi.rasi
Created April 2, 2020 12:46
Publishing my Rasi theme. Very simple, but at the same time elegant.
configuration {
show-icons: false;
sidebar-mode: false;
}
* {
// Default bg is transparent.
background-color: transparent;
// Default text is white
text-color: white;
@stoyanovgeorge
stoyanovgeorge / change_vlan_ip_mask.bat
Last active January 27, 2025 17:09
A batch script for Windows 10 which can change the IP address, the network mask, the gateway, the DNS and the VLAN ID of an interface. You need to execute the script with admin rights.
@echo off
:: Configuration Variables
set "ifName=Ethernet 2"
set "ipAddress=10.88.167.35"
set "subnetMask=255.255.255.240"
set "vlanID=702"
:: set "defaultGateway=x.x.x.x"
:: set "primaryDNS=x.x.x.x"
@stoyanovgeorge
stoyanovgeorge / graylog_nginx_config
Last active June 29, 2020 08:32
Working Graylog NGINX configuration file
$ cat /etc/nginx/snippets/graylog_self-signed.conf
ssl_certificate /etc/ssl/certs/graylog-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/graylog-selfsigned.key;
####################################################################################
$ cat /etc/nginx/snippets/graylog_ssl-params.conf
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparam.pem;