This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function mll { | |
local inputfile search_cmd | |
# If directory, assume sosreport and look for multipath output | |
if [[ -d $1 ]]; then | |
inputfile=$1/sos_commands/devicemapper/multipath_-v4_-ll | |
[[ -r $inputfile ]] || { echo -e "'$inputfile' unreadable\nRun with no args to see usage"; return 2; } | |
elif [[ -f $1 && -r $1 ]]; then | |
inputfile=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 'Loop' command | |
# I use this mostly for when machines are booting up and I don't want to | |
# keep manually trying to ssh over to them | |
function L { | |
local interval | |
if [[ $# -eq 0 || $1 = --help || $1 = -h || $1 = -\? ]]; then | |
echo "Usage: L [-N] COMMAND" | |
echo "Runs COMMAND [waiting N sec between failed attempts] until it succeeds" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Takes the pid of a dd process as an argument and loop-updates the status until it finishes | |
function ddinfo { | |
kill -USR1 $1 | |
while :; do | |
kill -0 $1 && { sleep 1m; kill -USR1 $1; } || { echo "DONE"; break; } | |
done | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Simply prints non-127 ip addresses | |
function myips { | |
echo "$(hostname) IP addrs:" >&2 | |
ip a | awk '/inet / {if ($2 !~ /^127/) print " "$2}' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run with the first argument as the path to the root of an extracted sosreport | |
function Distro { | |
ls -l "$1"/etc/*-release; echo | |
cat "$1"/etc/redhat-release; echo | |
grep --color=no ^serverURL= "$1"/etc/sysconfig/rhn/up2date; echo | |
egrep -i 'fedora|centos|oracle|enterprise|uek|suse|nv[0-9]' "$1"/installed-rpms | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Uses pgrep, ps, and awk to sum the RSS & VSZ of any process names or PIDs passed to it | |
function memsum { | |
if [[ -z $1 ]]; then | |
echo "memsum: requires at least one PID or [partial] process name" | |
return 1 | |
fi | |
local pid p | |
until [[ -z $1 ]]; do | |
if [[ $1 =~ ^[0-9]+$ ]]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Currently, I only have used this on RH/Fedora-based systems, so.... | |
# The way *I* use this: I put the function into /etc/profile.d/reusessh.sh | |
# or something like that, and then call it from each user's ~/.bash_profile | |
# Reuse SSH Agent -- handles a per-user system-wide reusable ssh-agent | |
# This just sets up a function; you still need to call it from ~/.bash_profile | |
# (or simply run on demand, as a replacement for running 'ssh-agent bash') | |
function ssh_agent_systemwide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# (To change mtime instead of atime, switch the -a to -m) | |
atime_change_1month_ago() | |
{ | |
if [[ -e $1 ]]; then | |
month=`date +%m` | |
[ `echo $month|cut -c1` -eq 0 ] && month=`echo $month|cut -c2` | |
month=$((month - 1)) | |
[ `expr length $month` -eq 1 ] && month="0$month" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Start Zenity (might not be installed by default) as a bash coprocess | |
coproc zenity --progress --pulsate --title='Testing' --text='Starting up...' | |
z1=${COPROC[1]} | |
# Update Zenity... | |
sleep 2s | |
echo 33 >&$z1 | |
echo '#One third done...' >&$z1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fcntl.h> | |
#include <sys/un.h> | |
#include <sys/socket.h> | |
#include <sys/stat.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
int main(int argc, char **argv) | |
{ | |
// The following line expects the socket path to be first argument |
OlderNewer