AIX系统日志学习笔记之三

来源:岁月联盟 编辑:exp 时间:2012-02-18
一、系统硬件诊断工具
AIX还给我门提供了diag命令来判断问题,并且分析问题。
#diag
比如:
# diag -d sysplanar0-v –e
http://www.kuqin.com/aixcmds/aixcmds2/diag.htm
二、查看系统日志 www.2cto.com
在AIX中可以使用alog命令来查看系统日志。
# man alog
alog Command
Purpose
       Creates and maintains fixed-size logfiles created from standard input.
Syntax
To Show theContents of a Log File
       alog -f LogFile [ -o ]
To Log Data to aSpecified Log File
       alog -f LogFile | [ [ -q ] [ -s Size ] ]
To Display theVerbosity Value of a Specified Log Type
       alog -t LogType -V
...skipping...
alog Command
Purpose
       Creates and maintains fixed-size logfiles created from standard input.
Syntax
To Show the Contents of a Log File
       alog -f LogFile[ -o ]
To Log Data to a Specified Log File
       alog -f LogFile| [ [ -q ] [ -s Size ] ]
To Display the Verbosity Value of a Specified Log Type
       alog -t LogType-V
To Change the Attributes of a Specified Log Type
       alog -C -tLogType [ -f LogFile ] [ -s Size ] [ -w Verbosity ]
To Display the Current Attributes of a Specified Log Type
       alog -L [ -tLogType ]
To Display the Usage of the alog Command
       alog -H
Description
       The alog command reads standard input,writes to standard output, and
       copies the output into a fixed-sizefile. This file is treated as a
       circular log. If the file is full, newentries are written over the
       oldest existing entries.
       The alog command works with log filesthat are specified on the command
       line or with logs that are defined inthe alog configuration database.
       Logs that are defined in the alogconfiguration database are identified
       by LogType. The File, Size, andVerbosity attributes for each defined
       LogType are stored in the alogconfiguration database with the LogType.
       You can add a new LogType to the alogconfiguration database using the
       odmadd command. You can change theattributes of LogType defined in the
       alog configuration database using thealog command.
