Sponsored Content
Full Discussion: Distribution of load
Top Forums Shell Programming and Scripting Distribution of load Post 302850911 by summer_cherry on Friday 6th of September 2013 02:53:29 AM
Old 09-06-2013
hope below perl can help you some

Code:
my %overload;
my %idle;

sub handle{
	OUTER:
	foreach my $os (sort keys  %overload){
		foreach my $is (sort keys %idle){
			my $ol = $overload{$os};
			my $available = $idle{$is};
			if($available > $ol){
				print "$os ",$ol," can be done on $is\n";
				$idle{$is} = $available - $ol;
				delete $overload{$os};
				next OUTER;
			}
			elsif ($available == $ol){
				print "$os ",$ol," can be done on $is\n";
				delete $overload{$os};
				delete $idle{$is};
				next OUTER;
			}
			else{
				print "$os ",$available," can be done on $is\n";
				delete $idle{$is};
				$overload{$os} = $ol-$available;
				next;
			}
		}
	}
}

sub remain{
	my @ol = keys %overload;
	if($#ol>=0){
		print "Still have below to be accormodated\n";
		foreach(@ol){
			print $_,":",$overload{$_},"\n";
		}
	}
	
	my @id = keys %idle;
	if($#id>=0){
		print "Still have below idle\n";
		foreach(@id){
			print $_,":",$idle{$_},"\n";
		}
	}
}

while(<DATA>){
	chomp;
	my @arr = split("-",$_);
	@arr = map {s/\s+//g;$_} @arr;
	if($arr[1] eq 'OverLoad'){
		$overload{$arr[0]}=$arr[2];
	}
	else{
		$idle{$arr[0]} =  $arr[2];
	}		
}

handle();

remain();
__DATA__
Server1 - OverLoad - 252
Server2 - OverLoad - 431
Server3 - AcceptLoad - 550
Server4 - AcceptLoad - 59
Server5 - AcceptLoad - 224
Server6 - OverLoad - 1000

 

5 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

could not load hme

After installing Solaris patches, i faced this problem which the system could not load hme ( network interface). after booting up the system i try to configure the IP add. on hme (ifconfig hme inet ......),but it fails. the /etc/hostname.hme0 file exists & is ok & in Prom mode also after running... (1 Reply)
Discussion started by: nikk
1 Replies

2. UNIX for Dummies Questions & Answers

Load error

hi i am facing a problem when i run a shell script to load a table.the error is Record 1: Rejected - Error on table TRENDS."SHP_CUST_ORD_ITM". ORA-14400: inserted partition key is beyond highest legal partition key Record 2: Rejected - Error on table TRENDS."SHP_CUST_ORD_ITM", column... (4 Replies)
Discussion started by: musavir19
4 Replies

3. UNIX for Dummies Questions & Answers

load Balance

Guys im trying to create a script that will load ballance 3 devices. Unix is still very alien to me having only been in this position for 3 months now. Not to mention the fact that i've been thrown in the deep end. Anyway so far i've managed to make a script that looks at all 4 devices and make a... (1 Reply)
Discussion started by: yorkyboy
1 Replies

4. Shell Programming and Scripting

Need help in wrting Load Script for a Load-Resume type of load.

hi all need your help. I am wrting a script that will load data into the table. then on another load will append the data into the existing table. Regards Ankit (1 Reply)
Discussion started by: ankitgupta
1 Replies

5. UNIX for Dummies Questions & Answers

VPS has load 200, httpd load no activity, netstat nothing

Hello, on my hostserver i see one VPS of mine got load of 200.00 and netstat nothing (not a single blank line on netstat command) after some time, netstat started showing connections, but i see no excessive IP connections. tail -f /var/log/httpd/access_log shows no activity /var/log/messages ;... (1 Reply)
Discussion started by: postcd
1 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 03:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy