Showing posts with label ESB. Show all posts
Showing posts with label ESB. Show all posts

Monday, February 1, 2016

Monitoring SNMP WSO2 ESB with Cacti



Prerequisite


  1. Enable SNMP monitoring in WSO2 ESB using  

          https://docs.wso2.com/display/ESB490/SNMP+Monitoring



Installing SNMP package
  1. Install SNMP and SNMPD packages using following commands
     
sudo apt-get update
sudo apt-get install snmp snmpd


Installing Cacti

  1. Install required dependencies for Cacti

sudo apt-get install mysql-server apache2 libapache2-mod-php5 php5-mysql php5-cli php5-snmp

  1. Installing Cacti
   
apt-get install cacti

  1. While installing Cacti provide following commands
  configuring libphp-adodb
-> press ok

configuring cacti
configure database for cacti with dbconfig-common
-> press yes

password of your database's administrative user
-> mysql root password (empty by default, fill accordingly)

mysql application password for cacti
-> give the password you would like cacti to connect to mysql with

webserver type
-> Apache2

  1. Got to http://<Cacti-installed-host>/cacti URL
ex: http://127.0.0.1/cacti (If you have confidured Cacti in localhost)

  1. Click next button in the ‘Cacti Installation Guide’ window.

  1. Select ‘New Installation’ from the list in next windows and click next button.

  1. Make sure every field is marked ‘FOUND’
           
          cacti-install-checklist.png

  1. You will be directed into user login window. Use ‘admin’ username and ‘admin’ password for first login.

  1. Enter new password and confirm that password in the next window.

  1. Following page will be loaded if you have successfully installed Cacti
 
  Screenshot from 2016-01-12 14:52:50.png


Creating new device

  1. Click on ‘console’ tab.

  1. Click ‘Create devices for network’ to create new device

  1. Click ‘Add’ button in Devices page
           Screenshot from 2016-01-12 15:00:09.png
   
     4.   Fill following fields and click create button to create the device
          Screenshot from 2016-01-12 15:12:02.png

  • General Host Options

  • Description - Device name
  • Hostname - Hostname of the SNMP client device
  • Host Template - Select ‘Generic SNMP-enabled Host’ as the host template

  • SNMP Options

  • SNMP version - Select ‘Version 1’ for the SNMP version
  • SNMP Community - Provide SNMP community name : default community name is ‘public’
  • SNMP Port - Provide the ESB SNMP port value: default ESB SNMP value 9161


If Cacti can contact newly added SNMP client device (ESB server) you should be able to.Once you have created the device it will be appeared in the device list in devices page

Screenshot from 2016-01-12 15:29:16.png



Creating new data source

  1. Click ‘console’ tab.
  2. Click on ‘data sources’ listed under Management section
  3. Click Add button in the data sources page.
  4. Fill following fields and click create button to create new datasource.

  • Selected Data Template - SNMP - Generic OID Template
  • Host - Created devices will be appeared here and select that host. (Ex: ESB (127.0.0.1)

Screenshot from 2016-01-12 16:59:35.png

    5. Same page will be refreshed with some additional fields to be filled. Fill those fields with  following  values and click save button to complete Data source creation

  • Data Source Fields
    • Name - Suitable name for the OID which is monitored in this data source

  • Data Source Item Fields [snmp_oid]
    • Maximum Value - The maximum value of data that is allowed to be collected

Screenshot from 2016-01-13 01:15:16.png


Important : If this value is smaller than data stat value, those data points will not be added to records. You can look at Cacti Log to estimate the maximum value which should be set.

  1. Click on ‘console’ tab.
  2. Click on System Utilities  button under Utilities section.
  3. Select ‘View Cacti Log File’ to view Cacti log.

You can observe output values for the specific OID in this log. Use set of values to estimate the maximum value.  

Note: We you start up WSO2 ESB server you can see the list of OIDs in debug logs. Please choose one OID for a data source. That is the OID which we are going to use for collecting stats.

SNMPAgent Registering org.apache.synapse:Type=Transport,Name=passthru-https-sender@ActiveThreadCount as OID: 1.3.6.1.4.1.18060.14.2.18.1.0
SNMPAgent Registering org.apache.synapse:Type=Transport,Name=passthru-https-sender@AvgSizeReceived as OID: 1.3.6.1.4.1.18060.14.2.18.2.0
SNMPAgent Registering org.apache.synapse:Type=Transport,Name=passthru-https-sender@AvgSizeSent as OID: 1.3.6.1.4.1.18060.14.2.18.3.0
SNMPAgent Registering org.apache.synapse:Type=Transport,Name=passthru-https-sender@BytesReceived as OID: 1.3.6.1.4.1.18060.14.2.18.4.0
………………………………....


Adding graph node

  1. Click on ‘Graph Management’ under ‘Management’ section in ‘console’ tab

  1. You can see existing graph nodes in this page. Click ‘Add’ button to add new graph node.

  1. Fill following fields and click create button

  • Selected Graph Template - SNMP - Generic OID Template
  • Host - Device name which has been added to be monitored

Screenshot from 2016-01-12 19:37:24.png

      4.  Once you create the graph , following page will be displayed. Fill fields providing more configurations of the graph node. You have to provide the intended data source to be monitored in ‘Data Source[ snmp-oid] field.

Screenshot from 2016-01-13 00:29:40.png


   5. Finally click on save button to save graph node configurations.

You can create data source and graph node for each OID which should be monitored using Cacti.


Displaying graphs

  1. Click on ‘graphs’ tab and expand ‘Default tree’
  2. Click on the device which is to be monitored (ex: Host:ESB) and all graph nodes that has been created under that device will be displayed.

Note: Cacti will take approximately 15 minutes to start displaying data on newly created graph nodes.

Screenshot from 2016-01-13 00:57:36.png



Troubleshooting

If you are not getting any data on graphs (even after considerable time), recheck and configure data source using rrdtool

  1. Go to folder location where all data files are stored
cd  /var/lib/cacti/ rra/

          (You can view corresponding data file using following command)

rrdtool fetch esb_snmp_oid_9.rrd AVERAGE

  1. Check datasource configurations using following command

rrdtool info esb_snmp_oid_9.rrd
           
  1. Possible reason for not showing data on graphs  is data source maximum value is too small. You can reconfigure corresponding data source maximum value using following command

rrdtool tune esb_snmp_oid_9.rrd --maximum snmp_oid:<maximum value>

ex: rrdtool tune esb_snmp_oid_9.rrd --maximum snmp_oid:1000000

Tuesday, March 3, 2015

String concatenation in WSO2 ESB

There may some incidents where we want to concatenate two strings and create new string (value of a property ) in WSO2 ESB. Here I am using two property values and join them in to a new property.

1. Property #1

 <property name="myFirstProperty" value="WSO2"/>  

2. Property #2

<property name="mySecondProperty" value="ESB"/>

3. Concatenating above two properties

 <property name="ConcatenatedProperty" expression="fn:concat(get-property('myFirstProperty'),get-property('mySecondProperty')"/>

Note: You can provide any number of values to be concatenated in to the fn:concat() function.

Value of "ConcatenatedProperty" property is "WSO2ESB"


Thursday, January 22, 2015

How to send string content as the response from WSO2 ESB Proxy/API

We can send XML content or JSON content as the response out from our WSO2 ESB proxy/REST API. But there may be a scenario where we want to send string content (which is not in XML format) as the response of our service. Following synapse code snippet shows you how to do it

As an example think you have to send following string content to your client service

<result1>malintha</result1>+<result2>adikari</result2>

Note :
  • Above is not in XML format. So we cannot generate this directly through payload factory mediator.
  • We have to send <,> symbols inside the response, but WSO2 ESB doesn't allow to keep those inside your synapse configuration.
1. First you have to encode above expected response. You can use this tool to encode your xml. We get following xml after encoding in our example

&lt;result1&gt;malintha&lt;/result1&gt;+&lt;result2&gt;adikari&lt;/result2&gt;

Note : If you want to encode dynamic payload content you can use script mediator or class mediator for that task

2. Now we can attach the require string content to our payload as follows

 <outSequence>  
       <payloadFactory media-type="xml">  
         <format>  
          <ms11:text xmlns:ms11="http://ws.apache.org/commons/ns/payload">$1</ms11:text>  
         </format>  
         <args>  
          <arg value="&lt;result1&gt;malintha&lt;/result1&gt;+&lt;result2&gt;adikari&lt;/result2&gt;"/>  
         </args>  
       </payloadFactory>  
       <property name="messageType" value="text/plain" scope="axis2"/>  
       <send/>  
    </outSequence>  

Here we are using payload factory mediator to create our payload. You can see still our media-type is XML. Then load our string content as argument value and finally we change the message type to "text/plain". So this would return string content as it's response.