diff options
Diffstat (limited to 'contrib/diskmon')
| -rw-r--r-- | contrib/diskmon/README | 112 | ||||
| -rw-r--r-- | contrib/diskmon/getdisk.pl | 30 | ||||
| -rw-r--r-- | contrib/diskmon/sample.cfg | 25 | ||||
| -rw-r--r-- | contrib/diskmon/showdisk.pl | 14 |
4 files changed, 181 insertions, 0 deletions
diff --git a/contrib/diskmon/README b/contrib/diskmon/README new file mode 100644 index 0000000..bb428bd --- /dev/null +++ b/contrib/diskmon/README @@ -0,0 +1,112 @@ +======================================
+ DiskMon (getdisk.pl and showdisk.pl)
+======================================
+by Steven Micallef <smic@wire.net.au>
+
+---------------
+What they do
+---------------
+
+getdisk.pl and showdisk.pl work on the client/server principal.
+
+showdisk.pl - runs off the 'server' displaying disk partition % used.
+getdisk.pl - runs off the 'client' and connects to the 'server' to get disk
+ info off showdisk.pl.
+
+
+-------------------
+Before you begin
+-------------------
+
+Before you Install, you need the following:
+
+- Perl
+- Net::Telnet Perl Module.
+
+You can get this straight from:
+
+ftp.oleane.net/pub/CPAN/mirrors/modules/by-module/Net/Net-Telnet-3.01.tar.gz
+
+
+-------------
+Installation
+-------------
+
+The following steps apply to EACH MACHINE YOU WANT TO MONITOR...
+
+1. Copy the showdisk.pl script to the host you wish to monitor.
+
+2. In your /etc/inetd.conf, insert the line:
+
+df stream tcp nowait root <path of your TCP wrapper> <path of showdisk.pl>
+
+Of course, the TCP wrapper isn't mandatory, but if you want to restrict access
+to the viewing of free disk space, I really recommend you install it.
+
+3. In your /etc/services file, put in the following line:
+
+df 9047/tcp
+
+The port you choose is up to you, but if you do change it from 9047, be sure
+to update getdisk.pl too (the port number is specified in the first few lines
+of the script).
+
+4. kill -HUP your inetd
+
+5. Test it by telnetting to the host at port 9047. You should get the
+following:
+
+bash~# telnet hostname 9047
+< usual connect messages >
+30
+40
+10
+20
+.
+.
+etc..
+
+Of course, the output depends on
+a) how many disks are on the machine, and
+b) how much space in % is used on each disk.
+
+If you didn't get any output, go back and make sure you did everything
+properly.
+
+
+--------------------------------
+Setting up getdisk.pl with MRTG
+--------------------------------
+
+The getdisk.pl script runs like so:
+
+./getdisk.pl <hostname> <disk number>
+
+For example, doing a ./getdisk sparky 1 will show how much % of the first
+partition (usually the root partition) on sparky is used.
+
+So how do you map a number to a partition?
+On the host you installed showdisk.pl on, do the following:
+
+bash~# df -k
+Filesystem 1024-blocks Used Available Capacity Mounted on
+/dev/hda1 202222 78786 112993 41% /
+/dev/hdc3 2486311 1247138 1110635 53% /usr
+/dev/hdc1 1486150 375570 1033782 27% /backup
+ ^
+The first disk is 1, the second 2, and so on.. |
+Example: |
+ bash~# ./getdisk.pl hostname 3 |
+ 27 <-------------------------------------'
+
+Please look at sample.cfg to see how to setup getdisk.pl with MRTG.
+
+
+---
+I hope this is as useful to you as it has been to me. If you have any
+problems/bug reports/advice/complaints, email me.
+
+Enjoy.
+
+Steven Micallef
+<smic@wire.net.au>
\ No newline at end of file diff --git a/contrib/diskmon/getdisk.pl b/contrib/diskmon/getdisk.pl new file mode 100644 index 0000000..6c5f124 --- /dev/null +++ b/contrib/diskmon/getdisk.pl @@ -0,0 +1,30 @@ +#!/usr/bin/perl
+# This script is used to establish a TCP connection with a host to get the +# disk info provided by showdisk.pl. +# +# use: ./getdisk.pl <hostname> <disk number> +# +# By Steven Micallef <smic@wire.net.au> on the 24/4/1999. +# Externale bug fixed by Alon Goldberg <pyro@elapsed.net> 27/2/2000. + +use Net::Telnet; + +$hostname = $ARGV[0]; +$disk_no = $ARGV[1]; + +# If you've changed the port showdisk.pl runs on, change it here too. +$port = 9047; + +$i = 0; + +if (!defined($disk_no)) { print "Usage: $0 <hostname> <disk number>\n"; exit } + +$t = new Net::Telnet ( Host => $hostname, Port => $port); +$t->open("$hostname"); + +while ($i ne $disk_no) { + $data = $t->getline(Timeout => 40); + $i++; + print $data, 0, "\n" if $i eq $disk_no; +} + diff --git a/contrib/diskmon/sample.cfg b/contrib/diskmon/sample.cfg new file mode 100644 index 0000000..8dda588 --- /dev/null +++ b/contrib/diskmon/sample.cfg @@ -0,0 +1,25 @@ +Target[hostAdisk]: `/mrtg/getdisk.pl hostA 1`
+Title[hostAdisk]: HostA's Root partition % used
+MaxBytes[hostAdisk]: 100
+PageTop[hostAdisk]: <H1> HostA's Root partition % used </H1>
+Suppress[hostAdisk]: y
+LegendI[hostAdisk]: % used
+LegendO[hostAdisk]:
+Legend1[hostAdisk]: % used
+Legend2[hostAdisk]:
+YLegend[hostAdisk]: percent used
+ShortLegend[hostAdisk]: used
+Options[hostAdisk]: gauge
+
+Target[hostBdisk]: `/mrtg/getdisk.pl hostB 1`
+Title[hostBdisk]: HostB's Root partition % used
+MaxBytes[hostBdisk]: 100
+PageTop[hostBdisk]: <H1> HostB's Root partition % used </H1>
+Suppress[hostBdisk]: y
+LegendI[hostBdisk]: % used
+LegendO[hostBdisk]:
+Legend1[hostBdisk]: % used
+Legend2[hostBdisk]:
+YLegend[hostBdisk]: percent used
+ShortLegend[hostBdisk]: used
+Options[hostBdisk]: gauge
diff --git a/contrib/diskmon/showdisk.pl b/contrib/diskmon/showdisk.pl new file mode 100644 index 0000000..e8f95bf --- /dev/null +++ b/contrib/diskmon/showdisk.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl
+# Displays disk info to the hosts that connect to it.
+#
+# No command line options, just put it in /etc/inetd.conf as shown in
+# the README file.
+#
+# By Steven Micallef <smic@wire.net.au> on the 24/4/1999.
+
+foreach $_ (`df -k | grep -v "Filesystem"`)
+{
+ ($device, $size, $used, $free, $percent, $mount) = split(/\s+/);
+ chop($percent);
+ print "$percent\n";
+}
|
