Skip to content

Instantly share code, notes, and snippets.

@orimanabu
orimanabu / rpmadd_rhel6.sh
Created December 1, 2010 16:14
add rpms necessary for a minimum installed RHEL6 system to use ssh and mount.nfs
#!/bin/sh
# this is a script to add some rpms necessary for a minimum installed RHEL6 system to use ssh, mount.nfs and lftp.
# supported distro: RHEL6.0
baseurl=ftp://FTPSERVER/PATH_TO_MOUNTED_ISOIMAGE
arch=x86_64
rpmopts=-ivh
@orimanabu
orimanabu / purr.pl
Created December 1, 2010 22:52
get how much physical CPU resources really used from ppc64 Linux running on LPAR of Power Systems
#!/usr/bin/perl
# calcurate average physical CPU usage from Processor Utilization Resources Register, aka PURR.
# see URL below in detail.
# http://www.ibm.com/developerworks/wikis/display/LinuxP/Entries+in+the+proc+Filesystem
use strict;
use warnings;
$| = 1;
@orimanabu
orimanabu / yum_groupinfo_all.sh
Created December 3, 2010 10:52
yum muzui...
#!/bin/sh
x=0
for group in `yum --enablerepo=rhel60 grouplist -v | grep '^ ' | sed -e 's/.*(\(.*\))/\1/' | sort`; do
echo "===> ($x) ${group}"
yum --enablerepo=rhel60 groupinfo ${group}
((x = x + 1))
done
@orimanabu
orimanabu / tail-f.pl
Created December 4, 2010 21:33
"tail -f" in perl
#!/usr/local/bin/perl
use strict;
use warnings;
open FILE, $ARGV[0] or die;
my $curpos;
for (;;) {
for ($curpos = tell(FILE); $_ = <FILE>; $curpos = tell(FILE)) {
print;
@orimanabu
orimanabu / tail-f.rb
Created December 4, 2010 21:34
"tail -f" in ruby
#!/usr/local/bin/ruby
f = open(ARGV[0])
while true
if (line = f.gets)
puts line
else
sleep 1
end
end
@orimanabu
orimanabu / tail-f.py
Created December 4, 2010 21:34
"tail -f" in python
#!/usr/local/bin/python
import sys
import time
file = open(sys.argv[1])
while True:
where = file.tell()
line = file.readline()
if not line:
@orimanabu
orimanabu / scsi_pr.sh
Created May 10, 2011 09:55
Send SCSI-3 Persistent Reserve/Release command using sg_persist
#!/bin/sh
# Send SCSI-3 Persistent Reserve/Release command using sg_persist
# Inspired by http://www.redhat.com/archives/cluster-devel/2006-June/msg00084.html
# eg1. send SCSI Persistent Reserve to /dev/sde,
# where type of PROUT is "exclusive access - registrants only"
# $ sudo ./scsi_pr.sh reserve /dev/sde 6
# eg2. send SCSI Persistent Release to /dev/sde,
# where type of PROUT is "exclusive access - registrants only"
@orimanabu
orimanabu / gist:2962513
Created June 20, 2012 22:06
MegaCli -help
MegaCLI SAS RAID Management Tool Ver 8.04.07 May 28, 2012
(c)Copyright 2011, LSI Corporation, All Rights Reserved.
NOTE: The following options may be given at the end of any command below:
[-Silent] [-AppLogFile filename] [-NoLog] [-page[N]]
@orimanabu
orimanabu / local_sync.sh
Created August 7, 2012 08:27
postgres repo sync script among mainline and local and personal github
#!/bin/sh
current_branch=$(git branch | grep '^\*' | sed -e 's/^\* //')
echo "==> checking current branch: ${current_branch}"
if [ x"${current_branch}" != x"master" ]; then
echo "current branch is not 'master'."
echo "===> checking out master..."
git checkout master
if [ x"$?" != x"0" ]; then
@orimanabu
orimanabu / rhn_get_kernel_errata.py
Created September 6, 2012 09:15
Obtain kernel related errata for RHEL6 from RHN
#!/usr/bin/env python
# Obtain kernel related errata for RHEL6 from RHN.
# This depends on rhnapi (https://github.com/lanky/python-rhnapi).
import sys
import re
import rhnapi
from pprint import pprint
from rhnapi import channel