Re: Q: What instances have I?
Posted in 1997
}From: rferdy@kuwait.net (Rudy Fernandes)
}Date: Sun, 13 Apr 97 07:13:45 GMT
}X-Informix-List-Id: <news.36504>
}
}In article <860693229.16150@dejanews.com>, science@raptor.cqi.com wrote:
}>How does one find information about various instances that exist on one's
}>machine? Specifically, say you go up to a new (to you) machine and want
}>to answer the question, "What are my instances, and what are their
}>configurations?" I'm having a little problem with this.
}>
}>For example, one can set the INFORMIXSERVER variable, then run "onstat
}>-c", but if the ONCONFIG variable is not set, it always gives the contents
}>of $INFORMIXDIR/etc/onconfig. If you set the ONCONFIG variable to
}>something that does not correspond to the true configuration file
}>associated with the INFORMIXSERVER setting, onstat will duly give you the
}>information associated with the ONCONFIG setting. And one can't rely on
}>using, say, "grep '^DBSERVERNAME' $INFORMIXDIR/etc/* | grep
}>$INFORMIXSERVER" because several files like this might exist in that
}>directory.
}>
}>Also, the instance files in $INFORMIXDIR/etc/.infos.* don't appear to be
}>guaranteed accurate, either. These could be wiped out (the DBA Guide,
}>vol. 2 tells how to regenerate *one* for a given INFORMIXSERVER), and the
}>documentation also says that when an instance is taken offline, this file
}>is removed.
}>
}
}Hi Charlie,
}
}To get a list of instances on the server, you can, as suggested by
}Peter, use information in the $INFORMIXDIR/etc/sqlhosts file. The
}following script will give you a list of instances and indicate
}which ones are on-line.
}
}:
}for SERVER in `cat $INFORMIXDIR/etc/sqlhosts | grep -v '^#' | \\
} awk '{print $1}'`
}do
} INFORMIXSERVER=$SERVER
} export INFORMIXSERVER
} STATUS=`onstat -p | sed -n '2p' | cut -b 39-45`
} echo $SERVER $STATUS
}done
}
}It still doesn't tell you the configuration of the instance, but
}there's hope yet. In the script above, if you remove the 2 lines
}related to STATUS and replace them by a single line as below
}
} onmonitor
}
}you end up running onmonitor (obviously!). If you now use the
}configuration option to output the SERVER's configuration to
}a file, you get
Hi,
I've got several comments.
First, 'onstat -c' prints the current configuration file, so there's no
need to go to onmonitor.
Secondly, you can simply export the value of INFORMIXSERVER for the
specific command:
INFORMIXSERVER=$SERVER STATUS=`onstat -p | sed -n '2p' | cut -b 39-45`
The 'cut' command quoted isn't perfect because you can get longer messages
if a check point is requested, for instance. I'd replace the sed/cut
combination with an extended sed command which picks up all the text
between the first two double-dashes on the status line output.
INFORMIXSERVER=$SERVER STATUS=`onstat -p | sed -n -e '2s/.*-- \\(.*\\) -- Up.*/\\1/p'`
Thirdly, the command sequence only works if all the servers are using the
same INFORMIXDIR. If you have different versions of Informix-OnLine
installed with different values of INFORMIXDIR (as I do), then it only
works for one value of INFORMIXDIR. If you have multiple possible values
for INFORMIXDIR, you have to know what they are to get the server
configurations. (I do have a single sqlhosts file with multiple links to
it so that each INFORMIXDIR sees the same set of entries in the sqlhosts
file, but this is no help.) I don't have a general solution for this
problem. I have a rigid set of conventions which allows me to track the
various instances of OnLine, but nothing that would work on all machines
for all versions of OnLine, nor anything like it.
Fourthly, the command doesn't restrict its search to OnLine systems on the
local machine. You'd probably want to grep for configurations on this
machine only, probably using just awk to replace cat+grep+awk:
: ${INFORMIXSQLHOSTS:=${INFORMIXDIR:-/usr/informix}/etc/sqlhosts}
host=`uname -n`
for SERVER in `awk '$3 ~ /'"$host"'/ && $0 !~ /^#/ { print $1; }' ${INFORMIXSQLHOSTS}`
Fifthly, this doesn't find OnLine configurations which are not currently
running.
I'm not sure how general the problems of the multiple-INFORMIXDIRs and
non-running OnLine instances are -- they would affect your search for
OnLine instances on my machine (seven instances of OnLine, only two
running, each with their own INFORMIXDIR).
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>