From 9099841ab14a5119aa0d601ab43ef05e3561cbc1 Mon Sep 17 00:00:00 2001 From: arjen Date: Wed, 21 Nov 2007 15:34:12 +0000 Subject: [PATCH] Scripts for collecting data on Gnucomo clients. --- scripts/gnucomo_report | 32 +++++++++++++++++++++++++++ scripts/ls-rpm | 55 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/package-debian | 39 +++++++++++++++++++++++++++++++++ scripts/package-solaris | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ scripts/pkg-solaris.awk | 4 ++++ scripts/sgi-rpm | 5 +++++ scripts/systemload | 35 +++++++++++++++++++++++++++++ 7 files changed, 228 insertions(+) create mode 100755 scripts/gnucomo_report create mode 100755 scripts/ls-rpm create mode 100755 scripts/package-debian create mode 100755 scripts/package-solaris create mode 100644 scripts/pkg-solaris.awk create mode 100755 scripts/sgi-rpm create mode 100755 scripts/systemload diff --git a/scripts/gnucomo_report b/scripts/gnucomo_report new file mode 100755 index 0000000..b41e7bd --- /dev/null +++ b/scripts/gnucomo_report @@ -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 index 0000000..139973c --- /dev/null +++ b/scripts/ls-rpm @@ -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 index 0000000..445de50 --- /dev/null +++ b/scripts/package-debian @@ -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 "" +echo "" +echo " " +echo " package list" +echo " $HOST" +echo " $TIME" +echo " " +echo " " + +echo " " + +COLUMNS=180 +export COLUMNS + +dpkg -l | grep '^ii' | sed -e 's/&/&/' | while read FLAGS PACKAGE VERSION DESCRIPTION +do + echo "" + echo " $DESCRIPTION" + echo " $VERSION" + echo "" +done + + +echo " " +echo " " +echo "" + diff --git a/scripts/package-solaris b/scripts/package-solaris new file mode 100755 index 0000000..d79fdad --- /dev/null +++ b/scripts/package-solaris @@ -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 "" +echo "" +echo " " +echo " package list" +echo " $HOST" +echo " $TIME" +echo " " +echo " " + +echo " " + +pkginfo -l|awk -f $FILTER |sed -e 's/&/&/' + +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 "" + echo " Solaris patch $PREV_PATCH" + echo " $PREV_VERSION" + echo "" + fi + PREV_PATCH=$PATCH + PREV_VERSION=$VERSION +done < /tmp/patchlist.$$ + +tail -1 /tmp/patchlist.$$ >/tmp/patchtail.$$ +read PATCH VERSION " +echo " Solaris patch $PATCH" +echo " $VERSION" +echo "" + +echo " " +echo " " +echo "" + +rm /tmp/patchlist.$$ +rm /tmp/patchtail.$$ + diff --git a/scripts/pkg-solaris.awk b/scripts/pkg-solaris.awk new file mode 100644 index 0000000..92cac93 --- /dev/null +++ b/scripts/pkg-solaris.awk @@ -0,0 +1,4 @@ +/PKGINST:/ { OFS=""; print ""; OFS=" " } +/DESC:/ { $1=""; print " ", $0, "" } +/VERSION:/ { OFS=""; print " ", $2, ""; OFS=" " } +/^$/ { print "" } diff --git a/scripts/sgi-rpm b/scripts/sgi-rpm new file mode 100755 index 0000000..0cc043a --- /dev/null +++ b/scripts/sgi-rpm @@ -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 index 0000000..8363466 --- /dev/null +++ b/scripts/systemload @@ -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 "" +echo "" +echo " " +echo " XML" +echo " $HOST" +echo " $TIME" +echo " " +echo " " + +echo " " + +PROCESSES=`ps ax|wc -l|awk ' {print $1}'` +LOADAV=` uptime|awk ' { print $11 }' | tr -d ,` + +echo "" +echo " System processing load" +echo " $PROCESSES" +echo " $LOADAV" +echo "" + +echo " " +echo " " +echo "" -- 2.11.0