Cover V07, I03
Article
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6

mar98.tar


Listing 1: UNIX System

#!/bin/ksh
#
# Class:    UnixSystem
####################################################################
ObjectId=$1
LTYPE=$(uname)
case $LTYPE in
SunOS|HP-UX)    RCMD=remsh    ;;
AIX|Linux)    RCMD=rsh    ;;
esac
### _GetUsers () ###################################################
eval "${ObjectId}_GetUsers()    {
print \$(\$RCMD $ObjectId 'w|wc -l')
}"
### _GetDiskUsage() ################################################
eval "${ObjectId}_GetDiskUsage() {
if [[ \$# = \"1\"|| \$# = \"0\" ]]; then
HIGHDISK=\${1:-90}
${ObjectId}_GetDiskUsage \$($RCMD $ObjectId \
'bdf||df -k' 2>/dev/null) else ## now we have args shift 7;((x=0)) while [[ \$1 != \"\" ]]; do ${ObjectId}_DEVICE[x]=\$1 ${ObjectId}_MOUNTP[x]=\$6 ${ObjectId}_PUSED[x]=\${5%%\%} if (( ${ObjectId}_PUSED[x] > \$HIGHDISK ));then eval ${ObjectId}_DEVICE[x]="!"\${${ObjectId}_DEVICE[x]} fi ((x=x+1)) shift 6 done ${ObjectId}_TOTALDEVS=\$x fi }" ### _ShowDiskUsage() ############################################### eval "${ObjectId}_ShowDiskUsage() { ((x=0)) while (( x < \$${ObjectId}_TOTALDEVS )); do eval print -n \"${ObjectId}: \${${ObjectId}_DEVICE[x]}\"; eval print -n \"\ MOUNT: \${${ObjectId}_MOUNTP[x]}\"; eval print \"\ USED: \${${ObjectId}_PUSED[x]}\"; ((x=x+1)) done }" ### _GetLoad() ##################################################### eval "${ObjectId}_GetLoad() { LoadString=\$($RCMD $ObjectId 'uptime') LoadString=\${LoadString##*:} print \$LoadString ## Write to STDOUT ## now set numeric variable ${ObjectId}_LAVG=\${LoadString%%,*} }" ### _GetWindow() ################################################### eval "${ObjectId}_GetWindow() { ARGS=\$1 if [[ \$ARGS = \"\" ]]; then ARGS=\"/bin/ksh\" fi eval $RCMD $ObjectId \\ '/usr/bin/X11/xterm -display \$DISPLAY -exec \$ARGS' }" # End of File