You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Introduction

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



1)Add theCustom field name to NMIS, in this example we are using "Device CI" as our custom field name.

/usr/local/nmis9/conf-default/Table-Nodes.nmis

/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 in /usr/local/nmis9/conf/Config.nmis


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


'node_summary_field_list' => 'host,uuid,customer,fruit,device_ci,businessService,serviceStatus,snmpdown,wmidown',


1)add a custom_indices field in Config.nmis.
Config.nmis::database:: 
 
'custom_indices' => {
      'nodes' => [
          [ {'configuration.device_ci' => 1}, { unique => 1, partialFilterExpression => { "configuration.device_ci" => { '$exists' => true } }  }] 
        ]
}

2)After the addition of custom indices, please run ensure indexes to add custom index. 

Then verify by running the following code
perl -c /usr/local/nmis9/conf/Config.nmis

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

Then go to
System -> System Configuration -> NMIS Nodes


4)Add the Device Ci to the admin node table
/usr/local/omk/lib/json/admin/table_schemas/admin_node-ip.json

{
   "name": "nodes.configuration.device_ci",
   "label": "Device CI",
   "cell": "String",
   "editable": false,
   "search": "iregex"
}

5)Add the Device Ci to the opCharts node table
/usr/local/omk/lib/json/opCharts/table_schemas/opCharts_node-list.json

{
   "name": "nodes.configuration.device_ci",
   "label": "Device CI",
   "cell": "String",
   "editable": false,
   "search": "iregex"
}

6)Add the Device Ci to the admin edit node fields
vi /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"}
 }}


To 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 and add the device_ci as shown below

// 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"}
]


3)New validation plugins are present at
we have a directory
/usr/local/nmis9/conf-default/plugins/
the plugin is present in 
/usr/local/nmis9/conf-default/validation_plugins/
 
Now we need to do is 
create a directory 
/usr/local/nmis9/conf-default/plugins_available/
 
then create a soft link of that file in plugins
/usr/local/nmis9/conf-default/plugins/

Commands to use
cd /usr/local/nmis9/conf-default/
mkdir plugins_available
cp /usr/local/nmis9/conf-default/validation_plugins/NodeValidations.pm  /usr/local/nmis9/conf-default/plugins_available/
 
cd plugins
ln -s /usr/local/nmis9/conf-default/plugins_available/NodeValidations.pm NodeValidations.pm


sudo service nmis9d restart
sudo service omkd restart


  • No labels