|
Packit |
667938 |
======================================
|
|
Packit |
667938 |
DiskMon (getdisk.pl and showdisk.pl)
|
|
Packit |
667938 |
======================================
|
|
Packit |
667938 |
by Steven Micallef <smic@wire.net.au>
|
|
Packit |
667938 |
|
|
Packit |
667938 |
---------------
|
|
Packit |
667938 |
What they do
|
|
Packit |
667938 |
---------------
|
|
Packit |
667938 |
|
|
Packit |
667938 |
getdisk.pl and showdisk.pl work on the client/server principal.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
showdisk.pl - runs off the 'server' displaying disk partition % used.
|
|
Packit |
667938 |
getdisk.pl - runs off the 'client' and connects to the 'server' to get disk
|
|
Packit |
667938 |
info off showdisk.pl.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
-------------------
|
|
Packit |
667938 |
Before you begin
|
|
Packit |
667938 |
-------------------
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Before you Install, you need the following:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
- Perl
|
|
Packit |
667938 |
- Net::Telnet Perl Module.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
You can get this straight from:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
ftp.oleane.net/pub/CPAN/mirrors/modules/by-module/Net/Net-Telnet-3.01.tar.gz
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
-------------
|
|
Packit |
667938 |
Installation
|
|
Packit |
667938 |
-------------
|
|
Packit |
667938 |
|
|
Packit |
667938 |
The following steps apply to EACH MACHINE YOU WANT TO MONITOR...
|
|
Packit |
667938 |
|
|
Packit |
667938 |
1. Copy the showdisk.pl script to the host you wish to monitor.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
2. In your /etc/inetd.conf, insert the line:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
df stream tcp nowait root <path of your TCP wrapper> <path of showdisk.pl>
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Of course, the TCP wrapper isn't mandatory, but if you want to restrict access
|
|
Packit |
667938 |
to the viewing of free disk space, I really recommend you install it.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
3. In your /etc/services file, put in the following line:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
df 9047/tcp
|
|
Packit |
667938 |
|
|
Packit |
667938 |
The port you choose is up to you, but if you do change it from 9047, be sure
|
|
Packit |
667938 |
to update getdisk.pl too (the port number is specified in the first few lines
|
|
Packit |
667938 |
of the script).
|
|
Packit |
667938 |
|
|
Packit |
667938 |
4. kill -HUP your inetd
|
|
Packit |
667938 |
|
|
Packit |
667938 |
5. Test it by telnetting to the host at port 9047. You should get the
|
|
Packit |
667938 |
following:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
bash~# telnet hostname 9047
|
|
Packit |
667938 |
< usual connect messages >
|
|
Packit |
667938 |
30
|
|
Packit |
667938 |
40
|
|
Packit |
667938 |
10
|
|
Packit |
667938 |
20
|
|
Packit |
667938 |
.
|
|
Packit |
667938 |
.
|
|
Packit |
667938 |
etc..
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Of course, the output depends on
|
|
Packit |
667938 |
a) how many disks are on the machine, and
|
|
Packit |
667938 |
b) how much space in % is used on each disk.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
If you didn't get any output, go back and make sure you did everything
|
|
Packit |
667938 |
properly.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
--------------------------------
|
|
Packit |
667938 |
Setting up getdisk.pl with MRTG
|
|
Packit |
667938 |
--------------------------------
|
|
Packit |
667938 |
|
|
Packit |
667938 |
The getdisk.pl script runs like so:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
./getdisk.pl <hostname> <disk number>
|
|
Packit |
667938 |
|
|
Packit |
667938 |
For example, doing a ./getdisk sparky 1 will show how much % of the first
|
|
Packit |
667938 |
partition (usually the root partition) on sparky is used.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
So how do you map a number to a partition?
|
|
Packit |
667938 |
On the host you installed showdisk.pl on, do the following:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
bash~# df -k
|
|
Packit |
667938 |
Filesystem 1024-blocks Used Available Capacity Mounted on
|
|
Packit |
667938 |
/dev/hda1 202222 78786 112993 41% /
|
|
Packit |
667938 |
/dev/hdc3 2486311 1247138 1110635 53% /usr
|
|
Packit |
667938 |
/dev/hdc1 1486150 375570 1033782 27% /backup
|
|
Packit |
667938 |
^
|
|
Packit |
667938 |
The first disk is 1, the second 2, and so on.. |
|
|
Packit |
667938 |
Example: |
|
|
Packit |
667938 |
bash~# ./getdisk.pl hostname 3 |
|
|
Packit |
667938 |
27 <-------------------------------------'
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Please look at sample.cfg to see how to setup getdisk.pl with MRTG.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
---
|
|
Packit |
667938 |
I hope this is as useful to you as it has been to me. If you have any
|
|
Packit |
667938 |
problems/bug reports/advice/complaints, email me.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Enjoy.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Steven Micallef
|
|
Packit |
667938 |
<smic@wire.net.au>
|