Sponsored Content
Top Forums Shell Programming and Scripting Required formatted output on mail for disk utilization Post 303010671 by as7951 on Friday 5th of January 2018 05:46:37 AM
Old 01-05-2018
Required formatted output on mail for disk utilization

Hi Experts,

Could you pls help with below query

I have written below script to capture disk utilization and then send the output on mail. But getting unformated output on mail

Code:
#!/bin/bash 
echo "Hi Sur,">dfoutput.csv
printf '\n' >>dfoutput.csv
echo "Please find BAYSQUAR2 filesystem details as below. ">>dfoutput.csv
printf '\n' >>dfoutput.csv
df -hP /Baysquar2/undo /Baysquar2/redo1 /Baysquar2/redo2 /Baysquar2/temp /Baysquar2/arch01 /Baysquar2/disk04 /Baysquar2/disk03 /Baysquar2/disk02 /Baysquar2/disk01 /Tat
icr/data04 /Taticr/data05 /Baysquar2/disk08 /Baysquar2/disk07 /Baysquar2/disk06 /Baysquar2/disk05 /Baysquar2/arch02_new /Baysquar2/disk09 /Baysquar2/disk10 /Baysquar2/
disk11 /Baysquar2/disk12 /Baysquar2/disk13|awk '{printf "%-5s|%-5s|%-5s|%-5s|%5s\n", $2,$3,$4,$5,$6}' >>dfoutput.csv
printf '\n' >>dfoutput.csv
echo "Regards">>dfoutput.csv
echo "Unix Team">>dfoutput.csv
cat dfoutput.csv|mailx -s "BAYSQUAR2 172.17.5.199(Tata-Icr2)" xyz@abc.com

Current output(irregularize)
Code:
Size |Used |Avail|Use% |Mounted
99G  |96G  |3.2G |97%  |/Baysquar2/undo
50G  |12G  |39G  |23%  |/Baysquar2/redo1 50G  |9.2G |41G  |19%  |/Baysquar2/redo2 99G  |93G  |6.2G |94%  |/Baysquar2/temp
99G  |5.2G |94G  |6%   |/Baysquar2/arch01
148G |147G |1.4G |100% |/Baysquar2/disk04 148G |147G |1.4G |100% |/Baysquar2/disk03 168G |167G |1.2G |100% |/Baysquar2/disk02 296G |296G |9.0M |100% |/Baysquar2/disk01 1.2T |867G |339G |72%  |/Taticr/data04
1008G|719G |290G |72%  |/Taticr/data05
788G |785G |2.5G |100% |/Baysquar2/disk08 540G |536G |3.7G |100% |/Baysquar2/disk07 493G |491G |1.5G |100% |/Baysquar2/disk06 542G |539G |2.7G |100% |/Baysquar2/disk05 247G |91G  |144G |39%  |/Baysquar2/arch02_new
1008G|957G |619M |100% |/Baysquar2/disk09 956G |1.7G |100%

Below is expected output which i need to have
Code:
Size |Used |Avail|Use% |Mounted
99G  |96G  |3.2G |97%  |/Baysquar2/undo
50G  |12G  |39G  |23%  |/Baysquar2/redo1
50G  |9.2G |41G  |19%  |/Baysquar2/redo2
99G  |93G  |6.2G |94%  |/Baysquar2/temp
99G  |5.2G |94G  |6%   |/Baysquar2/arch01
148G |147G |1.4G |100% |/Baysquar2/disk04
148G |147G |1.4G |100% |/Baysquar2/disk03
168G |167G |1.2G |100% |/Baysquar2/disk02
296G |296G |9.0M |100% |/Baysquar2/disk01
1.2T |867G |339G |72%  |/Taticr/data04

Regards
 

7 More Discussions You Might Find Interesting

1. Red Hat

Disk Utilization is very high

Hi, I have monitored that disk utilization is very high on one of red hat linux VM. Would like to know how to find out that issue of high disk utilization is because of disk or Installed Application on that server is causing the problem. Regards, Manoj (1 Reply)
Discussion started by: manoj.solaris
1 Replies

2. Infrastructure Monitoring

Disk Utilization between Global + Zone

Dear Gentleman in my environment I have Solaris10 OS Box in Global Zone with 136 GB and mount point from SAN Storage 500 GB (Orastorage) Zone1 mounted on /Zones folder with 66 GB when I run zpool list output -bash-3.00$ zpool list NAME SIZE ALLOC FREE CAP HEALTH... (0 Replies)
Discussion started by: Hosam
0 Replies

3. Red Hat

Disk Utilization

Hi, Can anybody explain why my newly created 120G FS shows 100% utilization when only 113G of disk space has been used? ...... # df -h . Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg01-lvol0 119G 113G 0 100% /u02 #du -h /u02 16K ... (3 Replies)
Discussion started by: Duffs22
3 Replies

4. UNIX for Dummies Questions & Answers

Disk utilization

