OpenManage Server Administrator 1.0

Batch Programming with the Command Line Interface

Dell OpenManage™


By Michael O’Hara ()

Jianwen Yin ()

Anil Rao ()

June 2002


Contents

Introduction

Writing Simple Batch File Commands Under Microsoft® Windows® 2000

Setting the Asset Tag under Microsoft Windows

Simple reports

Writing Simple Batch File Commands Under Red Hat® Linux®

Setting the Asset Tag Value under Red Hat Linux

Simple Reports

Writing Simple Batch File Commands Under Novell® NetWare®

Simple Reports

Configuration from a Batch File

Writing Windows 2000 Shell Scripts

Collecting output in XML format

Writing Red Hat Linux Shell Scripts

Configuration from a shell script file under Red Hat Linux

Collecting output in XML format under Red Hat Linux

How to Get a Batch File or Script File to the Machine

How to Schedule a Task on the Target Machine

How to Get the Result Back

Conclusion


June 2002Page 1Dell Enterprise Systems Group

Section 1

Introduction

This Step-By-Step white paper describes a number of Dell OpenManage™ Server Administrator Command Line Interface (CLI) programming techniques in detail. This information is designed primarily for server system administrators. Some batch file examples are provided.

The Dell OpenManage Server Administrator v1.0 product contains two methods to change or display systems management variables on a single computer, by an easy-to-use Web-based interface, or by an easy-to-use CLI.

The CLI uses words to request reports, set systems management information, change bios settings, update bios or firmware etc. Basically, any systems management configuration that can be changed using the Web-based interface can also be changed using the command line interface. The command line interface can be used from the systems console of the managed server. It can also be used through remote console software, such as Microsoft Systems Management Server, or Computer Associates ShipIT, to run a batch file remotely.

Section 2

Writing Simple Batch File Commands Under Microsoft® Windows® 2000

The CLI is designed to be OS independent. For example, instead of using the built in DOS file redirection output capability, the CLI uses a built in file redirection capability. However, some aspects of the batch files below are OS dependent, such as conditional execution. The examples below run under Microsoft Windows 2000.

Setting the Asset Tag under Microsoft Windows

The assettag is a customer assignable text field that can be used to identify your computer. This example shows how to set it with a batch file. It is called with one parameter, the asset tag value.

For example, if this file is saved to asset.bat, it could be called by:

a)asset mysystem

b)asset thisassettagistoolong

example b) will produce an error

@echo off

REM Example OpenManage Server Administrator batch file - Set the Asset Tag

REM

REM set the asset tag as assettag and output to a file named omtemp.txt

REM one parameter expected, the asset tag value

omconfig chassis info index=0 tag=%1 -outc omtemp.txt

REM

find "Error!" omtemp.txt

if %errorlevel% EQU 0 goto setfailure

goto setsuccessful

:setfailure

echo omconfig cannot set value !

goto done

:setsuccessful

echo omconfig set successfully !

:done

pause

@echo on

Alternatively, it is an option to choose to use the return value from the commands: omreport, omconfig, omdiag and omupdate in order to make errorlevel checks. This is defined as a return value of 0 for successful execution.

Simple reports

OpenManage Server Administrator allows for the generation of reports on just about any aspect of a server’s state or settings using the CLI omreport command.

The following batch file generates some simple text reports and writes the output to a single text file:

@echo off

REM Example OpenManage Server Administrator batch file

REM The name of the output text file is passed to this batch file as a parameter

REM

REM Write system summary information to a new file

omreport system summary -outc %1

REM

REM Now lets get health summary and append it

omreport chassis -outa %1

REM

REM append asset information

omreport system assetinfo -outa %1

REM

REM append probe information

omreport chassis currents -outa %1

omreport chassis fans -outa %1

omreport chassis temps -outa %1

omreport chassis volts -outa %1

If the above batch file was saved as report.bat, then it could be invoked by typing “report report.txt” . The text file report.txt would be written to the current directory of the server and will contain the requested reports concatenated together.

Section 3

Writing Simple Batch File Commands Under Red Hat® Linux®

Examples of batch files that are OS dependent for Red Hat Linux are shown in this section.

Setting the Asset Tag Value under Red Hat Linux

This example sets the asset tag value. It is called with one parameter, the asset tag value.

Example, if this file is saved to asset.sh, it could be called by:

a)./asset.sh mysystem

b)./asset.sh thisassettagistoolong

example b) will produce an error

#!/bin/sh

# Example OpenManage Server Administrator shell script file - Set the Asset Tag

#

# set the asset tag as assettag and output to a file named omtemp.txt

# one parameter expected, the asset tag value

omconfig chassis info index=0 tag=$1 -outc omtemp.txt

#

grep Error omtemp.txt

if [ $? = 0 ];

then

echo omconfig cannot set value !

else

echo omconfig set successfully

fi

Alternatively you can choose to use the return value from the commands: omreport, omconfig, omdiag and omupdate in order to make $? checks. This is defined as a return value of 0 for successful execution.

