Both. As I don't have any experience woth mpstat , please prepare an input sample for, say, 3 cpus and 3 intervals, e.g. 5 minutes apart, and the final result after the overall processing.
Here is a sample for mpstat for CPU3 in one of the blades
# mpstat -P 3 2
Linux 3.0.101-0.15.1.6550.0.PTF-default (SC-1) 11/10/16 _x86_64_
22:29:16 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
22:29:18 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
22:29:20 3 0.00 0.00 0.50 0.00 0.00 0.00 0.00 0.00 99.50
22:29:22 3 0.00 0.00 0.50 0.00 0.00 0.00 0.00 0.00 99.50
22:29:24 3 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.50
22:29:26 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
22:29:28 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Here is the actual output of my script, which creates a XML file containing the snapshot of CPU usage. Note that this file does not correspond to the input sample I showed above
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="MeasDataCollection.xsl"?>
<measCollecFile xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec">
<measCollec beginTime="2016-11-10T19:44:30+11:00"/>
<measData>
<measInfo measInfoId="OSProcessingLogicalUnit">
<measType p="1">CPULoad.IOWait</measType>
<measType p="2">CPULoad.IRQ</measType>
<measType p="3">CPULoad.Nice</measType>
<measType p="4">CPULoad.SoftIRQ</measType>
<measType p="5">CPULoad.System</measType>
<measType p="6">CPULoad.Total</measType>
<measType p="7">CPULoad.User</measType>
<measValue measObjLdn="OSProcessingUnit=SC-1,OSProcessingSocketUnit=0,OSProcessingLogicalUnit=0">
<r p="1">0</r>
<r p="2">0</r>
<r p="3">0</r>
<r p="4">0.02</r>
<r p="5">0.09</r>
<r p="6">0.25</r>
<r p="7">0.14</r>
</measValue>
<measValue measObjLdn="OSProcessingUnit=SC-1,OSProcessingSocketUnit=0,OSProcessingLogicalUnit=1">
<r p="1">0</r>
<r p="2">0</r>
<r p="3">0</r>
<r p="4">0.01</r>
<r p="5">0.07</r>
<r p="6">0.16</r>
<r p="7">0.07</r>
</measValue>
</measInfo>
</measData>
<fileFooter>
<measCollec endTime="2016-11-10T19:59:30+11:00"/>
</fileFooter>
</measCollecFile>
Any hints on my last question...
- To start the script on the next quarter hour
You could try something like:
#!/bin/ksh
delay=$(( 15 - ( $(date +%M) % 15) ))
[ $delay -eq 1 ] && unit=minute || unit=minutes
at now + $delay $unit <<-EOF
date
EOF
replacing the date shown in red with the commands you want to run on the next quarter hour.