Operating System - HP-UX
1833004 Members
2904 Online
110048 Solutions
New Discussion

Re: favorite sysadmin scripts you always keep around [2]

 
SOLVED
Go to solution
Bill McNAMARA_1
Honored Contributor

favorite sysadmin scripts you always keep around [2]

This is the continuation of

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x026250011d20d6118ff40090279cd0f9,00.html

favourite spelt incorrectly for American search engines! ;)

PS: when attaching scripts, rather than pasting them into the reply box, attach them as .txts. This helps both formatting problems and lots of scrolling ctrl c, ctrl v s..

TESTED SCRIPTS ONLY PLEASE!

If you find any scripts buggy, please feel free to post an improved version!

That's what the forum is about right! - sharing experiences, helping each other out! right?

Hope the scripts help!

attached is my remote system watch script that xwds and xwuds - I find it useful for remotly watching a windows display - or x display - screenhots logged into a unix box with relaxed xhost permissions. I used it for remote training where sharedX/ HPVC suffered due to network lag.

Later,
Bill
It works for me (tm)
141 REPLIES 141
Michael Campbell
Trusted Contributor
Solution

Re: favorite sysadmin scripts you always keep around [2]

Sorry, 2nd time lucky!!!

Simple but very handy, sorts directories and files by size (blocks)

MC
John Poff
Honored Contributor

Re: favorite sysadmin scripts you always keep around [2]

Hi,

Here is a script that I use on one of our Oracle development systems. We keep the developers home directories in the /home/oradev tree, and every so often one of them will decide to copy a huge file into their home directory which fills up /home. I wrote this script to e-mail me a list of the top 10 disk hogs in the /home/oradev tree, which I then e-mail to all the developers. When /home fills and some developers can't do any work, they get this e-mail and they can ask the person in the next cubicle why the are hogging all the disk space. Peer pressure works much better for making them clean up after themselves than having me bug them individually! The script will also check each of the large files in the report to see if any processes are holding it open. I got tired of them deleting large files that someone else had open and not getting the space back.

JP
Tim D Fulford
Honored Contributor

Re: favorite sysadmin scripts you always keep around [2]

OK

netstat -na | grep -i close
If the above returns anything you may need the following script. It saves a reboot if you have sockest in cloae_wait state & have run out....

#!/usr/bin/ksh
#
# Author Tim Fulford
# Date 22 Jan 2001
# Purpose Kills CLOSE_WAIT sockets using ndd

close_wait_ip_collect ()
{
netstat -na | grep CLOSE | cut -c20-65 > /tmp/close_wait_ip_collect.out
}

close_wait_ip_convert_to_hex ()
{
cat /tmp/close_wait_ip_collect.out | while read TRGT SRCE
do
echo ${TRGT}.${SRCE} | awk -F"." '{printf "%02x%02x%02x%02x%04x%02x%02x%02x%02x%04x\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10}'
done
}
close_wait_remove_socket ()
{
cat /tmp/close_wait_ip_convert_to_hex.out | while read SOCKET
do
echo "Clearing socket HEX address : ${SOCKET}"
echo "ndd -set /dev/tcp tcp_discon_by_addr ${SOCKET}"
done
}
close_wait_clear_up ()
{
rm /tmp/close_wait_ip_convert_to_hex.out /tmp/close_wait_ip_collect.out
echo "Finished...."
}


close_wait_ip_collect
close_wait_ip_convert_to_hex > /tmp/close_wait_ip_convert_to_hex.out
close_wait_remove_socket
close_wait_clear_up
-
Bill McNAMARA_1
Honored Contributor

Re: favorite sysadmin scripts you always keep around [2]

5 points when not attached in attachment!
It works for me (tm)
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

Here is a tested script that has clued me in to hardware problems and let me get drives replaced prior to failure.

checkhardware.sh

#!/bin/sh
#
# checkwardare.sh Created 2/13/2001
# Steven E. Protter
#
# Designed to check for hardware lbolts and send out an alert email
#
/usr/sbin/dmesg | grep lbolt > /tmp/checkwardware
errs=`wc -l /tmp/checkwardware | awk {'print $1'}`
if [ $errs -ne 0 ]
then
# echo "Errors ${errs}"
/usr/sbin/dmesg > /tmp/checkwardware
/usr/sbin/dmesg | mailx -s "Hardware error detected /tmp/checkhardware" email@you.com
/usr/sbin/dmesg | mailx -s "Hardware error detected /tmp/checkhardware" yourboss@you.com
/usr/sbin/dmesg | mailx -s "Hardware error detected /tmp/checkhardware" yourboss'sboss@you.com
/usr/sbin/dmesg | mailx -s "Hardware error detected /tmp/checkhardware" root
/usr/bin/np -qQhp5000 /tmp/checkwardware
fi


