<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Shell Script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2827623#M940693</link>
    <description>Once again, just in case ...&lt;BR /&gt;&lt;BR /&gt;Hello, &lt;BR /&gt;&lt;BR /&gt;using shell ... cat your input to this script : &lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;&lt;BR /&gt;while read DBS &lt;BR /&gt;do &lt;BR /&gt;read BLOCKS &lt;BR /&gt;read USED &lt;BR /&gt;read &lt;BR /&gt;PERC=$(($USED \* 100 / $BLOCKS)) &lt;BR /&gt;[ "$PERC" -gt 80 ] &amp;amp;&amp;amp; &lt;BR /&gt;{ &lt;BR /&gt;echo "\n$DBS has ${PERC}% blocks used\n" | mailx -s "Free space in $DBS" phelix &lt;BR /&gt;} &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;And you will receive : &lt;BR /&gt;&lt;BR /&gt;Date: Thu, 17 Oct 2002 09:16:30 +0200 (METDST) &lt;BR /&gt;From: Jean-Louis Phelix &lt;BR /&gt;To: phelix &lt;BR /&gt;Subject: Free space in tmpdbs &lt;BR /&gt;&lt;BR /&gt;tmpdbs has 99% blocks used</description>
    <pubDate>Thu, 17 Oct 2002 13:35:16 GMT</pubDate>
    <dc:creator>Jean-Louis Phelix</dc:creator>
    <dc:date>2002-10-17T13:35:16Z</dc:date>
    <item>
      <title>Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2827621#M940691</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am writing a shell script which will give me the database free space information and alert. I am getting the following output :&lt;BR /&gt;&lt;BR /&gt;ds1dbs&lt;BR /&gt;5000000&lt;BR /&gt;991156&lt;BR /&gt;&lt;BR /&gt;tmpdbs&lt;BR /&gt;1000000&lt;BR /&gt;999944&lt;BR /&gt;&lt;BR /&gt;c3dbs&lt;BR /&gt;2000000&lt;BR /&gt;932508&lt;BR /&gt;&lt;BR /&gt;s2dbs&lt;BR /&gt;5000000&lt;BR /&gt;1860968&lt;BR /&gt;&lt;BR /&gt;rootdbs&lt;BR /&gt;512000&lt;BR /&gt;8815&lt;BR /&gt;&lt;BR /&gt;testdbs&lt;BR /&gt;4000000&lt;BR /&gt;1087746&lt;BR /&gt;&lt;BR /&gt;My requirement is that the script will calculate the percentage for all the above database like for testdbs:&lt;BR /&gt;1087746/4000000*100=27.19%.&lt;BR /&gt;&lt;BR /&gt;If this percentage is more then 80% then it should send a mail to me?&lt;BR /&gt;&lt;BR /&gt;Can anyone help me to get started?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Raje.</description>
      <pubDate>Thu, 17 Oct 2002 04:27:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2827621#M940691</guid>
      <dc:creator>Sanjiv Sharma_1</dc:creator>
      <dc:date>2002-10-17T04:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2827622#M940692</link>
      <description>Raje,&lt;BR /&gt;&lt;BR /&gt;You could use perl for the whole thing.&lt;BR /&gt;&lt;BR /&gt;while(&amp;lt;&amp;gt;) {&lt;BR /&gt; chomp;&lt;BR /&gt; if (/^\d+$/) {&lt;BR /&gt;  chomp($n2=&amp;lt;&amp;gt;);&lt;BR /&gt;  $pct=100*$n2/$_;&lt;BR /&gt;  push(@db,sprintf "%3d %s",$pct,$db) if $pct &amp;gt; 80;&lt;BR /&gt; } else {&lt;BR /&gt;  $db=$_;&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;if (scalar @db) {&lt;BR /&gt; open(OUT,"|mailx -s 'Some databases are over 80%' youremail\@yourhome.com'");&lt;BR /&gt; print OUT $_,"\n" foreach @db;&lt;BR /&gt; close(OUT);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 17 Oct 2002 13:24:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2827622#M940692</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-10-17T13:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2827623#M940693</link>
      <description>Once again, just in case ...&lt;BR /&gt;&lt;BR /&gt;Hello, &lt;BR /&gt;&lt;BR /&gt;using shell ... cat your input to this script : &lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;&lt;BR /&gt;while read DBS &lt;BR /&gt;do &lt;BR /&gt;read BLOCKS &lt;BR /&gt;read USED &lt;BR /&gt;read &lt;BR /&gt;PERC=$(($USED \* 100 / $BLOCKS)) &lt;BR /&gt;[ "$PERC" -gt 80 ] &amp;amp;&amp;amp; &lt;BR /&gt;{ &lt;BR /&gt;echo "\n$DBS has ${PERC}% blocks used\n" | mailx -s "Free space in $DBS" phelix &lt;BR /&gt;} &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;And you will receive : &lt;BR /&gt;&lt;BR /&gt;Date: Thu, 17 Oct 2002 09:16:30 +0200 (METDST) &lt;BR /&gt;From: Jean-Louis Phelix &lt;BR /&gt;To: phelix &lt;BR /&gt;Subject: Free space in tmpdbs &lt;BR /&gt;&lt;BR /&gt;tmpdbs has 99% blocks used</description>
      <pubDate>Thu, 17 Oct 2002 13:35:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2827623#M940693</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2002-10-17T13:35:16Z</dc:date>
    </item>
  </channel>
</rss>

