Bug 426464 - The check-oracle-space-usage.sh script could be made more robust
The check-oracle-space-usage.sh script could be made more robust
Status: CLOSED CURRENTRELEASE
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Other (Show other bugs)
510
All Linux
low Severity low
: ---
: ---
Assigned To: Jan Pazdziora
Sayli Karmarkar
https://www.redhat.com/mailman/privat...
: Triaged
Depends On:
Blocks: 456985
  Show dependency treegraph
 
Reported: 2007-12-21 04:52 EST by Jan Pazdziora
Modified: 2009-09-10 16:22 EDT (History)
2 users (show)

See Also:
Fixed In Version: sat530
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-09-10 16:22:56 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jan Pazdziora 2007-12-21 04:52:40 EST
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 04:53:59 EST
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 09:49:48 EST
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 08:23:55 EST
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 07:30:40 EST
With compose Satellite-5.3.0-RHEL5-re20090220.1 available, moving ON_QA.
Comment 7 Sayli Karmarkar 2009-02-24 10:31:19 EST
Verified on Satellite-5.3.0-RHEL5-re20090220.1.

~SayliK
Comment 8 Milan Zazrivec 2009-08-27 09:16:28 EDT
Verified in stage -> RELEASE_PENDING
Comment 9 Brandon Perkins 2009-09-10 16:22:56 EDT
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.