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
Month: January 2011
usb vfs: cannot open root device sda1 or unknown-block
if you get that error while trying to boot from a USB disk, and you’re 100% sure it is the right disk and partition, then
pass:
rootdelay=10
to your grub parameters. That will make the kernel wait a bit until your usb drive appears.
76/433
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
giz magazine
this is good
http://www.gizmag.co.uk/
– rdircio
287/433
get a vnc session forwarded
This is basic ssh port forwarding, but i always forget…
so, you have hosta, hostb and yourpc.
you’re not in the same network as hostb, so you need to connect this way
yourpc –> hosta —> hostb
and you have a vnc session at hostb:1 (5901)
you want to connect to hosta:11 (5911) and get your vnc screen at hostb:1 (5901)
All you have to do is, from hosta
rdircio@hosta $ ssh -g -C hostb -L 5911:localhost:5901
then point the vnc client on yourpc to hosta:11.
196/433
Get server model and manufacturer
dmidecode | more
Thanks to Justin Lim
Disable NIS client in solaris
mv /a/usr/lib/netsvc/yp/ypbind /a/usr/lib/netsvc/yp/ypbind.orig
mv /a/usr/lib/netsvc/yp/ypserv /a/usr/lib/netsvc/yp/ypserv.orig
init 6
97/433
s9y comment spam protection
I was been attacked by comment spam in this blog… this had me a bit down for a while.
Soon i found out there is an easy way to make comment spam difficult on serendipity(s9y) blog.
Go to “Configure Plugins” —> “Event Plugins” —-> “Spam Protector”
And you’ll solve all your problems 🙂
– rdircio
253/433
Make a copy of your root disk on solaris 10
if you need to make a copy of your boot disk, and you don’t have
disksuite, and you only have one slice as “/”, and this is solaris 10,
you can do:
#prtvtoc /dev/rdsk/c0t0d0s0 | fmthard -s – /dev/rdsk/c0t1d0s0
#newfs /dev/dsk/c0t1d0s 0
#mount /dev/dsk/c0t1d0s0 /a
#cd /
#find . -mount | cpio -pmdv /a
#installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0
#vi /a/etc/vfstab
(change references from c0t0d0s0 to c1)
#mkdir /a/tmp
#mkdir /a/dev
#mkdir /a/proc
#touch /a/etc/mnttab
#mkdir /a/etc/svc/volatile
#mkdir /a/system/object
#mkdir /a/system/contract
#umount /a
#init 0
#boot otherdisk -r
And the system will boot fine from the other disk.
Remember it should be better to do this in single user mode, and with apps down.
200/433
configure up2date on RHEL AS 2.1
If you don’t like graphics…
go to /etc/sysconfig/rhn
and edit “up2date” and “rhn_register”
… and a happy new year
212/433
random wallpaper in gnome
Say you want a random Gnome wallpaper from google each 60 seconds, but if your machine is not connected, just take
the backdrop from a local directory ~/Desktop/backdrops. you can put up a couple of scripts to do this, the main one
would be /scripts/changewall.ksh
#!/bin/bash
mkdir -p /tmp/wallpapers
E=`ps -ef | grep -i changewall | grep -i $USER | grep -iv grep | wc -l`
if [ $E -gt 2 ];then
echo “wallpaper changer already running for $USER”
exit 1
fi
i=120
while true;do
i=`cat /scripts/time.txt`
rm -fR /tmp/wallpapers/*
RANGE=10
number=$RANDOM
let “number %= $RANGE”
number=$(($number))
ping -w 10 -c 2 www.google.com > /dev/null 2>&1
R=$?
if [ $R -eq 0 ] && [ $number -lt 9 ];then
/scripts/wallpaper.ksh > /dev/null 2>&1
F=`ls /tmp/wallpapers`
N=`echo $F | wc -c`
if [ $N -gt 1 ];then
gconftool-2 -t string -s /desktop/gnome/background/picture_filename “/tmp/wallpapers/$F”
# cp “/tmp/wallpapers/$F” $HOME/Desktop/backdrops/
else
cd $HOME/Desktop/backdrops
ls -1 *.jpg | head -n`expr $RANDOM % `ls -1 *.jpg | wc -l“ | tail -n1 | echo `pwd`/`xargs` | gconftool-2 -t string -s /desktop/gnome/background/picture_filename “`xargs`”
fi
else
cd $HOME/Desktop/backdrops
ls -1 *.jpg | head -n`expr $RANDOM % `ls -1 *.jpg | wc -l“ | tail -n1 | echo `pwd`/`xargs` | gconftool-2 -t string -s /desktop/gnome/background/picture_filename “`xargs`”
fi
sleep $i
done
Then you would need the support script, to get images from google according to a random word that comes
from /scripts/wallpaper-subjects.txt program: /scripts/wallpaper.ksh
#!/bin/ksh
cat /scripts/wallpaper-subjects.txt | head -n`expr $RANDOM % `cat /scripts/wallpaper-subjects.txt | wc -l“ | tail -n1 > /tmp/subject
QUERY=`cat /tmp/subject | sed ‘s/ /%20/g’`
RANGE=10
number=$RANDOM
let “number %= $RANGE”
number=$(($number + 1))
IMG=`curl -m 10 -A “Mozilla/3.0 (compatible; AvantGo 3.2)” “http://images.google.com/images?as_q=${QUERY}&as_filetype=jpg&biw=1680&bih=1024&safe=active&as_st=y&tbs=isch:1,itp:photo,islt:2mp,isz:l,ift:jpg” 2>/dev/null |sed -e ‘s/>/>n/g’ | awk ‘{s=substr($0,index($0,”http”),index($0,”jpg”));print substr(s,1,index(s,”.jpg”)+3)}’ | grep jpg |egrep -v ‘starkeith|gstatic|scaredmonkeys|tripod|flickr’|sed ‘s/2520/20/g’ | head -$number | tail -1`
mkdir -p /tmp/wallpapers
cd /tmp/wallpapers
wget –timeout=10 $IMG
you can add /scripts/changewall.ksh to your autostart stuff in gnome, going to system –> preferences –>
startup applications
ENJOY!