- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- favourite sysadmin scripts you always keep around....
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2002 11:33 AM
02-15-2002 11:33 AM
Re: favourite sysadmin scripts you always keep around....
-Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2002 11:41 AM
02-15-2002 11:41 AM
Re: favourite sysadmin scripts you always keep around....
The format of the text schedule file is:
MMDDYY:TAPENAME
It's been great when I've been out of the office. The other admins are automatically reminded to change the tape.
Thanks.
-Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2002 12:03 PM
02-15-2002 12:03 PM
Re: favourite sysadmin scripts you always keep around....
I am trying to know what disks are used by LVM.
No check for lvmtab done. I think it is usefull for large disks environments.
********
mkdir /tmp/carlos/mapas
for i in /dev/*/group
do
vg=`dirname $i`
vgmap=`basename $vg`
echo $i $vg $vgmap
vgexport -s -m /tmp/carlos/mapas/${vgmap} -p $vg
done
for dsk in /dev/rdsk/*
do
echo $dsk "\c"
dd if=$dsk bs=1024 skip=8 count=9 | dd bs=8 skip=2 count=1 | od -x
done > vgids_alldisks
awk ' $1 ~ "/dev/rdsk" { print $3 $4 $5 $6, $1 }' vgids_alldisks | sort >vgids_bydisk
grep VGID mapas/* | sed -e "s#mapas/##" -e "s/:VGID//" | sort +1.0 > vgids_byvg
join -j1 2 -j2 1 -a 1 -a 2 -e "------" -o 2.2 2.1 1.1 vgids_byvg vgids_bydisk > vgids.lst
*****
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2002 08:07 PM
02-15-2002 08:07 PM
Re: favourite sysadmin scripts you always keep around....
ftp://contrib:9unsupp8@hprc.external.hp.com/sysadmin/
Look in coolscripts, cronscripts, programs and profiles. TYhe most popular ones (in coolscripts):
bdfmegs (very useful, use -v for details)
ljdisplay (personalize your LaserJet front panel)
lls (long listing sorted by size)
loadmedia (simple
psgrep (grep through the ps listing)
psram (sort all processes by RAM usage)
viman (read man pages with vi)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2002 08:05 PM
02-16-2002 08:05 PM
Re: favourite sysadmin scripts you always keep around....
cheers,
t+-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2002 03:11 AM
02-22-2002 03:11 AM
Re: favourite sysadmin scripts you always keep around....
some cool scripts!
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2002 12:50 PM
02-22-2002 12:50 PM
Re: favourite sysadmin scripts you always keep around....
Here is my contribution,
=======================================================================
#!/bin/ksh
# -------------------------------------------------------------------
# prodify -- set the file parameters properly on a subtree for
# production
#
# Anthony Khan 2001
#
# -------------------------------------------------------------------
PROGNAME=`basename $0`
USAGE="
Usage: ${PROGNAME} [-o owner:group] [-u umask] [-v] directory\n
\n
This sets the owner/permissions/etc of all files recursively under\n
the directory into a form suitable for production. The umask is set\n
when the file executes, but does not do much atm.\n"
# -------------------------------------------------------------------
# optional args.
#
OWNER_STRING="prod:xxprod"
UMASK=002
VERBOSE=0
while getopts ":o:u:v" opt
do
case $opt in
o) OWNER_STRING=$OPTARG;;
u) UMASK=$OPTARG;;
v) VERBOSE=1 ;;
\?)
echo $USAGE
exit 1;;
esac
done
shift `expr $OPTIND - 1`
# -------------------------------------------------------------------
# non-optional args
#
DIR=${1:?"Provide a directory"}
# -------------------------------------------------------------------
# steps
#
# umask
umask ${UMASK}
# go to directory
if [ $VERBOSE -gt 0 ]
then echo "cd ${DIR}";
fi
cd ${DIR} || exit 1
# chown
if [ $VERBOSE -gt 0 ]
then echo "Changing ownership...";
fi
chown -R ${OWNER_STRING} . || exit 1
# chmod dirs
if [ $VERBOSE -gt 0 ]
then echo "Changing directory permissions...";
fi
find . -type d -mount -exec chmod 2775 {} \; || exit 1
# chmod files
if [ $VERBOSE -gt 0 ]
then echo "Changing file permissions...";
fi
find . -type f -mount -perm -u=x -exec chmod 4774 {} \; || exit 1
find . -type f -mount ! -perm -u=x -exec chmod 0664 {} \; || exit 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2002 06:42 PM
02-22-2002 06:42 PM
Re: favourite sysadmin scripts you always keep around....
/usr/sbin/sar -u -M > /logging/perf/`date +%b%Y`/cpu`date +%d` 2> /dev/null
/usr/sbin/sar -b > /logging/perf/`date +%b%Y`/buffer`date +%d` 2> /dev/null
/usr/sbin/sar -d > /logging/perf/`date +%b%Y`/disk`date +%d` 2> /dev/null
Regards,
Kenny.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2002 09:15 PM
02-22-2002 09:15 PM
Re: favourite sysadmin scripts you always keep around....
Here is my favourite.. This was written to check if a particular port on a remote host is alive ..
---------------------------------------
# Author : Shabu Khan/Alan Acevedo
#!/usr/local/bin/perl -w
# Initialize!
use IO::Socket;
$numarg = @ARGV;
if ($numarg != 2) {
print "usage: tcpping
exit 1;
}
$host=$ARGV[0];
$tcpport=$ARGV[1];
# Main
$socket=IO::Socket::INET->new
(
PeerAddr => "$host",
PeerPort => "$tcpport",
Proto => "tcp",
Type => SOCK_STREAM
) or die "Could not open port $tcpport.\n";
print "Able to open port $tcpport.\n";
close($socket);
---------------------------------------------
-Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2002 05:34 AM
02-25-2002 05:34 AM
Re: favourite sysadmin scripts you always keep around....
Portscan on a line (almost):
start_port=1
end_port=10000
host=127.0.0.1
if [ $# -eq 0 ]
then
echo "No options supplied, using defaults"
sleep 2
clear
else
echo "Startport = $1, Endport = $2, Host = $3"
export start_port=$1
export end_port=$2
export host=$3
fi
[[ $start_port -gt $end_port ]] && echo "Start Port is Higher than the End Port" && exit
1
portscan ()
{
echo " close"|telnet $host $start_port > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Port $start_port is open"
fi
export start_port=$(($start_port + 1))
}
while [ $start_port -lt $(($end_port + 1)) ]
do
portscan
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2002 12:04 PM
02-25-2002 12:04 PM
Re: favourite sysadmin scripts you always keep around....
a multi-line file into fields that I can do something with. Using the example of /etc/hosts:
FILE=/etc/hosts
LENGTH=`wc -l |$FILE|awk '{ print $1 }'`
COUNTER=1
while test $COUNTER1 -le $LENGTH
do
LINE=`head -$COUNTER1 $FILE|tail -1`
FIELD1=`echo $LINE|awk '{ print $1 }'`
FIELD2=`echo $LINE|awk '{ print $2 }'`
# etc.....
COUNTER1=`echo "$COUNTER1 + 1"|bc`
done
Not every Unix supports the READ command, but
all of them support HEAD and TAIL. Therefore
this script can be used across all platforms.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2002 12:37 PM
02-25-2002 12:37 PM
Re: favourite sysadmin scripts you always keep around....
let x=$(grep -i
physical: /var/adm/syslog/syslog.log | head -1 | awk '{print $7}
')/1048
let z=$(vmstat|tail -1|awk '{print $5}')*4096;let z=$z/1000000
let free=100000/$x*$z
let free=$free/1000
let free=100-$free
echo "$x Mb physical memory \n$z Mb memory free \n$free % used"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2002 12:40 PM
02-25-2002 12:40 PM
Re: favourite sysadmin scripts you always keep around....
#!/usr/bin/ksh
##############################################################################
# Script to grep for host name in /etc/hosts #
##############################################################################
site=$1
while [ ! "$site" ]
do
echo "\nPlease speckify a host name\n"
read site junk
done
grep $site /etc/hosts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2002 02:08 PM
02-25-2002 02:08 PM
Re: favourite sysadmin scripts you always keep around....
emails stats for last 2 sessions, tape used for last session, next 10 tapes in the pool, and tapes in poor condition.
One of my first scripts but it works so I don't mess with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2002 07:37 PM
02-25-2002 07:37 PM
Re: favourite sysadmin scripts you always keep around....
bdf > /tmp/fstmplog
num=0
while read fs kbyte used avail percent mount
do
if [ "$mount" != "" ] && [ X"$mount" != X"Mounted on" ] && [ "$mount" != "/cdrom" ] ; then
count=`/usr/bin/echo $percent | cut -d"%" -f 1`
if [ "$count" -ge "96" ] ; then
/usr/bin/echo "$mount reach $percent."
let "num = $num + 1"
fi
fi
done < /tmp/fstmplog
if [ $num = 0 ] ; then
/usr/bin/echo "All File Systems are ok!"
fi
Regards,
Kenny.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 11:28 AM
02-26-2002 11:28 AM
Re: favourite sysadmin scripts you always keep around....
insert your latest Application CD-Rom into the drive and run this script to see whether it has newer versions of installed software available.
I expect the CD to be mounted on /cdrom (initialized on line 14)
I skip japanese, german,french etc (lines 63 and on)
2. stm.pl
a perl/Tk script to display the system's architecture and print it to a postscript printer
you'll need perl, and the perl modules Tk, Tk::TreeGraph , and Graph
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 06:28 PM
02-26-2002 06:28 PM
Re: favourite sysadmin scripts you always keep around....
Many of the scripts are being word wrapped to 80 col therefore requiring a bit of debugging before execution.
Thanks
Glenn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 12:33 AM
02-27-2002 12:33 AM
Re: favourite sysadmin scripts you always keep around....
status=`/usr/sbin/cmviewcl | grep cluster | awk '{print $2}'`
case $status in
up )
/usr/bin/echo "Cluster is $status."
Logging "Cluster is $status." ;;
down )
/usr/bin/echo "Cluster is $status"
Error "Cluster is $status"
code=101
Pager Operator $code
Pager Kenny $code ;;
starting )
/usr/bin/echo "Cluster is $status"
Error "Cluster is $status"
code=102
Pager Operator $code ;;
halting )
/usr/bin/echo "Cluster is $status"
Error "Cluster is $status"
code=103
Pager Operator $code ;;
unknown )
/usr/bin/echo "Cluster is $status"
Error "Cluster is $status"
code=104
Pager Operator $code ;;
* )
/usr/bin/echo "Cluster is $status"
Error "Cluster is $status."
code=105
Pager Operator $code ;;
esac
The Pager function will use mailx to send mail to the pagers. The Error function will log down the error.
Regards,
Kenny.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 01:14 AM
02-27-2002 01:14 AM
Re: favourite sysadmin scripts you always keep around....
ever had to check filesystems on 5 systems the same time ?
Need to set date/time on 8 boxes concurrently, but no timeserver available ?
What about a call like this:
adsh bdf
adsh date
Not much music in this script, but a very nice tool!
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 05:26 AM
06-10-2002 05:26 AM
Re: favourite sysadmin scripts you always keep around....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 05:35 AM
06-10-2002 05:35 AM
Re: favourite sysadmin scripts you always keep around....
Here's one I use when setting up a new system - nothing fancy but it copies over all the system type files that we've customized, modified, tuned, whatever.
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 07:17 AM
06-10-2002 07:17 AM
Re: favourite sysadmin scripts you always keep around....
This is a perl wrapper that makes it's output somewhat more useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 07:20 AM
06-10-2002 07:20 AM
Re: favourite sysadmin scripts you always keep around....
N/A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 07:26 AM
06-10-2002 07:26 AM
Re: favourite sysadmin scripts you always keep around....
The other invaluable script I run everynight is fairly site specific but I would recommend that everyone has one - Its a script to remotely print out all of the necessary information to recreate the system on a different box following a disaster and its proved invaluable many times (at least for recovery tests). Include output from the following to ensure you have enough information.
vgdisplay -v
bdf
Your last omniback database backup tape No
Full list of backup tapes for at least the last month.
ioscan -fn
print of /etc/fstab
ll /dev/vg??/group (saves working out the minor numbers :@) )
swlist
sysdef (plus a print out of /stand/system)
Anyone else have any suggestions - I do also regualrly print out the LVMCollect script output mentioned in the earlier posting in this thread as it does come in handy for later reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 07:34 AM
06-10-2002 07:34 AM
Re: favourite sysadmin scripts you always keep around....
This is now a favorite of mine. Issue:
I had to mass change the password for a 'specific' group of users (identified by loginname=all cap letters & their password had expired).
What we (Sven Liessem of HP Canada & me) came up with:
Take a dummy account and key in the new password to get the encrypted password...
Here's the script:
newpass="
cat /etc/passwd | while read line #read /etc/passwd line by line
do
echo $line | grep -q '^[A-Z][A-Z]*:[^:]*,3\.\.\.:' #see if it matches the criteria
if [ $? -eq 0 ]
then #now replace old passwd for new passwd and print line
username=`echo $line | cut -d: -f1`
therest=`echo $line | cut -d: -f 3-`
echo $username:$newpass:$therest
else #print unmodified lines
echo $line
fi
done
Well it worked for me..anyone else would need to edit the grep criteria to suit your needs..
Rgrds,
Rita