Skip to content

Instantly share code, notes, and snippets.

@staaldraad
staaldraad / awk_netstat.sh
Last active July 5, 2024 01:55
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){
@noseka1
noseka1 / How to approve OpenShift operator upgrade using CLI.md
Last active May 16, 2024 10:57
How to approve OpenShift operator upgrade using CLI

Install the operator using the Manual approval strategy, see the attached screenshot.

An install plan has been created but not executed as it has not been approved:

oc get installplan -n openshift-logging
NAME            CSV                                    APPROVAL   APPROVED
install-dq68d   clusterlogging.4.5.0-202007012112.p0   Manual     false
@joseluisq
joseluisq / resize_disk_image.md
Last active July 12, 2024 14:00
How to resize a qcow2 disk image on Linux

How to resize a qcow2 disk image on Linux

This example takes olddisk.qcow2 and resizes it into newdisk.qcow2, extending one of the guest's partitions to fill the extra space.

1. qcow2 format

1.1. Verify the filesystems of olddisk.qcow2

@PabloHiro
PabloHiro / kubectl.md
Last active September 15, 2023 07:32
Kubectl tips and tricks

Troubleshooting

kubectl run -it --rm --image=wbitt/network-multitool network-multitool -- sh

Top of pods in a node

kubectl get pods --all-namespaces -o wide | grep NODE_NAME | awk '{print $1" "$2}' | xargs -n2 kubectl top pods --no-headers --namespace | sort -t ' ' --key 2 --numeric --reverse

List pods resources requests

kubectl get pod -A -o custom-columns="Name:metadata.name,CPU-request:spec.containers[*].resources.requests.cpu,CPU-limit:spec.containers[*].resources.limits.cpu,Memory-request:spec.containers[*].resources.requests.memory,Memory-limits:spec.containers[*].resources.limits.memory"

List per node resources requests and limits

#!/bin/bash
# Drop this script in /usr/local/bin and run it with sudo to install/update to the latest maven. Keeps older versions around just in case.
# Works for me on Ubuntu, YMMV.
set -e
# Make sure we can write to /opt
if [ ! -w "/opt" ]; then
echo "/opt is not writeable. Try using sudo!"