NMIS Model Overrides
Available in NMIS 9.6.0, NMIS model overrides allow changing or adding any setting/value in a model after it is loaded. These files should exist to help tune existing models without having to copy the whole file into models-custom before changing them. Modifying a threshold value or adding a new selection to a threshold are perfect examples of activities that should use NMIS model overrides.
To use this feature two things are required:
create override file
add override file to Config.nmis
Create override file
Override files should be added to nmis9/models-custom/. They start with “Override-”, use a string to help them be identifiable. Their structure matches Models- and Common- nmis files. All keys/values are applied after the model/common files are loaded.
To modify an existing threshold, create “nmis9/models-custom/Override-custom-threshold.nmis”, add just the keys you would like to change. In this example, for selection 10 of the response threshold, change the fatal value to 5000 (instead of the default 3000). Note: all other settings of this threshold will remain, event/item/control etc will stay the same because they are not being defined so they will not be overridden
%hash = (
'threshold' => {
'name' => {
'response' => {
'select' => {
'10' => {
'value' => {
'fatal' => '5000',
}
}
}
}
}
}
);
To add a new threshold selection value to an existing threshold, add in new keys and values that do not exist in the model. This example adds in a new control specifically for a group named ‘mycustomersfavouritegroup’
'%hash = (
'threshold' => {
'name' => {
'response' => {
'select' => {
'99' => {
'control' => '$group =~ qr/mycustomersfavouritegroup/',
'value' => {
'fatal' => '31',
'critical' => '21',
'major' => '11',
'minor' => '10',
'warning' => '1'
}
}
}
}
}
}
);
Any part of the model can be in this file, not just thresholds, database/stats/systemHealth are all valid.
Add override file to Config.nmis
Override files are only loaded if they are adding to Config.nmis. To add them, use the string after “Override-” in the config. E.G. if you created Override-threshold.nmis and Override-customer1.nmis, add this to your Config.nmis file:
'global_model_overrides' => [ "threshold",”customer1” ],
Debugging tools
Many files are merged to make a final model, it can be difficult to know what the final outcome is. There are a few options to see what the final result of modelling is:
Inspect NMIS model cache
By default, all cached models are loaded into nmis9/var/nmis_system/model_cache/, you can find each model that is being used here as a json file. To inspect the model being used for “net-snmp”:
json_xs < /usr/local/nmis9/var/nmis_system/model_cache/Model-net-snmp.json
dev-tools
the test folder contains a script called “dev-tools.pl” which should only be used while making changes to a test/dev environment. It provides quick, but less safe, access to NMIS internal functions.
To see the model being used for node localhost, try this function
./dev-tools.pl act=model node=localhost
This will essentially output the same data that is in the model cache. It is a quick way to force the model cache to be reloaded and see the changes.
Caveats
If two or more models use the same name for a key but they do different things, global model overrides will apply to both of them if they are being overridden. These overrides are applied to all models after loading, there is currently no selectivity.
FYI: nmis9d should not need to be restarted. NMIS model caching checks if files are modified and reloads them when changes are detected.