[O so Cool] Connecting your Raspberry PI (RPi) to OMS.

8 Feb

 

At my home I have a Raspberry to do all my home automation. (Light, temperature, alarm, cams etc.) . Since the OMS Linux agent is available I was wondering if I could use this agent to monitor my raspberry pi without having a SCOM environment in place.

AND guess what? YES you can!!!

First before you are accusing me of plagiarism I have to say all the credits go to the guy of this blog ( http://kentablog.cluscore.com/2015/12/raspberry-pi-iot-oms_62.html ).

So I followed the steps and it worked. You can’t use the wget described on the oms Quick install Guide ( https://github.com/Microsoft/OMS-Agent-for-Linux ) because this one will fail due to the pre check of AMD64.

Since the RPI platform isn’t AMD64 you will have to trick it a little.

So you will have to follow the steps below:

1

Install The OS on your RPI

We take the latest RASPBIAN WEEZY

https://downloads.raspberrypi.org/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip

2

Open a putty and log on as pi / raspberry

 

3

Now we install the Ruby , and fluent modules

sudo aptitude install ruby-dev git make

sudo gem install fluentd

sudo fluent-gem install fluent-plugin-td

     

4

Next we create a user that the OMS agent service is using for running. Remember the password you provide

sudo adduser omsagent

     

5

Now we are going to get the OMS source code for github

git clone https://github.com/Microsoft/OMS-Agent-for-Linux.git

6

Next is to create the directory structure since we can’t use the OMS installer

sudo mkdir -p /etc/opt/microsoft/omsagent/certs

sudo mkdir -p /etc/opt/microsoft/omsagent/conf/omsagent.d

sudo mkdir -p /etc/opt/microsoft/omsagent/sysconf

sudo mkdir -p /etc/opt/microsoft/scx/conf

sudo mkdir -p /opt/microsoft/omsagent/bin

sudo mkdir -p /opt/microsoft/omsagent/plugins

sudo mkdir -p /var/opt/microsoft/omsagent/tmp

sudo mkdir -p /var/opt/microsoft/omsagent/run

sudo mkdir -p /var/opt/microsoft/omsagent/log

sudo mkdir -p /var/opt/microsoft/omsconfig/log

sudo mkdir -p /var/opt/microsoft/omsconfig/run

sudo chown omsagent:omsagent -R /var/opt/microsoft/omsconfig

sudo chown omsagent:omsagent -R /var/opt/microsoft/omsagent

sudo ln -s /usr /opt/microsoft/omsagent/ruby

sudo ln -s /usr/local/bin/fluentd /opt/microsoft/omsagent/bin/omsagent

7

We setup the correct config files for the OMS agent service

sudo cp OMS-Agent-for-Linux/installer/scripts/auth_key.rb /opt/microsoft/omsagent/bin/

sudo cp OMS-Agent-for-Linux/installer/scripts/omsadmin.sh /opt/microsoft/omsagent/bin/

sudo chmod u+x /opt/microsoft/omsagent/bin/omsadmin.sh

sudo cp OMS-Agent-for-Linux/installer/scripts/service_control /opt/microsoft/omsagent/bin/

sudo cp OMS-Agent-for-Linux/installer/scripts/omsagent.ulinux /etc/init.d/omsagent

sudo chmod u+x /etc/init.d/omsagent

sudo cp -Rf OMS-Agent-for-Linux/source/code/plugins /opt/microsoft/omsagent/

8

We copy the default agent configuration files , we are going to change this later on to specify what we want to monitor

sudo cp OMS-Agent-for-Linux/installer/conf/omsagent.conf /etc/opt/microsoft/omsagent/conf/

sudo mv /etc/rsyslog.conf /etc/rsyslog.conf.default

sudo cp OMS-Agent-for-Linux/installer/conf/rsyslog.conf /etc/

9

And this is probably the trick for this all. We fake the OMS agent to believe it’s an AMD64 platform.

sudo echo “1.0.0-47 20151102 Developer_Build” > /tmp/installinfo.txt

sudo echo `date +%Y-%m-%dT%H:%M:%S` >> /tmp/installinfo.txt

sudo mv /tmp/installinfo.txt /etc/opt/icrosoft/omsagent/sysconf/

sudo echo “OSName=Ubuntu” > /tmp/scx-release

sudo echo “OSVersion=14.04” >> /tmp/scx-release

sudo echo “OSFullName=Ubuntu 14.04 (x86_64)” >> /tmp/scx-release

sudo echo “OSAlias=UniversalD” >> /tmp/scx-release

sudo echo “OSManufacturer=Canonical Group Limited” >> /tmp/scx-release

sudo mv /tmp/scx-release /etc/opt/icrosoft/scx/conf/

10

Now we are going to onboard the OMS agent to your OMS workspace.

Get your (1) <workspace id> and (20 <key> from the OMS page -> Settings -> Connected Sources

 

 

 

11

And we fill it in the omsadmin script as parameters

sudo /opt/microsoft/omsagent/bin/omsadmin.sh -w <workspace id> -s <key>

   

If everything is successful it will give you the onboard message. If not check the keys.

12

Next is to edit the OMS agent config to let it know what it should monitor.

Since the OMI agent isn’t installed on this platform we can only do the syslog stuff for now.

sudo vi /etc/opt/microsoft/omsagent/conf/omsagent.conf

13

The most important is to check if this elements exists in the file

<source>

type syslog

port 25224

bind 127.0.0.1

tag oms.syslog

</source>

 

<filter oms.syslog.**>

type filter_syslog

</filter>

14

Now we are going to let the OMS agent startup correctly as a service. We have to manipulate the init.d file a bit to have it run from of the source files we got from git hub.

sudo vi /etc/init.d/omsagent

15

Edit the file

Change this line:

START_QUALS=”-d $PIDFILE –no-supervisor -o $LOGFILE”

To:

START_QUALS=”-d $PIDFILE –no-supervisor -o $LOGFILE -p /opt/microsoft/omsagent/plugins -c /etc/opt/microsoft/omsagent/conf/omsagent.conf

16

Next we setup the syslog log levels. Just get all 😉

sudo vi /etc/rsyslog.conf

add this row

*.* @127.0.0.1:25224

17

And we startup the OMS agent

sudo service omsagent start

18

And the syslog deamon

sudo service rsyslog restart

19

Now you logon to the portal http://oms.microsoft.com

And you watch for the syslog event type messages. Could take some minutes.

Go to Search and type: “* Type=Syslog” (without the quotes)

Or you search by name if you know the PRI host name: “* HostName=raspberrypi” (without the quotes)

20

This could be the output. We see the startup syslog messages!!!

 

Cool isn’t it!!

Next step would be to get the OMI agent working so we can readout the performance data.

 

Happy OMS’ing

Michel Kamp

Touching SCOM

https://michelkamp.wordpress.com

 

 

Advertisements

5 Responses to “[O so Cool] Connecting your Raspberry PI (RPi) to OMS.”

  1. MarekKu August 28, 2016 at 08:15 #

    I tried following your steps, but it looks like something is missing (I am using 1.2.25 build), the agent keeps crying that:

    Failed to start omsagent.service: Unit omsagent.service failed to load: No such file or directory

    Second thing – there is a typo in step 9 “(/icrosoft)” + the whole madness with double quotes on wordpress (but we all know that already… 😉 )

    • Michel Kamp August 28, 2016 at 10:11 #

      Hi,

      Just wait a little time , I have found a different way of posting Data to OMS . So no agent is required any more. When I have time I will make a post on it.

      Question what are you trying to do with you rpi and OMS?

      Michel

      Sent from my iPhone

      >

      • Ryan February 23, 2017 at 18:56 #

        Number 9 the third step down. “Microsoft” is miss- spelled. Just an FYI

      • Michel Kamp February 23, 2017 at 21:11 #

        Thanks. Beter is to use the OMS log ingestion API and forget this agent at all.

  2. OBerghmans September 26, 2016 at 21:31 #

    I keep getting the error:
    Sep 26 22:27:46 RU-Pi2 omsagent[27472]: Starting Operations Management Suite agent: 2016-09-26 22:27:46 +0200 [error]: fluent/supervisor.rb:615:rescue in main_process: config error file=”/etc/opt/microsoft/omsagent/conf/omsagent.conf” error=”Unknown filter plugin ‘filter_syslog’. Run ‘gem search -rd fluent-plugin’ to find plugins”

    Do you have any idea? I did do the modification to the /etc/init.d/omsagent file stating the plugins directory. In that directory there is the file filter_syslog.rb …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: