Operating System - HP-UX
1848319 Members
6727 Online
104024 Solutions
New Discussion

Re: favorite sysadmin scripts you always keep around (3)

 
SOLVED
Go to solution
Bill McNAMARA_1
Honored Contributor

favorite sysadmin scripts you always keep around (3)

As the previous thread was getting quite large, I've decided to start a new thread:

favorite sysadmin scripts you always keep around (2)

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

favourite sysadmin scripts you always keep around (1)

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

PLEASE attach scripts as a txt file to facilitate cut and paste.

TOP POINTS for tried tested and improved and corrected scripts! (ie use at your own risk!)

Later,
Bill
It works for me (tm)
116 REPLIES 116
Geoff Wild
Honored Contributor
Solution

Re: favorite sysadmin scripts you always keep around (3)

Not really an individual script - but a tool nonetheless. For anyone running a MC/SG cluster, this is a valuable tool to monitor your environment to ensure all nodes are configured equally.

http://h40045.www4.hp.com/data/ccmon-service-brief.pdf

There is a small cost - usually just 1 or 2 "technical service days" from your support contract.

Note: This doesn't have to be just for MC/SG - any application where you need to monitor similiar configurations across multiple machines will work as well (IE SAP App Servers).

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Procnus
Frequent Advisor

Re: favorite sysadmin scripts you always keep around (3)

Here's a short perl script I use to find out who is logged in more than once. It's output is a little nicer than sorting and uniq'ing a who

Steven
Ramkumar Devanathan
Honored Contributor

Re: favorite sysadmin scripts you always keep around (3)

Five tips - not scripts - for configuring apache.

((teaser below))

1. AcceptMutex
2. Use 2.0 and threading (worker MPM)
3. SSL session cache
4. KeepAliveTimeout
5. Using mod_status

And the link is this -
http://builder.com.com/article.jhtml?id=u00320020423ere01.htm&page=1&vf=fb

HTH.

- ramd.
HPE Software Rocks!
Stefan Farrelly
Honored Contributor

Re: favorite sysadmin scripts you always keep around (3)


Script to loop every second showing how many bytes are coming in to your default lancard. Easily changed to show outbound also. Very handy to see how much traffic is going in and out.

#!/bin/ksh
function lanad
{
lanadmin</tmp/t 2>&1
lan
display

quit
EOF
cat /tmp/t|grep Inbound|grep Oct|awk '{print $4}'
}
echo "Inbound Bytes per second on default lan interface"
let z=0
while true
do
sleep 1
let x=$(lanad)
let t=$x-$z
echo $t
let z=$x
done
Im from Palmerston North, New Zealand, but somehow ended up in London...
Doug Burton
Respected Contributor

Re: favorite sysadmin scripts you always keep around (3)

Two things for your .kshrc file.

Cleanup your ps|grep search.
Usage: seek something

alias seek='ps -ef|grep -v grep|grep -v "ps -ef"|grep -i '

Add the server name and current directory your in
to the top of an xterm or dtterm window. NOTE: Changes
the "cd" command.

####################################
# Set window and icon titles
####################################

# put text on the X-window title bar

setTitle()
{
hn="$1"
if [ "$TERM" = "hp" -o "$TERM" = "hpterm" ]
then
echo "^[&f0k${#hn}D$hn^M\c"
elif [ "$TERM" = "xterm" -o "$TERM" = "vt100" ]
then
echo "\033]2;$hn\007\c"
elif [ "$TERM" = "dtterm" -o "$TERM" = "vt220" ]
then
echo "\033]2;$hn\007\c"
fi
}
typeset -fx setTitle

# Lets set an alias

_cd()
{
'cd' ${1:-$HOME} ${2:-}
setTitle "`hostname`:`pwd`" 1>&2
}

alias -x cd="_cd"
_cd .
Doug Burton
Respected Contributor

Re: favorite sysadmin scripts you always keep around (3)

I don't remember why but I needed a big test file. I then got a bit carried away and made this....
Doug Burton
Respected Contributor

Re: favorite sysadmin scripts you always keep around (3)

