Share:|

MyIT leverages the power of social media to help your employees take Digital innovation to the next level.  We live in an age where collaboration needs to be seamless and information has to be just a few clicks or taps away. 

 


 

 

Social Data Model

 

MyIT Social is a combination of Node.js (java script engine) and MongoDB.

 

MyITSocialIntro.PNG

 

When you log into the Universal Client and look at the Updates tab, most of this activity stream is actually being retrieved from MongoDB. For example whenever you comment, like, share or view the timeline you are actually inserting/viewing  this information to and from MongoDB.

 

NodeMongoDBUC.PNG

 

 

As you can see from my illustration below, the Web UI layer (Angular.js) utilizes Node.js to send and retrieve data to and from MongoDB. This works particularly well as both Node.js and MongoDB use Javascript and JSON.

MongoDBSocialDataModel.PNG

 

So what happens when you create or update a Service Request from MyIT or the Mid-Tier ?

 

1) Tomcat communicates directly to AR System via the REST API

2) Workflow is triggered and data is copied to the relevant AR System forms

3) The SEM plugin is called and a reference of the SR is created in Social

 

So let's see what happens under the hood when you post something on the wall:

 

1) Tomcat makes a POST request

 

Reqest http://clm-hou-007518.bmc.com:9000/ux/rest/v2/activity is made with the following payload:

 

{"text":"Anyone know where Tom is ?","type":"microblog"}  (This will be converted into the social API parameter)

 

2) The Service layer (Tomcat) then calls the Social service API (node.js)

 

Request: http://clm-hou-007518.bmc.com:9001/social/rest/v1/activity/microblog

 

Data is inserted into MongoDB at this point a response is sent back to social:

 

[2016-02-25 04:47:33.811] [INFO] [default] - POST params:{"userId":"appadmin","tenantId":"000000000000001","text":"Anyone know where Tom is ?"}

[2016-02-25 04:47:33.833] [DEBUG] [default] - New microblog created for id:56cedbc589ac8ed009e6fc8a

 

Note:

id - This is only for a microblog

guid - This is for INC/REQ/WO

 

And for the activity stream:

 

1) Tomcat makes a GET request

 

http://clm-hou-007518.bmc.com:9000/ux/rest/v2/activity_stream

 

2) The Service layer (Tomcat) then calls the social service API (node.js)

 

|METHOD=GET|URL/social/rest/v1/user/appadmin/activitystream

 

...and the response is sent back.

 

Activitystreamrespons1.PNG Activitystreamrespons2.PNG

 

As you might have guessed, we need both Node.js and MongoDB to be fully functional to use MyIT. So how can you find them ? Well, you'll find node.js running as a process on Linux:

 

NodeJSRun.PNG

 

In the event you make any changes to the config.js (social configuration file in the social directory) or you need to restart it, you'll find the startup/shutdown scripts in the "/etc/init.d" directory. If they're registered you can also restart by using the stop/stop command as shown below:

 

StopStartNode.PNG

If you're looking for it on Windows, node.js is actually listed as a service called "MyITSocialService"

NodeJSWindows.PNG

 

Now that we've gone through Node.js, let's get into more depth about it's humongous partner in action - MongoDB. At a high level, MongoDB is a document-oriented DBMS, similar to MySQL but with JSON-like objects comprising the data model rather than RDBMS tables. For those of you familiar with SQL, the following illustration will help you understand the terms:

MongoDB SQL.PNG

 

Connecting to MongoDB

 

MyIT/Smart IT is shipped with MongoDB but if you're planning on setting up a replication set you'll need to download the package from Mongodb.org and configure it (see link at the bottom of this blog).

You can connect to MongoDB by navigating to the mongo "bin" directory and typing "mongo". In the screenshot below I'm connected to our Social Database (social) which is created when you run the MyIT/SmartIT installer. By default, mongo enters the shell and connects to the "test" database but you can easily switch over to social by typing the "use  social" command.

 

MongoNoAuth.PNG

 

 

The other alternative is to use a GUI such as UMongo, RoboMongo or MongoChef.  In the example below I'm using MongoChef to connect to the primary MongoDB Server of my Replication set.

 

Note: The secondary servers are set up for write only which is why I'm connected to my primary to read the data. On the other hand, if I was already connected to the shell on secondary I could just type "rs.slaveOK()" and this will allow read operations to run.

 

MongoChefSetup.PNG MongoChefSetupUser.PNG

 

As soon as the connection is successful you'll see a nice graphical representation of your Social DB.There are some additional features of this tool such as "intellishell", "Query builder" and "Export". "Intellishell" allows you to quickly open the shell from inside the GUI and execute commands as normal. "Query builder" is particularly useful if you're performing complex searches and "Export" helps you export out as many collections as you like.

 

MongoChefExplanation.PNG

 

The following table will give you an idea what each collection contains:

 

MongoDBContents.PNG

 

MongoDB Replication

 

Replication is the process of synchronizing data across servers to ensure high availability so if you're running in a production environment it's highly recommended you consider this.

 

The following three-member replica set has two secondary members. The secondaries replicate the primary’s oplog and apply the operations to their data sets.

 

Replication Set.PNGMongoDBReplicaSet.png

 

When a primary does not communicate with the other members the replica set will attempt to select another member to become the new primary. The first secondary that receives a majority of the votes becomes primary.

 

MongoDB 3.0 Wired Tiger

 

Starting with MyIT 3.0 we now bundle MongoDB 3.0 which comes with Wired Tiger - MongoDB's new high performance Engine. It isn't setup by default when you install MongoDB so there are two ways of enabling it:

 

a) For a new setup, follow the steps in our MongoDB documentation at the bottom of this Blog.

 

b) From an existing MongoDB 3.0 replication set without WT enabled

 

1) Stop MongoDB on one of the secondary’s

2) Add "storageEngine = wiredTiger" to the mongo.cfg file

3) Backup & delete the data in the mongodata directory

4) Start MongoDB and the data will be copied over from one of the other MongoDB servers in the replication set.

 

Note: The format of the Mongo data will now change to Wired Tiger.

 

Wired Tiger Format.PNG

 

5) Go to current primary and do "rs.stepDown()" and stop the mongo service

 

This will force the database into secondary and trigger one of the other servers into primary mode.

 

6) Add "storageEngine = wiredTiger" to the mongo.cfg file

7) Delete the data in the mongodata directory

8) Start MongoDB

9) Stop your remaining secondary

10) Add "storageEngine = wiredTiger" to mongo.cfg

11) Start MongoDB

 

Troubleshooting MongoDB/Node.js

 

If there's a problem with node.js you may see your data dissapear from the Universal Client and a connection error:

 

NodeJSDown.PNG

 

MongoDB on the other hand might just show a spinning wheel:

 

MongoDBdown.PNG

In the event you see either of these symptoms:

 

  • Check the MongoDB and the Social Services are running

 

a) For MongoDB on Linux issue the following command:

 

[root@clm-aus-000627 ~]# ps -ef | grep mongo

root    15236    1  0 Aug17 ?        06:52:24 /opt/bmc/Smart_IT_MyIT/Smart_IT_MyIT/mongodb/bin/mongod --fork -f /opt/bmc/Smart_IT_MyIT/Smart_IT_MyIT/mongodb/mongod.cfg

root    16254 16220  0 03:03 pts/5    00:00:00 grep mongo

 

Notice the mongod process above is running. If you don't see it, start it by issuing the following command:

 

[root@clm-aus-000627 ~]service myitmongod start

 

For Windows simply highlight the service to start or stop.

 

MongoWinService.PNG

 

b) Check Node.js on Linux by using the grep command:

 

[root@clm-aus-000627 ~]# ps -ef | grep node

 

NodeJSRun.PNG

 

....and if this command isn't returning anything, you can start it by issuing the following command:

 

[root@clm-aus-000627 ~]service socialserviced start

 

Same again for Windows, just highlight the service to start/stop.

 

MyITSocialServiceWindows.PNG

 

Some additional things to check are as follows:

 

  • Check Social service health:

 

Pre-MongoDB 3.0

http://myithost:9001/social/rest/v1/installationcheck

Response:

{"success":"Hello World"}

 

MongoDB 3.0

http://myithost:9001/social/rest/v1/mongoconnection

Response:

{"connection-status":"available"}

OR

