![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| unary operator expected error | ssuresh1999 | UNIX for Dummies Questions & Answers | 2 | 10-28-2008 09:33 PM |
| "test: argument expected" error | mvalonso | UNIX for Dummies Questions & Answers | 7 | 10-17-2008 12:16 PM |
| missing binary operator before token "(" | mannam srinivas | Linux | 4 | 08-07-2008 07:43 AM |
| Argument ${1} returning "dev" [newbie inside] | felipebb | Shell Programming and Scripting | 1 | 06-09-2008 04:03 PM |
| Returning a "0" if folder is empty | Raynon | Shell Programming and Scripting | 12 | 06-01-2007 06:59 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi All,
I am new to shell scripting and right now I am just limited to using the pre-written scripts. I am in to Infrastructure management where we use different scripts to get the information passed on to the monitoring tools. I am trying to use this script to get the information about the process consuming most CPU and it works for me in RHEL 5 machine but when I run on Solaris 10 box, I am getting the following error: awk: syntax error near line 1 awk: illegal statement near line 1 ./check_top_process.sh: line 39: [: ==: unary operator expected The script is as follows: #! /bin/sh # # Bill Beavis # # todo: better checking for commandline arguments CLIMIT=80 WLIMIT=50 STATE_OK=0 STATE_CRITICAL=2 STATE_WARNING=1 print_help() { echo "" echo "Usage: check_top_process -w <warning> -c <critical>" echo "" echo "This plugin checks the top running process." echo "" exit 0 } case "$1" in -w) WLIMIT=$2 CLIMIT=$4 ;; -c) CLIMIT=$2 WLIMIT=$4 ;; --help) print_help exit $STATE_OK ;; -h) print_help exit $STATE_OK ;; *) esac if [ `echo $WLIMIT $CLIMIT |awk '{print ($1 > $2) ? "true" : "false" }'` = "true" ] then echo "Error: WARNING value must be below CRITICAL value" print_help exit $STATE_OK fi x=`UNIX95= ps -eo pcpu,comm,user,pid,time |sort -rnk1 | head -1` y=`echo $x |awk '{print $1 "% command=" $2 " user=" $3 " pid=" $4 " cputime=" $5}'` if [ `echo $x $CLIMIT |awk '{print ($1 > $6) ? "true" : "false" }'` = "true" ] then echo $y exit $STATE_CRITICAL fi if [ `echo $x $WLIMIT |awk '{print ($1 > $6) ? "true" : "false" }'` = "true" ] then echo $y exit $STATE_WARNING fi echo $y exit $STATE_OK I know that I am missing on something but am unable to find the exact issue. The script is giving errors on the lines highlighted in RED color. Please help ..... Thanks in advance for your help..... Amrit |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|