How to produce beep sound if value in a file goes beyond 80%

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nihar147
    New Member
    • Sep 2013
    • 2

    #1

    How to produce beep sound if value in a file goes beyond 80%

    I have written a PHP script which shows the file system usages of some unix servers in a dashboard. I want to get a sound to be generated when the usage in any file system goes beyond 80%.
    I am providing my script and a sample of my output as it shows in the dashboard.
    Please help.

    Code:
    <?php
    
    //Get the parameter type
    
    $Mountpointtype=$_POST["mountpointtype"];
    
    /*Call scripts to generate filter data8*/
    
    system("/shLog/scripts/preProd/viewmountpointdata.sh $Mountpointtype");
    
    /* Handle exception If File exist then proceed to display data*/
    $InputFileName="/shLog/scripts/output/Dashboard/resources/storageData/displayData.log";
    
    if(!file_exists("$InputFileName"))
       {
    /* Show Error Message ...*/ 
       echo "
    <div id=bv_Text1 style=position:absolute;left:97px;top:70px;width:637px;height:28px;z-index:0 align=top><img src=images/img_error1.jpg id=Image1 alt= align=top border=0 style=width:14px;height:14px;><font style=font-size:14px color=#0000FF face=Arial align=top><b>**<i>Input Data file not available. Please verify and try again.</i></b></font></div>
    
    ";
       die("");
        
       }
     else
       {
    
    /* Input  data from csv file*/ 
    $file_handle = fopen("$InputFileName", "r");
    
       }
    echo "<html>";
    echo "
    <head> <style type='text/css'>
            body { font-family:Arial, Helvetica, Sans-Serif; font-size:0.7em;}
            #report { border-collapse:collapse;}
            #report h4 { margin:0px; padding:0px;}
            #report img { float:right;}
            #report ul { margin:10px 0 10px 40px; padding:0px;}
            #report th { background:#7CB8E2 url(images/img_header_bkg.png) repeat-x scroll center left; color:#fff; padding:5px 20px; text-align:left;}
            #report td { background:#C7DDEE none repeat-x scroll center left; color:#000; padding:2px 20px; }
            #report tr.odd td { background:#fff url(images/img_row_bkg.png) repeat-x scroll center left; cursor:pointer; }
            #report div.arrow { background:transparent url(images/img_arrows.png) no-repeat scroll 0px -16px; width:16px; height:16px; display:block;}
            #report div.up { background-position:0px 0px;}
        </style> <script src=jquery.min.js type='text/javascript'></script> <script type='text/javascript'>  
            $(document).ready(function(){
                $('#report tr:odd').addClass('odd');
                $('#report tr:not(.odd)').hide();
                $('#report tr:first-child').show();
                
                $('#report tr.odd').click(function(){
                    $(this).next('tr').toggle();
                   $(this).find('.arrow').toggleClass('up');
                });
                //$('#report').jExpand();
            });
        </script> </head>
    
    ";
    
    echo "<body> <font style=font-size:15px;background-color:#FFFFFF  color=#00008B face=Tahoma  text-align:center><b>******FileSystem mount Point Usage</b></font> <br><br> <table id=report  style=font-size:11px ; face=Georgia ; font-family:Arial, Helvetica, Sans-Serif ;  align=left> <tr> <th>Hostname</th> <th>Time</th> <th>%Usage</th> <th>MountpointName</th> <th>Status</th> <th>Type</th> </tr>
    ";
    
    //Output a line of the file until the end is reached
    
    while (!feof($file_handle) ) {
    
    $line_of_text = fgetcsv($file_handle, 1024);
    
    echo "
    <tr> <td>$line_of_text[0]</td> <td>$line_of_text[2]</td> <td>$line_of_text[4]</td> <td>$line_of_text[5]</td> <td>$line_of_text[6]</td> <td>$line_of_text[7]</td> </tr> <tr>
    
    	       echo "
    				</ul> </td> </tr>
    				";
    }
    
    echo "</table>";
    echo "</body>";
    echo "</html>";
    
    fclose($file_handle);
    
    ?> 
    
    My Output
    -------------
      FileSystem mount Point Usage 
    
    Hostname Time %Usage MountpointName Status Type 
    PRMSWB02 11:00 83 / critical Local  
    
    PFMWDB02 11:00 83 /nim critical Local  
    
    PRMSCM01 11:00 80 / critical Local  
    
    PORAID02 11:00 79 /home critical Local  
    
    PRMSCM01 11:00 76 /home critical Local  
    
    POUBDB01 11:00 76 /dataou critical San  
    
    PFMWDB02 11:00 76 /datafm critical San  
    
    POUBDB01 11:00 72 /opt critical Local  
    
    PFMWDB01 11:00 69 /opt warning Local  
    
    PRMSAP02 11:00 68 /tmp warning Local  
    
    POUBDB01 11:00 67 /home warning Local  
    
    PRMSCM02 11:00 65 /app warning San  
    
    PRMSCM01 11:00 65 /app warning San  
    
    POUBDB01 11:00 65 /dataou5 warning San  
    
    POUBDB01 11:00 65 /dataou10 warning San  
    
    POUBDB01 11:00 64 /dataou6 warning San  
    
    PMSGMS01 11:00 64 / warning Local  
    
    PRMSPO01 11:00 62 / warning Local  
    
    PRMSPO01 11:00 61 /u01 warning Local  
    
    POUBDB01 11:00 61 /dataou9 warning San  
    
    POUBDB01 11:00 60 /dataou3 warning San  
    
    PFMWDB02 11:00 57 /djb warning Local  
    
    PORAID01 11:00 55 /home warning Local  
    
    PORAID01 11:00 55 /u01 warning Local  
    
    PFMWDB02 11:00 54 /usr warning Local  
    
    PFMWDB01 11:00 54 /usr warning Local  
    
    POUBDB01 11:00 53 /usr warning Local  
    
    PFMWDB01 11:00 53 / warning Local  
    
    PRMSDB02 11:00 52 /usr warning Local  
    
    PMSGMS02 11:00 50 / warning Local  
    
    PFMWDB01 11:00 50 /tmp warning Local


    Thank You
    Last edited by Rabbit; Sep 19 '13, 03:26 PM. Reason: Please use code tags when posting code or formatted data.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Basically you want to play a sound in a webbrowser

    Google for:
    play sound in a browser site:stackoverf low.com
    and you will find an answer

    Comment

    • nihar147
      New Member
      • Sep 2013
      • 2

      #3
      Thanks for the link but i want help how to play the sound when a certain condition rises(condition is in my earlier post).


      Thanks...

      Comment

      • Luuk
        Recognized Expert Top Contributor
        • Mar 2012
        • 1043

        #4
        after line#70
        Code:
        if ($line_of_text[4]>80)
           { echo "put code to play sound here...."; }

        Comment

        Working...