{"connection-status":"not_avaialable"}

 

  • Open the UX log located in the SmartIT MyIT log directory and search for anything related to social
  • Open the mongo log (path specified in the mongod.cfg) and look for any exceptions
  • Make sure you have diskspace (linux command is "df -h").
  • Check your JRE version is supported (java  -version)
  • If using a replication set check the config.js file (located in the social directory) is pointing at the right nodes.
  • Check all hostnames are all resolvable by pinging them
  • Try telneting to the hostname/IP address
  • Check node.js and mongo ports are not being used by another process (node is 9001 and mongo is 27017)
  • Tomcat queries Mongo for a key (held in the MongoDB) to authenticate so check to make sure it's being returned by entering the following in your browser:

 

http://myithost:9001/social/rest/v1/api/myit

 

You should get something like this:

 

"key": "01a86963-b8e8-e19c-4bb0-ffaf30a9d209“

 

  • If using Linux, check what the ulimit values are set to by typing "ulimit -a" from the command line.

Reccomended Ulimits.PNG

  • If MongoDB starts crashing on your Linux system check your system log by typing "dmesg" or the following:

 

[root@clm-aus-000627 ~]# grep mongod /var/log/messages

 

For MyIT/SRM integration, check the following:

 

  • Open the SHR:SHR_KeyStore form and ensure the MyIT URL is correct & the token/secret is the same as the one in the connect.properties file on the MyIT Tomcat Server.

SHRKeyStore.PNGCPropertiesToken.PNG

  • Open the "pluginsvr_config.xml" file on the AR Server and check the path references to the plugin file are correct
  • Ensure plugin reference in the ar.cfg is also present.

PluginSVRConfig.PNGPluginConf.PNG

  • Open the MyIT Administration menu and make sure the SRM provider has the correct Mid-Tier path and remedy application service password

  • Enable Social Event Manager debug as follows:

 

a) Open the "log4j_pluginsvr.xml" in the pluginsvr directory and change these lines to debug:

 

<logger additivity="true" name="com.bmc.arsys.pluginsvr">

            <level value="debug"/>

      </logger>

   <logger additivity="true" name="com.bmc.arsys.pluginsvr.plugins">

            <level value="debug"/>

      </logger>

     <logger additivity="true" name="com.bmc.remedy.itsm.SocialCloud">

                     <level value="debug"/>

       <appender-ref ref="SocialCloudPluginLog"/>

   </logger>

 

b) Restart the AR Server, reproduce the problem and check/send us the SocialEventManager and arjavaplugin logs.

 

Note: Starting with MyIT 2.6 we replaced the social cloud plugin with the Social Event plugin.

 

  • For MongoDB replication set troubleshooting use the rs.status() command to check the overall health of your MongoDB replication set.

 

Note: If you've enabled authentication you need to be logged into the admin DB with a user who has permission to issues these commands:

 

myitsocial:PRIMARY> use admin

switched to db admin

myitsocial:PRIMARY> db.auth("siteRootAdmin", "admin");

1

myitsocial:PRIMARY> rs.status()

{

        "set" : "myitsocial",

        "date" : ISODate("2016-02-26T12:16:37.455Z"),

        "myState" : 1,

        "members" : [

                {

                        "_id" : 0,

                        "name" : "clm-aus-009799:27017",

                        "health" : 1,

                        "state" : 1,

                        "stateStr" : "PRIMARY",

                        "uptime" : 6558893,

                        "optime" : Timestamp(1456485910, 1),

                        "optimeDate" : ISODate("2016-02-26T11:25:10Z"),

                        "electionTime" : Timestamp(1455196320, 1),

                        "electionDate" : ISODate("2016-02-11T13:12:00Z"),

                        "configVersion" : 3,

                        "self" : true

                },

                {

                        "_id" : 1,

                        "name" : "172.22.239.230:27017",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 6558889,

                        "optime" : Timestamp(1456485910, 1),

                        "optimeDate" : ISODate("2016-02-26T11:25:10Z"),

                        "lastHeartbeat" : ISODate("2016-02-26T12:16:35.755Z"),

                        "lastHeartbeatRecv" : ISODate("2016-02-26T12:16:36.715Z"

),

                        "pingMs" : 1,

                        "syncingTo" : "clm-aus-009799:27017",

                        "configVersion" : 3

                },

                {

                        "_id" : 2,

                        "name" : "172.22.229.100:27017",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 1292611,

                        "optime" : Timestamp(1456485910, 1),

                        "optimeDate" : ISODate("2016-02-26T11:25:10Z"),

                        "lastHeartbeat" : ISODate("2016-02-26T12:16:35.717Z"),

                        "lastHeartbeatRecv" : ISODate("2016-02-26T12:16:35.622Z"

),

                        "pingMs" : 1,

                        "syncingTo" : "clm-aus-009799:27017",

                        "configVersion" : 3

                }

        ],

        "ok" : 1

}

           

