Skip to content

Commit b2e37b6

Browse files
authored
Merge pull request #576 from afumagalli98/updated-sar-scripts
Updated sar scripts
2 parents 1bb949a + 940103b commit b2e37b6

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

fetch/linux/sar_cpu_only_linux.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# You should have received a copy of the GNU General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
#Needed for AM/PM in the sar output
19+
export LC_ALL=en_US.UTF-8
20+
1821
#Retrieve os (linux, aix, sunos)
1922
inizio=`date`
2023
os_system=`uname -a | awk '{print $1}' | tr '[:upper:]' '[:lower:]'`

fetch/linux/sar_disks_only_linux.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
# You should have received a copy of the GNU General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
#Notes
19+
20+
#tps: indicate the number of transfers per second that were issued to the device.
21+
#rd_sec/s: number of sectors read from the device. The size of a sector is 512 bytes.
22+
#wr_sec/s: number of sectors written to the device. The size of a sector is 512 bytes.
23+
24+
#IOMB = (rd_sec/s + wr_sec/s) * 512 / (1024 * 1024 ) -> MB/s
25+
26+
#Needed for AM/PM in the sar output
27+
export LC_ALL=en_US.UTF-8
28+
1829
#Retrieve os (linux, aix, sunos)
1930
inizio=`date`
2031
os_system=`uname -a | awk '{print $1}' | tr '[:upper:]' '[:lower:]'`
@@ -88,18 +99,18 @@ if [ $os_system == 'linux' ]
8899
#Array creation
89100
dates_array+=($dates_second)
90101
tps_array+=(${myarray[0]})
91-
iomb_array+=($(echo "scale=2;(${myarray[1]}+${myarray[2]})*$sector_size/1024" | bc))
102+
iomb_array+=($(echo "scale=2;(${myarray[1]}+${myarray[2]})" | bc))
92103
#Is an average line after the restart line, arrays have to be reinitialized with the current values
93104
else
94105
(( last_index=${#dates_array[@]}-1 ))
95106
tps_array[$last_index]=$(echo "scale=2;${myarray[0]}" | bc)
96-
iomb_array[$last_index]=$(echo "scale=2;(${myarray[1]}+${myarray[2]})*$sector_size/1024" | bc)
107+
iomb_array[$last_index]=$(echo "scale=2;(${myarray[1]}+${myarray[2]})" | bc)
97108
fi
98109
else
99110
#Other lines to be summarized to the initialized line
100111
(( last_index=${#dates_array[@]}-1 ))
101112
tps_array[$last_index]=$(echo "scale=2;${tps_array[$last_index]}+${myarray[0]}" | bc)
102-
iomb_array[$last_index]=$(echo "scale=2;${iomb_array[$last_index]}+((${myarray[1]}+${myarray[2]})*$sector_size/1024)" | bc)
113+
iomb_array[$last_index]=$(echo "scale=2;${iomb_array[$last_index]}+((${myarray[1]}+${myarray[2]}))" | bc)
103114
fi
104115
fi
105116
done
@@ -129,7 +140,7 @@ if [ $os_system == 'linux' ]
129140
hour_column="${myarray[0]}"
130141
ampm_column="${myarray[1]}"
131142
tps_column="${myarray[2]}"
132-
iomb_column=$(echo "scale=2;(${myarray[3]}+${myarray[4]})*$sector_size/1024" | bc)
143+
iomb_column=$(echo "scale=2;(${myarray[3]}+${myarray[4]})" | bc)
133144
#Current line datetime in seconds
134145
current_line_datetime=(`date -d "$file_date $hour_column$ampm_column" +%s`)
135146
#if last element datetime = current element datetime -> sum tps and iomb (two or more different disks -> sum values)

0 commit comments

Comments
 (0)