This is another file system size checking script using bdf.

File system is >= 90% - email root.
File system is > 95% - page somebody.

It will work when lvol names are large and running bdf drops the "kbytes used" etc data to the next line.

Sajith V Mannadiar
Frequent Advisor

Re: favorite sysadmin scripts you always keep around (3)

Attached are some useful scripts,

bigfile -> To find large files in a filesystem
For eg, bigfile /var 10\*1024\*1024
will list all files of size greater than 10MB

Regards,
Sajith
Sajith V Mannadiar
Frequent Advisor

Re: favorite sysadmin scripts you always keep around (3)

Attached script (bigdir) will list you all large folders in a filesystem

for eg., bigdir /var 100\*1024\*1024

will list all folders larger than 100MB in /var


Regards,
Sajith
John Meissner
Esteemed Contributor

Re: favorite sysadmin scripts you always keep around (3)

Here is a script that will let you open a terminal window on someone's workstation and post a messgage to it. I've found this to be useful at times.
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: favorite sysadmin scripts you always keep around (3)

This script can be used as a splash screen at the beginning of a script. It contains 2 files. the script and a wxd image file. I won't go into how to create the image file but I'm tar/gzip'ing the script and an image file (as an example)
All paths lead to destiny
Sajith V Mannadiar
Frequent Advisor

Re: favorite sysadmin scripts you always keep around (3)

Here is a very handy script to create all the mount points required for the filesystems listed in fstab...

The script -> create_mnts
-----------

#!/bin/ksh
cd /
echo "Creating the required mount points..."
cat /etc/checklist |grep -v "^#"|awk '{print $2}'| while read dir_name
do
if [ ! -d ${dir_name:="/etc"} ]
then
umask 022;mkdir -p $dir_name
echo "Directory $dir_name created..."
fi
done
echo "Creating the required symbolic links..."
cat /etc/checklist |grep "symbolic link" | while read link_entry
do
sdir=`echo $link_entry|cut -d" " -f2`
ddir=`echo $link_entry|cut -d" " -f3`
ddir1=`dirname $ddir`
ddir2=`basename $ddir`
umask_val=`echo $link_entry|cut -d" " -f8`
umask $umask_val
mkdir -p $ddir1
cd $ddir1
ln -s $sdir $ddir2
echo "Created link $ddir -> $sdir "
umask 022
done

---------------------------------------

Sample fstab attached
--------------------


In our lab, at times, the systtem load increases due to some runaway processes...

Here is a one-liner to catch hold of them.. I call it 'runproc'

#!/bin/ksh

ps -elf|grep " R "|grep -v -E 'grep|ps'


-----------------
John Meissner
Esteemed Contributor

Re: favorite sysadmin scripts you always keep around (3)

this script will report the number of CPS's and their speeds.
All paths lead to destiny
Dave La Mar
Honored Contributor

Re: favorite sysadmin scripts you always keep around (3)

Attached is a script written because we got tired of mailing out files for the HP CE Tech.
When invoked, the CE can attach a number of files and send to a number of email addresses.
The call to MOTD has a privacy message for our protection, so you can be calling your own or comment this out.
The $MAILX_FILE is an executable that simply performs the mailx command and send out the attachments.

Have fun.

dl
"I'm not dumb. I just have a command of thoroughly useless information."
Charles Harris
Super Advisor

Re: favorite sysadmin scripts you always keep around (3)

Hi, here's my totaly pointless script to add that Matrix feel to anything you like:-

#!/usr/bin/sh
# scroll
# Don't ask.

typeset -i x=0
strg_len=`echo "$*" | wc -m`
#clear

delay ()
{
base=0
time=$1
while (( time > base ))
do
(( time = time - 1 ))
delays[x]="Delay?"
done
unset delays[*]
}

while (( x < $strg_len )) && (( $strg_len < 1024 ))
do
(( x = x + 1 ))
scroll[x]=`echo "$*" |cut -c $x`
[ ${scroll[x]} ] 2> /dev/null && {
print "${scroll[x]}\c"
delay 2000
} || {
print "${scroll[x]}\c"
delay 5000
}
done
tput cud1

