Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

In NMIS /and opCharts we can add custom validations for custom fields .

This is a list of the steps the customer needs to follow :-

in the nodes table.

In 1)Add the custom field name to NMIS, in this example we are using "Device CIci" as the name of our custom field name.and "CI" as the label to be displayed in the screens.

The steps below are how to accomplish the validation and integration.

Add the custom field to NMIS 

This is done by adding a code block similar to the below in /usr/local/nmis9/conf-default/Table-Nodes.nmis.

NOTE: If this configuration file does not currently exist in the /usr/local/nmis9/conf/ directory, it will need to be copied from /usr/local/nmis9/conf-default.

Code Block
languageperl
title/usr/local/nmis9/conf-default/Table-Nodes.nmis
{ device_ci => { header => 'Device CI', display => 'header,text',value => [""] }}, 

2)Modify the node_summary_field_list list attribute

To include the new custom field (ci), this is done by updating 'node_summary_field_list' in /usr/local/nmis9/conf/Config.nmis to the below.

Code Block
languageperl
title/usr/local/nmis9/conf/Config.nmis
'node_summary_field_list' => 'host,uuid,customer,device_ci,businessService,serviceStatus,snmpdown,wmidown',

Image Removed

Adding custom index

In /usr/local/nmis9/conf/Config.nmis add the following code block under the 'database' section of the configuration.3)add a custom_indices field in Config.nmis.
Config.nmis::database:: 

Code Block
languageperl
title/usr/local/nmis9/conf/Config.nmis
'custom_indices' => {
      'nodes' => [
          [ {'configuration.device_ci' => 1}, { unique => 1, partialFilterExpression => { "configuration.device_ci" => { '$exists' => true } }  }] 
        ]
}

Image Removed

The end result will look similar to the below.Image Added

Once the above has been completed, then save the file. You can also verify that the code is valid by executing the below command.Then verify by running the following command

Code Block
themeMidnight
titleperl -c /usr/local/nmis9/conf/Config.nmis
perl -c /usr/local/nmis9/conf/Config.nmis

If it returns something other than /usr/local/nmis9/conf/Config.nmis syntax OK, you will need to verify that the configurations have been added correctly.

Image Removed4)After the addition of custom indices, please run ensure indexes to add custom index. you will also need to run the below command.

Code Block
themeMidnight
title/usr/local/nmis9/bin/nmis-cli act=ensure_indexes debug=9
/usr/local/nmis9/bin/nmis-cli act=ensure_indexes debug=9

/usr/local/nmis9/bin/nmis-cli act=ensure_indexes debug=9

Image Removed

...

Add the Device CI to opCharts and Node Admin Schemas

Node Admin:
Copy Ci to the admin node table /usr/local/omk/lib/json/admin/table_schemas/admin_node-ip.json to /usr/local/omk/conf/table_schemas/ and add in the below:

Code Block
title/usr/local/omk/lib/jsonconf/admin/table_schemas/admin_node-ip.json
{
   "name": "nodes.configuration.device_ci",
   "label": "Device CI",
   "cell": "String",
   "editable": false,
   "search": "iregex"
}

6)Add the Device Ci to the opCharts node table
opCharts:
Copy /usr/local/omk/lib/json/opCharts/table_schemas/opCharts_node-list.json to /usr/local/omk/conf/table_schemas and add in the below:

Code Block
title/usr/local/omk/libconf/json/opCharts/table_schemas/opCharts_node-list.json
{
   "name": "nodes.configuration.device_ci",
   "label": "Device CI",
   "cell": "String",
   "editable": false,
   "search": "iregex"
}

Node Admin Edit Node Fields:

Create 7)Add the Device Ci to the admin edit node fields. (admin_nodes.json file will need to be created in the "/usr/local/omk/conf/form_schemas/" directory )
vi /usr/local/omk/conf/form_schemas/admin_nodes.json and add in the below:

Code Block
title/usr/local/omk/conf/form_schemas/admin_nodes.json
{"label": "Device Ci",
 "description": "Edit in conf/form_schemas/admin_nodes.json",
 "component": ["node_admin"],
 "tags": ["node"],
 "schema": {
         "configuration.device_ci": {
                 "title": "Device CI",
                 "type": "Text"}
 }}
}

opCharts Node Summary Table:

Copy 8)Add the device_ci to omk/opCharts/nodes so it shows in the node info table
vi /usr/local/omk/lib/json/opCharts/table_schemas/opCharts_node-summary-table.json to /usr/local/omk/conf/table_schemas/ and add the device_ci as shown below:

Code Block
title/usr/local/omk/lib/json/opChartsconf/table_schemas/opCharts_node-summary-table.json
// VERSION=1.518.0
[  
  "group",
  "host",
  "host_addr",
  "location",
  "nodeVendor",
  "nodeModel",
  { "name" : "device_ci", "label": "Device CI", "cell": "String"},
  { "name" : "sysDescr", "label": "sysDescr", "cell": "Tooltip", "formatter": "ShortenedString", "maxLength" : 48},
  { "name" : "lastUpdateSec", "label" : "Last Updated", "cell" : "String", "formatter" : "UnixTime"},
  { "name" : "sysUpTimeSec", "label" : "Uptime", "cell" : "String", "formatter" : "UpTime"},
  { "name" : "remote", "label" : "Managed by"}
]

Final Steps

Create a directory named plugins_available in 9)New validation plugins are present at
we have a directory
/usr/local/nmis9/conf-default/plugins/
the plugin is present in 
:

Code Block
cd /usr/local/nmis9/conf-default/
mkdir plugins_available

Copy the NodeValidation.pm from validation_plugins/
 
Now we need to do is 
create a directory 
/usr/local/nmis9/conf-default/validation_plugins/NodeValidation.pm into the plugins_available /
 
then create a soft link of that file in plugins
directory.

Then change directory into the /usr/local/nmis9/conf-default/plugins/Commands to use
cd /usr/local/nmis9/conf-default/
mkdir plugins_available
cp

Code Block
cp /usr/local/nmis9/conf-default/validation_plugins/

...

NodeValidation.pm  /usr/local/nmis9/conf-default/plugins_available/

...


cd plugins


Create a soft link:

Code Block
ln -s /usr/local/nmis9/conf-default/plugins_available/NodeValidations.pm NodeValidations.pm

Once the above has been completed, then restart nmis9d and omkd services.

Code Block
sudo service nmis9d restart

...


sudo service omkd restart