Something interesting i spotted on Karansbir’s blog:
Running dstat normally gives you something like this :
# dstat --nocolor
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
3 0 97 0 0 0| 820k 456k| 0 0 | 800B 866B|1054 255
And you can split the disk metrics up based on devices using something like this :
# dstat -D sda,sdb,total --nocolor
----total-cpu-usage---- --dsk/sda-- --dsk/sdb-- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read writ: read writ: read writ| recv send| in out | int csw
1 1 97 0 0 0| 176k 77k: 30k 162k: 411k 478k| 0 0 |3608B 4005B|1447 1458
33 2 63 0 1 2| 0 0 : 0 216k: 0 432k|2470k 1611k| 0 0 |2915 6967
31 2 65 0 1 1| 0 0 : 0 0 : 0 0 |2210k 1338k| 0 0 |2866 6051
But you can also get deeper level device names / nodes to measure – which is required in many cases if you have drivers for storage creating nodes further down the tree than /dev. Eg. I have a setup where there are four mysql instances running, each with its own dedicated storage :
# mount | grep srv
/dev/cciss/c0d1 on /var/lib/mysql/node1 type ext3 (rw)
/dev/cciss/c0d2 on /var/lib/mysql/node2 type ext3 (rw)
/dev/cciss/c0d3 on /var/lib/mysql/node3 type ext3 (rw)
/dev/cciss/c0d4 on /var/lib/mysql/node4 type ext3 (rw)
/dev/cciss/c0d5 on /srv/wal type ext3 (rw)
so in this case, to get dstat reporting working you need to mention just the component level, like this :
# dstat -D cciss/c0d1,cciss/c0d2,cciss/c0d3 --nocolor
----total-cpu-usage---- dsk/cciss/c dsk/cciss/c dsk/cciss/c -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read writ: read writ: read writ| recv send| in out | int csw
3 0 97 0 0 0| 209k 89k: 201k 86k: 204k 85k| 0 0 | 799B 865B|1055 256
90 1 8 1 0 0|3196k 68k: 764k 0 : 816k 24k|1067k 1650k| 0 0 |1999 609
95 1 3 1 0 0|2548k 0 : 0 4084k:2448k 5700k| 660k 791k| 0 0 |1611 571
96 1 2 1 0 0|2628k 0 : 808k 0 :1620k 0 | 352k 798k| 0 0 |1835 1605
And you get the details, for each block device.
Categories: Desktop, Linux, Servers, Virtualization Tags: CentOS, Debian, Desktop, Fedora, Linux, Red Hat, Servers, USB, Virtualization
Your aim
You want to use Linux and OpenSSH to automize your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. You don’t want to enter any passwords, because you want to call ssh from a within a shell script.
How to do it
First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:
a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):
a@A:~> ssh b@B mkdir -p .ssh
b@B's password:
Finally append a’s new public key to b@B:.ssh/authorized_keys and enter b’s password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:
From now on you can log into B as b from A as a without password:
a@A:~> ssh b@B hostname
B
A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:
- Put the public key in .ssh/authorized_keys2
- Change the permissions of .ssh to 700
- Change the permissions of .ssh/authorized_keys2 to 640
The first test build of the upcoming Fedora 11 is out: “The Fedora project is proud to present the availability of Fedora 11 (Leonidas) Alpha. The Alpha release provides the first opportunity for the wider community to become involved with testing Fedora 11 by way of Rawhide.” Some of the more interesting features of this release include: “Windows Cross Compiler (mingw32-*); ext4 and Btrfs file systems, mew volume control; PackageKit firmware support; GNOME 2.26 development snapshot, KDE 4.2 RC 2 and Xfce 4.6 Beta; NetBeans 6.5, Python 2.6, Git 1.6.1.1.” Read the release announcement and release notes for more information.
Download the installable live CD images from these Fedora mirrors or via BitTorrent: F11-Alpha-i686-Live.iso (636MB, SHA1, torrent), F11-Alpha-i686-Live-KDE.iso (698MB, SHA1, torrent), F11-Alpha-x86_64-Live.iso (641MB, SHA1, torrent),F11-Alpha-x86_64-Live-KDE.iso (703MB, SHA1, torrent).