Skip to content

Instantly share code, notes, and snippets.

View ShahriyarR's full-sized avatar

Shahriyar Rzayev ShahriyarR

View GitHub Profile
@ShahriyarR
ShahriyarR / binlog_sync.py
Last active December 22, 2015 00:28
Remote Binary Log backup script
# Binary log backup script
import os
import configparser
import subprocess
import shlex
class BinlogSyncClass:
def __init__(self,conf = 'datadir.conf'):
# Opening config file
@ShahriyarR
ShahriyarR / binlog_to_txt.py
Created August 30, 2013 12:23
Output Binary log content to .txt file for parsing
import os
import subprocess
import shlex
import configparser
class BinlogToTxt:
def __init__(self,conf = 'datadir.conf'):
con = configparser.ConfigParser()
con.read(conf)
@ShahriyarR
ShahriyarR / metadata.py
Last active January 25, 2024 04:32
Script for getting Linux Metadata
import platform
from collections import namedtuple
import glob
import re
import os
class OsInfo():
def get_os_info(self):
## Activating Several Crucial Linux Repos:
## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
## Remi Dependency on CentOS 5 and Red Hat (RHEL) 5 ##
"""
Shahriyar Rzayev, rzayev.sehriyar@gmail.com
Written in Python 3 using shutil.make_archive. (Tested with Python 3.3.5)
Purpose of class to create tar.gz archive files.
General usage is to create crontab, for archiving log files or another .zip files, to one archive file.
After All usage process there will be created zip_archive.tar.gz file.
Compression level: Default
"""
Written in Python 3.
Running JAR file within Python file.
Especially for DWH super boy (after Shahmaddin) Rahim's JAR file (mail sender) :D :D
Using Oracle cx_Oracle library + Python 3's subprocess.Popen
"""
import cx_Oracle
@ShahriyarR
ShahriyarR / grep.txt
Last active August 29, 2015 14:00
GREP usage
1. # Searching for a single whole word in file #
# Note: Case Sensitive search
grep "InnoDB" logfile.log
2014-04-22 15:36:22 1022 [Note] Shutting down plugin 'InnoDB'
2014-04-22 15:36:22 1022 [Note] InnoDB: FTS optimize thread exiting.
2014-04-22 15:36:22 1022 [Note] InnoDB: Starting shutdown...
2014-04-22 15:36:24 1022 [Note] InnoDB: Shutdown completed; log sequence number 1626077
2. # Searching and counting match in file #
@ShahriyarR
ShahriyarR / awk.txt
Last active August 29, 2015 14:00
AWK usage
1. # Sadece Butun logfile-i oxuyur print edir.
awk '{print $0}' logfile.log --- print the entire line.
2. # Her setrden ilk column, field-i cixardir
awk '{print $1}' logfile.log
3. # Ilk olaraq 2ci field daha sonra 1ci field-i cixardir
awk '{print $2,$1}' logfile.log
4. # Regex-den istifade etmekle search
@ShahriyarR
ShahriyarR / sed.txt
Created May 1, 2014 13:56
SED usage
1. # Print first line
sed -n '1p' apa_az_news.sql
2. # Print last line
sed -n '$p' apa_az_news.sql
import mysql.connector
from mysql.connector import Error
try:
cnx = mysql.connector.connect(user='remote2', password='Pass@123#', host='192.168.1.77', database='world')
except Error as err:
print err