Hi, I have hundred folders under a fs /apps which is used by different users and they upload their data to these folders on a daily basis. Using du -sk gives me complete structure of the filesystem but i want to find out day to day utlization of the top ten highest accoriding to size wise ... (4 Replies)
Discussion started by: chetansingh23
4 Replies

5. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

6. Shell Programming and Scripting

Mail a formatted csv file

I have the below script i am getting the csv in garbled format.Please suggest the changes. SUNOS ####################################################################### ####MAIN SCRIPT ####################################################################### today=`date "+%m-%d-%Y ... (3 Replies)
Discussion started by: rafa_fed2
3 Replies

7. UNIX for Beginners Questions & Answers

Required cpu , memory, df output in mail for multiple servers

I have prepared script which will collect cpu, memory and df out out for multiple server and send in one mail, but my script only run in one server, and when I send to mail, it shows in text format. it should be show actual format. if any one can help , that would be very grateful. script... (1 Reply)
Discussion started by: yash_message
1 Replies
csv(n)								  CSV processing							    csv(n)

NAME
csv - Procedures to handle CSV data. SYNOPSIS
package require Tcl 8.3 package require csv ?0.3? ::csv::join values {sepChar ,} ::csv::joinlist values {sepChar ,} ::csv::read2matrix chan m {sepChar ,} {expand none} ::csv::read2queue chan q {sepChar ,} ::csv::report cmd matrix ?chan? ::csv::split line {sepChar ,} ::csv::split2matrix m line {sepChar ,} {expand none} ::csv::split2queue q line {sepChar ,} ::csv::writematrix m chan {sepChar ,} ::csv::writequeue q chan {sepChar ,} DESCRIPTION
The csv package provides commands to manipulate information in CSV FORMAT (CSV = Comma Separated Values). COMMANDS
The following commands are available: ::csv::join values {sepChar ,} Takes a list of values and returns a string in CSV format containing these values. The separator character can be defined by the caller, but this is optional. The default is ",". ::csv::joinlist values {sepChar ,} Takes a list of lists of values and returns a string in CSV format containing these values. The separator character can be defined by the caller, but this is optional. The default is ",". Each element of the outer list is considered a record, these are separated by newlines in the result. The elements of each record are formatted as usual (via ::csv::join). ::csv::read2matrix chan m {sepChar ,} {expand none} A wrapper around ::csv::split2matrix (see below) reading CSV-formatted lines from the specified channel (until EOF) and adding them to the given matrix. For an explanation of the expand argument see ::csv::split2matrix. ::csv::read2queue chan q {sepChar ,} A wrapper around ::csv::split2queue (see below) reading CSV-formatted lines from the specified channel (until EOF) and adding them to the given queue. ::csv::report cmd matrix ?chan? A report command which can be used by the matrix methods format 2string and format 2chan. For the latter this command delegates the work to ::csv::writematrix. cmd is expected to be either printmatrix or printmatrix2channel. The channel argument, chan, has to be present for the latter and must not be present for the first. ::csv::split line {sepChar ,} converts a line in CSV format into a list of the values contained in the line. The character used to separate the values from each other can be defined by the caller, via sepChar, but this is optional. The default is ",". ::csv::split2matrix m line {sepChar ,} {expand none} The same as ::csv::split, but appends the resulting list as a new row to the matrix m, using the method add row. The expansion mode specified via expand determines how the command handles a matrix with less columns than contained in line. The allowed modes are: none This is the default mode. In this mode it is the responsibility of the caller to ensure that the matrix has enough columns to contain the full line. If there are not enough columns the list of values is silently truncated at the end to fit. empty In this mode the command expands an empty matrix to hold all columns of the specified line, but goes no further. The overall effect is that the first of a series of lines determines the number of columns in the matrix and all following lines are truncated to that size, as if mode none was set. auto In this mode the command expands the matrix as needed to hold all columns contained in line. The overall effect is that after adding a series of lines the matrix will have enough columns to hold all columns of the longest line encountered so far. ::csv::split2queue q line {sepChar ,} The same as ::csv::split, but appending the resulting list as a single item to the queue q, using the method put. ::csv::writematrix m chan {sepChar ,} A wrapper around ::csv::join taking all rows in the matrix m and writing them CSV formatted into the channel chan. ::csv::writequeue q chan {sepChar ,} A wrapper around ::csv::join taking all items in the queue q (assumes that they are lists) and writing them CSV formatted into the channel chan. FORMAT
Each record of a csv file (comma-separated values, as exported e.g. by Excel) is a set of ASCII values separated by ",". For other lan- guages it may be ";" however, although this is not important for this case (The functions provided here allow any separator character). If a value contains itself the separator ",", then it (the value) is put between "". If a value contains ", it is replaced by "". EXAMPLE
The record 123,"123,521.2","Mary says ""Hello, I am Mary""" is parsed as follows: a) 123 b) 123,521.2 c) Mary says "Hello, I am Mary" SEE ALSO
matrix, queue KEYWORDS
csv, matrix, queue, package, tcllib csv 0.3 csv(n)
All times are GMT -4. The time now is 03:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy