#!/bin/sh
######################################################################
# Copyright (c)  2020 by Oracle Corporation
# zonesub.sh
# This script is called by OSWatcher.sh. This script is the data
# collector shell for zoneinfo. $1 is the output filename for the data
# collector. $2 is the data collector shell script to execute.
# $3 fixes timestamp date to be OSWg compliant.
######################################################################
if [ $3 != 0 ]; then
  echo "zzz ***"`date '+%a %b %e %T %Z %Y'` >> $1
else
  echo "zzz ***"`date` >> $1
fi

  cat /proc/zoneinfo | awk '
   BEGIN{
      ON=0
   }
   {
      if($1 == "Node"){
         if($NF ~ /Normal/){
            ON=1
    print $0;
         }else{
            ON=0
         }
      }else{
         if(ON==1){
            print $0
         }
      }
   }'  | egrep "Node [0-9]*, zone| pages free | min | low | high |
spanned | present | managed " >> $1

rm locks/zonelock.file
