Skip to content

Instantly share code, notes, and snippets.

View ncode's full-sized avatar

Juliano Martinez ncode

View GitHub Profile
@ncode
ncode / awk_netstat.sh
Created May 14, 2021 14:08 — forked from staaldraad/awk_netstat.sh
AWK to get details from /proc/net/tcp and /proc/net/udp when netstat and lsof are not available
# Gawk version
# Remote
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($3,index($3,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($3,i,2))}{print x":"strtonum("0x"substr($3,index($3,":")+1,4))}'
# Local
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($2,index($2,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($2,i,2))}{print x":"strtonum("0x"substr($2,index($2,":")+1,4))}'
# No Gawk
# Local
grep -v "rem_address" /proc/net/tcp | awk 'function hextodec(str,ret,n,i,k,c){
@ncode
ncode / sshclient.go
Created October 13, 2017 20:11 — forked from josephspurrier/sshclient.go
Golang SSH Client
package main
import (
"bufio"
"io/ioutil"
"os/signal"
//"syscall"
"fmt"
"log"
"os"
// https://gist.github.com/DavidWittman/b7a509632ed92fccf237 (SuperMicro)
package main
import (
"fmt"
"net"
"github.com/vmware/goipmi"
)
@ncode
ncode / ipmi.md
Created May 31, 2017 21:01 — forked from askmeegs/ipmi.md

//Vaquero IPMI stuff

package main

import ( "fmt"

"github.com/vmware/goipmi"

)

@ncode
ncode / resetting-csync2-cluster.md
Created May 12, 2017 12:55 — forked from scottsb/resetting-csync2-cluster.md
Guide to Resetting a csync2 Cluster

Guide to Resetting a csync2 Cluster

Introduction

These are possible steps to reset a csync2 cluster that has been seriously fubared. This is an apocalyptic approach and should only be used when more surgical fixes (like correcting an individual conflict) aren't workable.

Use Cases

package main
import (
"github.com/AllenDang/w32"
"io"
"os"
"unsafe"
"errors"
"fmt"
"syscall"
package httpclient
import (
"net"
"net/http"
"time"
)
type Config struct {
ConnectTimeout time.Duration
@ncode
ncode / sse.go
Created August 20, 2014 12:45 — forked from ismasan/sse.go
package main
import (
"fmt"
"log"
"net/http"
"time"
)
// Example SSE server in Golang.
package main
import (
"net"
"fmt"
"io"
"os"
)
func main() {
@ncode
ncode / proxy.go
Created August 16, 2014 09:23 — forked from vmihailenco/proxy.go
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"