Operating System - HP-UX
1752589 Members
4313 Online
108788 Solutions
New Discussion юеВ

Re: script required to check the size of Directory

 
SOLVED
Go to solution
g3jza
Esteemed Contributor

Re: script required to check the size of Directory

so the final script:

#!/bin/sh
cnt=0
cnt=`du -ks /tmp | awk '{ print $1 }'`
if [ $cnt -gt 1000 ]
then
opcmsg a=BAC o=EDMConnection msg_text="EDM Established Connection is $cnt" msg_grp=OpC s=major
fi


Dennis Handly
Acclaimed Contributor

Re: script required to check the size of Directory

>test: unknown operator /tmp

You need to separate out the size from the path:
cnt=$(du -ks /tmp | awk '{print $2}')

(Assuming that the size is the second field.)
If you want Gb you can do the divide in awk:
cnt=$(du -ks /tmp | awk '{printf "%d", $2/(1024*1024)}')
mjoshi
Trusted Contributor

Re: script required to check the size of Directory

@Dennis:

cnt=$(du -ks /tmp | awk '{printf "%d", $2/(1024*1024)}')

#!/bin/sh
cnt=0
cnt=$(du -ks /tmp | awk '{printf "%d", $2/(1024*1024)}')
if [ $cnt -gt 1000 ]
then
opcmsg a=BAC o=EDMConnection msg_text="The log level size exceeds 60 GB is $cnt" msg_grp=OpC s=major
fi


Output:
root@ggnems21 # sh EDMLogSize.sh
EDMLogSize.sh: syntax error at line 3: `cnt=$' unexpected

Dennis Handly
Acclaimed Contributor

Re: script required to check the size of Directory

>EDMLogSize.sh: syntax error at line 3: `cnt=$' unexpected

Again, this is perfectly valid syntax for a real shell. What OS are you running?
You can replace $() by the archaic `` construct:
cnt=`du -ks /tmp | awk '{printf "%d", $2/(1024*1024)}'`
mjoshi
Trusted Contributor

Re: script required to check the size of Directory

root@ggnems21 # uname -a
SunOS ggnems21 5.10 Generic_142900-02 sun4v sparc SUNW,SPARC-Enterprise-T5120
mjoshi
Trusted Contributor

Re: script required to check the size of Directory

Dennis its not runnning..


#!/bin/sh
cnt=0
cnt=`du -ks /tmp | awk '{printf "%d", $2/(1024*1024)}'`
if [ $cnt -gt 1000 ]
then
opcmsg a=BAC o=EDMConnection msg_text="The log level size exceeds 60 GB is $cnt" msg_grp=OpC s=major
fi
g3jza
Esteemed Contributor

Re: script required to check the size of Directory

SUN :) .

this is hp-ux forum...
g3jza
Esteemed Contributor

Re: script required to check the size of Directory

you should ask this question to some Oracle / Solaris forums....
Stephan_
Regular Advisor

Re: script required to check the size of Directory

Use ksh instead of sh in your first line, this will fix it on solaris.

 

hth,

Stephan

 

How to assign points on this new forums --> Kudos - what, where, how, and why!
How to find the right forum --> New forum location by ITRC tree

"we wouldn't call it code, if we could read it ..."
H.Merijn Brand (procura
Honored Contributor

Re: script required to check the size of Directory

I know that 'du' isn't 'di', but I'd like to share this related tool ...

After maybe 40 mails with the author of di, I am glad to say that the just release new version 4.29 works on all HP-UX that I could access, ranging from 10.20 +DAportable to 11.31 with gcc/64

I have uploaded the depots to my site which should be in sync within 20 hours, so feel free to grab your copy. Some examples:

$ di -l -c
s,m,b,u,v,p,T
/dev/vg00/root,/,"400.0M","333.2M","66.3M",83%,vxfs
/dev/vg00/data,/data,"12.0G","11.3G","0.6G",95%,vxfs
/dev/vg00/home,/home,"512.0M","265.1M","246.9M",52%,vxfs
/dev/vg00/opt,/opt,"6.5G","6.1G","0.4G",95%,vxfs
/dev/vg00/pro,/pro,"24.0G","22.2G","1.8G",93%,vxfs
/dev/vg00/stand,/stand,"304.0M","183.2M","119.9M",61%,vxfs
/dev/vg00/tmp,/tmp,"2.0G","0.8G","1.2G",40%,vxfs
/dev/vg00/usr,/usr,"5.3G","2.2G","3.1G",42%,vxfs
/dev/vg00/var,/var,"4.5G","1.8G","2.7G",41%,vxfs
/dev/vg00/wrk,/wrk,"1.0G","0.3G","0.6G",37%,vxfs
$ di -c >di.csv
$ env DBI_DSN="dbi:CSV:f_ext=.csv/r" qs -L f di w p '>' 90
SCHEMA: merijn, TABLE: di
[.]
select    s, m, b, u, v, p, t
from      di
where     p > '90'
s             |m      |b    |u    |v   |p  |t
/dev/vg00/data|/data  |12.0G|11.3G|0.6G|95%|vxfs
/dev/vg00/opt |/opt   |6.5G |6.1G |0.4G|95%|vxfs
/dev/vg00/pro |/pro   |24.0G|22.2G|1.8G|93%|vxfs
$

qs is a perl script that acts as a command-line SQL query interpreter (qs = quick select), and used here just to demonstrate how easy the output of the new -c option for di is parsable.

Enjoy, Have FUN! H.Merijn