Program: SERVERinfo.ksh
This script gathers server information from
each AIX server and inserts this information into
the CMDB database.
Usage: SERVERinfo.ksh [-v] [-a] [-m machineName]
Where '-v' = Verbose mode.
'-a' = Gather server information from all
servers defined in the CMDB Server table
whose Operating System is defined as AIX.
'-m' = Requires a single argument specifying
the IP name of a machine from which to
gather server information.
"AutoContent" enabled
Description:
This program gathers server information from AIX
servers, builds the appropriate SQL statements, then deletes
and inserts records into the MYSQL CMDB test database running
on mtxdoc.mtxia.com
The information gathered includes operating system name,
OS version, and OS maintenance level.
Assumptions:
This program assumes there is a script called "tsql.sh" in
the current directory. This script is expected to accept SQL
statements through standard input and perform all MSSQL database
communications.
The database table Server02 is assumed to already exist in the
MSSQL database and is configured appropriately to accept the
following fields -
Server02: name, osname, osversion, oslevel
See the database schema for further explanation of these fields.
Dependencies:
This script uses "rsh" to run commands on each machine that
generate the server information. The user running this
script must have "rsh" access to all machines for which this
script will be executed.
The output of the MSSQL SQL processor is a specific format and
this script is expecting the data to exist in that format. If
the SQL processor is changed, this script must be modified to
correctly interpret the output from the SQL processor.
Products:
The product of this script is a list of SQL statements to
update the CMDB Server02 table. The CMDB database is NOT
modified as a result of this script. The SQL statements
generated by this script must be executed by a separate
SQL processor.
Configured Usage:
This script is designed to be executed from the command line
or scheduled as a background process.
Details:
Build a command to be executed on each remote machine
via "rsh" This command will generate a series of shell
variable assignment that will contain values representing the
current configuration of the server.
This script is currently configured to be executed from
a specific machine in a specific directory i.e.
mtxdoc:/home/french/mysql
This will be changed in future iterations of the script, but
for now thats just the way it is.
Check to see if the user identified a specific machine
from which to gather user and group information, or
requested the script to run gather infor for all machines.
Depending upon what the user specified, the server name
and database record number for each server is selected from
the database and output to a temporary file.
Read each server ID number and server name from the temporary
file.
Unset the shell variable containing the configuration values
of the server to ensure values from previous iterations of
the loop are not carried forward.
A ping test is performed to determine if the target machine
is network accessible. If it can not be pinged, it is skipped.
If the ping test is successful, the previously built command
command is executed on the remote machine. The result of
the command is a series of korn shell variable assignments.
These statements are redirected to a temporary file and the
temporary file will be execute to perform the assignments.
The 'rsh' command is performed in the background and this
script is told to sleep for 10 seconds while the rsh command
is executing. After 10 seconds, if the rsh command is
still executing, it is assumed to be hung and killed. If
the rsh command was hung, no update command is issued since
no values were returned.
Gather a list of all grandchild processes so they may also
be killed if necessary.
If the 'rsh' command does not return after 10 seconds, assume
it is hung and kill the process. Also kill all grandchild
processes associated with this 'rsh' child process.
If the rsh command was successful, make the temporary file,
containing the korn shell variable assignments, executable
and execute it in the current shell environment.
If after the temporary file is executed the shell variable
'SERVNAME' contains a value, generate an SQL command to
update the CMDB with the new values associated with the server.
Continue with the next iteration of the loop which goes to
the next server in the list.
Cleanup any temporary files
This file last modified 11/02/10
|