Installing Weathermap

Hello,

I’ve managed to install LibreNMS on CentOS. I’m new to LibreNMS and Linux, but want to learn both.

I’ve added a few devices to LibreNMS and I now want to install some 3rd party apps, especially the weathermaps.

I’m using this https://docs.librenms.org/Extensions/Weathermap/#installing-network-weathermap

The first part I’m stuck on is creating the Cron file/job:

Step 3.

Enable the cron process by editing your current LibreNMS cron file (typically /etc/cron.d/librenms) and add the following: LibreNMS: */5 * * * * librenms /opt/librenms/html/plugins/Weathermap/map-poller.php >> /dev/null 2>&1

[root@localhost cron.d]# cd ./librenms
-bash: cd: ./librenms: Not a directory
[root@localhost cron.d]# ls
0hourly  librenms
[root@localhost cron.d]#

What am I doing wrong?

If I go to the Weathermaps page I also get:

The map config directory is not writable by the web server user. You will not be able to edit any files until this is corrected.

I’m using CentOS 7 (Nginx)

Thanks

You need to add that line to the Cron file (LibreNMS)
Using a text editor such as vi or nano.

Eg: sudo vi /etc/cron.d/librenms

In regards to the second point, there’s possibly a few permissions you need to fix, can you provide the output of /opt/librenms/validate.php

Also SELinux on CentOS can get in the way, try disabling that and see if issues continue.

Hi Derova,

I’ve managed to edit the Cron job, but I’m stuck on the permissions error when I go to Overview > Plugins > Weathmap

The map config directory is not writable by the web server user. You will not be able to edit any files until this is corrected.

Here is the file contents you asked for, sorry I just can’t seem to copy the text and keep the format (even using the preformatted text option)…

#!/usr/bin/env php

<?php /* * LibreNMS * * Copyright (c) 2014 Neil Lathwood * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ use LibreNMS\Config; use LibreNMS\ValidationResult; use LibreNMS\Validator; chdir(__DIR__); // cwd to the directory containing this script ini_set('display_errors', 1); require_once 'includes/common.php'; require_once 'includes/functions.php'; require_once 'includes/dbFacile.php'; $options = getopt('g:m:s::h::'); if (isset($options['h'])) { echo "\n Validate setup tool Usage: ./validate.php [-g ] [-s] [-h] -h This help section. -s Print the status of each group -g Any validation groups you want to run, comma separated: Non-default groups: - mail: this will test your email settings (uses default_mail option even if default_only is not set) - distributedpoller: this will test for the install running as a distributed poller - rrdcheck: this will check to see if your rrd files are corrupt Default groups: - configuration: checks various config settings are correct - database: checks the database for errors - dependencies: checks that all required libraries are installed and up-to-date - disk: checks for disk space and other disk related issues - php: check that various PHP modules and functions exist - poller: check that the poller and discovery are running properly - programs: check that external programs exist and are executable - updates: checks the status of git and updates - user: check that the LibreNMS user is set properly Example: ./validate.php -g mail. " ; exit; } // Buffer output ob_start(); $precheck_complete = false; register_shutdown_function(function () { global $precheck_complete; if (!$precheck_complete) { // use this in case composer autoloader isn't available spl_autoload_register(function ($class) { include str_replace('\\', '/', $class) . '.php'; }); print_header(version_info()); } }); // critical config.php checks if (!file_exists('config.php')) { print_fail('config.php does not exist, please copy config.php.default to config.php'); exit; } $pre_checks_failed = false; $syntax_check = `php -ln config.php`; if (!str_contains($syntax_check, 'No syntax errors detected')) { print_fail('Syntax error in config.php'); echo $syntax_check; $pre_checks_failed = true; } $first_line = rtrim(`head -n1 config.php`); if (!starts_with($first_line, '<?php')) { print_fail("config.php doesn't start with a <?php - please fix this ($first_line)"); $pre_checks_failed = true; } if (str_contains(`tail config.php`, '?>')) {
print_fail("Remove the ?> at the end of config.php");
$pre_checks_failed = true;

}

// Composer checks
if (!file_exists(‘vendor/autoload.php’)) {
print_fail(‘Composer has not been run, dependencies are missing’, ‘./scripts/composer_wrapper.php install --no-dev’);
exit;
}

// init autoloading
require_once ‘vendor/autoload.php’;

$dep_check = shell_exec(‘php scripts/composer_wrapper.php install --no-dev --dry-run’);
preg_match_all(‘/Installing ([^ ]+/[^ ]+) (/’, $dep_check, $dep_missing);
if (!empty($dep_missing[0])) {
print_fail(“Missing dependencies!”, “./scripts/composer_wrapper.php install --no-dev”);
$pre_checks_failed = true;
print_list($dep_missing[1], “\t %s\n”);
}
preg_match_all(‘/Updating ([^ ]+/[^ ]+) (/’, $dep_check, $dep_outdated);
if (!empty($dep_outdated[0])) {
print_fail(“Outdated dependencies”, “./scripts/composer_wrapper.php install --no-dev”);
print_list($dep_outdated[1], “\t %s\n”);
}

$validator = new Validator();
$validator->validate(array(‘dependencies’));
if ($validator->getGroupStatus(‘dependencies’) == ValidationResult::FAILURE) {
$pre_checks_failed = true;
}

if ($pre_checks_failed) {
exit;
}
$init_modules = ;
require ‘includes/init.php’;

// make sure install_dir is set correctly, or the next includes will fail
if (!file_exists(Config::get(‘install_dir’).‘/config.php’)) {
$suggested = realpath(DIR);
print_fail(‘'install_dir' config setting is not set correctly.’, “It should probably be set to: $suggested”);
exit;
}

if (\LibreNMS\DB\Eloquent::isConnected()) {
$validator->ok(‘Database connection successful’, null, ‘database’);
} else {
$validator->fail(‘Error connecting to your database.’, null, ‘database’);
}

$precheck_complete = true; // disable shutdown function
print_header($validator->getVersions());

if (isset($options[‘g’])) {
$modules = explode(‘,’, $options[‘g’]);
} elseif (isset($options[‘m’])) {
$modules = explode(‘,’, $options[‘m’]); // backwards compat
} else {
$modules = array(); // all modules
}

// run checks
$validator->validate($modules, isset($options[‘s’])||!empty($modules));

function print_header($versions)
{
$output = ob_get_clean();
@ob_end_clean();

echo <<< EOF

====================================

Component Version
LibreNMS ${versions[‘local_ver’]}
DB Schema ${versions[‘db_schema’]}
PHP ${versions[‘php_ver’]}
MySQL ${versions[‘mysql_ver’]}
RRDTool ${versions[‘rrdtool_ver’]}
SNMP ${versions[‘netsnmp_ver’]}
====================================

$output
EOF;
}

// output matches that of ValidationResult
function print_fail($msg, $fix = null)
{
c_echo(“[%RFAIL%n] $msg”);
if ($fix && strlen($msg) > 72) {
echo PHP_EOL . " ";
}

if (!empty($fix)) {
    c_echo(" [%BFIX%n] %B$fix%n");
}
echo PHP_EOL;

}

Hey Gonzo,

Looks like you’ve dumped the contents of the file itself, my apologies - I need you to run validate.php and send the results.

sudo /opt/librenms/validate.php

This should show if there are permissions issues on the directories.

Hello,

Sorry about that.

This is what I get

[root@localhost ~]# sudo /opt/librenms/validate.php

Component Version
LibreNMS 1.54-29-gcec10c1
DB Schema 2019_07_09_150217_update_users_widgets_settings (140)
PHP 7.2.19
MySQL 5.5.60-MariaDB
RRDTool 1.4.8
SNMP NET-SNMP 5.7.2
====================================

[OK] Composer Version: 1.9.0
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[WARN] Your install is over 24 hours out of date, last update: Fri, 09 Aug 2019 20:55:14 +0000
[FIX]:
Make sure your daily.sh cron is running and run ./daily.sh by hand to see if there are any errors.
[root@localhost ~]#

I get get a for fixes which I applied that were related to security. If I go to Overview > Plugins > Weathermap it sends me to http://server-ip/plugin/p=Weathermap but fails to load anything.

Should I install again?

cd /opt/librenms/html/plugins/Weathermap
sudo chown www-data:www-data /configs

Hmm I get this:

[root@localhost plugins]# cd /opt/librenms/html/plugins/Weathermap
[root@localhost Weathermap]# sudo chown www-data:www-data /configs
chown: invalid user: ‘www-data:www-data’
[root@localhost Weathermap]#

if www-data doesnt exist then it’s probably apache or nginx user, you need to check your webserver configuration file to see which user and group it’s configured to run as.

I use nginx for my setup, this is what is shows:

[root@localhost conf.d]# pwd
/etc/nginx/conf.d

[root@localhost conf.d]# vi librenms.conf

server_name 192.168.189.151;
root /opt/librenms/html;
index index.php;

charset utf-8;
gzip on;
gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /api/v0 {
try_files $uri $uri/ /api_v0.php?$query_string;
}
location ~ .php {
include fastcgi.conf;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php7.2-fpm.sock;
}
location ~ /.ht {
deny all;
}
}

Thanks for the link.

It seems it’s the ‘nginx’ user, I’m assuming I should be seeing ‘www-data’?

[root@localhost ~]# ps aux|grep nginx|grep -v grep
root 1658 0.0 0.0 125120 2300 ? Ss Aug13 0:00 nginx: master process /usr/sbin/nginx
nginx 1659 0.0 0.1 125904 4116 ? S Aug13 0:00 nginx: worker process
nginx 1661 0.0 0.1 125908 4144 ? S Aug13 0:00 nginx: worker process
nginx 1762 0.1 0.9 400244 36284 ? S Aug13 0:40 php-fpm: pool www
nginx 1763 0.1 0.7 394100 30124 ? S Aug13 0:39 php-fpm: pool www
nginx 1764 0.1 0.9 400256 36240 ? S Aug13 0:40 php-fpm: pool www
nginx 1766 0.1 0.9 400384 36288 ? S Aug13 0:40 php-fpm: pool www
nginx 1769 0.1 0.9 400244 36252 ? S Aug13 0:38 php-fpm: pool www
nginx 5541 0.1 0.9 400244 36272 ? S Aug13 0:40 php-fpm: pool www
nginx 8129 0.1 0.8 398196 34192 ? S 00:31 0:39 php-fpm: pool www
nginx 8154 0.1 0.9 400244 36260 ? S 00:31 0:39 php-fpm: pool www
nginx 8160 0.1 0.8 398196 34188 ? S 00:31 0:40 php-fpm: pool www
nginx 8161 0.1 0.7 394104 30072 ? S 00:31 0:39 php-fpm: pool www
[root@localhost ~]# grep user /etc/nginx/nginx.conf
user nginx;
log_format main '$remote_addr - $remote_user [$time_local] “$request” ’
‘"$http_user_agent" “$http_x_forwarded_for”’;
[root@localhost ~]#