Simple Reports

The following batch file generates some simple text reports and writes the output to a shell script file.

#!/bin/sh

# Example OpenManage Server Administrator batch file

# The name of the output text file is passed to this batch file as a parameter

#

# Write system summary information to a new file

omreport system summary -outc $1

#

# Now lets get health summary and append it

omreport chassis –outa $1

#

# append asset information

omreport system assetinfo -outa $1

#

# append probe information

omreport chassis currents -outa $1

omreport chassis fans -outa $1

omreport chassis temps -outa $1

omreport chassis volts -outa $1

If the above shell script file was saved as report.sh, after changing its mode to executable (chmod a+x report.sh), then it could be invoked by typing “report.sh report.txt”. The text file report.txt is written to the current directory of the server and contains the requested reports concatenated together.

Section 4

Writing Simple Batch File Commands Under Novell® NetWare®

Under Novell NetWare, files with extension .ncf can be used for batch files. For example the simple report can be written as shown below.

Simple Reports

The following batch file generates some simple text reports and writes the output to a batch file. (Instead of using command line parameters, give the file name directly.)

# Example OpenManage Server Administrator batch file

# The name of the output text file is passed to this batch file as a parameter

#

# Write system summary information to a new file

omreport system summary -outc report.txt

#

# Now lets get health summary and append it

omreport chassis –outa report.txt

#

# append asset information

omreport system assetinfo -outa report.txt

#

# append probe information

omreport chassis currents -outa report.txt

omreport chassis fans -outa report.txt

omreport chassis temps -outa report.txt

omreport chassis volts -outa report.txt

If the above shell script file was saved as report.ncf.

After those batch files or shell script files are created, you can ftp them to each machine, and run them on each machine. Under Microsoft Windows, if SMS (System Management Server) has been installed, you can packet those files, distribute them and schedule them on each SMS client through SMS. OMSA CLI provides the flexibility for you to use batch or script to automatic those commands, and it is your choice what kind of tool you like to use.

Section 5

Configuration from a Batch File

Writing Windows 2000 Shell Scripts

The CLI command omconfig allows a user to change settings on a server. This example shows haw to change some BIOS settings and some probe warning thresholds:

@echo off

REM Example OpenManage Server Administrator batch file - omconfig

REM The name of the output text file is passed to this batch file as a parameter

REM

REM on boot, set numlock to off, set speaker to off, bootsequence to hard drive only

omconfig chassis biossetup attribute=numlock setting=off -outc %1

omconfig chassis biossetup attribute=speaker setting=off -outa %1

omconfig chassis biossetup attribute=bootsequence setting=hdonly -outa %1

REM

REM Set some probe warning thresholds to tighter values.

REM Note probes are identified by index number. In this example,

REM these settings are specific to a Dell PowerEdge 2400

omconfig chassis fans index=0 minwarnthresh=1000 maxwarnthresh=5000 -outa %1

omconfig chassis fans index=0 minwarnthresh=1000 maxwarnthresh=5000 -outa %1

REM

REM make the server as quiet as possible

omconfig chassis fancontrol speed=quiet

If the above batch file was saved as config.bat, then it could be invoked by typing “config conf.txt” . The text file config.txt would be written to the current directory of the server and will contain the results of the configuration.

Collecting output in XML format

Reports may be generated in table format, plain text, semicolon separated values, or XML.

If XML format output is desired, then it is recommended to write the ouput of each report to a separate file. This is because each XML format report is well formatted XML. However, the action of concatenating two or more reports together will result in malformed XML.

Example

@echo off

REM Example OpenManage Server Administrator batch file - XML format reports

REM

REM Write system summary information to a new file

omreport system summary –outc summary.xml –fmt xml

REM

REM Now lets get health summary

omreport chassis -outc health.xml –fmt xml

REM

REM append asset information

omreport system assetinfo –outc assetinfo.xml –fmt xml

REM

REM append probe information

omreport chassis currents -outc currents.xml –fmt xml

omreport chassis fans -outc fans.xml –fmt xml

omreport chassis temps -outc temps.xml –fmt xml

omreport chassis volts -outc volts.xml –fmt xml

Writing Red Hat Linux Shell Scripts

The examples below run under Red Hat Linux. It is the counterpart of above introduced examples in Red Hat Linux Shell script.

Configuration from a shell script file under Red Hat Linux

#!/bin/sh

# Example OpenManage Server Administrator batch file - omconfig

# The name of the output text file is passed to this batch file as a parameter

#

# on boot, set numlock to off, set speaker to off, bootsequence to hard drive only

omconfig chassis biossetup attribute=numlock setting=off -outc &1

omconfig chassis biossetup attribute=speaker setting=off -outa &1

omconfig chassis biossetup attribute=bootsequence setting=hdonly -outa &1

#

# Set some probe warning thresholds to tighter values.

# Note probes are identified by index number. In this example,

# these settings are specific to a Dell PowerEdge 2400