A definite winner. The np commands assume installation of openspool which I recommend you not do. Its a legacy product with us.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ken Hubnik_2
Honored Contributor

Re: favorite sysadmin scripts you always keep around [2]

Command to show top ten CPU users on the system
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

A script to quickly build a depot out of a bunch of patches you need to install together. Particularly useful when check_security_patch recommends 6 kernel patches all requiring a reboot.

Out of the HP Certification Study Guide.

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

gkill

Kill a process or series of processes based on a command line parameter. Very powerful and useful.

I use it all the time, read it before you use it. I built in some basic protection to not let you to a process kill for strings like root and stuff, but its far from bullet proof.

This is a mod from some book.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

Another book script.

psg

its a modifived ps -ef | grep that makes sure the grep among other things doesn't show up.

psg oracle shows all processes with the string oracle

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Balaji N
Honored Contributor

Re: favorite sysadmin scripts you always keep around [2]

Hi.

I use this to search for files. Idea is borrowed from locate of linux.

Setup a cron job to create a datbase containing list of files on the system.

find / -print > /tmp/locate.db

Run the attached script as

locate filenmae[s].

Pretty useful.

hth
-balajio
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Tony Contratto
Respected Contributor

Re: favorite sysadmin scripts you always keep around [2]

Get the date when an ignite tape was created.

--
Tony
got root?
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

Yeah!

I finally earned some points.

This is the best thread I've seen.

I went through the old one and collected 40 scripts. They need some mod, but still a gold mine.

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

Delete an Oracle User. I will upload the component called as well in another post.

This is part of a three function, six script system.

One for Deleting Oracle Users.
One for Adding Oracle Users.
One for Resetting their password when they forget.

This is a pre-ldap situation. When we do LDAP, this all changes.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
fg_1
Trusted Contributor

Re: favorite sysadmin scripts you always keep around [2]

Hello all

This script is used for collecting various
areas of information from sar. The script
utilizes data collected from the SA files
located in: /var/adm/sa/sa##.

cron entry is below which will write an entry
in the file every hr on the hr.

0 * * * * /usr/lbin/sa/sa1 3600 1 &

Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

userdel.ksh

He is called by the prior script. I'd zip them but am lazy today. Since its a set, feel free to do just 5 points per script.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
fg_1
Trusted Contributor

Re: favorite sysadmin scripts you always keep around [2]

Here is a script for all of you that are
using veritas netbackup as your backup
architecture. This script will compile a
report of all backup jobs executed for the
preceding 24hr period and report them in
html format. The html is very basic so feel
free to pretty it up some.
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

Add an Oracle User

This time, I took the time to make a tar file.

AddOracleUser is the main script
useradd.ksh (even though its probably using the posix shell, my dba is a little loose about checking this), is called.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

Reset Oracle Users passwords when the lock their accounts.

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

This one is the oracle environment setting program included in all of the above scripts.

This script sets the default oracle environoment based on the first entry in the /etc/oratab file

This building block should have been first.

If I missed something, let me know, I'll post it up.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
steven Burgess_2
Honored Contributor

Re: favorite sysadmin scripts you always keep around [2]

Hi

Script to get lancard ID, state and speed

Steve
take your time and think things through
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around [2]

Improved Megabytes bdf program.

I just added a display variable to allow commands like bdf /sag to work.

A minor improvement.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Carlos Ruffin
Advisor

Re: favorite sysadmin scripts you always keep around [2]

Script to show bdf in megabytes: I know there is already one but here's another.
Kim Kendall
Regular Advisor

Re: favorite sysadmin scripts you always keep around [2]


A real nice disk space monitor. There's a test section near the bottom so you can see what it does. Enjoy!
Richard Darling
Trusted Contributor

Re: favorite sysadmin scripts you always keep around [2]

Here are a couple of small ones I use:

"b" makes the backspace key functional if it isn't working in a shell.
"lsd" list only the subdirectories in a directory.
"mtcd" and "umtcd" mount and unmount my cd drive.

RD