Flags
       -C
            Changes the attributes for aspecified LogType. Use the -C flag
            with the -f, -s, and -w flags tochange the File, Size, and
            Verbosity attributes for the specifiedLogType. The -t LogType
            flag is required.
            Note: Using the -C flag with -sSizeonly changes the size value in
            ODM and does not change the size ofthe actual log file.
            If the -C flag is used, the alogcommand does not copy standard
            input to standard output or to alog file.
            When the -C flag is used to modifythe attributes for the console
            log type, the console log file isalso modified and the console
            device driver is updated to use thenew values. This is a
            deviation from the normal operationof alog -C and is done to
            accommodate special formatting inthe console log file.
            Note: You must have root userauthority to change alog attributes.
       -f LogFile
            Specifies the name of a log file.If the specified log file does
            not exist, one is created. If thealog command is unable to write
            to a log file, it writes to/dev/null. Use the -f LogFile flag
            with the -C and -t flags to changethe File attribute for a
            LogType defined in the alogconfiguration database.
       -H
            Displays the usage of the alogcommand.
       -L
            Lists the log types currentlydefined in the alog configuration
            database. If you use the -L flagwith the -t LogType flag, the
            attributes for a specified LogTypeare listed. The current values
            of the File, Size, and Verbosityattributes are listed as colon
            separated values:
           <File>:<Size>:<Verbosity>
            If the -L flag is used, the alogcommand does not copy standard
            input to standard output or toFile.
       -o
            Lists the contents of the log file.Writes the contents of the log
            file to standard output insequential order.
       -q
            Copies standard input to a log filebut does not write to standard
            output.
       -s Size
            Specifies the size limit of the logfile in bytes. The space for
            the log file is reserved when it iscreated. If you create a new
            log file and do not specify theSize attribute, the minimum size,
            4096 bytes, is used. If the logfile already exists, its size will
            be changed. The size you specify isrounded upward to the next
            integral multiple of 4096 bytes.The maximum size for a log file
            is 2 GB. If the specified size isgreater than 2 GB, only 2 GB is
            considered. If you decrease thesize of the log file, the oldest
            entries in the log are deleted ifthey do not fit within the new
            size limit. You must have writepermission for the log file to
            change its size.
            Use the -s Size flag with the -Cand the -t flags to change the
            Size attribute for LogType definedin the alog configuration
            database. Only the size value inODM is changed. The size of the
            actual log file remains the same.The new Size attribute value is
            used the next time a log file iscreated.
       -t LogType
            Identifies a log defined in thealog configuration database. The
            alog command gets the log's filename and size from the alog
            configuration database. If LogFiledoes not exist, one is created.
            If the alog command cannot get theinformation for the specified
            LogType from the alog configurationdatabase or if the alog
            command is unable to write toLogFile, it writes to /dev/null.
            If you specify LogType and LogFileusing the -f flag, LogFile is
            used and LogType is ignored.
       -V
            Writes the current value of theVerbosity attribute for LogType
            that is defined in the alogconfiguration database to standard
            output. If you do not specifyLogType, or the LogType you specify
            is not defined, nothing is written tostandard output.
            The value output using the alogcommand with the -t LogType and
            the -V flags can be used by acommand that is piping its output to
            the alog command to control theverbosity of the data it writes to
            the pipe.
       -w Verbosity
            Changes the Verbosity attribute forLogType defined in the alog
            configuration database when usedwith the -C and the -t flags.
            The Verbosity attribute can have avalue from 0 to 9. If the value
            is 0, no information is copied toLogFile by the alog command. All
            of the information is still writtento standard output. If the
            value is not 0, all of theinformation piped to the alog command's
            standard input is copied to LogFileand to standard output.
 
Examples
       1   To record the current date and time in a log file named
            sample.log, enter:
            date | alog -f /tmp/sample.log
       2   To list the contents of /tmp/sample.log log file, enter:
            alog -f /tmp/sample.log -o
       3   To change the size of the log file named /tmp/sample.log to 8192
            bytes, enter:
            echo "resizing log file"| alog -f /tmp/sample.log -s 8192
       4   To add a new log type sample to the alog configuration database,
            create the alog.add file in thefollowing format:
            SWservAt:
                attribute="alog_type"
                deflt="sample"
                value="sample"
            SWservAt:
               attribute="sample_logname"
               deflt="/tmp/sample.log"
               value="/tmp/sample.log"
            SWservAt:
                attribute="sample_logsize"
                deflt="4096"
                value="4096"
            SWservAt:
               attribute="sample_logverb"
                deflt="1"
                value="1"
            After creating the alog.add file,enter:
            odmadd alog.add
            This adds the alog.add file to theSWservAt database.
       5   To change the name of the log file for the log type sample to
            /var/sample.log in the alogconfiguration database, enter:
            alog -C -t sample -f /var/sample.log
       6   To change the size of the boot log to 8192 bytes and reflect the
            new size in ODM, enter:
            alog -C -t boot -s 8192
            echo "Changed log size" |alog -t boot -s 8192
Files
       /etc/objrepos/SWservAt
            Software Service Aids AttributesObject Class
RelatedInformation
       The odmadd command.
       How to Add Objects to an Object Class inAIX Version 6.1 General
       Programming Concepts: Writing andDebugging Programs.
 
常用的命令
查看日志类型
# alog -L
boot
bosinst
nim
console
cfg
mdmplog
lvmt
lvmcfg
dumpsymp
日志文件的大小可以通过以下命令来修改
#alog –t boot –s 8192
显示系统启动的信息
# alog -o -t boot | more
显示console信息
#alog –o –t console
显示lvm的信息
# alog -t lvmcfg –o
 

摘自 wolf