Good for a laugh!

-ChaZ-


Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around (3)

Its been a while since I contribued here.

I have a few more.

check_rootlogin

It reports on bad root login attempts. I use it in cron. It can be set to auto disable the id, but I didn't think that was a very good idea.

SEP

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 (3)

dailydisk.sh

Provides sysadmin with a list of new large files created in size order.

This is a production script.

BTW, I did check my back posts for dups.

SEP

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
John Meissner
Esteemed Contributor

Re: favorite sysadmin scripts you always keep around (3)

I just finished, and tested successfully, this script. I've been using make_sys_image for a while writting to tape. I wanted to write create an ISO image instead. This script will create a bootable DVD image that you can use a DVD burner to write the image with. You will need CDRW software installed on your HP-UX machine (it's usually installed here:

/opt/OpenSource/xcdroast-0.98

You may need to edit some of the paths in the script for your own use - but on my system it works very well.
All paths lead to destiny
Karthik S S
Honored Contributor

Re: favorite sysadmin scripts you always keep around (3)

Lots of great scripts are available at,

( Unix Power Tools, 2nd Edition: Examples )

ftp://ftp.oreilly.com/published/oreilly/power_tools/unix/upt9707.tgz

Regards,
Karthik
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Jim Gerken
Occasional Advisor

Re: favorite sysadmin scripts you always keep around (3)

Hey you guys are right on it...

I have the following script which seems to give me what I need.

echo "PID USER CPU% MEM_SIZE COMMAND"
while true
do
UNIX95= ps -eo "pid ruser pcpu vsz=Kbytes" -o comm | grep oracleT5751
sleep 1
done

It returns something like this...

8532 ormesa 0.02 32832 oracleT5751
536 ormesa 0.02 32832 oracleT5751
524 ormesa 0.02 32832 oracleT5751
22005 ormesa 0.02 32832 oracleT5751
8536 ormesa 0.02 40128 oracleT5751

I need to graph this in excel to show the memory / cpu consumed by each pid. I'm a little confused on how to setup the graph? any ideas...
H.Merijn Brand (procura
Honored Contributor

Re: favorite sysadmin scripts you always keep around (3)

perl/Tk

several examples can be found in the graph scripts included in the Statistics on https://www.beepz.com/personal/merijn/#Statistics or http://www.cmve.net/~merijn/#Statistics

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Chris Vail
Honored Contributor

Re: favorite sysadmin scripts you always keep around (3)

The attached script answers the simplest, fundamental question that we syadmins have to deal with: are all systems up and running?

It uses secure shell to ll the /etc/hosts directory on each remote system. If the directory listing is successful, it assumes that the system is up and running. If not, it advises to "Update your resume'". It emails the results. We run this every day at 8 AM, so that we have no surprises at the 9 AM meeting.



Chris
Fragon
Trusted Contributor

Re: favorite sysadmin scripts you always keep around (3)

Hi,all
Here is my backup script,which is invoked by cron every night.
She will check the tape first, if type is not ready, she send a mail to a certain mailbox. When this mailbox receive this special mail, it will send a message to the adminiatrator by mobile phone.
After backup, it will truncate some log files of the DB, and make a total report and send it to the administrator.

This keep the backup always done correctly!!!

-ux
Jack C. Mahaffey
Super Advisor

Re: favorite sysadmin scripts you always keep around (3)

Looks like I didn't read the last post in the last post so I'm reposting in this thread.


There's been numerous times I've wanted to know which corresponding chmod command was needed to securing files and directories. Here's a script that I've created awhile back that others may want to have. Very useful for determining the chmod integer combinations. It lists the 4 digit code, security string, object type, owner:group, and filename. It has saved my rear-end multiple times and I call it from other scripts for when I may need to reset the security properties for a file or directory.

Here's an example of running the script...
# getchmod /etc/inetd.conf
0644 -rw-r--r-- file root:sys /etc/inetd.conf

And yes, it will use wildcards...

I've named the script getchmod....

jack...