New script to report file systems
[gnucomo.git] / scripts / report_filesystems
1 #!/bin/bash
2 #
3 # Gnucomo filesystems report.
4 #
5 # Create a parameter report with the usage of all file systems.
6
7
8
9 OS=`uname`
10 if test $OS = 'Linux' ; then
11    HOST=`hostname --fqdn`
12 elif test $OS = 'SunOS' ; then
13    HOST=`hostname`
14 fi
15
16 TIME=`date`
17
18 echo "<?xml version='1.0'?>"
19 echo "<gcmt:message xmlns:gcmt='http://gnucomo.org/transport/'>"
20 echo "  <gcmt:header>"
21 echo "      <gcmt:messagetype>XML</gcmt:messagetype>"
22 echo "      <gcmt:hostname>$HOST</gcmt:hostname>"
23 echo "      <gcmt:time>$TIME</gcmt:time>"
24 echo "   </gcmt:header>"
25 echo "   <gcmt:data>"
26
27 echo "   <gcmt:parameters gcmt:class='filesystem'>"
28
29 df -lPk -x devtmpfs -x tmpfs|tail --lines=+2 | while read DEVICE BLOCKS USED AVAILABLE CAPACITY MOUNTPOINT
30 do
31       echo "<gcmt:parameter name='$MOUNTPOINT'>"
32       echo "   <gcmt:property name='device'>$DEVICE</gcmt:property>"
33       echo "   <gcmt:property name='size'>$BLOCKS</gcmt:property>"
34       echo "   <gcmt:property name='used'>$USED</gcmt:property>"
35       echo "   <gcmt:property name='available'>$AVAILABLE</gcmt:property>"
36       echo "</gcmt:parameter>"
37 done
38
39 df -lPi -x devtmpfs -x tmpfs|tail --lines=+2 | while read DEVICE INODES IUSED IFREE CAPACITY MOUNTPOINT
40 do
41       echo "<gcmt:parameter name='$MOUNTPOINT'>"
42       echo "   <gcmt:property name='device'>$DEVICE</gcmt:property>"
43       echo "   <gcmt:property name='Inodes'>$INODES</gcmt:property>"
44       echo "   <gcmt:property name='Iused'>$IUSED</gcmt:property>"
45       echo "   <gcmt:property name='Ifree'>$IFREE</gcmt:property>"
46       echo "</gcmt:parameter>"
47 done
48
49 echo "    </gcmt:parameters>"
50 echo "   </gcmt:data>"
51 echo "</gcmt:message>"