Running a check platform script

Hi,

I want to run a check platform & application script under ksh (Soaris boxes).
It runs some commands and it take some time.
I want to customize it like that:

  • output is too big, hence I want some output of the commands to be redirect
    ed in an output file (or maybe two or three) - not all just a part of them
    & commands alternate by execution order
  • I want to run it in bg only when I want to allow some
    other jobs meanwhile - customize it by params.when it is launched?

Which is the easiest way to implement it?

Thx,

Suppose your script is something like:

#!/usr/bin/ksh

test1
test2
if [ $somevar -eq 5 ]
then
test3
fi

if [ "`hostname`" == "bigserver" ]
then
test4
fi

test5
test6
test7

etc

You can group some part using "{" and "}" and redirect the output for all command withing a group to the same file.

so

#!/usr/bin/ksh
{
test1
test2
} > resultfile1

{
if [ $somevar -eq 5 ]
then
test3
fi

if [ "`hostname`" == "bigserver" ]
then
test4
fi
} > resultfile2

{
test5
test6
test7
} resultfile3

if you want errors included in those files just change e.g.
> resultfile1
into
> resultfile1 2>&1

It works to group some part using "{" and "}" and redirect the output OK but in fact I want both - the output to be displayed and meanwhile to be redirected in some result file running the same command only once.
For some commands I want both for some other not.

Also I want that my script to analyse an output already generated previously - more specific:

After I run a "df -k" command I want that my output of "df -k" to be analysed later in the same script.
I'm interested only in those partitions that starts with "/dev/" or that have a specific name (excluding swap & similar) and if the percentage of the occupied space is greater than some critical value the script must display a NOK and in addition that line from "df -k" again as a warning - otherwise OK.

Does anyone know if this is possible?

{
............
} | tee resultfile

to have output displayed as well as redirected to a file.

If you want to use the out of a command later on the script you either have to store the result in variables or send it to a file and read back this file later on.

The have the result of only specific filesystems is a matter of piping the output of df -k to grep with the right regular expression

If the purpose of this script is to check the system and generate some kind of "alarms" in specific situations you better check out SNMP