From: Arjen Baart Date: Tue, 3 Nov 2020 07:19:59 +0000 (+0100) Subject: New script to report file systems X-Git-Url: http://www.andromeda.nl/gitweb/?p=gnucomo.git;a=commitdiff_plain;h=75ca0e7b8fd01bce97e75dbafc4b2c09c37693b3 New script to report file systems --- diff --git a/scripts/gnucomo_report b/scripts/gnucomo_report index bfc1ee0..9157c8d 100755 --- a/scripts/gnucomo_report +++ b/scripts/gnucomo_report @@ -1,14 +1,24 @@ -#!/bin/sh +#!/bin/bash # # Gnucomo system state report # # Obtain various system parameters and mail # the output to the gnucomo server. -PATH=$PATH:/usr/local/bin +PATH=$PATH:/srv/local/bin:/usr/local/bin +HOST=`hostname --fqdn` + +# Where to mail gnucomo reports to GNUCOMO_ADDRESS=gnucomo@`dnsdomainname` +GNUCOMO_ADDRESS=gnucomo@andromeda.nl +# For direct delivery on this machine +DELIVER="gcm_input -h $HOST" +# For deliver through email +#DELIVER="mail -s 'Gnucomo report' $GNUCOMO_ADDRESS" + OS=`uname` + if test $OS = "Linux"; then if PACKAGER=`which rpm` @@ -19,28 +29,26 @@ if test $OS = "Linux"; then PACKAGER='package-debian' fi - if [ "x$PACKAGER" == x ] + 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 + $PACKAGER | eval $DELIVER + sleep 1 + report_filesystems | eval $DELIVER elif test $OS = "SunOS"; then PACKAGER='package-solaris' - $PACKAGER | mail -s 'Gnucomo package report' $GNUCOMO_ADDRESS - sleep 10 - df -lk -F ufs | mail -s 'Gnucomo filesystem report' $GNUCOMO_ADDRESS + $PACKAGER | eval $DELIVER + sleep 1 + df -lk -F ufs | eval $DELIVER fi sleep 10 -systemload | mail -s 'Gnucomo load report' $GNUCOMO_ADDRESS -sleep 10 -gnucomo_hardware | mail -s 'Gnuicomo hardware report' $GNUCOMO_ADDRESS +systemload | eval $DELIVER +#sleep 10 +#gnucomo_hardware | mail -s 'Gnucomo hardware report' $GNUCOMO_ADDRESS diff --git a/scripts/report_filesystems b/scripts/report_filesystems new file mode 100755 index 0000000..630d3a7 --- /dev/null +++ b/scripts/report_filesystems @@ -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 "" +echo "" +echo " " +echo " XML" +echo " $HOST" +echo " $TIME" +echo " " +echo " " + +echo " " + +df -lPk -x devtmpfs -x tmpfs|tail --lines=+2 | while read DEVICE BLOCKS USED AVAILABLE CAPACITY MOUNTPOINT +do + echo "" + echo " $DEVICE" + echo " $BLOCKS" + echo " $USED" + echo " $AVAILABLE" + echo "" +done + +df -lPi -x devtmpfs -x tmpfs|tail --lines=+2 | while read DEVICE INODES IUSED IFREE CAPACITY MOUNTPOINT +do + echo "" + echo " $DEVICE" + echo " $INODES" + echo " $IUSED" + echo " $IFREE" + echo "" +done + +echo " " +echo " " +echo "" diff --git a/scripts/report_repository.py b/scripts/report_repository.py old mode 100644 new mode 100755 index ae39f15..3ec2e71 --- a/scripts/report_repository.py +++ b/scripts/report_repository.py @@ -1,3 +1,4 @@ +#!/usr/bin/python3 # # Gnucomo repository report. # @@ -99,12 +100,12 @@ def rsplit2(src, sep): # Make sure we have the repository directory as argument. if len(sys.argv) != 2: - print "Usage: ", sys.argv[0], " " + print ("Usage: ", sys.argv[0], " ") sys.exit(1) packages = [] for name in glob.glob(os.path.join(sys.argv[1],"*.rpm")): - pack = rsplit2(os.path.basename(name),".") + pack = os.path.basename(name).rsplit(".",2) if pack[0] != "": packages.append(pack[0]) @@ -116,8 +117,8 @@ previous = "" # Select the latest package in case of duplicates. for name in packages: - p1 = rsplit2(previous,"-") - p2 = rsplit2(name,"-") + p1 = previous.rsplit("-",2) + p2 = name.rsplit("-", 2) if p1[0] == p2[0]: if compare_versions(p1[1], p2[1]) < 0: #print "Skipping old package ", previous @@ -133,4 +134,4 @@ for name in packages: latest_packages.append(previous) for p in latest_packages: - print p + print (p) diff --git a/scripts/systemload b/scripts/systemload index dba2ca4..8a5fef6 100755 --- a/scripts/systemload +++ b/scripts/systemload @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Gnucomo system load report. #