mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +00:00
Adding linux_config_files application support (#14776)
This commit is contained in:
parent
a27a53cc03
commit
56e9fa3742
@ -961,6 +961,41 @@ The application should be auto-discovered as described at the top of
|
||||
the page. If it is not, please follow the steps set out under `SNMP
|
||||
Extend` heading top of page.
|
||||
|
||||
## linux_config_files
|
||||
|
||||
linux_config_files is an application intended to monitor a Linux distribution's configuration files via that distribution's configuration management tool/system. At this time, ONLY RPM-based (Fedora/RHEL) SYSTEMS ARE SUPPORTED utilizing the rpmconf tool. The linux_config_files application collects and graphs the total count of configuration files that are out of sync and graphs that number.
|
||||
|
||||
Fedora/RHEL: Rpmconf is a utility that analyzes rpm configuration files using the RPM Package Manager. Rpmconf reports when a new configuration file standard has been issued for an upgraded/downgraded piece of software. Typically, rpmconf is used to provide a diff of the current configuration file versus the new, standard configuration file. The administrator can then choose to install the new configuration file or keep the old one.
|
||||
|
||||
### SNMP Extend
|
||||
|
||||
1. Copy the python script, linux_config_files.py, to the desired host
|
||||
```
|
||||
wget https://github.com/librenms/librenms-agent/raw/master/snmp/linux_config_files.py -O /etc/snmp/linux_config_files.py
|
||||
```
|
||||
|
||||
2. Make the script executable
|
||||
```
|
||||
chmod +x /etc/snmp/linux_config_files.py
|
||||
```
|
||||
|
||||
3. Edit your snmpd.conf file and add:
|
||||
```
|
||||
extend linux_config_files /etc/snmp/linux_config_files.py
|
||||
```
|
||||
|
||||
4. (Optional on an RPM-based distribution) Create a /etc/snmp/linux_config_files.json file and specify the following:
|
||||
a.) "pkg_system" - String designating the distribution name of the system. At the moment only "rpm" is supported ["rpm"]
|
||||
b.) "pkg_tool_cmd" - String path to the package tool binary ["/sbin/rpmconf"]
|
||||
```
|
||||
{
|
||||
"pkg_system": "rpm",
|
||||
"pkg_tool_cmd": "/bin/rpmconf",
|
||||
}
|
||||
```
|
||||
|
||||
5. Restart snmpd.
|
||||
|
||||
## mailcow-dockerized postfix
|
||||
|
||||
### SNMP Extend
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
$app_name = 'linux_config_files';
|
||||
$colours = 'psychedelic';
|
||||
$lower_limit = 0;
|
||||
$polling_type = 'app';
|
||||
$unit_text = 'Configs';
|
||||
$unitlen = strlen($unit_text);
|
||||
|
||||
$rrdArray = [
|
||||
'number_of_confs' => ['descr' => 'Out-Of-Sync'],
|
||||
];
|
||||
|
||||
$rrd_filename = Rrd::name($device['hostname'], [
|
||||
$polling_type,
|
||||
$app_name,
|
||||
$app->app_id,
|
||||
]);
|
||||
|
||||
if (Rrd::checkRrdExists($rrd_filename)) {
|
||||
foreach ($rrdArray as $rrdVar => $rrdValues) {
|
||||
$rrd_list[] = [
|
||||
'cdef_rpn' => $rrdValues['cdef_rpn'] ?? null,
|
||||
'colour' => $rrdValues['colour'] ?? null,
|
||||
'descr' => $rrdValues['descr'],
|
||||
'divider' => $rrdValues['divider'] ?? null,
|
||||
'ds' => $rrdVar,
|
||||
'filename' => $rrd_filename,
|
||||
'multiplier' => $rrdValues['multiplier'] ?? null,
|
||||
];
|
||||
}
|
||||
} else {
|
||||
d_echo('RRD ' . $rrd_filename . ' not found');
|
||||
}
|
||||
|
||||
require 'includes/html/graphs/generic_multi_line_exact_numbers.inc.php';
|
@ -453,6 +453,9 @@ $graphs['wireguard'] = [
|
||||
'traffic',
|
||||
'time',
|
||||
];
|
||||
$graphs['linux_config_files'] = [
|
||||
'number_of_confs',
|
||||
];
|
||||
|
||||
echo '<div class="panel panel-default">';
|
||||
echo '<div class="panel-heading">';
|
||||
|
25
includes/html/pages/device/apps/linux_config_files.inc.php
Normal file
25
includes/html/pages/device/apps/linux_config_files.inc.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$graphs = [
|
||||
'linux_config_files_number_of_confs' => 'Configuration Files Out-Of-Sync',
|
||||
];
|
||||
|
||||
foreach ($graphs as $key => $text) {
|
||||
$graph_type = $key;
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '215';
|
||||
$graph_array['to'] = time();
|
||||
$graph_array['id'] = $app['app_id'];
|
||||
$graph_array['type'] = 'application_' . $key;
|
||||
|
||||
echo '<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">' . $text . '</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">';
|
||||
include 'includes/html/print-graphrow.inc.php';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
41
includes/polling/applications/linux_config_files.inc.php
Normal file
41
includes/polling/applications/linux_config_files.inc.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Exceptions\JsonAppException;
|
||||
use LibreNMS\Exceptions\JsonAppMissingKeysException;
|
||||
use LibreNMS\RRD\RrdDefinition;
|
||||
|
||||
$app_name = 'linux_config_files';
|
||||
$output_success = 'OK';
|
||||
$polling_type = 'app';
|
||||
|
||||
try {
|
||||
$polling_data = json_app_get($device, $app_name, 1)['data'];
|
||||
} catch (JsonAppMissingKeysException $e) {
|
||||
$polling_data = $e->getParsedJson();
|
||||
} catch (JsonAppException $e) {
|
||||
echo PHP_EOL . $app_name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL;
|
||||
update_application($app, $e->getCode() . ':' . $e->getMessage(), []);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$rrd_name = [$polling_type, $app_name, $app->app_id];
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('number_of_confs', 'GAUGE', 0);
|
||||
|
||||
$number_of_confs = (int) $polling_data['number_of_confs'] ?? null;
|
||||
|
||||
$fields = [
|
||||
'number_of_confs' => $number_of_confs,
|
||||
];
|
||||
|
||||
$tags = [
|
||||
'app_id' => $app->app_id,
|
||||
'name' => $app_name,
|
||||
'rrd_def' => $rrd_def,
|
||||
'rrd_name' => $rrd_name,
|
||||
];
|
||||
|
||||
data_update($device, $polling_type, $tags, $fields);
|
||||
|
||||
update_application($app, $output_success, $fields);
|
@ -592,5 +592,10 @@
|
||||
"rule": "applications.app_type = \"systemd\" && application_metrics.metric = \"sub_service_failed\" && application_metrics.value > \"0\"",
|
||||
"name": "Systemd Services Failed > 0",
|
||||
"severity": "warning"
|
||||
},
|
||||
{
|
||||
"rule": "applications.app_type = \"linux_config_files\" && application_metrics.metric = \"number_of_confs\" && application_metrics.value > \"0\"",
|
||||
"name": "linux_config_files Configuration Files Out-Of-Sync > 0",
|
||||
"severity": "warning"
|
||||
}
|
||||
]
|
||||
|
59
tests/data/linux_linux_config_files-v1.json
Normal file
59
tests/data/linux_linux_config_files-v1.json
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"os": {
|
||||
"discovery": {
|
||||
"devices": [
|
||||
{
|
||||
"sysName": "<private>",
|
||||
"sysObjectID": ".1.3.6.1.4.1.8072.3.2.10",
|
||||
"sysDescr": "Linux server 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64",
|
||||
"sysContact": "<private>",
|
||||
"version": "3.10.0-693.5.2.el7.x86_64",
|
||||
"hardware": "Generic x86 64-bit",
|
||||
"features": null,
|
||||
"location": "<private>",
|
||||
"os": "linux",
|
||||
"type": "server",
|
||||
"serial": null,
|
||||
"icon": "linux.svg"
|
||||
}
|
||||
]
|
||||
},
|
||||
"poller": "matches discovery"
|
||||
},
|
||||
"applications": {
|
||||
"discovery": {
|
||||
"applications": [
|
||||
{
|
||||
"app_type": "linux_config_files",
|
||||
"app_state": "UNKNOWN",
|
||||
"discovered": 1,
|
||||
"app_state_prev": null,
|
||||
"app_status": "",
|
||||
"app_instance": "",
|
||||
"data": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"poller": {
|
||||
"applications": [
|
||||
{
|
||||
"app_type": "linux_config_files",
|
||||
"app_state": "OK",
|
||||
"discovered": 1,
|
||||
"app_state_prev": "UNKNOWN",
|
||||
"app_status": "",
|
||||
"app_instance": "",
|
||||
"data": null
|
||||
}
|
||||
],
|
||||
"application_metrics": [
|
||||
{
|
||||
"metric": "number_of_confs",
|
||||
"value": 0,
|
||||
"value_prev": null,
|
||||
"app_type": "linux_config_files"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
10
tests/snmpsim/linux_linux_config_files-v1.snmprec
Normal file
10
tests/snmpsim/linux_linux_config_files-v1.snmprec
Normal file
@ -0,0 +1,10 @@
|
||||
1.3.6.1.2.1.1.1.0|4|Linux server 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64
|
||||
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.8072.3.2.10
|
||||
1.3.6.1.2.1.1.3.0|67|77550514
|
||||
1.3.6.1.2.1.1.4.0|4|<private>
|
||||
1.3.6.1.2.1.1.5.0|4|<private>
|
||||
1.3.6.1.2.1.1.6.0|4|<private>
|
||||
1.3.6.1.2.1.25.1.1.0|67|77552962
|
||||
1.3.6.1.4.1.8072.1.3.2.2.1.21.6.100.105.115.116.114.111|2|1
|
||||
1.3.6.1.4.1.8072.1.3.2.2.1.21.18.108.105.110.117.120.95.99.111.110.102.105.103.95.102.105.108.101.115|2|1
|
||||
1.3.6.1.4.1.8072.1.3.2.3.1.2.18.108.105.110.117.120.95.99.111.110.102.105.103.95.102.105.108.101.115|4x|7b226572726f72537472696e67223a2022222c20226572726f72223a20302c202276657273696f6e223a20312c202264617461223a207b226e756d6265725f6f665f636f6e6673223a20307d7d0a
|
Loading…
Reference in New Issue
Block a user