You are here

alp's notes - Alexander Pyhalov

What is my sftp server doing?

Sat, 10/20/2018 - 22:28
Well, I'm not familiar with DTrace, but sometimes want to find, what some application is doing. In this case I wanted to monitor my sftp server. Luckily, most illumos distributions provide dtrace patch (coming from Oracle Solaris) to find this out. Unluckily, I haven't found any documentation on it, just source code. After reading Translators chapter of DTrace Guide and looking at /usr/lib/dtrace/sftp.d I've come to this:
dtrace -n 'sftp*:::transfer-done { printf ("%d: %s %s %s %d", pid, xlate <sftpinfo_t *>((sftpproto_t*)arg0)->sfi_pathname, xlate <sftpinfo_t *>((sftpproto_t*)arg0)->sfi_user, xlate <sftpinfo_t *>((sftpproto_t*)arg0)->sfi_operation, xlate <sftpinfo_t *>((sftpproto_t*)arg0)->sfi_nbytes ); }'

dtrace: description 'sftp*:::transfer-done ' matched 8 probes
CPU ID FUNCTION:NAME
1 80412 process_read:transfer-done 7409: /export/home/user/1.pp user read 1808
1 80412 process_read:transfer-done 7409: /export/home/user/1.pp user read 0
1 80411 process_write:transfer-done 7409: /export/home/user/1.pp user write 1808
1 80412 process_read:transfer-done 7409: /export/home/user/dtrace/poll.d user read 53
1 80412 process_read:transfer-done 7409: /export/home/user/dtrace/poll.d user read 53

Seems rather interesting to me.
Categories: OpenIndiana

Quest: creating one hundred zones

Thu, 08/30/2018 - 16:46
Well, I need to create about one hundred zones once again. You could probably use ansible for this, but an old-fashioned man will do everything in shell. So: we have one "golden image" and have to create 100 zones like it. We could clone it, but with clones you receive wonderful issue - beadm activate fails in zone. So we create zones and do send/receive manually. This looks like this:
#!/bin/bash
set -e

for i in $(seq 1 100); do

#Creating interface for the zone
dladm create-vnic -l e1000g1 hnet$i

#Creating initial config

TEMPFILE=$(mktemp /tmp/XXXXXXXXXXXXXXXXXX)
cat > $TEMPFILE <<EOF
create -b
set zonepath=/zones/h$i
set autoboot=true
set ip-type=exclusive
add net
set physical=hnet$i
end
add capped-memory
set physical=2G
end
add rctl
set name=zone.max-swap
add value (priv=privileged,limit=2147483648,action=deny)
end
add rctl
set name=zone.max-locked-memory
add value (priv=privileged,limit=536870912,action=deny)
end
EOF

zonecfg -z h$i -f $TEMPFILE
zfs send -R data/zones/h0@initial | zfs recv -F data/zones/h$i

# Zone tools should know that zone is in installed state, not configured
# Also during installation zoneadm assigns uuid to zone (last field). We do this manually.
uuid=$(uuidgen)
gsed -i -e "/^h${i}:/ s/\$/${uuid}/" -e "/^h${i}:/ s/configured/installed/" /etc/zones/index
zoneadm -z h$i mount

# We known that golden image ip address ends in 254 and change it
addr=$((1+$i))
sed -i -e "s:hnet0:hnet$i:g" -e "s:\.254:.$addr:g" /zones/h$i/root/etc/ipadm/ipadm.conf
zoneadm -z h$i unmount
zfs destroy data/zones/h$i@initial
rm $TEMPFILE
zoneadm -z h$i boot
done
Seems
Categories: OpenIndiana