- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: favorite sysadmin scripts you always keep arou...
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
09-10-2003 06:27 AM
09-10-2003 06:27 AM
Re: favorite sysadmin scripts you always keep around (3)
not that I would consider this script to be one of my favorites.
I just dare to post this quick'n'dirty Perl script here because it is so HP-UX related it wouldn't be of any use on any other platform (you might even rightly question the usefulness on HP-UX)
And this forum deals about HP-UX, right?
We occasionally get network bottlenecks on some of our database servers during high peak.
Before I got the netperf tool I needed something quick to give me a rough estimate on the NICs' throughput and packet rates.
Lacking OID, MIB, and ASN knowledge of the SNMP to have done it properly I just took the MIB stats the lanadmin command is dumping.
Since the lanadmin command may even be issued by a non-root user (as long as one doesn't wish to set anything), this process can safely be run under a harmless euid.
Because of our special MC/SG cluster environment I do a little detour over the cmviecl command to obtain the active NIC.
But this isn't really necessary, and one can easily omit this command in the script.
The same reason holds for the parsing of the process table in one column in order to get the number of Oracle Net8 connections to get a rough overview of the database's connection handles.
This part can also easily be discarded from the script.
I fear it still is a bit buggy, since sometimes wrong counts appear in isolated lines of the logfile.
Maybe this is due to a failed NIC MIB query by lanadmin, which I so far didn't take any precautions to guard against.
But at least it doesn't seem to do any harm, and I have been running it now in daemon mode for a couple of weeks.
The script requires a decently current Perl version (e.g. >= 5.6).
If you made it executable and invoke it with the -h option you get a short help screen.
Would be nice if it is of any use to someone at all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2003 07:01 AM
09-10-2003 07:01 AM
Re: favorite sysadmin scripts you always keep around (3)
I'm sending a full package for user/accounts
administration of 2-nodes cluster. It is
no need to use NIS or other sophisticated
service. This package is using client-server
technology to support identical accounts on
all nodes with replication.
Regards, Stan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2003 11:58 AM
09-10-2003 11:58 AM
Re: favorite sysadmin scripts you always keep around (3)
It clears shared memory areas based on a filter.
clearipc sag
clears all shared memory for user sag.
This user had memory leak or something in one of its apps and didn't release shared memory as its supposed to.
The ipcrm command is commented out on purpose.
Try it, check the output.
The problem with it is when the ID is long it gets confused about fields
s2121212121212 ad0x00000000 --rw-rw-rw sag sag
does not process right.
Its okay, but I think Bill might give you a rabbit for upgrading it.
The script is tested and works except as noted above.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2003 05:02 AM
09-11-2003 05:02 AM
Re: favorite sysadmin scripts you always keep around (3)
this is to list users connected more than once from different IP @.
# dupuser : list of users connected on system more than once from
# different IP @
Rgds,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2003 11:21 AM
09-11-2003 11:21 AM
Re: favorite sysadmin scripts you always keep around (3)
It is simple and has the following characteristics:
It runs a group of scripts and puts the output to /tmp/morning.txt
running uptime eliminates questions about when was this last rebooted
Keeping daily track of the ERP package
It is started with date > /tmp/mornin.txt
and terminates with date >> /tmp/mornin.txt
Clearing and dating morning activity.
I also keep track of admin activity.
What did you do yesterday???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2003 10:45 PM
09-11-2003 10:45 PM
Re: favorite sysadmin scripts you always keep around (3)
Here is an Perl-programs, which are
client-server application, worked as
socket. In addition the server is made to
work as daemon on one system.The client
have to work on another mashine and connect
to server for doing some useful job.
I thing, this is a good template for
developing many system applicatins -
monitoring, replication of data
and so on.
Regards,Stan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2003 10:49 PM
09-11-2003 10:49 PM
Re: favorite sysadmin scripts you always keep around (3)
offer. The second script - the "client".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 03:03 AM
01-20-2004 03:03 AM
Re: favorite sysadmin scripts you always keep around (3)
#!/bin/sh
# A recursive grep.
while [ $# != 2 ]
do
if [ $# != 2 ]
then
echo "\nUsage:\trecurs
echo "Insufficient number of paramaters (errno 69)\n"
fi
exit 1
done
while [ $# = 2 ]
do
echo "Please hold while I check that directory...."
cd $2
find . -depth -type f -follow -exec fgrep -l -i "$1" {} \;
exit 0
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2004 03:19 AM
01-22-2004 03:19 AM
Re: favorite sysadmin scripts you always keep around (3)
emails in mail queue. Uses unique strings of from/to address when looking at queue using
mailq.
#!/bin/ksh
#set -x
#
# Trash junk email thats going nowhere.
# Jerry Moore 9/5/2001
#
PATH=/bin:/usr/sbin:.
DIR=/var/spool/mqueue
TFILE=/tmp/trash.file
>$TFILE
if [ ! "$1" ] ; then
echo ""
echo "Usage: trashit
exit 1
fi
for i in `ls $DIR/ | grep -v ^df | sort -u` ;do
grep $1 $DIR/$i >/dev/null 2>&1
if [ "$?" = "0" ];then
ls $DIR/$i >>$TFILE
fi
done
if [ -s $TFILE ] ; then
for i in `cat $TFILE`;do
echo "Removing qf file $i
rm $i
echo "Removing df file `echo $i | sed s/qf/df/`."
echo $i | sed s/qf/df/ | xargs rm
echo "Removing any xf files."
echo $i | sed s/qf/xf/ | xargs rm
done
else
echo "No control files match string ( $1 )"
fi
/bin/rm -f $TFILE
#END
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2004 02:13 AM
01-29-2004 02:13 AM
Re: favorite sysadmin scripts you always keep around (3)
it tests for the alternate path, minimal size, etc.
works on any 9000/700 or 9000/800 platform. I am busy extending the capability to work on Itanium hardware. only LVM at this time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2004 03:00 AM
01-29-2004 03:00 AM
Re: favorite sysadmin scripts you always keep around (3)
#!/bin/ksh
# Run netstat to get "FIN_WAIT_2" info.
# We then keeelllll them for fun.
stuff=$(/usr/bin/printf "%.2x%.2x%.2x%.2x%.4x%.2x%.2x%.2x%.2x%.4x\n" \
$(/usr/bin/netstat -an -f inet | /usr/bin/grep FIN_WAIT_2 | \
/usr/bin/awk '{print $4,$5}' | /usr/bin/sed 's/\./ /g'))
for x in $stuff
do
/usr/bin/ndd -set /dev/tcp tcp_discon_by_addr $x
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2004 06:09 AM
02-03-2004 06:09 AM
Re: favorite sysadmin scripts you always keep around (3)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 01:47 AM
03-04-2004 01:47 AM
Re: favorite sysadmin scripts you always keep around (3)
Wonderful.
Based on /etc/fstab
The Defragmentation Script.
Online JFS required.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 02:15 AM
03-04-2004 02:15 AM
Re: favorite sysadmin scripts you always keep around (3)
I'm not the originator for this script (Jan Verbakel is) but I did enhance it a bit.
Features:
# - Use a list of servernames to do more than 1 server at a time.
# - Have the script generate a list of servers with a specific release number.
# - Generate verbose output for easing reading/checking or
# Non-verbose output for use in spreadsheets.
# - Run a single command or a script full of commands on multiple servers.
# When running a script output is stored on the originating machine.
# No files are left on the remote servers, unless your script does so.
It uses the rtools series, so it's still useful for those of us without ssh everywhere!
Cheers,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 02:58 AM
03-04-2004 02:58 AM
Re: favorite sysadmin scripts you always keep around (3)
#!/bin/sh
SLOT=1
DEV=c4t0d0
BLK=/dev/dsk/${DEV}
RAW=/dev/rdsk/${DEV}
echo "This script recovers a system when the disk in slot 1 has failed."
echo "Slot 1 is at the bottom (LHS viewed from front at XXX) and shows"
echo "up in ioscan as $RAW, and in lvdisplay as $BLK"
echo "Check which drive is marked as 'stale' using lvdisplay, e.g."
echo " lvdisplay -v /dev/vg00/lvol
echo ""
echo "Are the stale extents on $DEV ? (y/n) \c"
read resp
case "$resp" in
[yY]* )
echo ""
;;
* )
echo "Abandoning"
exit 0
;;
esac
echo "Doing an ioscan now, to check the state of the disk..."
ioscan -fnCdisk
echo "The disk $RAW MAY show up in error, e.g. NO_HW"
echo "If you want to continue, remove the failed disk and press return"
echo "(Note, you must have another module ready, don't put it in yet, but"
echo "be ready to put it in within 5 minutes.)"
echo ""
echo "Press return when disk is out ...\c"
read resp
echo "Doing another ioscan so HPUX realises the disk has gone"
ioscan -fnCdisk
echo "OK, we really do expect $RAW to show up as NO_HW this time,"
echo "definitely not to show up as CLAIMED"
echo "If it is CLAIMED, it looks like you've removed the wrong disk."
echo ""
echo "Assuming all is well, put the replacement disk into the slot $SLOT"
echo "then press return ...\c"
read resp
echo "Doing another ioscan so HPUX realises the disk has changed."
echo "We now expect the disk to show up as CLAIMED."
ioscan -fnCdisk
echo "Did the disk $RAW show up as CLAIMED ? (y/n) \c"
read resp
case "$resp" in
[yY]* )
echo ""
;;
* )
echo "Abandoning"
exit 0
;;
esac
echo "OK, will start initialising the disk in 5 seconds (CTRL-C to stop)"
echo "5 \c"
sleep 1
echo "4 \c"
sleep 1
echo "3 \c"
sleep 1
echo "2 \c"
sleep 1
echo "1 \c"
sleep 1
echo "0"
echo "running vgcfgrestore"
vgcfgrestore -n /dev/vg00 $RAW
echo "vgchange"
vgchange -a y /dev/vg00
echo "vgsync - this should take several minutes, especially for lvol4 and lvol5"
vgsync /dev/vg00
echo "running mkboot"
mkboot -l $RAW
mkboot -a "hpux -lq (;0)/stand/vmunix" $RAW
echo "Running lvlnboot, though not sure its needed"
lvlnboot -r /dev/vg00/lvol3 /dev/vg00
lvlnboot -b /dev/vg00/lvol1 /dev/vg00
lvlnboot -s /dev/vg00/lvol2 /dev/vg00
lvlnboot -d /dev/vg00/lvol2 /dev/vg00
echo "Putting ODE onto the boot area"
mkboot -b /usr/sbin/diag/lif/updatediaglif \
-p ISL -p AUTO -p HPUX -p PAD -p LABEL $RAW
echo ""
echo "Done."
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 03:16 AM
03-04-2004 03:16 AM
Re: favorite sysadmin scripts you always keep around (3)
# Show the percentage of total used space in /users to each user
# 11/18/02 BRS
$user_thresh = 1 ;
# Get the size of each users home directory
# sub users_report {
$user_total = `du -sk /users 2> \/dev\/null`;
($user_total,$nothing) = split(/\s+/,$user_total) ;
print "/users's total usage is $user_total kb \n" ;
foreach (`du -sk /users/* 2> \/dev\/null` ) {
chop ;
($user_kb,$user_dir) = split (/\s+/);
$users_size{$user_dir} = $user_kb ;
$user_pct = int(($user_kb / $user_total) * 100) ;
if ( $user_pct > $user_thresh ) {
print "$user_dir ($user_kb kb) is $user_pct% \n" ;
}
}
Regards, Ernesto.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 03:28 AM
03-04-2004 03:28 AM
Re: favorite sysadmin scripts you always keep around (3)
#!/bin/sh
THRESHHOLD="7[0-9]%"
THRESHHOLD1="8[0-9]%"
THRESHHOLD2="9[0-9]%"
THRESHHOLD3="100%"
# BDF ON PIPPO_SERVER
echo "####################" > bdf_on_servers.txt
echo "# BDF ON PIPPO_SERVER #" >> bdf_on_servers.txt
echo "####################" >> bdf_on_servers.txt
echo "\n" >> bdf_on_servers.txt
echo "Filesystem kbytes used avail %used Mounted on \n" >> bdf_on_servers.txt
bdf -l | grep -e $THRESHHOLD -e $THRESHHOLD1 -e $THRESHHOLD2 -e $THRESHHOLD3 >> bdf_on_servers.txt
ux2dos bdf_on_servers.txt | mailx -s "BDF on UNIX SERVERS" pippo@ops.test.it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 07:14 AM
04-05-2004 07:14 AM
Re: favorite sysadmin scripts you always keep around (3)
#!/usr/bin/sh
for arg in `ps -fel |grep sas |grep -v grep|cut -c 15-21`
do
# echo "renicing" ${arg}
renice -n +19 ${arg}
done
I run it with a cron every five minutes:
1,6,11,16,21,26,31,36,41,46,51,55 * * * * /root/scripts/sasfix.sh >/tmp/trace1 2>&1
I'm trying to make a script to check and see if users have more that on process running and then kill off the older processes. Can anyone help?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 04:30 PM
04-05-2004 04:30 PM
Re: favorite sysadmin scripts you always keep around (3)
Here are some links to very good scripts
http://www-
http://www.intuitive.com/wicked/wicked-cool-shell-script-library.shtml
106.ibm.com/developerworks/linux/library/l-punix?open&l=765,t=grl,p=punix
Good Book on Shell Scripting
http://www.intuitive.com/wicked/table-of-contents.shtml
regards,
sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 06:46 PM
04-05-2004 06:46 PM
Re: favorite sysadmin scripts you always keep around (3)
# cstring
alias cstring='( ( vis -n; print ) | while read -r X; do Y="${Y}${X}"; done; print -r "${Y%\\n}" )'
# echo ' t \na' | cstring
\st\s\na
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2004 06:30 PM
04-06-2004 06:30 PM
Re: favorite sysadmin scripts you always keep around (3)
Just got to know of this thread 2 days ago, great stuff. Attached is a small script to monitor syslog.log for keyword for preactive/preventive alert. This is a live production script. To keep log fresh, it perform log rotation after 3 alerts and call /dev/null to zero the syslog.log - not sure this is right approach but it work for us. After the log refresh, it went to sleep for 1 hr. BTW, this script MUST run in root and in backgroud.
Usage: # /usr/bin/sh /usr/local/bin/syslog_mon.sh &
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2004 09:26 PM
04-06-2004 09:26 PM
Re: favorite sysadmin scripts you always keep around (3)
#!/usr/bin/sh
strings /etc/lvmtab | grep -v vg | grep -v "^$" | cut -d "/" -f4 >/tmp/use.out
# Below line will create list of cxtxdx
ioscan -funC disk | awk '{ if ($3 != "") printf ("%s",$0) ; else printf ("%s\n",$0)}' | grep -v DVD-ROM | grep -v Class | awk -F "/dev" '{p
rint $2}' | awk -F "/" '{print $3}' > /tmp/disk.lst
#Below line will create list of lun numbers d# But not used in this Script
ioscan -funC disk | awk '{ if ($3 != "") printf ("%s",$0) ; else printf ("%s\n",$0)}' | grep -v DVD-ROM | grep -v Class | awk -F "/" '{prin
t $7}' | cut -d "d" -f2 > /tmp/d.lst
clear
echo "\t SL.No \t DEVICE FILE \t DISK TYPE \t\t DISK SIZE IN GB \t DISK STATUS "
echo "\t ----- \t ----------- \t --------- \t\t --------------- \t -----------\n\n"
N=0
for i in `cat /tmp/disk.lst`
do
#for j in `cat /tmp/use.out`
#do
if [ `/usr/sbin/diskinfo /dev/rdsk/$i | grep size | awk '{ print $2 }'` -gt 50000 ]
then
grep $i /tmp/use.out 1> /dev/null
if [ "$?" != 0 ]
then STAT=" Unused "
else STAT=" Used "
fi
{ ((N=N+1))
if [ `echo $i | cut -d "d" -f2` -ne 0 ]
then
SIZE1=`/usr/sbin/diskinfo /dev/rdsk/$i | grep size | awk '{ print $2 / 1048576 }'`
echo "\t $N \t $i \t Array of disks [LUN=`echo $i | cut -d "d" -f2`] \t $SIZE1 \t $STAT "
else
SIZE=`/usr/sbin/diskinfo /dev/rdsk/$i | grep size | awk '{ print $2 / 1048576 }'`
echo "\t $N \t $i \t normal disk \t\t\t $SIZE \t $STAT "
fi
}
fi
done
echo " \n\n\t Note: Disk Status indicates use of Disk in LVM configuration only. \n\n"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2004 03:05 AM
05-03-2004 03:05 AM
Re: favorite sysadmin scripts you always keep around (3)
Output sample :
> ./bdf2
/dev/vg00/lvol1:298928:84392:184640:31%:/stand
/dev/vg00/lvol3:311296:278960:32120:90%:/
/dev/vg00/lvol4:4194304:2025800:2151600:48%:/opt
/dev/vg00/lvol5:524288:403808:120096:77%:/tmp
/dev/vg00/lvol6:1785856:1242328:539288:70%:/usr
/dev/vg00/lvol7:4194304:1056976:3113096:25%:/var
/dev/vg00/lvol8:262144:2344:257776:1%:/home
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2004 03:25 AM
05-03-2004 03:25 AM
Re: favorite sysadmin scripts you always keep around (3)
1) Which processes have racked up a lot of CPU.
ps -ef | cut -c42-80 | sort -nr | head
2) A "pipe to" thing to remove a list of files that I found some way:
| awk '{print "rm -r ",$NF,}' > useme
So I might use this for instance in cleaning up all the files that were created before April or May.
ll | grep -v -e Apr -e May | awk '{print "rm -r ",$NF,}' > useme
The file "useme" now contains a bunch of statements like:
rm -r Exaaaaae0123 (or whatever types of files they seem to be).
So then I:
chmod +x useme; ./useme
Best regards,
Kent M. Ostby
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2004 03:25 AM
05-03-2004 03:25 AM
Re: favorite sysadmin scripts you always keep around (3)
echo -e ":%s/STRING/SUBST/\\n:wq\\n"|vi FILENAME
Peace, R.