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
PAPS(1) 						      General Commands Manual							   PAPS(1)

NAME
paps - UTF-8 to PostScript converter using Pango SYNOPSIS
paps [options] files... DESCRIPTION
paps reads a UTF-8 encoded file and generates a PostScript language rendering of the file. The rendering is done by creating outline curves through the pango ft2 backend. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. --landscape Landscape output. Default is portrait. --columns=cl Number of columns output. Default is 1. --font=desc Set the font description. Default is Monospace 12. --rtl Do rtl layout. --paper ps Choose paper size. Known paper sizes are legal, letter, a4. Default is A4. --bottom-margin=bm Set bottom margin in postscript points (1/72 inch). Default is 36. --top-margin=tm Set top margin. Default is 36. --left-margin=lm Set left margin. Default is 36. --right-margin=rm Set right margin. Default is 36. --help Show summary of options. --header Draw page header for each page. --markup Interpret the text as pango markup. --encoding=ENCODING Assume the documentation encoding is ENCODING. --lpi Set the lines per inch. This determines the line spacing. --cpi Set the characters per inch. This is an alternative method of specifying the font size. --stretch-chars Indicates that characters should be stretched in the y-direction to fill up their vertical space. This is similar to the texttops behaviour. AUTHOR
paps was written by Dov Grobgeld <dov.grobgeld@gmail.com>. This manual page was written by Lior Kaplan <kaplan@debian.org>, for the Debian project (but may be used by others). April 17, 2006 PAPS(1)
All times are GMT -4. The time now is 01:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy