Bug 426464 - The check-oracle-space-usage.sh script could be made more robust
Summary: The check-oracle-space-usage.sh script could be made more robust
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Other
Version: 510
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Jan Pazdziora
QA Contact: Sayli Karmarkar
URL: https://www.redhat.com/mailman/privat...
Whiteboard:
Depends On:
Blocks: 456985
TreeView+ depends on / blocked
 
Reported: 2007-12-21 09:52 UTC by Jan Pazdziora
Modified: 2009-09-10 20:22 UTC (History)
2 users (show)

Fixed In Version: sat530
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-09-10 20:22:56 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Jan Pazdziora 2007-12-21 09:52:40 UTC
Description of problem:

The check-oracle-space-usage.sh calls

   su - oracle -c "db-control report"

and then processes its output. However, it seems some users have settings in
/etc/profile or other logon files that lead to some extra output being returned
by that su command. That in turns breaks our postprocessing

   awk '{print $5}'|sed '1d'| sed 's/%//g'

and leads to errors since non-numeric data appears on the output.

Version-Release number of selected component (if applicable):

rhn-dobby-5.0.1-10

How reproducible:

Deterministic if you have something in /etc/profile.

Steps to Reproduce:
1. Add "echo Test" to your /etc/profile.
2. Run /etc/cron.daily/check-oracle-space-usage.sh
  
Actual results:

# /etc/cron.daily/check-oracle-space-usage.sh
/etc/cron.daily/check-oracle-space-usage.sh: line 42: [: Use: integer expression
expected

Expected results:

No error, the script should be robust enough to work even in this case.

Additional info:

See the thread at
https://www.redhat.com/mailman/private/rhn-satellite-users/2007-December/msg00044.html

The post at
https://www.redhat.com/mailman/private/rhn-satellite-users/2007-December/msg00068.html
suggests using

   awk '/[0-9]%$/ {gsub("%", ""); print $NF}'

Which seems good enough.

Comment 1 Jan Pazdziora 2007-12-21 09:53:59 UTC
BTW -- don't forget to remove that "echo Test" from your /etc/profile when
you're done with this bug.

Comment 2 Jan Pazdziora 2008-01-09 14:49:48 UTC
Colin C.Coe noted in private email that it might be worth only processing those
lines ending with % sign that follow a line with "Tablespaces". That way, if
user's have some mess in their .bash_profiles ...

A cow orker has his .bash_profile output how full (in %) of the shared
/scratch.  The original awk DoesTheWrongThing(tm) if there is a line of
output the ends with a number and % sign as the last things on the line
before the actual output of 'db-control report'.  The below awk doesn't
print anything unless it has already seen a line starting with
'Tablespace'.

... we'll only process the correct lines.

Comment 5 Jan Pazdziora 2009-02-16 13:23:55 UTC
Fixed in Spacewalk repo, commit a091b99a1121ba2bcaf1415e0dd2eb47beed39a2.

I've ended up calling runuser without -, so that /etc/profile and ~/.bash_profile are not read at all.

Comment 6 Jan Pazdziora 2009-02-24 12:30:40 UTC
With compose Satellite-5.3.0-RHEL5-re20090220.1 available, moving ON_QA.

Comment 7 Sayli Karmarkar 2009-02-24 15:31:19 UTC
Verified on Satellite-5.3.0-RHEL5-re20090220.1.

~SayliK

Comment 8 Milan Zázrivec 2009-08-27 13:16:28 UTC
Verified in stage -> RELEASE_PENDING

Comment 9 Brandon Perkins 2009-09-10 20:22:56 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2009-1434.html


Note You need to log in before you can comment on or make changes to this bug.