issue:
ndd -get /dev/tcp ? | grep -i write | awk '{ print $1 }' |awk -F'(' '{ print $1 }' |while read p;do echo "$p `ndd -get /dev/tcp $p`"; done
some Unix notes
issue:
ndd -get /dev/tcp ? | grep -i write | awk '{ print $1 }' |awk -F'(' '{ print $1 }' |while read p;do echo "$p `ndd -get /dev/tcp $p`"; done
Get the date from a server
# date +%m%d%H%M%Y
060510252012
Use that result to set the date in another server
# ssh otherserver
otherserver#date 060510252012
flarcreate -S -n thisserver_flar -a rdircio -X exclude_list.txt thisserver.flar
# zoneadm –z halt <thezone>
# zoneadm –z detach <thezone>
# cd /export/zone/<thezone>
# find . -print -depth | cpio -o > /nas/.cpio
# zoneadm –z attach <thezone>
# zoneadm –z boot <thezone>
Mount your cdrom,
create /etc/yum.repos.d/local.repo , with contents:
[local]
name=cdrom
baseurl=file:///mnt/cdrom
then just “yum search” and “yum install”
if you want to know what kernel module your network interfaces use, you can use “getdriver.ksh”:
#!/bin/bash
ifconfig -a | egrep -i 'wlan|eth' | egrep -v 'vbox|mon'| awk '{ print $1 }'|while read i;do
echo -n "$i : "
readlink /sys/class/net/$i/device/driver| awk -F'/' '{ print $NF }'
done
the output is something like this:
root@kraftek:~# /scripts/getdriver
eth0 : atl1c
wlan0 : carl9170
wlan1 : brcmsmac
cfgadm -al | grep -i fabric | awk '{ print $1 }' | xargs cfgadm -c configure
devfsadm -C
format < /dev/null | egrep -i 'emc|dgc|hit|netapp'
ls /sys/class/fc_host/ | while read h;do echo $h echo 1 > /sys/class/fc_host/$h/issue_lip echo "- - -" > /sys/class/scsi_host/$h/scan done
We have a formula for shifts and a list of people, we need to fill a calendar with them.
These are the iterations for each week “formula.txt”, each row is a week, the first value is the iteration number, the other 4 values in the row are the number for a team member, these iterations are the sequence of combinations so that people are not oncall too frequently:
1 1 2 3 4
2 5 6 7 8
3 4 3 2 1
4 8 7 6 5
5 2 1 4 3
6 6 5 8 7
7 3 4 1 2
8 7 8 5 6
the numbers for the team members are in “roster.txt”:
1 FFlinstone XXJA01
2 Jdoe XXJD02
3 OOsbourne XXHR01
4 AHitchcock XXDD02
5 ARose XXAW04
6 EAPoe XXFP01
7 ACooper XXBC06
8 BJovi XXSL01
this is “oncall.ksh”
#!/bin/bash
start_date=20120604
end_date=20120902
formula_current_row=5
formula_rows=8
get_roster()
{
for p in `grep ^$1 formula.txt | awk ‘{ print $2″ “$3” “$4” “$5 }’`;do
echo -n “`grep ^$p roster.txt|awk ‘{ print $3″ ” }’`”
done
echo “”
}
get_weekend_roster()
{
for p in `grep ^$1 formula.txt | awk ‘{ print $2″ “$3” “$2” “$3 }’`;do
echo -n “`grep ^$p roster.txt|awk ‘{ print $3″ ” }’`”
done
echo “”
}
get_oncall()
{
tmpw=0
W=`date -d “$start_date $tmpw day” +”%W”`
for ((tmpw = 0; $(date -d “$start_date $tmpw day” +%s) <= $(date -d “$end_date” +%s); tmpw += 1))
do
P=$W
W=`date -d “$start_date $tmpw day” +”%W”`
if [ “$P” != “$W” ];then
let formula_current_row+=1
if [ $formula_current_row -gt $formula_rows ];then
formula_current_row=1
fi
fi
D=`date -d “$start_date $tmpw day” +”%Y-%m-%d %a%t”`
ISWEEKEND=`echo $D|egrep -i ‘sat|sun’|wc -l`
echo -n “$D ”
if [ $ISWEEKEND -gt 0 ];then
get_weekend_roster $formula_current_row
else
get_roster $formula_current_row
fi
done
}
generate_sql()
{
echo “use OnCall;”
get_oncall | while read l;do
ISWEEKEND=`echo $l|egrep -i ‘sat|sun’|wc -l`
if [ $ISWEEKEND -gt 0 ];then
echo $l | awk ‘{ print “insert into Detail (Date,Shift_C1_Pri,Shift_C1_Sec) values (“”$1″”,””$3″”,””$4″”) on DUPLICATE KEY UPDATE Shift_C1_Pri=””$3″”,Shift_C1_Sec=””$4″”;” }’
else
echo $l | awk ‘{ print “insert into Detail (Date,Shift_A1_Pri,Shift_A1_Sec,Shift_A2_Pri,Shift_A2_Sec) values (“”$1″”,””$3″”,””$4″”,””$5″”,””$6″”) on DUPLICATE KEY UPDATE Shift_A1_Pri=””$3″”,Shift_A1_Sec=””$4″”,Shift_A2_Pri=””$5″”,Shift_A2_Sec=””$6″”;” }’
fi
done
}
get_oncall
generate_sql > from_${start_date}_to_${end_date}.sql
Again another basic tivoli thing… in solaris TSM logs are at:
/var/tivoli