omconfig chassis fans index=0 minwarnthresh=1000 maxwarnthresh=5000 -outa &1

omconfig chassis fans index=0 minwarnthresh=1000 maxwarnthresh=5000 -outa &1

#

# make the server as quiet as possible

omconfig chassis fancontrol speed=quiet

# -outa &1 &2

If the above shell script file was saved as config.sh, after changing its mode to executable (chmod a+x config.sh), then it could be invoked by typing “config.sh conf.txt”. The text file config.txt would be written to the current directory of the server and will contain the results of the configuration.

Collecting output in XML format under Red Hat Linux

Reports may be generated in table format, plain text, semicolon separated values, or XML.

If XML format output is desired, then it is recommended to write the ouput of each report to a separate file. This is because each XML format report is well formatted XML. However, the action of concatenating two or more reports together will result in malformed XML.

Example

#!/bin/sh

# Example OpenManage Server Administrator batch file - XML format reports

# The name of the output text file is passed to this batch file as a parameter

#

# Write system summary information to a new file

omreport system summary –outc summary.xml –fmt xml

#

# Now lets get health summary

omreport chassis -outc health.xml –fmt xml

#

# append asset information

omreport system assetinfo –outc assetinfo.xml –fmt xml

#

# append probe information

omreport chassis currents -outc currents.xml –fmt xml

omreport chassis fans -outc fans.xml –fmt xml

omreport chassis temps -outc temps.xml –fmt xml

omreport chassis volts -outc volts.xml –fmt xml

How to Get a Batch File or Script File to the Machine

  1. ftp, if the ftp server is setup for Microsoft Windows or ftp is enabled under Red Hat Linux, you can ftp the batch files or script files to the target machine;
  2. Through the following batch file under Microsoft Windows:

Let us assume that the batch file named repgen.bat is under a shared directory “test” on machine “testmachine” under domain “testdoamin”:

@echo off

REM Delete the mapping of driver j:

net use j: /d

REM Mapping the driver j: to the testmachine

net use j:\\testmachine\test /user:testdomain\username password /per:no

REM copy the repgen.bat file to the current directory

copy j:\repgen.bat .

REM Delete the mapping of driver j:

Net use j:/d

How to Schedule a Task on the Target Machine

  1. at for Red Hat Linux:
    if you want to run the command at 6:00pm tomorrow, you can write:
    at 6:00pm tomorrow –f genrep.sh
    if you want to run the command at 6:00pm everyday, you can write:
    at 6:00pm –f genrep.sh
    scheduler for Microsoft Windows
  2. under StartSettingsControl PanelScheduled TasksAdded Schedule Task
    doubled click it, you will get a wizard to schedule the task as you want.

How to Get the Result Back

  1. ftp, similarly if the ftp server is setup for Microsoft Windows or ftp is enabled under Red Hat Linux, you can ftp the testing result from the target machine;
  2. Through the following batch file under Microsoft Windows:
    Let us assume that the report file named report.txt is under the current directory, and you want to copy it to a shared directory “test” on machine “testmachine” under domain “testdoamin”:
    @echo off
    REM Delete the mapping of driver j:
    net use j: /d
    REM Mapping the driver j: to the testmachine
    net use j:\\testmachine\test /user:testdomain\username password /per:no
    REM copy the repgen.bat file to the current directory
    copy report.txt j:\
    erase report.txt
    REM Delete the mapping of driver j:
    Net use j:/d

You can schedule a task to run this task everyday after giving even time to generate the report.

Section 6

Conclusion

Dell OpenManage Server Administrator provides a Command Line Interface for environments in which system administrators perform most tasks using scripts, which run on groups of servers. The examples provided in this paper are some typical examples to use to write batch or shell scripts through CLI, schedule the tasks on each server and get reports back regularly. It is possible to make full use of the flexibility provided by CLI by extending the examples presented in this paper through whatever tools users choose within their systems for batch or shell scripts.

THIS WHITE PAPER IS FOR INFORMATIONAL PURPOSES ONLY, AND MAY CONTAIN TYPOGRAPHICAL ERRORS AND TECHNICAL INACCURACIES. THE CONTENT IS PROVIDED AS IS, WITHOUT EXPRESS OR IMPLIED WARRANTIES OF ANY KIND.


Dell and PowerEdge are trademarks of Dell Computer Corporation. Microsoft and Windows are registered trademarks of Microsoft Corporation. Red Hat is a registered trademark of Red Hat, Inc. Linux is a registered trademark of Linus Torvalds. Novell and NetWare are registered trademarks of Novell Corporation. Other trademarks and trade names may be used in this document to refer to either the entities claiming the marks and names or their products. Dell disclaims proprietary interest in the marks and names of others.

©Copyright 2002 Dell Computer Corporation. All rights reserved. Reproduction in any manner whatsoever without the express written permission of Dell Computer Corporation is strictly forbidden. For more information, contact Dell.

Information in this document is subject to change without notice.


June 2002Page 1Dell Enterprise Systems Group