KBI 310702 New Feature: Linux/Unix Rule Based Event Priority
Version
Added to Argent Advanced Technology 3.1A-1310-A and later
Date
Wednesday, 9 Oct 2013
Summary
This feature allows Linux/Unix script rule to fire event with adjustable priority
This enhancement is extremely powerful
Customers often have internal standards for what constitutes a ‘Critical’ or ‘Low’ priority event
If customers wanted, say, CPU usage greater than 70% to be ‘Critical’, and CPU usage greater than 40% (but less than 70%) to be ‘Low’, then the only method in prior versions was to create two separate Linux/Unix script rules, and schedule them in two separate Relators
This enhancement removes the need for this duplicate monitoring and allows a single pass to monitor and set the priority at the Rule level
Technical Background
By default, the priority of an event fired by the Argent AT Engine is defined in the Relator
Starting with 3.1A-1310-A, the Linux/Unix Rule has been enhanced so that the Relator level setting can be overridden by the Rule
For example, a customer can specify several thresholds for high, medium and low priority respectively. Then depending on which threshold the metric exceeds, event of the specific priority is fired
To achieve this the Linux/Unix Rule introduces new tag call ‘PRIORITY‘
The function ‘xmlStatus‘ can be updated as follows:
xmlStatus() { cat <<! <QEResult> <status>$STATUS</status> <summary>$SUMMARY</summary> <comment>$COMMENT</comment> <priority>$PRIORITY</priority> </QEResult> ! } # End of xmlStatus()
The next step is to assign an appropriate value for the variable ‘PRIORITY‘ before calling xmlStatus in the script
The built-in values are Low, Medium and High standing for event priority
However numeric values of 0, 1, 2 for low, medium and high can also be used
If any text string other than the built-in values are assigned, it will be treated as custom priority text
Note:
Tag ‘Priority‘ is optional — if not specified, the priority defined at Relator level is used
A sample script is listed as follows:
#!/bin/sh # # SCP_LINUX_OS_LEVEL.TXT # # This script returns XML data to The Argent Guardian service running on W2000. # # The output will be the ASCII string of 'PASS' or 'FAIL'. # # # # # Copyright (c) 2013 ArgSoft Pacific Intellectual Property Holdings (HK), Limited # # All Rights Reserved. # # ArgSoft Pacific Intellectual Property Holdings (HK), Limited # 2017-2018 Metropolis Tower # The Metropolis, 10 Metropolis Drive # Hong Kong # # # # This is PROPRIETARY SOURCE CODE of ARB Intellectual Property Holdings (HK), Limited. # # The contents of this file may not be disclosed to third parties, copied or # duplicated in any form, in whole or in part, without the prior written # permission of ARB Intellectual Property Holdings (HK), Limited. # # RESTRICTED RIGHTS LEGEND: # Use, duplication or disclosure by the Government is subject to restrictions # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data # and Computer Software clause at DFARS 252.227-7013, and/or in similar or # successor clauses in the FAR, DOD or NASA FAR Supplement. # # Unpublished - rights reserved under the Copyright Laws of the United States # and other countries. # # # # # This rule checks the revision level of the operating system. # # The rule fails if the operating system level is under 2.4.18 # # For more information: email Unix@Argent.com. STATUS=NOVAL SUMMARY=NOVAL COMMENT=NOVAL PRIORITY=NOVAL # # xmlOut() - prints an entire XML output for a command script. # # Used for The Argent Guardian rules that return a PASS/FAIL # # status and summary and comment descriptions. # xmlOut() { xmlBegin xmlStatus xmlEnd } # # xmlBegin() - Prints out the definition of the XML format used to # # send status data to The Argent Guardian. # xmlBegin() { cat <<! <?xml version="1.0"?> <!DOCTYPE TAGResult [ <!ELEMENT TAGResult (QEResult+)> <!ELEMENT QEResult (status, summary, comment)> <!ELEMENT status (#PCDATA)> <!-- (PASS | FAIL) --> <!ELEMENT summary (#PCDATA) > <!ELEMENT comment (#PCDATA) > ]> <TAGResult> ! } # End of xmlBegin() # # xmlStatus() - Send a status block to The Argent Guardian. The # # status should be 'PASS' or 'FAIL'. The summary explains the result # # and the comment is a generic description of the Unix rule. # xmlStatus() { cat <<! <QEResult> <status>$STATUS</status> <summary>$SUMMARY</summary> <comment>$COMMENT</comment> <priority>$PRIORITY</priority> </QEResult> ! } # End of xmlStatus() # # xmlEnd() - Completes the XML data block. # xmlEnd() { cat <<! </TAGResult> ! } # End of xmlEnd() ############################# Main portion of script ########################## # # Get the name of the OS # OS=`uname` # # Define the earliest acceptable OS version here. For Solaris, we use the # # 'uname' command to get the version number. Strip any leading alphanumeric # # characters off the beginning of the version. # LINUXVERSION="2.4.18" VERSION=`uname -r | sed s/[a-zA-Z]*\([0-9.]*\)/\1/p` BASEVERSION=$LINUXVERSION # # Make sure the version command actually returned a string # if [ -z "$VERSION" ]; then STATUS=FAIL PRIORITY=HIGH SUMMARY="Error: Can not derive ${OS} OS version." xmlOut exit 1 fi # # Remove all but the first decimal point in the base and derived versions. # # For example, 4.3.3.3 becomes 4.333. # TESTBASEVER=$BASEVERSION TESTVER=$VERSION # # First, substitute 'xxx' for the first decimal point # TESTBASEVER=`echo "$TESTBASEVER" | sed "s/\./xxx/"` TESTVER=`echo "$TESTVER" | sed "s/\./xxx/"` # # Remove all remaining decimal points or dashes # TESTBASEVER=`echo "$TESTBASEVER" | sed "s/[\.\-]//g"` TESTVER=`echo "$TESTVER" | sed "s/[\.\-]//g"` # # Replace the 'xxx' with a decimal point # TESTBASEVER=`echo "$TESTBASEVER" | sed "s/xxx/\./"` TESTVER=`echo "$TESTVER" | sed "s/xxx/\./"` # # Compare the two test numbers # STATUS=FAIL PRIORITY=LOW SUMMARY="${OS} Version is $VERSION" EXIT_CODE=1 # # Report the findings back to The Argent Guardian # COMMENT="Linux Demo Rule" xmlOut exit $EXIT_CODE
Resolution
Upgrade to Argent Advanced Technology 3.1A-1310-A or later