Sponsored Content
Operating Systems AIX How to put customized error report on errpt ? Post 302885036 by linux.amrit on Thursday 23rd of January 2014 08:51:24 AM
Old 01-23-2014
Hi Akshay,

Thanks for reply, answers are below ...
Script as below ....
Code:
check_script=/var/scripts/root_expires
check_file_dir=/var/run
check_file1=${check_file_dir}/check_root_passwd_check_file1
check_file2=${check_file_dir}/check_root_passwd_check_file2.log
warndays=7
alertdays=-1

# force the check dir to exist with the right permissions
if [[ ! -d ${check_file_dir} ]]
then
    mkdir -p ${check_file_dir} > /dev/null 2> /dev/null
    chmod 755 ${check_file_dir} > /dev/null 2> /dev/null
    chown root:system ${check_file_dir} > /dev/null 2> /dev/null
fi

# make sure check_script exists
if [[ -x ${check_script} ]]
then
        # make sure the check file directory exists
        if [[ -d ${check_file_dir} ]]
        then
            # in theory, all pre-reqs in place let's go

            daystoexpire=$(${check_script}) # get the number of days to expire
            daysrc=$?                      # get the return code from the check_script command

            if [[ -f ${check_file1} ]]
            then
            #    echo "checkfile found"
                checkfileexists=yes
            else
            #    echo "checkfile NOT found"
                checkfileexists=no
            fi

            if [[ ${daysrc} -ne 0 ]]
            then
                echo "${check_script} returned non-zero return code, abort!" >&2
                exit 1
            fi

            if [[ "${daystoexpire}" = "" ]]
            then
                # nothing to do, password will not expire but remove a check file if it exists
                echo "password does not expire"
                if [[ ${checkfileexists} = "yes" ]]
                then
                    rm -f ${check_file1} > /dev/null 2> /dev/null
                        >${check_file2}  
                fi
            elif [[ ${daystoexpire} -le ${alertdays} ]]
            then
                echo "account expired"
                # if we have no checkfile, create one, generate full alert
                # if we have a checkfile, check the status, if it was warning, generate full alert and update checkfile
                # otherwise do nothing

                if [[ ${checkfileexists} = "no" ]]
                then
                    echo "updating checkfile with alert"
                    echo "alert" > ${check_file1}
                    echo "$(date +"%a %b %d %r %Z %Y") CRITICAL ALERT $(hostname) root password has expired - it required changing immediately."  > ${check_file2}
                else
                    alerttype=$(cat ${check_file1} 2>/dev/null)
                    if [[ $? -eq 0 ]]
                    then
                        if [[ ${alerttype} = "warning" ]]
                        then
                            echo "updating checkfile with alert"
                            echo "alert" > ${check_file1}
                    echo "$(date +"%a %b %d %r %Z %Y") CRITICAL ALERT $(hostname) root password has expired - it required changing immediately."  > ${check_file2}
                
                        fi
                    else
                        echo "could not read status from ${check_file1}, abort!" >&2
                        exit 1
                    fi
                fi
            elif [[ ${daystoexpire} -le ${warndays} ]]
            then
                echo "account below warning period"
                # if we have no checkfile, create one and generate a warning
                # if we have a checkfile, do nothing (this may cause an issue, if the checkfile is an alert type
                # then we may have missed out some runs and may not generate e-mail but it's safer than sending too
                # many alerts)

                if [[ ${checkfileexists} = "no" ]]
                then
                    echo "updating checkfile with warning"
                    echo "warning" > ${check_file1}
                echo "$(date +"%a %b %d %r %Z %Y") WARNING ALERT $(hostname) root password expires in ${daystoexpire} day(s) (0 means today).  Please change the root password immediately "  > ${check_file2}
                  
                fi
            else
                echo "account ok"
                # if the checkfile exists, remove it, otherwise do nothing
                if [[ ${checkfileexists} = "yes" ]]
                then
                    rm -f ${check_file1} > /dev/null 2> /dev/null
                    >${check_file2}
                fi
            fi
        else
            echo "${check_file_dir} not found, abort!" >&2
            exit 1
        fi
else
    echo "${check_script} not found, abort!" >&2
    exit 1
fi


But till now i am thinking how to generate errpt entry for password expiry.

And ur last question -- why do you leave codetags to moderator ? I don't know how it's happened ....


Thanks,
Amrit

---------- Post updated at 07:21 PM ---------- Previous update was at 06:41 PM ----------

hi .. all,
Can i change with errupdate
if id=AA8AB241,Detail Data=Root Password Expired
then DESCRIPTION should be Root Password Expired. any way possible.

Last edited by Franklin52; 01-23-2014 at 09:31 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. AIX

AIX 5.3 errpt full of message: DISK OPERATION ERROR

Hi All, Can anyone explain me the meanning of the following errors: LABEL: SC_DISK_ERR2 IDENTIFIER: B6267342 Description DISK OPERATION ERROR Probable Causes DASD DEVICE Failure Causes DISK DRIVE DISK DRIVE ELECTRONICS Recommended Actions PERFORM PROBLEM DETERMINATION... (1 Reply)
Discussion started by: gianlu
1 Replies

2. Shell Programming and Scripting

Customized copy.

HI guys, I'm working on a code with the following specs: 1. Retrieving files with a particular extensions from a location specified by the users. 2. Copying those files to user specified location i) but i need to pause copy if the network is busy ii) and the copy process must... (3 Replies)
Discussion started by: bill88
3 Replies

3. AIX

errpt - TTYHOG error

I am getting this temporary error on my errpt: IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION 0873CF9F 0623104510 T S pts/0 TTYHOG OVER-RUN LABEL: TTY_TTYHOG IDENTIFIER: 0873CF9F Date/Time: Tue Jun 22 02:00:53 GMT+08:00 2010 Sequence Number: 76... (3 Replies)
Discussion started by: famasutika
3 Replies

4. Shell Programming and Scripting

Can nmon be customized?

Hi, my name is Steve Ngai from Malaysia. This is my first post. Hope to learn more about Unix from this forum. My first question is can nmon be customized? When I run nmon, I need to manually type c to see CPU usage, then m for memory usage. Can I pass it some nmon option to automatically see... (2 Replies)
Discussion started by: ngaisteve1
2 Replies

5. Forum Support Area for Unregistered Users & Account Problems

customized username?

Hi i have registered but my username is set to default value ( my email). can i change this ? (2 Replies)
Discussion started by: customizeemai
2 Replies

6. AIX

I am getting the following error when I do an errpt. What do I need to do to fix it.

Hi Team, I am getting the following error when I do an errpt. What do I need to do to fix it. LABEL: LVM_SA_STALEPP IDENTIFIER: EAA3D429 Date/Time: Sat 12 Jan 01:10:56 2013 Sequence Number: 880 Machine Id: 00C57B904C00 Node Id: spg-lplaw-01... (1 Reply)
Discussion started by: ranjithm
1 Replies

7. Shell Programming and Scripting

./CARE_SM_SFTP.sh[27]: put: not found error while doing sftp

Hi, I am getting the below error while doing sftp in a script file but the same is getting executed when i run from command prompt ./CARE_SM2_SFTP.sh: put: not found Code :- sftp ${USER_ID}@${FTPHOST4}:/opt/path put <Filename with path> chmod 777 <FileName with Path>... (2 Replies)
Discussion started by: satishmallidi
2 Replies

8. Shell Programming and Scripting

Need to develop a bash script to create customized report from the server log

Hi, I need to develop a bash script to create customized report from the server log (red hat 5.8 64 bit Operating system). The following is one of the log for our internal application task. <2015.03.03 20:09:52 274 +0800><I><DSCTH01><http-0.0.0.0-443-2><security> GUI request succeeded for... (1 Reply)
Discussion started by: pugazhendhi_r
1 Replies

9. Shell Programming and Scripting

Customized command excution

Hi, The below commands will be inside a KSH script and SOLARIS machine. Command-1 //Executes in 10s,5s,..5mins,etc TIMER = Look for Command-1 execution status - IF finished in 25secs move to next command in the script IF NOT kill above command and move to next command. Command-2 Any... (9 Replies)
Discussion started by: penqueen
9 Replies

10. Shell Programming and Scripting

Customized text searches by using grep

I tried to ease text searches so made a customized grep: g () { if then i= for s in $2 do i="$i --include=*.$s" done else i='--include=*.txt --include=*.ini --include=*.*sh --include=*.c* --include=*.h --include=*.js --include=*.reg' fi grep -P -e \'$1\' -r "$i" } but I... (3 Replies)
Discussion started by: abdulbadii
3 Replies
All times are GMT -4. The time now is 11:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy