Operating System - HP-UX
1833053 Members
2816 Online
110049 Solutions
New Discussion

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

 
SOLVED
Go to solution
Brian DelPizzo
Frequent Advisor

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

Here is a cool script I wrote to run a defrag of my vxfs filesystems. You need to edit the very top of the script and fill in some key info. It lets you auto populate the list of filesystems to defrag or you can provide your own list. It also has HTML and regular e-mail for reports.

Here is the usage...
vxfs_defrag,sh [ -html ] [ -m ] [ -p ] [ -f ] [ -s ]


-html Create report using HTML output. -m is redundant
-m Mail report to (as defined in script)
-p Preview Mode. All functions are run, but files are not removed.
-f Force Mode. No prompts will be displayed. Script will answer yes to all prompts
-s Silent Mode. No messages to screen - No prompts (Force mode)

NOTE: All flags must be listed separately.

Cory Zito_1
New Member

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

Here's a Perl 4 script that gathers logical volume information for volume
groups >0 and creates a script to create the structure on another system. It is useful for cloning machines, DR, etc. This script works on HP-UX 10.20-11i machines and has been tested in Perl 5 as well as Perl 4.

It works great for the default lvol1, lvol2, lvol3 cases, and is not designed for non-standard lvol names, so you may have to modify the script for that.

Output looks something like this:
#!/bin/sh
# Create logical volume script for hostnamehere
# Created on: Tue Aug 19 13:55:21 CDT 2003

/sbin/lvcreate -l 387 -r n /dev/vg01 # /dev/vg01/lvol1
/sbin/lvcreate -l 1024 -r n /dev/vg01 # /dev/vg01/lvol2
/sbin/lvcreate -l 1024 -r n /dev/vg01 # /dev/vg01/lvol3
/sbin/lvcreate -l 1024 -r n /dev/vg01 # /dev/vg01/lvol4
/sbin/lvcreate -l 1274 -r n /dev/vg01 # /dev/vg01/lvol5
/sbin/lvcreate -l 1024 -r n /dev/vg01 # /dev/vg01/lvol6
Sandro Schaer_1
Advisor

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

compress all uncompressed files in a certain directory including subdirectories :

first 'cd' to the desired directory and then enter :

compress `find . |grep -v '.Z'`


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

Hi Bill,

Although i am using this forum a lot, this is my first time to join...

Everytime we create FS and LVs, we need to check first the free space of our VGs right? That's why i created this script. This give me an idea how much is the free space on each VGs. Hope this help :)

BTW, could anyone send me a script that will help me simplify my jobs in Symmetrix & BCV? Appreciate so much if you guys can send it over. Thank you so much!

script start here
--->
#!/usr/bin/ksh
#
#
VG_LIST=/tmp/vg_list.$$

vgdisplay | grep "/dev" | awk '{print $3}' > $VG_LIST

for i in `cat $VG_LIST`
do
VG_ALLOC=`vgdisplay $i|awk -v var=$i '/PE Size/ {PES=$NF} /Total PE/ {TPE=$NF} END{print "ALLOCATED SPACE for",var,vg=PES*TPE,"Mb"}'`
echo "$VG_ALLOC\c"
VG_USED=`vgdisplay $i|awk -v var1=$i '/PE Size/ {PES=$NF} /Alloc PE/ {APE=$NF} END{ print "\tUSED SPACE ",vg=APE*PES,"Mb"}'`
echo "$VG_USED\c"
VG_FREE=`vgdHi Bill,

Although i am using this forum a lot, this is my first time to join...

Everytime i need to create FS and LVs, we need to check first the free space of our VGs right? That's why i created this script. This give me an idea how much is the free space on each VGs. Hope this help :)

script start here
--->
#!/usr/bin/ksh
#
#
VG_LIST=/tmp/vg_list.$$

vgdisplay | grep "/dev" | awk '{print $3}' > $VG_LIST

for i in `cat $VG_LIST`
do
VG_ALLOC=`vgdisplay $i|awk -v var=$i '/PE Size/ {PES=$NF} /Total PE/ {TPE=$NF} END{print "ALLOCATED SPACE for",var,vg=PES*TPE,"Mb"}'`
echo "$VG_ALLOC\c"
VG_USED=`vgdisplay $i|awk -v var1=$i '/PE Size/ {PES=$NF} /Alloc PE/ {APE=$NF} END{ print "\tUSED SPACE ",vg=APE*PES,"Mb"}'`
echo "$VG_USED\c"
VG_FREE=`vgdisplay $i|awk -v var=$i '/PE Size/ {PES=$NF} /Free PE/ {FPE=$NF} END{ print "\tFREE SPACE ",vg=FPE*PES,"Mb"}'`
echo "$VG_FREE"
done


exit 0

sample output
--->

ALLOCATED SPACE for /dev/vg00 34712 Mb USED SPACE 28472 Mb FREE SPACE 6240 Mb
ALLOCATED SPACE for /dev/appl 20568 Mb USED SPACE 18672 Mb FREE SPACE 1896 Mb
isplay $i|awk -v var=$i '/PE Size/ {PES=$NF} /Free PE/ {FPE=$NF} END{ print "\tFREE SPACE ",vg=FPE*PES,"Mb"}'`
echo "$VG_FREE"
done


exit 0

sample output
--->

ALLOCATED SPACE for /dev/vg00 34712 Mb USED SPACE 28472 Mb FREE SPACE 6240 Mb
ALLOCATED SPACE for /dev/appl 20568 Mb USED SPACE 18672 Mb FREE SPACE 1896 Mb

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

Hi Bill,

Yehey i earned 10 points!!!!!
This forum is really great.

BTW, i have here a script that will disable the password aging feature after you convert your box into 'Trusted System'. Basically we have more than 800 users and there are some users that should have the feature of password aging such as oracle, informix id....

First, i list those IDs that should be exempted on password aging and put it into a file. Then just execute this script.

# ./passwd_aging_disable.sh
Usage: ./passwd_aging_disable.sh


Christian Schulze
Regular Advisor

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

We use this script to check if all mirrordisk are online (Status of all Extents current and not stale)

It runs once a day and tells us, if if a disk died.

never touch a running system
Jasmin Balgos
Occasional Contributor

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

Here's a script I use to monitor file systems and proactively cleans up certain file systems (i.e. home) if it reaches a threshold. It emails the admin, displaying a sorted, descending largest files.
Jim Mulshine
Frequent Advisor

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

timecalc calculates the difference in hours and minutes between two given times.

# SYNTAX: timecalc HH:MM HH:MM

# Output: hours minutes

# Example: timecalc 14:10 14:35
# gives: 0 25
#
# timecalc 23:45 01:30
# gives: 1 45
Scott Frye_1
Super Advisor

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

Watches top for runaway processes. Only thing you need is this script and a file counter.txt. The counter.txt file only needs to contain the number zero.

Onur Karakan
Advisor

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

Dear colleagues,
This script checks all PVs,VGs and LVs availability,free PEs,available spaces and so on. It wrotes the output to a log file named as system date. And mails the output to the user.

it is not a system specific.

i hope it will be usefull for you.

Note:if you have any idea that can be added for the daily checks for a unix system, please inform me.

Regards,

Onur
Mark Nieuwboer
Esteemed Contributor

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

Hi,

Here is a script for monitoring filesystem.
With 2 tresholds.

grtz. Mark
Onur Karakan
Advisor

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

Dear friends,
This script checks for total number of filesystems and filesystem percentages. If anyone is over limit that you will assign, mails the admin with over limited filesystem.

Regards,

Onur
Etienne Roseau
Frequent Advisor

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

hi everybody !!
small script about processes from users hard disconnection
E.
paolo barila
Valued Contributor

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

Hi,

just a "ksh" debugged revision of a previous script which select fields in a file for any purpose

Pablo
share share share
spex
Honored Contributor

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

Script to number columns of the console, and then execute a command. Similar to 'nl', but for columns instead of rows. It's especially useful for getting character positions for use with 'cut -c' and 'sort -k'. Example:

# noc.sh -b ls /usr/bin

111111111122222222223333333...
123456789012345678901234567890123456...
====================================...
X11 dts_null_provider...
acl_edit dtscp
adb dtsd
adb64 du
adjust dumpfs
admin dumpmsg
alias e
answer echo
ar ed

PCS
Rick Garland
Honored Contributor

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

A perl script that checks the /var/spool/lp/request directory to see if any print jobs are hanging out there that are older that a certain time. I have 3 hrs in this but can be changed to whatever.

Will send an email listing those jobs older that specified time so you are aware

Bill McNAMARA_1
Honored Contributor

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