In the example above you'll see my primary and two secondary MongoDB servers are communicating well whereas if the primary MongoDB crashes or is not reachable you'll see a failed attempt message:

 

myitsocial:PRIMARY> rs.status()

{

        "set" : "myitsocial",

        "date" : ISODate("2016-02-26T12:20:08.668Z"),

        "myState" : 1,

        "members" : [

                {

                        "_id" : 0,

                        "name" : "clm-aus-009799:27017",

                        "health" : 1,

                        "state" : 1,

                        "stateStr" : "PRIMARY",

                        "uptime" : 6559104,

                        "optime" : Timestamp(1456485910, 1),

                        "optimeDate" : ISODate("2016-02-26T11:25:10Z"),

                        "electionTime" : Timestamp(1455196320, 1),

                        "electionDate" : ISODate("2016-02-11T13:12:00Z"),

                        "configVersion" : 3,

                        "self" : true

                },

                {

                        "_id" : 1,

                        "name" : "172.22.239.230:27017",

                        "health" : 0,

                        "state" : 8,

                        "stateStr" : "(not reachable/healthy)",

                        "uptime" : 0,

                        "optime" : Timestamp(0, 0),

                        "optimeDate" : ISODate("1970-01-01T00:00:00Z"),

                        "lastHeartbeat" : ISODate("2016-02-26T12:20:08.295Z"),

                        "lastHeartbeatRecv" : ISODate("2016-02-26T12:19:52.972Z"

),

                        "pingMs" : 1,

                      "lastHeartbeatMessage" : "Failed attempt to connect to 1

72.22.239.230:27017; couldn't connect to server 172.22.239.230:27017 (172.22.239

.230), connection attempt failed",

                      "configVersion" : -1

                },

                {

                        "_id" : 2,

                        "name" : "172.22.229.100:27017",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 1292822,

                        "optime" : Timestamp(1456485910, 1),

                        "optimeDate" : ISODate("2016-02-26T11:25:10Z"),

                        "lastHeartbeat" : ISODate("2016-02-26T12:20:08.002Z"),

                        "lastHeartbeatRecv" : ISODate("2016-02-26T12:20:07.889Z"

),

                        "pingMs" : 0,

                        "syncingTo" : "clm-aus-009799:27017",

                        "configVersion" : 3

                }

        ],

        "ok" : 1

}

 

  • If all else fails, enable social DEBUG in the config.js file as shown below then restart the social service, reproduce the problem a few times and send us the social, UX and mongo logs (all logs are located in the Smart IT MyIT log directory with the exception of the mongo log which is defined in the mongod.cfg file)

 

SocialDebug.PNG

 

 

MongoDB Migration

 

You can migrate data easily by using mongodump & mongorestore with the following steps:

 

1) Take MongoDB backup using "mongodump" from existing standalone MongoDB by issuing the following command:

 

mongodump --host localhost --port 27017

 

 

MongoDump.PNG

 

2) Copy over the dump folder/contents to the same directory of your new MongoDB instance and use the "mongorestore" command (this command will check for the dump folder and restore all of it's contents).

 

MongoDBAdminRestore.PNG

 

Conclusion

 

MongoDB in combination with Node.js make a powerful Social Engine for MyIT/SmartIT. Please check out some or all of this content and share your feedback.

 

See more BMC Remedy Support Blogs

 

 

Additional Resources

 

  1. Introduction to MongoDB
  2. Installing and setting up MongoDB for MyIT/SmartIT (Linux)
  3. Installing and setting up MongoDB for MyIT/SmartIT (Windows)
  4. Configuring a MongoDB replica set for MyIT/SmartIT
  5. MongoChef
  6. About Node.js