/usr/lib/python3/dist-packages/glances/outputs/static/js/services/plugin_helper.js is in glances 2.11.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | glancesApp.service('GlancesPluginHelper', function () {
var plugin = {
'limits': {},
'limitSuffix': ['critical', 'careful', 'warning']
};
plugin.setLimits = function (limits) {
this.limits = limits;
};
plugin.getAlert = function (pluginName, limitNamePrefix, current, maximum, log) {
current = current || 0;
maximum = maximum || 100;
log = log || false;
var log_str = log ? '_log' : '';
var value = (current * 100) / maximum;
if (this.limits[pluginName] != undefined) {
for (var i = 0; i < this.limitSuffix.length; i++) {
var limitName = limitNamePrefix + this.limitSuffix[i];
var limit = this.limits[pluginName][limitName];
if (value >= limit) {
var pos = limitName.lastIndexOf("_");
var className = limitName.substring(pos + 1);
return className + log_str;
}
}
}
return "ok" + log_str;
};
plugin.getAlertLog = function (pluginName, limitNamePrefix, current, maximum) {
return this.getAlert(pluginName, limitNamePrefix, current, maximum, true);
};
return plugin;
});
|