Use Config helper (#10339)

remove usage of global variable
This commit is contained in:
Tony Murray
2019-06-23 00:29:12 -05:00
committed by GitHub
parent 342acf50f1
commit f3ba8947f7
367 changed files with 1589 additions and 1857 deletions

View File

@@ -1,5 +1,7 @@
<?php
use LibreNMS\Config;
/*
* LibreNMS
*
@@ -14,8 +16,8 @@
function prometheus_push($device, $measurement, $tags, $fields)
{
global $prometheus, $config;
if ($config['prometheus']['enable'] === true) {
global $prometheus;
if (Config::get('prometheus.enable') === true) {
if ($prometheus !== false) {
try {
$ch = curl_init();
@@ -36,7 +38,7 @@ function prometheus_push($device, $measurement, $tags, $fields)
}
}
$promurl = $config['prometheus']['url'].'/metrics/job/'.$config['prometheus']['job'].'/instance/'.$device['hostname'].$promtags;
$promurl = Config::get('prometheus.url') . '/metrics/job/' . Config::get('prometheus.job') . '/instance/' . $device['hostname'] . $promtags;
$promurl = str_replace(" ", "-", $promurl); // Prometheus doesn't handle tags with spaces in url
d_echo("\nPrometheus data:\n");