Home » Mailing lists » Users » Simple OpenVZ load average aggregation script
|
|
|
Re: Simple OpenVZ load average aggregation script [message #45421 is a reply to message #45420] |
Tue, 06 March 2012 00:03 |
Steven Crothers
Messages: 3 Registered: May 2011
|
Junior Member |
|
|
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@venck.us> wrote:
> vzlist -o veid,hostname,laverage
>
> On 3/6/12, Kir Kolyshkin <kir@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@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@gmail.com
> >>
> >>
--
Steven Crothers
steven.crothers@gmail.com
|
|
|
Re: Simple OpenVZ load average aggregation script [message #45422 is a reply to message #45421] |
Tue, 06 March 2012 00:21 |
Drago
Messages: 5 Registered: February 2010 Location: Bulgaria
|
Junior Member |
|
|
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@venck.us
> <mailto:martynas@venck.us>> wrote:
>
> vzlist -o veid,hostname,laverage
>
> On 3/6/12, Kir Kolyshkin <kir@openvz.org <mailto:kir@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@gmail.com <mailto:steven.crothers@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@gmail.com <mailto:steven.crothers@gmail.com>
> >>
> >>
> >> _______________________________________________
> >> Users mailing list
> >> Users@openvz.org <mailto:Users@openvz.org>
> >> https://openvz.org/mailman/listinfo/users
> >>
> >>
> >
> _______________________________________________
> Users mailing list
> Users@openvz.org <mailto:Users@openvz.org>
> https://openvz.org/mailman/listinfo/users
>
>
>
>
> --
> Steven Crothers
> steven.crothers@gmail.com <mailto:steven.crothers@gmail.com>
>
>
>
--
Dragomir Zhelev
CEO
Delta SoftMedia OOD
Cellular: +359 895 66 99 79
E-mail: drago@delta.bg
Web: Delta.BG
<http://delta.bg>
|
|
|
Re: Simple OpenVZ load average aggregation script [message #45423 is a reply to message #45422] |
Tue, 06 March 2012 08:42 |
Martin Dobrev
Messages: 14 Registered: November 2006
|
Junior Member |
|
|
And so we'll see the load avg for VEID 312 as many times as your VPS count is. Replace please 312 with $VEID.
Martin Dobrev
Sent from iPhonespam SPAMSPAM 4
On 06.03.2012, at 02:21, Dragomir Zhelev <drago@delta.bg> wrote:
>
> 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@venck.us> wrote:
>> vzlist -o veid,hostname,laverage
>>
>> On 3/6/12, Kir Kolyshkin <kir@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@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@gmail.com
>> >>
>> >>
>> --
>> Steven Crothers
>> steven.crothers@gmail.com
>>
>>
>>
> --
> Dragomir Zhelev
> CEO
> Delta SoftMedia OOD
> Cellular: +359 895 66 99 79
> E-mail: drago@delta.bg
> Web: Delta.BG
> <logo.png>
|
|
|
Goto Forum:
Current Time: Thu Nov 07 22:33:31 GMT 2024
Total time taken to generate the page: 0.03260 seconds
|