<?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: awk and numerical values in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723972#M63777</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I use a simple rendition of this. You could expand it to use what ever parameters you wish.&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# Simple script to get bdf information over a threshold&lt;BR /&gt;#&lt;BR /&gt;bdf | sed 's/^ *//' | awk 'NF==1{f=$0;getline;$0=f$0}{print}' | grep -e "8[0-9]%" -e "9[0-9]%" -e "100%"&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;~Michael~&lt;BR /&gt;</description>
    <pubDate>Tue, 14 May 2002 23:26:08 GMT</pubDate>
    <dc:creator>Michael Tully</dc:creator>
    <dc:date>2002-05-14T23:26:08Z</dc:date>
    <item>
      <title>awk and numerical values</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723971#M63776</link>
      <description>I have written a little script that goes out and looks for file system sizes that are above a threshold - works great - except when I ask it to lets say 50%, it also shows me 6%, 7%, and so on ... how do I force it to see the value as 50 not 5?</description>
      <pubDate>Tue, 14 May 2002 23:18:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723971#M63776</guid>
      <dc:creator>Joanne Joki_1</dc:creator>
      <dc:date>2002-05-14T23:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: awk and numerical values</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723972#M63777</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I use a simple rendition of this. You could expand it to use what ever parameters you wish.&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# Simple script to get bdf information over a threshold&lt;BR /&gt;#&lt;BR /&gt;bdf | sed 's/^ *//' | awk 'NF==1{f=$0;getline;$0=f$0}{print}' | grep -e "8[0-9]%" -e "9[0-9]%" -e "100%"&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;~Michael~&lt;BR /&gt;</description>
      <pubDate>Tue, 14 May 2002 23:26:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723972#M63777</guid>
      <dc:creator>Michael Tully</dc:creator>
      <dc:date>2002-05-14T23:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: awk and numerical values</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723973#M63778</link>
      <description>Hi Joanne,&lt;BR /&gt;&lt;BR /&gt; My guess, w/o seeing the script, would be that you're comparing strings &amp;amp; not numerics.&lt;BR /&gt;Make sure you use numeric tests - -ne -eq -lt etc.&lt;BR /&gt;and not string tests = != -n etc.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Jeff</description>
      <pubDate>Tue, 14 May 2002 23:26:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723973#M63778</guid>
      <dc:creator>Jeff Schussele</dc:creator>
      <dc:date>2002-05-14T23:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: awk and numerical values</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723974#M63779</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;you most probably need to take the string strip the % from it then turn it into a numeric with expr command.&lt;BR /&gt;&lt;BR /&gt;checkut this thread we covered previously&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x6aa08cc5e03fd6118fff0090279cd0f9,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x6aa08cc5e03fd6118fff0090279cd0f9,00.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;cheers&lt;BR /&gt;John.</description>
      <pubDate>Wed, 15 May 2002 01:55:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723974#M63779</guid>
      <dc:creator>John Carr_2</dc:creator>
      <dc:date>2002-05-15T01:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: awk and numerical values</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723975#M63780</link>
      <description>Learn perl, drop awk :)&lt;BR /&gt;&lt;BR /&gt;a5:/ 102 # bdf -l&lt;BR /&gt;Filesystem          kbytes    used   avail %used Mounted on&lt;BR /&gt;/dev/vg00/lvol3     204800   29232  164610   15% /&lt;BR /&gt;/dev/vg00/lvol1     299157   32096  237145   12% /stand&lt;BR /&gt;/dev/vg00/wrk      1024000   91636  874296    9% /wrk&lt;BR /&gt;/dev/vg00/var       516096  147025  347828   30% /var&lt;BR /&gt;/dev/vg00/lvol7    1335296  630974  660352   49% /usr&lt;BR /&gt;/dev/vg00/u        1024000  356696  628247   36% /u&lt;BR /&gt;/dev/vg00/tmp       409600   16307  369495    4% /tmp&lt;BR /&gt;/dev/vg00/pro      12288000 11355578  903970   93% /pro&lt;BR /&gt;/dev/vg00/opt       786432  532629  237985   69% /opt&lt;BR /&gt;/dev/vg00/home       16384    1109   14328    7% /home&lt;BR /&gt;/dev/vg00/data     2048000  634297 1325776   32% /data&lt;BR /&gt;a5:/ 103 # bdf -l | perl -ne '/(\d+)%/&amp;amp;&amp;amp;$1&amp;gt;66&amp;amp;&amp;amp;print'&lt;BR /&gt;/dev/vg00/pro      12288000 11355594  903954   93% /pro&lt;BR /&gt;/dev/vg00/opt       786432  532629  237985   69% /opt&lt;BR /&gt;a5:/ 104 #</description>
      <pubDate>Wed, 15 May 2002 09:02:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723975#M63780</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-05-15T09:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: awk and numerical values</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723976#M63781</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;Dont re-invent the wheel.&lt;BR /&gt;&lt;BR /&gt;Script from Andreas Voss Attached.&lt;BR /&gt;&lt;BR /&gt;It will do more than one server.&lt;BR /&gt;&lt;BR /&gt;____________________________________________&lt;BR /&gt;&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;# Check server diskspace &lt;BR /&gt;# check with bdf filesystems on multiple servers&lt;BR /&gt;# Ensure server is in /etc/hosts file &lt;BR /&gt;# (c) hpux@voss2000.de 2000-10-11&lt;BR /&gt;# for remote shell there has to be set permission in /.rhosts &lt;BR /&gt;# at the remote system(s)&lt;BR /&gt;# the script uses /tmp/bdfcheck directory to store percentage of&lt;BR /&gt;# each filesystem for history to avoid multiple message generation&lt;BR /&gt;&lt;BR /&gt;MAILUSER="paula@avro.co.uk" # &amp;lt;-- put here the email address for sending&lt;BR /&gt;HOSTLIST="N-0 k1 k2" # &lt;PUT here="" the="" hostnames="" blank="" separeted="" you="" want="" to="" check=""&gt;&lt;/PUT&gt;HIGHWATERMARK=95 # max percentage of filesystem usage&lt;BR /&gt;&lt;BR /&gt;[ ! -d /tmp/bdfcheck ] &amp;amp;&amp;amp; mkdir /tmp/bdfcheck&lt;BR /&gt;&lt;BR /&gt;for host in $HOSTLIST&lt;BR /&gt;do&lt;BR /&gt;  {&lt;BR /&gt;  if [ $host = $(hostname) ]&lt;BR /&gt;  then&lt;BR /&gt;    bdf -t hfs -t vxfs -l&lt;BR /&gt;  else&lt;BR /&gt;    remsh $host bdf -t hfs -t vxfs -l&lt;BR /&gt;  fi&lt;BR /&gt;  }|tail +2 |awk -vhost=$host '{&lt;BR /&gt;  if(length(fs)&amp;gt;1)&lt;BR /&gt;    fs=fs $0;&lt;BR /&gt;  else&lt;BR /&gt;  {&lt;BR /&gt;    if(NF == 1)&lt;BR /&gt;    {&lt;BR /&gt;      fs=$1;&lt;BR /&gt;      continue;&lt;BR /&gt;    }&lt;BR /&gt;    else&lt;BR /&gt;      fs=$0&lt;BR /&gt;  }&lt;BR /&gt;  printf("%-10s: %s\n",host,fs);&lt;BR /&gt;  fs="";&lt;BR /&gt;  }'&lt;BR /&gt;done |&lt;BR /&gt;awk -vmax=$HIGHWATERMARK -vdate="`date`" 'BEGIN{first=1}&lt;BR /&gt;{&lt;BR /&gt;percent=$7;&lt;BR /&gt;hostname=$1;&lt;BR /&gt;filesystem=$NF;&lt;BR /&gt;gsub("/","_",filesystem);&lt;BR /&gt;sub("%","",percent);&lt;BR /&gt;percent=sprintf( "%d",percent);&lt;BR /&gt;histfile="/tmp/bdfcheck/" hostname filesystem;&lt;BR /&gt;getline oldpercent &lt;HISTFILE&gt;&lt;/HISTFILE&gt;close(histfile);&lt;BR /&gt;print percent &amp;gt;histfile;&lt;BR /&gt;line=$0;&lt;BR /&gt;if(percent &amp;gt; oldpercent &amp;amp;&amp;amp; percent &amp;gt; max)&lt;BR /&gt;{&lt;BR /&gt;  if(first==1)&lt;BR /&gt;  {&lt;BR /&gt;    printf("%s\n\nFilesystems with more than %d%% usage:\n \n",date,max);&lt;BR /&gt;    printf("%-10s  Filesystem          kbytes  used      avail  %%used Mounted on\n","Hostname");&lt;BR /&gt;    first=0;&lt;BR /&gt;  }&lt;BR /&gt;  printf("%s\n",line);&lt;BR /&gt;}&lt;BR /&gt;}' &amp;gt;/tmp/bdf_$$&lt;BR /&gt;&lt;BR /&gt;if [ -s /tmp/bdf_$$ ]&lt;BR /&gt;then&lt;BR /&gt;  cat /tmp/bdf_$$ | mailx -s 'FILESYSTEMS WARNING' $MAILUSER&lt;BR /&gt;fi&lt;BR /&gt;rm -f /tmp/bdf_$$&lt;BR /&gt;cd /tmp/bdfcheck&lt;BR /&gt;rm *&lt;BR /&gt;_____________________________________________&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Paula&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 May 2002 09:43:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723976#M63781</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2002-05-15T09:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: awk and numerical values</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723977#M63782</link>
      <description>Hi Joanne:&lt;BR /&gt;&lt;BR /&gt;I think I will answer your specific question. The 'trick' in awk is to do something like this:&lt;BR /&gt;if (($4 + 0) &amp;gt;= 50) { xxx } else {yyy}&lt;BR /&gt;&lt;BR /&gt;The '+ 0' forces awk to treat the expression as numeric; the reverse operation is to concatenate the null string "" to an expression to force string context. These are standard awk idioms.&lt;BR /&gt;&lt;BR /&gt;Perl has separate comparison operators for numerics and strings to avoid this situation.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;</description>
      <pubDate>Wed, 15 May 2002 12:35:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-numerical-values/m-p/2723977#M63782</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-05-15T12:35:23Z</dc:date>
    </item>
  </channel>
</rss>

