This blog contains experience gained over the years of implementing (and de-implementing) large scale IT applications/software.

HowTo: Script ASE Configuration Check

Maybe you have lots of ASE database instances and you would like to ensure that they are all in alignment with regards to configuration.

In this post I show how to output a generic line of text for each configuration line in the ASE <SID>.cfg file.
The line includes the following items:

  • The filename (e.g. <SID>.cfg)
  • The section name of the file (e.g. [somesection])
  • The name of a parameter within the section.
  • The value of the parameter.

The output is in this format:
<filename>:<section>~<parameter> = <value>

This allows you to combine multiple ASE instance configuration files into a single log file, which can then either be downloaded into Excel for value comparison across the landscape or you can use tools such as “grep” to compare individual parameters.

The Process

First you need to gather up all the configuration files from across your landscape and place them all in one directory:

<SID1>.cfg
<SID2>.cfg
etc

For the above, I can recommend a custom operation via HostAgent and either a website with upload capability, an FTP site, SCP script, shared NFS location or some other common shared area where you can upload the files from each server.

Now we execute the code against the directory where the configuration files have been collected.

Switch to bash or ksh:

ksh

Run the code (change “your_dir” for your config files location):

ls -1 /your_dir/???.cfg | while read file 
do 
   awk '/^\[/ { print $0 }' $file | sort | while read line 
   do 
      awk -v input="$line" '{ if ( $0 == input ) { getline; while ( $0 !~ /^\[/ ) { if(match($0,/\t(.*)$/,aval)) { if (length(lval)>0){ lval=lval"\n" }; lval=lval""FILENAME":"input"~"aval[1] }; if (! getline) break; }}}END{if (lval) print lval}' $file 
   done 
done

This will list all output to the screen.
To make it go to a new file, append “ > newfile.log” to the very end like this:

...
   done 
done > newfile.log

You will see inside the newfile.log, that you have a great file format for use with “grep“, and can query the value of parameters like so:

NOTE: Replace “<section>” and “<parameter>” with your query values.

grep ':<section>~<parameter> ='  newfile.log

The above will list all matching parameters in a specific section, for each of the ASE instances, for comparison on the screen.
You can use this information to align parameters across your landscape or just as a configuration check.


Add Your Comment

* Indicates Required Field

Your email address will not be published.

*