Commit edbd42ae authored by Volodymyr Melnyk's avatar Volodymyr Melnyk
Browse files

Initial commit

parents
#!/bin/bash
PATH=/bin:/usr/bin
. /opt/snmp_stats/lib/common.sh
io_stats_dir="${_spool_dir}/io"
io_stats_timestamp="${io_stats_dir}/.timestamp"
while :; do
touch "${io_stats_timestamp}"
sudo /usr/sbin/iotop -d 10 -n 2 -k -b -a -o -P | \
awk \
-v iostats_dir="${io_stats_dir}" \
-f "${_lib_dir}/save_io_stats.awk"
find "${io_stats_dir}" -type f ! -newer "${io_stats_timestamp}" -delete
sleep 5
done
#!/bin/bash
PATH=/bin
. /opt/snmp_stats/lib/common.sh
io_stats_dir="${_spool_dir}/io"
io_stats_timestamp="${io_stats_dir}/.timestamp"
mib="${_mib_root}.10"
act="${1}"
req="${2}"
instance_number="${req#${mib}}"
instance_number="${instance_number#.}"
if [[ "${act}" = '-s' ]]; then
exit
fi
while [[ -f ${io_stats_timestamp} ]]; do
sleep 1
done
if [[ "${act}" = '-n' ]]; then
instance_number=$(
ls "${io_stats_dir}" | sort -n | \
awk \
-v instance_number="${instance_number}" \
-f "${_lib_dir}/snmp_io_stats_find_next.awk"
)
fi
if [[ -f "${io_stats_dir}/${instance_number}" ]]; then
echo "${mib}.${instance_number}"
io_stats="$(cat "${io_stats_dir}/${instance_number}")"
io_stats_r="${io_stats%:*}"
io_stats_w="${io_stats#*:}"
echo "integer"
echo "$(printf '%0.f' "${io_stats_w}")"
fi
_exit_status_ok=0
_exit_status_error=2
_exit_status="${_exit_status_ok}"
_root_dir='/opt/snmp_stats'
_lib_dir="${_root_dir}/lib"
_log_dir="${_root_dir}/log"
_var_dir="${_root_dir}/var"
_lock_dir="${_var_dir}/run"
_spool_dir="${_var_dir}/spool"
_mib_root=".1.3.6.1.4.1.53033.100"
BEGIN {
pass = 0
}
/^Total / {
pass++
}
/ qemu-kvm -name i-[0-9]+-[0-9]+-VM / {
if(pass == 2) {
if(split($14, instance_name, "-") == 4) {
print ($4 ":" $6) > ( iostats_dir "/" instance_name[3] )
}
}
}
BEGIN {
if(instance_number) {
found = 0
} else {
found = 1
}
}
// {
if(found == 1) {
print($0)
exit;
}
if(instance_number == $0) {
found = 1
}
}
12728.00:1514.00
656.00:373.00
144.00:221.00
128.00:196.00
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment