New script to report file systems
[gnucomo.git] / scripts / report_filesystems
diff --git a/scripts/report_filesystems b/scripts/report_filesystems
new file mode 100755 (executable)
index 0000000..630d3a7
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Gnucomo filesystems report.
+#
+# Create a parameter report with the usage of all file systems.
+# 
+
+
+OS=`uname`
+if test $OS = 'Linux' ; then
+   HOST=`hostname --fqdn`
+elif test $OS = 'SunOS' ; then
+   HOST=`hostname`
+fi
+
+TIME=`date`
+
+echo "<?xml version='1.0'?>"
+echo "<gcmt:message xmlns:gcmt='http://gnucomo.org/transport/'>"
+echo "  <gcmt:header>"
+echo "      <gcmt:messagetype>XML</gcmt:messagetype>"
+echo "      <gcmt:hostname>$HOST</gcmt:hostname>"
+echo "      <gcmt:time>$TIME</gcmt:time>"
+echo "   </gcmt:header>"
+echo "   <gcmt:data>"
+
+echo "   <gcmt:parameters gcmt:class='filesystem'>"
+
+df -lPk -x devtmpfs -x tmpfs|tail --lines=+2 | while read DEVICE BLOCKS USED AVAILABLE CAPACITY MOUNTPOINT
+do
+      echo "<gcmt:parameter name='$MOUNTPOINT'>"
+      echo "   <gcmt:property name='device'>$DEVICE</gcmt:property>"
+      echo "   <gcmt:property name='size'>$BLOCKS</gcmt:property>"
+      echo "   <gcmt:property name='used'>$USED</gcmt:property>"
+      echo "   <gcmt:property name='available'>$AVAILABLE</gcmt:property>"
+      echo "</gcmt:parameter>"
+done
+
+df -lPi -x devtmpfs -x tmpfs|tail --lines=+2 | while read DEVICE INODES IUSED IFREE CAPACITY MOUNTPOINT
+do
+      echo "<gcmt:parameter name='$MOUNTPOINT'>"
+      echo "   <gcmt:property name='device'>$DEVICE</gcmt:property>"
+      echo "   <gcmt:property name='Inodes'>$INODES</gcmt:property>"
+      echo "   <gcmt:property name='Iused'>$IUSED</gcmt:property>"
+      echo "   <gcmt:property name='Ifree'>$IFREE</gcmt:property>"
+      echo "</gcmt:parameter>"
+done
+
+echo "    </gcmt:parameters>"
+echo "   </gcmt:data>"
+echo "</gcmt:message>"