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

last failed/successful “sulog” entries for N days ago

You want to know for the latest N days who was able/unable to su, in solaris. Sulog is in /var/adm/sulog, and we don’t
have the niceties of GNU date, so we use perl inside a shell… “suentries.ksh”
#!/bin/ksh
#— n has how many days ago we want
n=$1
today=`/usr/bin/perl -e ‘printf “%dn”, time;’`
x=$n
while [ $x -gt -1 ];do
ago=$(($today-86400*${x}))
export ago
DAY=`perl -e ‘($a,$b,$c,$d,$e,$f,$g,$h,$i) =localtime($ENV{‘ago’});printf”%02d/%02dn”,$e+1,$d’`
echo “—- $DAY”
cat /var/adm/sulog | grep $DAY
x=$(($x-1))
done

Add a couple of disks to your zpool and grow some filesystems

First, check the status of your pool
bash-3.00# zpool status -v
pool: amx002zpool1
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
amx002zpool1 ONLINE 0 0 0
c6t60060480000190101353533030393543d0 ONLINE 0 0 0
c6t60060480000190101353533030393536d0 ONLINE 0 0 0
c6t60060480000190101353533030393530d0 ONLINE 0 0 0
c6t60060480000190101353533030393441d0 ONLINE 0 0 0
c6t60060480000190101353533030393434d0 ONLINE 0 0 0
c6t60060480000190101353533030433435d0 ONLINE 0 0 0
errors: No known data errors
Then add a couple of disks to it:
bash-3.00# zpool add amx002zpool1 c6t60060480000190101353533031343236d0
bash-3.00# zpool add amx002zpool1 c6t60060480000190101353533031343243d0
Now check if they’re added:
bash-3.00# zpool status -v
pool: amx002zpool1
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
amx002zpool1 ONLINE 0 0 0
c6t60060480000190101353533030393543d0 ONLINE 0 0 0
c6t60060480000190101353533030393536d0 ONLINE 0 0 0
c6t60060480000190101353533030393530d0 ONLINE 0 0 0
c6t60060480000190101353533030393441d0 ONLINE 0 0 0
c6t60060480000190101353533030393434d0 ONLINE 0 0 0
c6t60060480000190101353533030433435d0 ONLINE 0 0 0
c6t60060480000190101353533031343236d0 ONLINE 0 0 0
c6t60060480000190101353533031343243d0 ONLINE 0 0 0
errors: No known data errors
List free space on the pool:
bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
99/433
gskhr009zpool1 69.5G 5.87G 63.6G 8% ONLINE –
gskhr009zpool2 139G 73.6G 65.4G 52% ONLINE –
gskhr009zpool3 1.70T 1.24T 468G 73% ONLINE –
List all the filesystems in the pool:
bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
amx002zpool1 345G 157G 24.5K /amx002zpool1
amx002zpool1/amx21 64.6G 6.37G 64.6G /amx21
amx002zpool1/amx22 32.9G 4.12G 32.9G /amx22
amx002zpool1/amx23 26.1G 4.95G 26.1G /amx23
amx002zpool1/amx24 58.9G 6.15G 58.9G /amx24
amx002zpool1/amx25 49.6G 7.39G 49.6G /amx25
amx002zpool1/oracle 6.50G 1.50G 6.50G /oracle
amx002zpool1/oracle-export 21.6G 23.4G 21.6G /oracle/export
amx002zpool1/oracle2 24.5K 8.00G 24.5K /opt/oracle
amx002zpool1/psreports 24.5K 3.00G 24.5K /opt/reports
amx002zpool1/vendor 690K 20.0G 690K /opt/vendor
Get a quota and reservation for the filesystem to grow:
bash-3.00# zfs get quota amx002zpool1/amx21
NAME PROPERTY VALUE SOURCE
amx002zpool1/amx21 quota 71G local
bash-3.00# zfs get reservation amx002zpool1/amx21
NAME PROPERTY VALUE SOURCE
amx002zpool1/amx21 reservation 71G local
Grow the filesystem:
bash-3.00# zfs set quota=100G amx002zpool1/amx21
bash-3.00# zfs set reservation=100G amx002zpool1/amx21
That’s it, have fun
100/433