Scripts for collecting data on Gnucomo clients.
authorarjen <arjen>
Wed, 21 Nov 2007 15:34:12 +0000 (15:34 +0000)
committerarjen <arjen>
Wed, 21 Nov 2007 15:34:12 +0000 (15:34 +0000)
scripts/gnucomo_report [new file with mode: 0755]
scripts/ls-rpm [new file with mode: 0755]
scripts/package-debian [new file with mode: 0755]
scripts/package-solaris [new file with mode: 0755]
scripts/pkg-solaris.awk [new file with mode: 0644]
scripts/sgi-rpm [new file with mode: 0755]
scripts/systemload [new file with mode: 0755]

diff --git a/scripts/gnucomo_report b/scripts/gnucomo_report
new file mode 100755 (executable)
index 0000000..b41e7bd
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Gnucomo system state report
+#
+# Obtain various system parameters and mail
+# the output to the gnucomo server.
+
+PATH=$PATH:/usr/local/bin
+GNUCOMO_ADDRESS=gnucomo@andromeda.nl
+
+if PACKAGER=`which rpm`
+then
+   PACKAGER='rpm -qa'
+else
+   if PACKAGER=`which dpkg`
+   then
+      PACKAGER='package-debian'
+   fi
+fi
+
+if [ x$PACKAGER == x ]
+then
+   echo "Packages not available"
+fi
+
+$PACKAGER | mail -s 'Gnucomo package report' $GNUCOMO_ADDRESS
+sleep 10
+df -lPk -x tmpfs | mail -s 'Gnucomo filesystem report' $GNUCOMO_ADDRESS
+sleep 10
+df -lPi -x tmpfs | mail -s 'Gnucomo filesystem report' $GNUCOMO_ADDRESS
+sleep 10
+systemload | mail -s 'Gnucomo load report' $GNUCOMO_ADDRESS
diff --git a/scripts/ls-rpm b/scripts/ls-rpm
new file mode 100755 (executable)
index 0000000..139973c
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+#   Turn an 'ls' listing of RPM files into an 'rpm -qa' listing
+#   Reads a list of filenames, possibly preceeded by a directory and
+#   strips the directory path from the beginning and the two suffices
+#   from the end of each filename. For example, the name
+#   "/mnt/cdrom/RedHat/RPMS/kernel-2.4.20-13.7.i686.rpm" gets turned
+#   into a simple "kernel-2.4.20-13.7".
+#
+#  This is most usefull for maintaining a repository of the most recent
+#  packages. Using this script, you can keep a list of packages in the
+#  Gnucomo database. To do this, create a virtual object, for example
+#  with the name "redhat-7.3" and feed the list of RPM names into gcm_input
+#  like this:
+#
+#   ls /mnt/cdrom/RedHat/RPMS | ls-rpm | sort | uniq | gcm_input -h redhat-7.3
+#
+#  After that, enter the updated RPMs with the -i flag for gcm_input.
+#
+#  Examples:
+#  ls /archive/linux/update9.0/*/*.rpm /archive/linux/latest/RH9/*.rpm | ls-rpm \
+#     | sort | uniq | gcm_input -i -h redhat-9.0
+
+while read filename
+do
+   case $filename in
+   *.src.rpm)
+   ;;
+
+   *)
+      filename=`basename $filename .rpm`
+      case $filename in
+      *.athlon)
+         rpm=`basename $filename .athlon`
+      ;; 
+      *.i386)
+         rpm=`basename $filename .i386`
+      ;; 
+      *.i486)
+         rpm=`basename $filename .i486`
+      ;; 
+      *.i586)
+         rpm=`basename $filename .i586`
+      ;; 
+      *.i686)
+         rpm=`basename $filename .i686`
+      ;; 
+      *.noarch)
+         rpm=`basename $filename .noarch`
+      ;; 
+      esac
+      echo $rpm
+   ;;
+   esac
+done
diff --git a/scripts/package-debian b/scripts/package-debian
new file mode 100755 (executable)
index 0000000..445de50
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# Gnucomo package parameter report.
+#
+# Create a list of packages and patches on a Debian Linux system
+# that can be read by the Gnucomo input program, gcm_input.
+# 
+
+
+HOST=`hostname --fqdn`
+TIME=`date`
+
+echo "<?xml version='1.0'?>"
+echo "<gcmt:message xmlns:gcmt='http://gnucomo.org/transport/'>"
+echo "  <gcmt:header>"
+echo "      <gcmt:messagetype>package list</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='package'>"
+
+COLUMNS=180
+export COLUMNS
+
+dpkg -l | grep '^ii' | sed -e 's/&/&amp;/' | while read FLAGS PACKAGE VERSION DESCRIPTION
+do
+      echo "<gcmt:parameter name='$PACKAGE'>"
+      echo "   <gcmt:description>$DESCRIPTION</gcmt:description>"
+      echo "   <gcmt:property name='version'>$VERSION</gcmt:property>"
+      echo "</gcmt:parameter>"
+done
+
+
+echo "    </gcmt:parameters>"
+echo "   </gcmt:data>"
+echo "</gcmt:message>"
+
diff --git a/scripts/package-solaris b/scripts/package-solaris
new file mode 100755 (executable)
index 0000000..d79fdad
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# Gnucomo package parameter report.
+#
+# Create a list of packages and patches on a Solaris system
+# that can be read by the Gnucomo input program, gcm_input.
+# 
+
+
+HOST=`hostname`
+TIME=`date`
+FILTER=/usr/local/bin/pkg-solaris.awk
+
+echo "<?xml version='1.0'?>"
+echo "<gcmt:message xmlns:gcmt='http://gnucomo.org/transport/'>"
+echo "  <gcmt:header>"
+echo "      <gcmt:messagetype>package list</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='package'>"
+
+pkginfo -l|awk -f $FILTER |sed -e 's/&/&amp;/'
+
+showrev -p | cut -f2 "-d " |sort| tr '-' ' ' > /tmp/patchlist.$$
+read PREV_PATCH PREV_VERSION < /tmp/patchlist.$$
+
+while read PATCH VERSION
+do
+   if [ $PREV_PATCH = $PATCH ]
+   then
+      PREV_VERSION=$VERSION
+   else
+      echo "<gcmt:parameter name='$PREV_PATCH'>"
+      echo "   <gcmt:description>Solaris patch $PREV_PATCH</gcmt:description>"
+      echo "   <gcmt:property name='version'>$PREV_VERSION</gcmt:property>"
+      echo "</gcmt:parameter>"
+   fi
+   PREV_PATCH=$PATCH
+   PREV_VERSION=$VERSION
+done < /tmp/patchlist.$$
+
+tail -1 /tmp/patchlist.$$ >/tmp/patchtail.$$
+read PATCH VERSION </tmp/patchtail.$$
+echo "<gcmt:parameter name='$PATCH'>"
+echo "   <gcmt:description>Solaris patch $PATCH</gcmt:description>"
+echo "   <gcmt:property name='version'>$VERSION</gcmt:property>"
+echo "</gcmt:parameter>"
+
+echo "    </gcmt:parameters>"
+echo "   </gcmt:data>"
+echo "</gcmt:message>"
+
+rm /tmp/patchlist.$$
+rm /tmp/patchtail.$$
+
diff --git a/scripts/pkg-solaris.awk b/scripts/pkg-solaris.awk
new file mode 100644 (file)
index 0000000..92cac93
--- /dev/null
@@ -0,0 +1,4 @@
+/PKGINST:/     { OFS=""; print "<gcmt:parameter name='", $2, "'>"; OFS=" " }
+/DESC:/        { $1="";  print  "   <gcmt:description>", $0, "</gcmt:description>" }
+/VERSION:/     { OFS=""; print "   <gcmt:property name='version'>", $2, "</gcmt:property>"; OFS=" " }
+/^$/           { print "</gcmt:parameter>" }
diff --git a/scripts/sgi-rpm b/scripts/sgi-rpm
new file mode 100755 (executable)
index 0000000..0cc043a
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+HOST=`hostname`.wt.tno.nl
+
+showprods -3 -n|awk '{printf "%s-%s\n",$2,$3}'|grep -v '^[-=]' |grep -v Version-Description
diff --git a/scripts/systemload b/scripts/systemload
new file mode 100755 (executable)
index 0000000..8363466
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# Gnucomo system load report.
+#
+# Create a parameter report with two values:
+# The total number of processes and the 5-min load average.
+# 
+
+
+HOST=`hostname --fqdn`
+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='systemload'>"
+
+PROCESSES=`ps ax|wc -l|awk ' {print $1}'`
+LOADAV=`  uptime|awk ' { print $11 }' | tr -d ,`
+
+echo "<gcmt:parameter name='Load'>"
+echo "   <gcmt:description>System processing load</gcmt:description>"
+echo "   <gcmt:property name='processes'>$PROCESSES</gcmt:property>"
+echo "   <gcmt:property name='runqueue'>$LOADAV</gcmt:property>"
+echo "</gcmt:parameter>"
+
+echo "    </gcmt:parameters>"
+echo "   </gcmt:data>"
+echo "</gcmt:message>"