Wednesday, November 27, 2013

Alarm on high non-global zone memory usage

We use a lot of Solaris non-global zones for various reasons. Our tools admin enabled memory usage alarms on these ng zones and they alerted incorrectly (due to the misleading internal resource stats). We still use native resource counters to alarm on global zones, but scripted the following bit of perl to alarm when ng zones exceed a defined threshold:

use strict;
use warnings;
use Time::localtime;

my $ram_threshold = "90";

my $zones = `prstat -Z 1 1 | /usr/sfw/bin/ggrep -A 99 ZONEID | egrep -vi 'total|global|zoneid' | awk '{ print \$5","\$8 }'`;
my @zoneSplit = split("\n",$zones);

foreach my $zone (@zoneSplit) {
                my @zone_info = split(",",$zone);
                my $zone_ram = substr($zone_info[0], 0, -1);
                my $zone_name = $zone_info[1];

                if ($zone_ram gt $ram_threshold) {
                                $ConsoleMessage->Severity("Normal");
                                $ConsoleMessage->Application("zone_pool");
                                $ConsoleMessage->Object("object");
                                $ConsoleMessage->MsgText("$zone_name memory exceeded $ram_threshold, value is $zone_ram");
                                $ConsoleMessage->Send();
                }

}

1 comment:

  1. You are brilliant eathernet. Please keep this coming.

    ReplyDelete