Disk Space Utilization in HTML format working in one environment and not working on the other

Tags
final stage, shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 06-21-2018
Wrench Disk Space Utilization in HTML format working in one environment and not working on the other

Hi Team,

I have written the shell script which returns the result of the disk space filesystems which has crossed the threshold limit in HTML Format. Below mentioned is the script which worked perfectly on QA system.

Code:
df -h | awk -v host=`hostname` '
BEGIN {
print "<table border="4" bordercolor=greencellpadding=\"3\" cellspacing=\"7\">"
printf "<tr BGCOLOR=#FFAF6E><td><B>%s</B></td></tr>\n", host
print "<tr BGCOLOR=#EBE3E3><th>Filesystem</th><th>Size</th><th>Used</th><th>Avail</th><th>Used%</th><th>Mounted on</th></tr>"
}
NR>1&&($5+0)>70{
     print "<tr>"
    for( i = 1; i <= NF; i++ ) {
printf "%s", "<td"
      if (i==5&&$i+0>85) printf " bgcolor=#FF2C2C"
       else if (i==5&&$i+0>=75) printf " bgcolor=#FFC200"
       print ">" $i "</td>"
    }
     print "</tr>"
  }
   END { print "</table>" }' > DSReport.html

But the same thing was not working on PRODUCTION system. SmilieSmilie

For PROD system, How we login is using swrap <admin>@<servername>

then we will execute the script.

The result displayed is actually blank tables even though there are filesystems which crossed the threshold. I am getting Headers only as output.

Please help me to resolve this issue. QUICK RESPONSE IS APPRECIATED. Thank you.

Not an order , My biggest request as i Need to complete this task before sunday.
# 2  
Old 06-21-2018
What is swrap?

If you get an empty table, then the first place to look is the the df -h command.

Start with the basics -
Use your login procedure (whatever that is) on PROD:
Code:
df -h  && echo 'OK'  || echo 'df command failed'

# 3  
Old 06-21-2018
swrap is like sudo

I tried the command df -h && echo 'OK' || echo 'df command failed' and got the output as normal df -h and in the end 'OK'.

I think the df -h doesn't have any problem. IS there any other way to get the result ?
# 4  
Old 06-21-2018
Could it be that your production environment is a Solaris/SunOS system?

You may need to change awk to /usr/xpg4/bin/awk or nawk
This User Gave Thanks to Chubler_XL For This Post:
jim mcnamara (06-21-2018)
# 5  
Old 06-22-2018
No, Its linux OS only both PROD and QA.

Script was working fine in outside local systems BUT why not in PROD ? Smilie
# 6  
Old 06-25-2018
Partially Resolved

Dear All,

I have made the below changes to make the script generates a HTML report. Now I need your help . If the filesystems crossed the threshold matching the below code , as per the code it should create a DSReport.html file or else it should create a text file stating that NO ISSUES REPORTED on the server.

Please help me to modify this code. Please

Code:
df -Ph | awk -v host=`hostname` '
BEGIN {
print "<table border="4" bordercolor=greencellpadding=\"3\" cellspacing=\"7\">"
printf "<tr BGCOLOR=#FFAF6E><td><B>%s</B></td></tr>\n", host
print "<tr BGCOLOR=#EBE3E3><th>Filesystem</th><th>Size</th><th>Used</th><th>Avail</th><th>Used%</th><th>Mounted on</th></tr>"
}
NR>1&&($5+0)>70{
     print "<tr>"
    for( i = 1; i <= NF; i++ ) {
printf "%s", "<td"
      if (i==5&&$i+0>85) printf " bgcolor=#FF2C2C"
       else if (i==5&&$i+0>=75) printf " bgcolor=#FFC200"
       print ">" $i "</td>"
    }
     print "</tr>"
  }
   END { print "</table>" }' > DSReport.html

# 7  
Old 06-25-2018
Try
Code:
df -Ph | awk -v host=`hostname` '
BEGIN   {print "<table border="4" bordercolor=greencellpadding=\"3\" cellspacing=\"7\">"
         printf "<tr BGCOLOR=#FFAF6E><td><B>%s</B></td></tr>\n", host
         print "<tr BGCOLOR=#EBE3E3><th>Filesystem</th><th>Size</th><th>Used</th><th>Avail</th><th>Used%</th><th>Mounted on</th></tr>"
        }

NR > 1 &&
($5+0) > 70     {XVAL = 1
                 print "<tr>"
                 for( i = 1; i <= NF; i++ )     {printf "%s", "<td"
                                                 if (i==5 && $i+0 > 85)         printf " bgcolor=#FF2C2C"
                                                 else if (i==5 && $i+0 >= 75)   printf " bgcolor=#FFC200"
                                                 print ">" $i "</td>"
                                                }
                 print "</tr>"
                }
END             {print "</table>"
                 exit XVAL+0
                }
' > DSReport.html && { echo "NO ISSUES REPORTED" > DSResult.txt; rm DSReport.html; }

This User Gave Thanks to RudiC For This Post:
Harihsun (06-25-2018)
Login to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
i am working on migration project, 8.5 sever able to embedded HTML report to mail body with below sy JatinInfy UNIX for Beginners Questions & Answers 0 07-16-2018 02:27 PM
Working out percentage of memory utilization simpsa27 Shell Programming and Scripting 7 08-08-2017 11:37 AM
Html format not working Arun_p Shell Programming and Scripting 4 09-07-2016 12:19 PM
RHEL 7: Backup Space and Delete is not working in console kalpeer Red Hat 4 10-06-2015 11:33 AM
Sendmail cmd for html body and attachment not working close2jay Shell Programming and Scripting 2 06-11-2015 10:53 PM
Working with disk sets from replicated LUNs abohmeed Solaris 2 03-18-2014 10:22 AM
Need simpler way to find all my disk space utilization using df -h aakhan2011 Shell Programming and Scripting 2 03-09-2014 02:18 PM
Date Format not working in python script AReddy Shell Programming and Scripting 1 09-20-2013 10:08 AM
Html java script not working scriptscript Web Programming 1 07-22-2013 07:27 PM
sed command working different in linux environment. vee_789 Shell Programming and Scripting 9 11-28-2011 09:26 AM
disk space utilization script svajhala Shell Programming and Scripting 6 12-27-2010 12:24 PM
Display o/p in HTML format from unix environment apsprabhu Shell Programming and Scripting 3 04-12-2010 09:55 AM
grep not working when search string has a space in it sekhar gajjala AIX 3 02-26-2010 05:55 AM
Substring not working if more than 1 space prassu UNIX for Dummies Questions & Answers 3 08-22-2008 08:59 PM
All times are GMT -4. The time now is 07:27 AM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?