Operating System - HP-UX
1833473 Members
3416 Online
110052 Solutions
New Discussion

favourite sysadmin scripts you always keep around....

 
SOLVED
Go to solution
S.K. Chan
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

Script that I wrote to check LVM and device file status. See script for usage.
Pete Randall
Outstanding Contributor

Re: favourite sysadmin scripts you always keep around....

While not necessarily applicable to everyone, we find the attached script to move programs from development to production invaluable. We call it the Program Migration System, or PMS for short - politically incorrect for sure.

Pete

Pete
Nick Wickens
Respected Contributor

Re: favourite sysadmin scripts you always keep around....

I have the attached script running at least once a day just to check if anything (particularly hardware) has changed or failed on the system since the previous run of the script just as a backup to other syslog checks.
Hats ? We don't need no stinkin' hats !!
Yogeeraj_1
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

Hello,

nice initiative BILL ;)

Maybe this forum could have a section dedicated this topic.

My contribution is the RDA(Remote Diagnostic Agent) which helps people running Oracle People should use to document their systems each time they do a change.

Poeple having access to Metalink will get the latest version from here: http://metalink.oracle.com/cgi-bin/cr/getfile_cr.cgi?281592

otherwise the current version is attached.

Cheers
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
John Carr_2
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

Hi Bill

here is my bdf in MB , not as goos as yours but I needed a simple script quickly.

John.
Gnananandhan
Frequent Advisor

Re: favourite sysadmin scripts you always keep around....

Hi,
This script will help in taking oracle database backup using tar utility.

Regards,
Gnana A.
If there is a better way to do it, find it !
Yogeeraj_1
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

Hello,

Another useful script that allows me to export my Oracle database and at the same time compress it. Saving precious diskspace.

---------------------------------------------
#!/bin/csh -vx

setenv UID /
setenv FN exp.`date +%j_%Y`.dmp
setenv PIPE /tmp/exp_tmp_ora8i.dmp

setenv MAXSIZE 500m
setenv EXPORT_WHAT "full=y COMPRESS=n"

echo $FN

cd /nfs/atc-netapp1/expbkup_ora8i
ls -l

rm expbkup.log export.test exp.*.dmp* $PIPE
mknod $PIPE p

date > expbkup.log
( gzip < $PIPE ) | split -b $MAXSIZE - $FN. &

# uncomment this to just SPLIT the file, not compress and split
#split -b $MAXSIZE $PIPE $FN. &

exp userid=$UID buffer=20000000 file=$PIPE $EXPORT_WHAT >>&
expbkup.log
date >> expbkup.log


date > export.test
cat `echo $FN.* | sort` | gunzip > $PIPE &

# uncomment this to just SPLIT the file, not compress and split
#cat `echo $FN.* | sort` > $PIPE &

imp userid=sys/o8isgr8 file=$PIPE show=y full=y >>& export.test
date >> export.test

tail expbkup.log
tail export.test

ls -l
rm -f $PIPE
-----------------------------------------------

This also always does an 'integrity' check of the export right after it is done with an import show=y, that shows how to use these split files with import.
----------------------------------------------

!!!
cat `echo $FN.* | sort` | gunzip > $PIPE &


sorts the filenames, sends them to cat, which give them to gunzip in the right order.

Hope this will 1000's of you people

Best Regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Bill McNAMARA_1
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

Thanks all,
Good scripts, and keep them coming!

Later,
Bill
It works for me (tm)
Yogeeraj_1
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

hi,

This script DBAs will love it! ;)

I still don't recall where i borrowed it however.

Email Notification whenever an error (ORA type) occurs in the database.

Hope someone appreciate it as we do it here!

NB. please do the appropriate modifications before executing it.

cheers
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
noBADy
Occasional Contributor

Re: favourite sysadmin scripts you always keep around....

Hi,

I would like to contribute with this small script, which I use to rename VG.
Be careful, because we have a little bit different convention for naming VG and LV as usually used. No problem, script is easy customized...

#!/sbin/sh
export VG_OLD=$1 #Number of an old VG
export VG_NEW=$2 #Number of a new VG
vgchange -a n vg${VG_OLD}
vgexport -s -m /tmp/vg${VG_OLD}.map vg${VG_OLD}
mkdir /dev/vg${VG_NEW}
mknod /dev/vg${VG_NEW}/group c 64 "0x"${VG_NEW}"0000"
awk -v VG_NEW="${VG_NEW}" '{if ($2 ~ /^lv/) {print $1 " lv" VG_NEW} else {print $0}}' /tmp/vg${VG_OLD}.map > /tmp/vg${VG_OLD}_.map
vgimport -s -m /tmp/vg${VG_OLD}_.map vg${VG_NEW}
vgchange -a y vg${VG_NEW}

Have a nice time,
Brano.
Ceesjan van Hattum
Esteemed Contributor

Re: favourite sysadmin scripts you always keep around....

statusinformation to html.
This script collects specific system information; the smileys not attached.

I use it to see in one glimps of an eye to check the status of the disks, system messages, specific processes, mail etc.

The script is straightforward.
Holger Knoppik
Valued Contributor

Re: favourite sysadmin scripts you always keep around....

Hi,

running this script once a month, i can get a quick overview of my machines.
I hope the format of this attachment is ok ...
If not, sorry !
Hey, where is Robin Wakefield ??? I got the STM stuff from him.

RGDS, Holger
Live long and prosper!
Stefan Farrelly
Honored Contributor

Re: favourite sysadmin scripts you always keep around....


serialnumber.sh

echo "sel path system\ninfolog\nexit"|cstm|grep "System Serial Number"


Im from Palmerston North, New Zealand, but somehow ended up in London...
Yogeeraj_1
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

Hello,

this one i use it quite often to locate my "memory hungry" sessions most of the time "zombies"...

psram.sh

regards
Yogeeraj

PS. Source from HP Forum ;)
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Justo Exposito
Esteemed Contributor

Re: favourite sysadmin scripts you always keep around....

Hi,

Based in an Stefan Farrelly Original Idea (http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xa482107d277ad611abdb0090277a778c,00.html), this script change the permits to the original, for all the products an O.S. installed.

Regards,

Justo.
Help is a Beatiful word
Holger Knoppik
Valued Contributor

Re: favourite sysadmin scripts you always keep around....

Wow,

great stuff on this page ...
Attached you will find a little modification of the smbstatus command in combination with cmviewcl and ssh ...

RGDS, Holger
Live long and prosper!
Cheryl Griffin
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

I got this one years ago which will send a page if bdf reaches a threshold:

Cron entry:
08 * * * * /cag/thresh /filesystem_here 75 2>&1


# cat thresh
#!/usr/bin/ksh
#bdf paging script to page when threshold is reached
# $1 = Filesystem
# $2 = Threshold

CAPTHRESH=$2
bdf -i $1 | grep -v "^Filesystem" | paste - - | read FS V W X CAP Y Z IN
OD MP
if [[ ${CAP%\%*} -gt $CAPTHRESH ]]
then
echo "WARNING Filesystem $1 reach ${CAP%\%*}"%" Filesystem is almost Full"
/usr/bin/mailx -s "Filesystem Alert" cag@youremail.com
fi

Cheryl
"Downtime is a Crime."
Cheryl Griffin
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

I saw Stefan's serial number post and wanted to add:
Starting at 11.11 some machines (Superdome, rp8400 and rp7410) will return serial number with:
# getconf CS_MACHINE_SERIAL

From C, use
confstr(_CS_MACHINE_SERIAL).


Memory configuration:
# echo "selclass qualifier memory;info;wait;infolog"|cstm > /tmp/meminfo

Processor information:
# echo "selclass qualifier cpu;info;wait;infolog"|cstm > /tmp/procinfo

What disk and/or kernel you booted from:
# echo 'boot_string/S'|adb /stand/vmunix /dev/mem
"Downtime is a Crime."
H.Merijn Brand (procura
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

And the serial command line (how useful!) does not work on 10.20

just FYI

N/A
Enjoy, Have FUN! H.Merijn
Holger Knoppik
Valued Contributor

Re: favourite sysadmin scripts you always keep around....

Hi again Bill,

cannot get enough of this script collection and want to add something from our HA CIFS stuff ...

NOTE: Every samba documentation i've read says, the daemons automatically re-read their configuration, but i didn't see any changes from testparm after manipulating the conf file ...
So i wrote this little script sending a HANGUP to specific samba procs. The script also considers the different Fileservers ...

-----------------------------------------------
#!/bin/sh
#
#set -x

PATH=$PATH:/opt/samba/bin

usage () {
echo "USAGE: $0 | "
}

if [ "$#" != 1 ]
then
echo "ERROR in handling"
usage
exit 1
fi

case $1 in
Fileserver1) NETBIOS=fs_1
;;
Fileserver2) NETBIOS=fs_2
;;
*) echo "ERROR: $1 is an unknown instance!"
usage
exit 2
;;
esac

echo "NOTE: Sending HANGUP to all samba procs belonging to $1"
ps -ef | grep mb | grep ${NETBIOS} | grep -v grep | awk '{print $2}' | while read samba_proc;do
echo "RELOADING ${samba_proc}"
kill -1 ${samba_proc}
done
-----------------------------------------------

Hope it will be useful !

RGDS, Holger
Live long and prosper!
Thomas D. Harrison
Frequent Advisor

Re: favourite sysadmin scripts you always keep around....

chk.expired.passwd.sh
Used Regularly on 11.0

This script generates a report with seven sections for accounts that are not allowed to login to the system and emails it to the sys admin.

The seven reasons are:

1) Expired Passwords
2) Inactive Accounts
3) Past Absolute Account Lifetime
4) Excessive Invalid Login Attempts
5) Password Required but Using a Null Password
6) Administrative Lock
7) Password is "*"

The script does use the /usr/lbin/getprpw command which is NOT supported by HP. These are used by SAM.

Review the script before using. It assumes that the Working Directory is /sysadm/util/
Imbibo ergo sum.
Thomas D. Harrison
Frequent Advisor

Re: favourite sysadmin scripts you always keep around....

vicp
Used regularly on 11.0

# vi and copy command
#
# This command copies the file you are about to edit
# if this is the first time it is being edited on
# the current date. If you use it multiple times
# you will still have a copy of the days original
# version. The backup file name is in the original
# directory with the date (yymmdd format) appended
# to the end.
#
# Syntax: vicp
# Examples: vicp hosts
# vicp /etc/hosts
#
# Results in a backup file called hosts.010602 if
# this were run on 06.02.2001

It also used vipw for /etc/passwd and runs a grpck for /etc/group
Imbibo ergo sum.
Thomas D. Harrison
Frequent Advisor

Re: favourite sysadmin scripts you always keep around....

getmac
Used regularly on 11.0

# Script Description
# This script is used to determine the MAC address of a system. It only works for
# systems on the same subnet ( ie. 10.40.**.** )

It's simple enough. It simply uses ping, arp, and cut to get the info.
Imbibo ergo sum.
Thomas D. Harrison
Frequent Advisor

Re: favourite sysadmin scripts you always keep around....

killname
Used regularly on 11.0

This script greps "ps -ef" for up to 3 strings.
If ONLY one job meets the criteria it prompts you with a (y/n) to kill it.
If you replied "y" it does a "kill PID", sleeps 3 seconds, and then checks to see if the job has ended.

e.g. killname run-amuck


Imbibo ergo sum.
Bill Hassell
Honored Contributor

Re: favourite sysadmin scripts you always keep around....

Just a note about Thomas's kill-by-name script. A little-known feature in ps (called XPG4 behavior) will improve the reliability of this type of script immeasureably.

Typical:
ps -ef | grep something | grep -v grep

Easy and super reliable:
UNIX95= ps -f -C something

By setting (temporarily) UNIX95, the ps command inherits a bunch of new options such as -C -H and -o. -C does the grep for you but never looks at the entire line. Instead, -C finds the exact name of the process. Thus, -C sh will not find ksh but will find sh and -sh.

Try these two examples:

ps -ef | grep sh | grep -v grep
UNIX95= ps -f -C sh


Bill Hassell, sysadmin