<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Bash Scripting in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/bash-scripting/m-p/4798361#M44522</link>
    <description>Hello Folks,&lt;BR /&gt;&lt;BR /&gt;I am newbie in Linux and working as jr. admin&lt;BR /&gt;I need some help to write script for SMART monitoring tool.&lt;BR /&gt;I have to write a script which will run every morning "smartctl" command on around 500 systems to scan hard drives for errors and mail it to admins. This script should only mail errors and show the server it associated with.&lt;BR /&gt;Currenlty we have smartd running on all systems and receive e-mail from each individual system if there is any error.  Management want to recevie only one e-mail every morning which will have all disk errors.&lt;BR /&gt;&lt;BR /&gt;I have written a script which scans drives in all systems and save the result in a file.&lt;BR /&gt;But I am not sure how to extract the date,&lt;BR /&gt;eg:&lt;BR /&gt;System Name = ?, Disk=?, Error.&lt;BR /&gt;&lt;BR /&gt;or &lt;BR /&gt;&lt;BR /&gt;if there is any other way to grep for errors which are genereated by SMART monitoring tools.&lt;BR /&gt;&lt;BR /&gt;Thank you so much in advance.  &lt;BR /&gt;&lt;BR /&gt;Frank&lt;BR /&gt;</description>
    <pubDate>Tue, 14 Jun 2011 00:19:19 GMT</pubDate>
    <dc:creator>Frank_A</dc:creator>
    <dc:date>2011-06-14T00:19:19Z</dc:date>
    <item>
      <title>Bash Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-scripting/m-p/4798361#M44522</link>
      <description>Hello Folks,&lt;BR /&gt;&lt;BR /&gt;I am newbie in Linux and working as jr. admin&lt;BR /&gt;I need some help to write script for SMART monitoring tool.&lt;BR /&gt;I have to write a script which will run every morning "smartctl" command on around 500 systems to scan hard drives for errors and mail it to admins. This script should only mail errors and show the server it associated with.&lt;BR /&gt;Currenlty we have smartd running on all systems and receive e-mail from each individual system if there is any error.  Management want to recevie only one e-mail every morning which will have all disk errors.&lt;BR /&gt;&lt;BR /&gt;I have written a script which scans drives in all systems and save the result in a file.&lt;BR /&gt;But I am not sure how to extract the date,&lt;BR /&gt;eg:&lt;BR /&gt;System Name = ?, Disk=?, Error.&lt;BR /&gt;&lt;BR /&gt;or &lt;BR /&gt;&lt;BR /&gt;if there is any other way to grep for errors which are genereated by SMART monitoring tools.&lt;BR /&gt;&lt;BR /&gt;Thank you so much in advance.  &lt;BR /&gt;&lt;BR /&gt;Frank&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Jun 2011 00:19:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-scripting/m-p/4798361#M44522</guid>
      <dc:creator>Frank_A</dc:creator>
      <dc:date>2011-06-14T00:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Bash Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-scripting/m-p/4798362#M44523</link>
      <description>&lt;!--!*#--&gt;&amp;gt; [...] I am not sure how to extract the&lt;BR /&gt;&amp;gt; date,&lt;BR /&gt;&lt;BR /&gt;Do you mean "the date" or "the data"?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I have written a script [...]&lt;BR /&gt;&lt;BR /&gt;With my weak psychic powers, I can't see it&lt;BR /&gt;from here.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] and save the result in a file.&lt;BR /&gt;&lt;BR /&gt;I can't see its result file, either, so I&lt;BR /&gt;also have no idea how to extract anything&lt;BR /&gt;from it.  Perhaps if you could post a sample&lt;BR /&gt;of the data in the file, you might get some&lt;BR /&gt;useful suggestions.</description>
      <pubDate>Tue, 14 Jun 2011 03:35:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-scripting/m-p/4798362#M44523</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-06-14T03:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Bash Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-scripting/m-p/4798363#M44524</link>
      <description>Thanks Steven for looking into it.&lt;BR /&gt;&lt;BR /&gt;I would like to grep for the following lines along with the name of system and drive which is causing a problem.&lt;BR /&gt;&lt;BR /&gt;- SMART overall-health self-assessment test result: PASSED&lt;BR /&gt;&lt;BR /&gt;(If any line showing "FAILING_NOW" eg:&lt;BR /&gt;- 190 Airflow_Temperature_Cel 0x0022   041   036   045    Old_age   Always   FAILING_NOW 59 (255 255 61 58)&lt;BR /&gt;&lt;BR /&gt;- (If value of Offline_Uncorrectable is &amp;gt; 0)&lt;BR /&gt;- 198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       1&lt;BR /&gt;----------------------------------------&lt;BR /&gt;Script&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;echo&lt;BR /&gt;StatusLog=/home/aeronaut/smart/StatusLog&lt;BR /&gt;ErrorLog=/home/aeronaut/smart/ErrorLog&lt;BR /&gt;DashLine="---------------------------"&lt;BR /&gt;&lt;BR /&gt;if [ -f $StatusLog ]&lt;BR /&gt;then&lt;BR /&gt;        rm $StatusLog&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ -f $ErrorLog ]&lt;BR /&gt;then&lt;BR /&gt;        rm $ErrorLog&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;SYSTEMS_LIST=$1&lt;BR /&gt;&lt;BR /&gt;for SYSTEM in `cat $1`&lt;BR /&gt;        do&lt;BR /&gt;        SystemName=$SYSTEM&lt;BR /&gt;        echo $DashLine $SystemName $DashLine &amp;gt;&amp;gt; $StatusLog&lt;BR /&gt;        Drives=/home/aeronaut/smart/Drives&lt;BR /&gt;        /usr/bin/ssh -x root@$SYSTEM "awk '{ print \$4 }' /proc/partitions" &amp;gt;&amp;gt; $Drives&lt;BR /&gt;        for drive in `cat $Drives`&lt;BR /&gt;                do&lt;BR /&gt;                if expr length $drive = 3 &amp;amp;&amp;gt; /dev/null&lt;BR /&gt;                then&lt;BR /&gt;                        echo "Disk /dev/$drive in $SystemName" &amp;gt;&amp;gt; $StatusLog&lt;BR /&gt;                        /usr/bin/ssh -x root@$SYSTEM "smartctl -H -A /dev/$drive" &amp;gt;&amp;gt; $StatusLog&lt;BR /&gt;                fi&lt;BR /&gt;                done&lt;BR /&gt;&lt;BR /&gt;                rm $Drives &lt;BR /&gt;        done&lt;BR /&gt;&lt;BR /&gt;                #cat $StatusLog | egrep 'FAILING_NOW|Uncorrectable_Sector' &amp;gt;&amp;gt; $ErrorLog&lt;BR /&gt;                #echo $SystemName &amp;gt;&amp;gt; $ErrorLog&lt;BR /&gt;                #cat $StatusLog | grep PASSED &amp;gt;&amp;gt; $ErrorLog&lt;BR /&gt;                #echo $DashLine &amp;gt;&amp;gt; ErrorLog&lt;BR /&gt;&lt;BR /&gt;-------------------------------------------&lt;BR /&gt;Ouput of command in a file..&lt;BR /&gt;&lt;BR /&gt;[root@Server smart]# cat StatusLog&lt;BR /&gt;---------------------------Hostname---------------------------&lt;BR /&gt;Disk /dev/sda in Hostname&lt;BR /&gt;smartctl version 5.38 [x86_64-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen&lt;BR /&gt;Home page is &lt;A href="http://smartmontools.sourceforge.net/" target="_blank"&gt;http://smartmontools.sourceforge.net/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;=== START OF READ SMART DATA SECTION ===&lt;BR /&gt;SMART overall-health self-assessment test result: PASSED&lt;BR /&gt;See vendor-specific Attribute list for marginal Attributes.&lt;BR /&gt;&lt;BR /&gt;SMART Attributes Data Structure revision number: 10&lt;BR /&gt;Vendor Specific SMART Attributes with Thresholds:&lt;BR /&gt;ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE&lt;BR /&gt;  1 Raw_Read_Error_Rate     0x000f   105   100   006    Pre-fail  Always       -       93059077&lt;BR /&gt;  3 Spin_Up_Time            0x0003   096   096   000    Pre-fail  Always       -       0&lt;BR /&gt;  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       30&lt;BR /&gt;  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0&lt;BR /&gt;  7 Seek_Error_Rate         0x000f   078   060   030    Pre-fail  Always       -       78288284&lt;BR /&gt;  9 Power_On_Hours          0x0032   074   074   000    Old_age   Always       -       23298&lt;BR /&gt; 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0&lt;BR /&gt; 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       30&lt;BR /&gt;187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0&lt;BR /&gt;189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0&lt;BR /&gt;190 Airflow_Temperature_Cel 0x0022   043   039   045    Old_age   Always   FAILING_NOW 57 (255 255 58 56)&lt;BR /&gt;194 Temperature_Celsius     0x0022   057   061   000    Old_age   Always       -       57 (0 22 0 0)&lt;BR /&gt;195 Hardware_ECC_Recovered  0x001a   058   056   000    Old_age   Always       -       83729161&lt;BR /&gt;197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0&lt;BR /&gt;198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0&lt;BR /&gt;199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0&lt;BR /&gt;200 Multi_Zone_Error_Rate   0x0000   100   253   000    Old_age   Offline      -       0&lt;BR /&gt;202 TA_Increase_Count       0x0032   100   253   000    Old_age   Always       -       0&lt;BR /&gt;&lt;BR /&gt;Disk /dev/sdb in Hostname&lt;BR /&gt;smartctl version 5.38 [x86_64-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen&lt;BR /&gt;Home page is &lt;A href="http://smartmontools.sourceforge.net/" target="_blank"&gt;http://smartmontools.sourceforge.net/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;=== START OF READ SMART DATA SECTION ===&lt;BR /&gt;SMART overall-health self-assessment test result: PASSED&lt;BR /&gt;See vendor-specific Attribute list for marginal Attributes.&lt;BR /&gt;&lt;BR /&gt;SMART Attributes Data Structure revision number: 10&lt;BR /&gt;Vendor Specific SMART Attributes with Thresholds:&lt;BR /&gt;ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE&lt;BR /&gt;  1 Raw_Read_Error_Rate     0x000f   093   078   006    Pre-fail  Always       -       202368475&lt;BR /&gt;  3 Spin_Up_Time            0x0003   097   097   000    Pre-fail  Always       -       0&lt;BR /&gt;  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       34&lt;BR /&gt;  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       5&lt;BR /&gt;  7 Seek_Error_Rate         0x000f   082   060   030    Pre-fail  Always       -       190767494&lt;BR /&gt;  9 Power_On_Hours          0x0032   054   054   000    Old_age   Always       -       40480&lt;BR /&gt; 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0&lt;BR /&gt; 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       65&lt;BR /&gt;187 Reported_Uncorrect      0x0032   028   028   000    Old_age   Always       -       72&lt;BR /&gt;189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0&lt;BR /&gt;190 Airflow_Temperature_Cel 0x0022   041   036   045    Old_age   Always   FAILING_NOW 59 (255 255 61 58)&lt;BR /&gt;194 Temperature_Celsius     0x0022   059   064   000    Old_age   Always       -       59 (0 28 0 0)&lt;BR /&gt;195 Hardware_ECC_Recovered  0x001a   048   045   000    Old_age   Always       -       1951677&lt;BR /&gt;197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       1&lt;BR /&gt;198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       1&lt;BR /&gt;199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0&lt;BR /&gt;200 Multi_Zone_Error_Rate   0x0000   100   253   000    Old_age   Offline      -       0&lt;BR /&gt;202 TA_Increase_Count       0x0032   100   253   000    Old_age   Always       -       0&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Jun 2011 13:55:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-scripting/m-p/4798363#M44524</guid>
      <dc:creator>Frank_A</dc:creator>
      <dc:date>2011-06-14T13:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Bash Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-scripting/m-p/4817821#M44590</link>
      <description>&lt;P&gt;Something like this might do it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# grep -A20 FAILING_NOW &amp;lt;file&amp;gt; | egrep 'FAILING_NOW|Disk'&lt;/P&gt;&lt;P&gt;190 Airflow_Temperature_Cel 0x0022 043 039 045 Old_age Always FAILING_NOW 57 (255 255 58 56)&lt;/P&gt;&lt;P&gt;Disk /dev/sdb in Hostname1&lt;/P&gt;&lt;P&gt;190 Airflow_Temperature_Cel 0x0022 041 036 045 Old_age Always FAILING_NOW 59 (255 255 61 58)&lt;/P&gt;&lt;P&gt;Disk /dev/sdf in Hostname2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Depending on the data, it could pick up extra lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2011 20:13:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-scripting/m-p/4817821#M44590</guid>
      <dc:creator>Kurt Boyack</dc:creator>
      <dc:date>2011-07-07T20:13:01Z</dc:date>
    </item>
  </channel>
</rss>

