[Users] Simple OpenVZ load average aggregation script
Dragomir Zhelev
drago at delta.bg
Mon Mar 5 19:21:16 EST 2012
Some fixes to work better :
#!/bin/bash
NO_HEADER=0
NO_COLOR=0
while getopts "hHC" OPTION; do
case $OPTION in
h)
echo "usage $0 options"
echo "OPTIONS:"
echo " -h Show this help message"
echo " -H Disable the header"
echo " -C Disable colors"
exit 1
;;
H)
NO_HEADER=1
;;
C)
NO_COLOR=1
;;
esac
done
if [ $NO_HEADER -eq 0 ]; then
printf " %-15s %-20s %-15s %-9s %s\r\n" "VEID" "Hostname"
"Load: 1min" "5min" "15min"
fi
for VEID in `vzlist -H -octid`; do
source /etc/vz/conf/$VEID.conf
#LOADTOTAL=$(cat /vz/root/$VEID/proc/loadavg | awk '{print
$1,$2,$3}')
LOADTOTAL=$(vzctl exec 312 cat /proc/loadavg | awk '{print
$1,$2,$3}')
LOAD_1MIN=$(echo $LOADTOTAL | awk '{print $1}')
LOAD_5MIN=$(echo $LOADTOTAL | awk '{print $2}')
LOAD_15MIN=$(echo $LOADTOTAL | awk '{print $3}')
LOAD=${LOAD_1MIN/.*}
[ ${#HOSTNAME} -gt 20 ] && HOSTNAME="${HOSTNAME:0:17}..."
if [ $NO_COLOR -eq 0 ]; then
[ $LOAD -lt 3 ] && COLOR="\033[1;32m"
[ $LOAD -ge 3 ] && COLOR="\033[1;33m"
[ $LOAD -ge 7 ] && COLOR="\033[1;31m"
fi
printf "$COLOR %-15s %-20s %10s %9s %10s\033[0m\r\n" $VEID
$HOSTNAME $LOAD_1MIN $LOAD_5MIN $LOAD_15MIN
done
On 6.03.2012 02:03, Steven Crothers wrote:
> Also, as a side note, I'm really really good at reading man pages.
>
> (What I really mean is I'm not)
>
> Thanks guys!
>
> PS: Mine has color :P
>
> On Mon, Mar 5, 2012 at 6:52 PM, Martynas Venckus <martynas at venck.us
> <mailto:martynas at venck.us>> wrote:
>
> vzlist -o veid,hostname,laverage
>
> On 3/6/12, Kir Kolyshkin <kir at openvz.org <mailto:kir at openvz.org>>
> wrote:
> > If I am not mistaken (can't check right now), vzlist have a
> field for that.
> > On Mar 6, 2012 3:27 AM, "Steven Crothers"
> <steven.crothers at gmail.com <mailto:steven.crothers at gmail.com>> wrote:
> >
> >> I needed something to show me load averages of each individual
> VE quickly.
> >>
> >> Figured I would share it with the community in case someone
> else was
> >> looking for similar functionality.
> >>
> >> https://gist.github.com/1981920
> >>
> >> Disclaimer: Yes, I'm aware I probably don't follow bash best
> practices,
> >> however I don't really care since its under 50 lines anyway :)
> >>
> >> --
> >> Steven Crothers
> >> steven.crothers at gmail.com <mailto:steven.crothers at gmail.com>
> >>
> >>
> >> _______________________________________________
> >> Users mailing list
> >> Users at openvz.org <mailto:Users at openvz.org>
> >> https://openvz.org/mailman/listinfo/users
> >>
> >>
> >
> _______________________________________________
> Users mailing list
> Users at openvz.org <mailto:Users at openvz.org>
> https://openvz.org/mailman/listinfo/users
>
>
>
>
> --
> Steven Crothers
> steven.crothers at gmail.com <mailto:steven.crothers at gmail.com>
>
>
>
> _______________________________________________
> Users mailing list
> Users at openvz.org
> https://openvz.org/mailman/listinfo/users
--
Dragomir Zhelev
CEO
Delta SoftMedia OOD
Cellular: +359 895 66 99 79
E-mail: drago at delta.bg
Web: Delta.BG
<http://delta.bg>
-------------- next part --------------
Skipped content of type multipart/related
More information about the Users
mailing list