Tuesday, December 6, 2016

We were discussing System Center Managers such as from Azure. We look at AWS System center manager next. It's a service that helps you automatically collect software inventory, apply OS patches, create system images, and configure windows and Linux operating systems. It enables to seamlessly bridge the existing infrastructure with AWS. In other words, it can help manage both EC2 and on-premise resources.
The design is similar to Azure SCOM. EC2 systems manager uses a  light-weight agent installed on the EC2 instances and on-premise servers that communicate securely with the Systems Manager service and executes management tasks. This helps you manage resources for Windows and Linux  regardless of whether they are running VMWare ESXi, Microsoft Hyper-V and other platforms.  The Systems Manager service is a cloud service.
EC2 Systems Manager exposes an interface that lets us define management tasks and then select a set of resources to manage. Tasks can be configured to run automatically based either on the results of the software inventory collection or events registered with Amazon CloudWatch events. Amazon EC2 RunCommand is one such interface. It can be used from the EC2 console,  the AWS command line interface,  windows Powershell, or the AWS SDKs. As an example of using it from the Windows powershell, we can specify the following:
Set-AWSCredentials –AccessKey key_name –SecretKey key_name
Set-DefaultAWSRegion -Region us-east-1
To List all available documents:
Get-SSMDocumentList
Get-SSMDocumentDescription -Name "AWS-RunPowerShellScript"
$runPSCommand=Send-SSMCommand -InstanceId @('Instance-ID', 'Instance-ID') -DocumentName AWS-RunPowerShellScript -Comment  'Demo AWS-RunPowerShellScript with two instances' -Parameter @{'commands'=@('dir C:\Users', 'dir C:\')}
Most of the commands that you can run with RunCommand are available as documents. For example, if we want to run a command to remote install python, we can use the AWS-InstallApplication document and pipe the output to a local file.
For Linux machines, we can install the SSM agent:
curl https://amazon-ssm-region.s3.amazonaws.com/latest/linux_amd64/amazon-ssm-agent.rpm -o /tmp/ssm/amazon-ssm-agent.rpm
Run the installer and start the service
sudo yum install -y /tmp/ssm/amazon-ssm-agent.rpm
sudo systemctl start amazon-ssm-agent

We can also RunCommand using the AWS console as well as the AWS CLI.
RunCommand is an example of remote administration for on-premise and AWS EC2 instances.
Other tasks facilitated by the System Center Manager include Inventory Management, State Management, Maintenance and deployment automation.

The Inventory Manager automates the collection of software inventory from managed instances.
The State Manager automates the process of keeping managed instances in a predefined state.
Automation automates common maintenance and deployment tasks.

#codingexercise
Given four key strokes : letter 'A', Ctrl-A, Ctrl-C, Ctrl-V, print the maximum number of A in N strokes:
static int getCount(int N, int copy, int current) 
        {
            if(N <=0)  
                return 0; 
            if (N <= 6) 
                return N; 
            int count0 = current+getCount(N-3, current, current * 2); // ctrl A+C+V 
            int count1 =  copy * 2 + getCount(N-2, copy, current + copy * 2); // ctrl V + ctrl V 
            int count2 = copy + getCount(N-1, copy, current+copy); // ctrl V 
            int count3 = 1 + getCount( N-1, copy, current+1); 
            var counts = new List<int>(){ count0, count1, count2, count3 };
            int max = counts.Max(); 
            return current + max; 
        }

 

No comments:

Post a Comment