My Apache virtual hosts

I have some domains on a single machine, over a single dynamic DNS connection, that means a single ip, and I need to
show a different page for each domain name it is accessed.
This is the section of my httpd.conf that enables that:
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /usr/local/apache2/htdocs/ttoes
ServerName www.ttoes.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /usr/local/apache2/htdocs
ServerName www.kraftek.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /usr/local/apache2/htdocs
ServerName rdircio.no-ip.org
</VirtualHost>

Translate / Convert ssd to cxtxdx

You can translate ssd disk syntax to cxtxdx (c$t$d$) by comparing iostat -E to iostat -En output:
iostat -E | grep Soft | awk ‘{ print $1}’ > /tmp/a; iostat -En | grep Soft|awk ‘{ print $1 }’ > /tmp/b; paste /tmp/a
/tmp/b
sd6 c0t6d0
ssd0 c1t1d0
ssd1 c1t0d0
ssd2 c1t3d0
ssd3 c1t4d0
ssd4 c1t5d0
ssd5 c4t3d0
ssd6 c4t4d0
ssd7 c1t2d0
ssd8 c4t5d0
ssd9 c4t2d0
ssd10 c4t1d0
ssd11 c4t0d0
Thanks to Hiram Ruiz
230/433

rstatd performance daemon

Well, i didn’t know that rstatd can be used to obtain a remote’s server performance counters….
It is usually disabled for security purposes.
Just make sure it is configured at /etc/inetd.conf, by uncommenting the proper line
bash-2.05# grep rstat /etc/services
bash-2.05# grep rstat /etc/inetd.conf
rstatd/2-4 tli rpc/datagram_v wait root /usr/lib/netsvc/rstat/rpc.rstatd rpc.rstatd
Then restart inetd
bash-2.05# ps -ef | grep inetd
root 355 1 0 Apr 26 x y z 0:00 /usr/sbin/inetd -s -t
bash-2.05# kill -HUP 355
It will be running
bash-2.05# ps -ef | grep rstat
root 23620 23616 0 18:01:48 pts/1 0:00 grep rstat
root 21694 355 0 17:39:37 x y z 0:01 rpc.rstatd
You can use a fine rstatd client called java perfmeter: http://jperfmeter.sourceforge.net/
If you have CDE you can use sdtperfmeter
bash-3.00$ /usr/dt/bin/sdtperfmeter othermachine
If you have gnome, you might as well use gnome-perfmeter
# gnome-perfmeter othermachine
242/433

Automate ssh login with expect

Sometimes you are not allowed to use keys to autologin to your machines, so you must find a way to automate your
login using password authentication.
This expect script can help you do it:
#!/usr/local/bin/expect —
set timeout 30
spawn ssh user@ipaddress
while 1 {
expect {
“*(yes/no)?” { send “yesn”}
“*password:” { send “passwordn”}
“*user]#” { send “shutdown -h nownexitn”}
}
}
266/433

Metafree

If you want to know how much space you have free for soft partitioning use Adrian Ball's script "metafree", get it at:
http://majords.co.uk/scripts/metafree
or just copy/paste this:
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
168/433
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
=="-p" {print }' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
*### It's a metadevice, use metastat to find the size
*cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
169/433
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
*### It's a real device, work out size assuming full disk/LUN is used
*cap=$(prtvtoc $c | nawk '
kraftek.html POSTS rescue rescued.html rescued.txt x y z /bytes/sector/ {bs=
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
170/433
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
}
kraftek.html POSTS rescue rescued.html rescued.txt x y z /sectors/cyl/ {sc=
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
171/433
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
}
kraftek.html POSTS rescue rescued.html rescued.txt x y z /accessible cyl/ {as=
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
172/433
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
}
kraftek.html POSTS rescue rescued.html rescued.txt x y z END kraftek.html POSTS rescue rescued.html rescued.txt x y z {print bs*sc*as/1024^3}')
else
*### Assume we have a cXtX form of device, use prtvtoc to work out
*### the size of the slice
*cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
kraftek.html POSTS rescue rescued.html rescued.txt x y z BEGIN {split(c,a,"s"); s=a[2]}
kraftek.html POSTS rescue rescued.html rescued.txt x y z /bytes/sector/ {bs=
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
173/433
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
}
kraftek.html POSTS rescue rescued.html rescued.txt x y z ==s {print *bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
kraftek.html POSTS rescue rescued.html rescued.txt x y z
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
174/433
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
=="-p" && ==c {split(
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
175/433
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }*
END** { print used/2048/1024 }
')
echo $cap $used | nawk '{print -
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
176/433
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct % "$devs"
done
,
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
177/433
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct % "$devs"
done
/*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '==c &&
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct % "$devs"
178/433
done
="-p" {printf "%s ", }')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct % "$devs"
done

grub-install cannot find /boot device

Got this fine hint from the gentoo grub error collection
Could Not Find Device For /boot/boot: Not Found Or Not a Block Device
Situation
When running grub-install during the GRUB installation, you receive the
following error:
Grub Output
# grub-install –root-directory=/boot /dev/hda
Could not find device for /boot/boot: not found or not a block device
Solution
Check that you didn’t forget the following:
Updating the mtab file
# cp /proc/mounts /etc/mtab
213/433

Sendmail starts using “-C” in solaris 10

If sendmail starts only using local.cf and something like this appears:
# ps -ef | grep -i sendmail
root 22616 1 0 11:13:11 x y z 0:00 /usr/lib/sendmail -bd -q15m -C /etc/mail/local.cf
smmsp 22614 1 0 11:13:10 x y z 0:00 /usr/lib/sendmail -A
And you want it not to run only local, you can do:
# svccfg -s svc:/network/smtp:sendmail setprop config/local_only = false
# svcadm refresh svc:/network/smtp:sendmail
# /usr/bin/svcprop -p config/local_only svc:/network/smtp:sendmail
false
# svcadm disable sendmail
# svcadm enable sendmail
And now it runs without local.cf
# ps -ef | grep -i sendmail
root 24465 1 0 11:18:13 x y z 0:00 /usr/lib/sendmail -bd -q15m
smmsp 24463 1 0 11:18:13 x y z 0:00 /usr/lib/sendmail -Ac -q15m
18/433

tar and gzip

this is first grade, but in case you forget how to create a tar and gzip on the fly if you do not have gnu tar…
to unpack on the fly:
# gunzip < filename.tar.gz | tar xvf –
to pack on the fly:
# tar cvf – files_to_tar | gzip -c > filename.tar.gz
249/433