Configuration System Center Testing Windows 10 Xplat

OMS – Install Linux Agent on Windows 10 Bash

windows10-ubuntu

Do you know these “WOW!” moments in an IT Pro’s life? Well I just had one of these moments recently when I heard about the Windows 10 Insider build feature where you can run Bash shell on Windows 10 as a dedicated subsystem. The description of the system is like this…

This isn’t a virtual machine, a container, or Linux software compiled for Windows (like Cygwin). Instead, Windows 10 gains a Linux Subsystem for Windows, which is based on Microsoft’s abandoned Project Astoria work for running Android apps on Windows. Think of it as the opposite of Wine. While Wine allows you to run Windows applications directly on Linux, the Linux Subsystem for Windows allows you to run Linux applications directly on Windows. (Source)

Microsoft co-operated with Canonical to offer a full Ubuntu-based Bash shell that runs atop this subsystem. Cool, now why is Microsoft doing this? Well, there was always an urge to have SSH on Windows for managing also any non-Windows system. I guess this is one reason and probably also for developers to develop scripts and utilities. We have an Ubuntu-based Bash shell, it is not a full blown Linux server (!), it is just a shell having tools installed and similar file structure as a Linux server but it does not have the Linux kernel deployed at all. Ok so what else can we do with it? I was wondering if the Linux OMS agent will run on that subsystem :). Sounds cool? Well, let’s see…

Bash Installation

The installation of Bash is pretty easy, install the latest Windows 10 Insider Preview build and make sure you update it immediately. In my environment it shows this version…

image

Next enable Windows Subsystem for Linux (Beta) on the client…

image

Restart the client and execute bash…

image

Next, you need to provide user and password and then you should have your full blown Bash…

image

It shows the following version…

image

If you need very detailed steps, Scott Hanselmann has recorded a video with some more installation steps and also some additional information.

Next let’s install the OMS Linux agent…

OMS Linux Agent Installation

The installation of the agent is very well described on GitHub or I had also written a post some time ago. If you need detailed info, please check these articles first.

Download the agent using this command…

wget https://github.com/Microsoft/OMS-Agent-for-Linux
/releases/download/v1.1.0-217/omsagent-1.1.0-217.universal.x64.sh

image

Next, we need to create a new link to /sbin/initctl…

sudo dpkg-divert –local –rename –add /sbin/initctl

ln -s /bin/true /sbin/initctl

…otherwise we get during installation errors like this…

image

…additionally the installation checks for a file /var/run/utmp, this we create like this…

cat /dev/null > /var/run/utmp

otherwise we get during installation errors like this…

image

…if you run all the commands using root, it looks like this…image

Add the computer name, in my case WINLX, to the hosts file in C:\Users\root\AppData\Local\lxss\rootfs\etc…

image

…you can use Notepad 🙂

image

Next, we need to allow services to start and therefore modify the policy file /usr/sbin/policy-rc.d , we use vi …

image

  • press the key “i” for insert
  • edit the line with a “#”
  • press the “Esc” key to change the vi mode
  • press “:”
  • type “wq!” for writing and quite

…the uncomment the line should look like this…

image

Now we are ready to install the package…

sudo sh ./omsagent-1.1.0-217.universal.x64.sh –upgrade -w <YOUR OMS WORKSPACE ID> -s <YOUR OMS WORKSPACE PRIMARY KEY>

image

The installation will take a moment and end like this…

image

Although there appear some errors, we simply ignore them :)…

OMS Workspace

Within the OMS workspace you will find the connected agent, because I uninstalled and reinstalled the agent once I have 2 servers “connected”…

image

Next go to the DATA section and add some or all performance counters for Linux. After your selection click Save…

image

Soon, you will receive Heartbeat every 5 minutes from the agent…

image

And the performance counters appear…

image

…and more details…

image

…additionally some Syslog messages…

image

This is a cool demo to show the potential of Bash and in my opinion a fun thing, collecting Linux performance data on Windows 10 via OMS. There might be other ways to bring this agent up and running, my approach was installing and then troubleshooting the errors and find a way to fix it.

Note: This is not a production scenario nor is this supported by Microsoft. There are also errors during installation, meaning there are still some issues. So this is just for experimental purposes! Have fun…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.