Link to home
Start Free TrialLog in
Avatar of harmsingh
harmsingh

asked on

Disk viewing in GB /Script for sending alert on unmount filesystem or raid failure

Hi

Is there any scripts for calculating the size of filesystem in GB.i had tried the below script but its giving syntax error.

df -k | sort -n -k4 | awk '{as = $3; if (as > 1024 * 1024) {as /= 1024 * 1024; su = "G";} if (as > 1024) {as /= 1024; su = "M"} printf("%8.2f%c  %s\n", as, su, $0);}'

also if any tool or script is there that whwnever the hdisk in raid fails or any filesystem gets unmounted it send a alert message.thru email or sms.

Its urgently needed.

anybody has some freeware tool other than nmon for genreating monthly graphical analysis reports for client presentation.Pls do forward me.

Thanks
Avatar of Graeme_Cowell
Graeme_Cowell

1.  What syntax error are you getting?  Your script works OK on my machines.

2.  Your RAID supplier should be able to help with disk failure alerting, depends what RAID array you're using.

3.  If you're generating reports for client presentation I would suggest that you look to buy or develop a package and not rely on freeware (although something like MRTG might be what you want).
Avatar of harmsingh

ASKER

i get the below  error on the script described

df -k | sort -n-k4 |awk ' {as = $3; if (as> 1024 * 1024) {as /=1024 * 1024; su = "G"; } if (as > 1024) {as /=1024; su = "M"} printf("%8.2f%c %s\n", as, su, $0):}'





df -k | sort -n-k4 |awk ' {as = $3; if (as> 1024 * 1024) printf("%8.2f%c %s\n", as, su, $0):}'


#df -k | sort -n-k4 |awk ' {as = $3; if (as> 1024 * 1024)
> printf("%8.2f%c %s\n", as, su, $0):}'
sort: illegal option -- -
Usage:   sort   [-Abcdfimnru] [-T Directory] [-t Character] [-o File]
                [-y[Kilobytes]] [-z Recordsize] [-k Keydefinition]...
                [[+Position1][-Position2]]... [File]...
 syntax error The source line is 2.
 The error context is
                printf("%8.2f%c %s\n", as, su, >>>  $0): <<<
 awk: The statement cannot be correctly parsed.
 The source line is 2.
#  su = "M"} printf("%8.2f%c %s\n", as, su, $0):}'                           <
sort: illegal option -- -
Usage:   sort   [-Abcdfimnru] [-T Directory] [-t Character] [-o File]
                [-y[Kilobytes]] [-z Recordsize] [-k Keydefinition]...
                [[+Position1][-Position2]]... [File]...
 syntax error The source line is 1.
 The error context is
                 {as = $3; if (as> 1024 * 1024) {as /=1024 * 1024; su = "G"; } if (as > 1024) {as /=1024; su = "M"} printf("%8.2f%c %s\n", as, su, >>>  $0): <<<
 awk: The statement cannot be correctly parsed.
 The source line is 1.
ASKER CERTIFIED SOLUTION
Avatar of Graeme_Cowell
Graeme_Cowell

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial