Skip to content

Instantly share code, notes, and snippets.

View 7171u's full-sized avatar

Jijin P 7171u

  • Berlin
  • 10:28 (UTC -12:00)
View GitHub Profile
@7171u
7171u / WSL2-Net-Fix.ps1
Created May 20, 2021 11:02 — forked from danvy/WSL2-Net-Fix.ps1
Reset your WSL network connection trying to fix WSL2 media disconnected error
# Check these threads before proceeding:
# https://github.com/microsoft/WSL/discussions/5857
# https://github.com/microsoft/WSL/issues/5821
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
$CmdLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CmdLine
Exit
}
# Restart the Host Network Service
Restart-Service -Force -Name hns
@7171u
7171u / ListTimeInZone.sh
Last active June 5, 2021 16:48
List Timezones Using Bash
#!/usr/bin/env bash
for tz in Asia/Kolkata US/Eastern Europe/Berlin Asia/Dubai Asia/Singapore Australia/Sydney; do
echo -en "\n$tz "
for i in $(seq -f %02g 0 23); do
echo -n $(TZ=":${tz}" date --date="TZ=\"Asia/Kolkata\" ${i}00" +%H:%M )" "
done
echo ""
done | column -s " " -t 2>/dev/null
@7171u
7171u / iptables_rules.sh
Created December 7, 2016 07:07 — forked from virtualstaticvoid/iptables_rules.sh
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
@7171u
7171u / foldfields.awk
Last active May 24, 2018 06:43
awk Script To Fold Each Field To n Characters Per Line ( works for comma separated files - CSV)
#usage awk -F"," -v fm=n -f foldfields.awk <file.csv> | column -t -s","
#Where n is the fold width
{
maxblk=1;
for (i=1;i<=NF;i++) {
blk=1;
while (length($i)) {
y[i"@"blk]=substr($i,1,fm) ;
blk++;
$i=substr($i,fm-1);
@7171u
7171u / logstash-output-nagios_nsca for Icinga2.markdown
Last active May 12, 2016 11:44
How to configure logstash-output-nagios_nsca for Icinga2

How to configure logstash-output-nagios_nsca for Icinga2

Configure logstash to read yum.log of 'exampleserver' and notify via Icinga2 if any new packages are installed.

Environment

OS: RHEL 7
icinga2 : 2.3.10
Logstash Ver : 2.0

Configure icinga2 passive service

a. vim /etc/icinga2/zones.d/global-templates/templates.conf

template Service "passive-service" {

@7171u
7171u / rrb_redux.sh
Created November 17, 2015 14:38
pnp4nagios last update error (No recent data in graph).
#!/bin/bash
#Author:Anon
#Run against all .rrd files inside /usr/local/pnp4nagios/var/perfdata/
for file in $(find /usr/local/pnp4nagios/var/perfdata/ -name "*.rrd"); do
rrdtool dump "$file" | perl -ne 'BEGIN {$t=`date +%s`; chomp($t);} $a=$_; if ($a =~ /lastupdate.\d+..lastupdate/) { $a =~ s/(lastupdate.)\d+(..lastupdate)/$1$t$2/; } print $a' | rrdtool restore -f - "$file"
done
@7171u
7171u / How deep is your FS
Last active October 13, 2015 13:33
#FunWithLinux #Find #Linux #FileSystem
Today I was just curious which directory holds the deepest file on my Linux PC.
The below command will print the dir with maximum depth.
>find / -type d | awk -F "/" -v slash=0 '{if (NF > slash) { slash=NF; DIR=$0}} END { print DIR":"slash}'
The result I got is 16 as max depth which was a ruby dir.
For a linux kernel below 3.2.0-22.25
yum install kernel-devel automake autoconf gcc glib make ncurses-devel ncurses sysfsutils
yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed xmlto
yum install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel
yum install newt-devel python-devel zlib-devel
Download sysfsutils-2.1.0.tar.gz
tar xvf sysfsutils-2.1.0.tar.gz
cd sysfsutils-2.1.0
Requires a linux kernel higher than 3.2.0-22.25
Server Side:
1. sudo apt-get install linux-source-3.2.0
2. mkdir ~/build
3. tar xvf /usr/src/linux-source-3.2.0.tar.bz2 -C ~/build
4. cd ~/build
5. sudo apt-get install libwrap0-dev gcc libglib2.0-dev libtool automake autoconf pkg-config libsysfs-dev
6. cd drivers/staging/usbip/userspace/
7. ./autogen.sh
@7171u
7171u / Cntlm Authentication Proxy for Docker.txt
Last active April 5, 2019 17:43
Docker Behind Proxy Network with Cntlm on Centos/RHEL
Install and Configure Cntlm:
1. Configure EPEL Repo and install cntlm
yum install cntlm
3. Generate hashes for password-less configuration and add one of the values to /etc/cntlm.conf
cntlm -u <user>@<domain> -H
3. vi /etc/cntlm.conf
Username <Username>
Domain <Domain>
PassNTLMv2 BCB555F5BA8709B8186C2A813C47A4BD # Only for user '<user>', domain '<domain>'
Proxy <ProxyServer>:<Port>