• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 452
  • Last Modified:

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
0
harmsingh
Asked:
harmsingh
  • 2
1 Solution
 
Graeme_CowellCommented:
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).
0
 
harmsinghAuthor Commented:
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.
0
 
Graeme_CowellCommented:
You need a space between the -n and the -k4 in the sort command!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now