diff --git a/LibreNMS/Util/Clean.php b/LibreNMS/Util/Clean.php index 115dae06b8..95e965787f 100644 --- a/LibreNMS/Util/Clean.php +++ b/LibreNMS/Util/Clean.php @@ -40,7 +40,7 @@ class Clean */ public static function fileName($file) { - return preg_replace('/[^a-zA-Z0-9\-._]/', '', $file); + return preg_replace('/[^a-zA-Z0-9\-._]/', '', $file ?? ''); } /** diff --git a/app/Console/Commands/DevicePoll.php b/app/Console/Commands/DevicePoll.php index 28fe287899..69422c6875 100644 --- a/app/Console/Commands/DevicePoll.php +++ b/app/Console/Commands/DevicePoll.php @@ -40,7 +40,7 @@ class DevicePoll extends LnmsCommand try { /** @var \LibreNMS\Poller $poller */ - $poller = app(Poller::class, ['device_spec' => $this->argument('device spec'), 'module_override' => explode(',', $this->option('modules'))]); + $poller = app(Poller::class, ['device_spec' => $this->argument('device spec'), 'module_override' => explode(',', $this->option('modules') ?? '')]); $polled = $poller->poll(); if ($polled > 0) { diff --git a/app/Models/Device.php b/app/Models/Device.php index ac6b340025..acb2e6a1f4 100644 --- a/app/Models/Device.php +++ b/app/Models/Device.php @@ -470,7 +470,7 @@ class Device extends BaseModel public function setIpAttribute($ip): void { - $this->attributes['ip'] = inet_pton($ip); + $this->attributes['ip'] = inet_pton($ip ?? ''); } public function setStatusAttribute($status): void diff --git a/billing-calculate.php b/billing-calculate.php index f02c940c21..19189b4e67 100755 --- a/billing-calculate.php +++ b/billing-calculate.php @@ -38,7 +38,7 @@ foreach (dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_id`') as $bill) { $period = Billing::getPeriod($bill['bill_id'], $datefrom, $dateto); - $date_updated = str_replace('-', '', str_replace(':', '', str_replace(' ', '', $check['updated']))); + $date_updated = $check ? str_replace(['-', ':', ' '], '', $check['updated']) : 0; // Send the current dir_95th to the getRates function so it knows to aggregate or return the max in/out value and highest direction $dir_95th = $bill['dir_95th']; @@ -70,7 +70,7 @@ foreach (dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_id`') as $bill) { $percent = Number::calculatePercent($rate_data['total_data'], $bill['bill_quota']); } - echo strftime('%x @ %X', strtotime($datefrom)) . ' to ' . strftime('%x @ %X', strtotime($dateto)) . ' ' . str_pad($type, 8) . ' ' . str_pad($allowed_text, 10) . ' ' . str_pad($used_text, 10) . ' ' . $percent . '%'; + echo \Carbon\Carbon::parse($datefrom)->toDateTimeString() . ' to ' . \Carbon\Carbon::parse($dateto)->toDateTimeString() . ' ' . str_pad($type, 8) . ' ' . str_pad($allowed_text, 10) . ' ' . str_pad($used_text, 10) . ' ' . $percent . '%'; if ($i == '0') { $update = [ @@ -91,7 +91,7 @@ foreach (dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_id`') as $bill) { echo ' Updated! '; } - if ($check['bill_id'] == $bill['bill_id']) { + if (isset($check['bill_id']) && $check['bill_id'] == $bill['bill_id']) { $update = [ 'rate_95th' => $rate_data['rate_95th'], 'rate_95th_in' => $rate_data['rate_95th_in'], diff --git a/includes/services/check_icmp.inc.php b/includes/services/check_icmp.inc.php index 9113e1838b..2f2209fb5f 100644 --- a/includes/services/check_icmp.inc.php +++ b/includes/services/check_icmp.inc.php @@ -3,29 +3,31 @@ // check_cmd is the command that is run to execute the check $check_cmd = \LibreNMS\Config::get('nagios_plugins') . '/check_icmp ' . $service['service_param'] . ' ' . ($service['service_ip'] ? $service['service_ip'] : $service['hostname']); -// Check DS is a json array of the graphs that are available -$check_ds = '{"rtt":"s","pl":"%"}'; +if (isset($rrd_filename)) { + // Check DS is a json array of the graphs that are available + $check_ds = '{"rtt":"s","pl":"%"}'; -// Build the graph data -$check_graph = []; -$check_graph['rtt'] = ' DEF:DS0=' . $rrd_filename . ':rta:AVERAGE '; -$check_graph['rtt'] .= ' LINE1.25:DS0#' . \LibreNMS\Config::get('graph_colours.mixed.0') . ":'" . str_pad(substr('Round Trip Average', 0, 15), 15) . "' "; -$check_graph['rtt'] .= ' GPRINT:DS0:LAST:%5.2lf%s '; -$check_graph['rtt'] .= ' GPRINT:DS0:AVERAGE:%5.2lf%s '; -$check_graph['rtt'] .= ' GPRINT:DS0:MAX:%5.2lf%s\\l '; -$check_graph['rtt'] .= ' DEF:DS1=' . $rrd_filename . ':rtmax:AVERAGE '; -$check_graph['rtt'] .= ' LINE1.25:DS1#' . \LibreNMS\Config::get('graph_colours.mixed.1') . ":'" . str_pad(substr('Round Trip Max', 0, 15), 15) . "' "; -$check_graph['rtt'] .= ' GPRINT:DS1:LAST:%5.2lf%s '; -$check_graph['rtt'] .= ' GPRINT:DS1:AVERAGE:%5.2lf%s '; -$check_graph['rtt'] .= ' GPRINT:DS1:MAX:%5.2lf%s\\l '; -$check_graph['rtt'] .= ' DEF:DS2=' . $rrd_filename . ':rtmin:AVERAGE '; -$check_graph['rtt'] .= ' LINE1.25:DS2#' . \LibreNMS\Config::get('graph_colours.mixed.2') . ":'" . str_pad(substr('Round Trip Min', 0, 15), 15) . "' "; -$check_graph['rtt'] .= ' GPRINT:DS2:LAST:%5.2lf%s '; -$check_graph['rtt'] .= ' GPRINT:DS2:AVERAGE:%5.2lf%s '; -$check_graph['rtt'] .= ' GPRINT:DS2:MAX:%5.2lf%s\\l '; + // Build the graph data + $check_graph = []; + $check_graph['rtt'] = ' DEF:DS0=' . $rrd_filename . ':rta:AVERAGE '; + $check_graph['rtt'] .= ' LINE1.25:DS0#' . \LibreNMS\Config::get('graph_colours.mixed.0') . ":'" . str_pad(substr('Round Trip Average', 0, 15), 15) . "' "; + $check_graph['rtt'] .= ' GPRINT:DS0:LAST:%5.2lf%s '; + $check_graph['rtt'] .= ' GPRINT:DS0:AVERAGE:%5.2lf%s '; + $check_graph['rtt'] .= ' GPRINT:DS0:MAX:%5.2lf%s\\l '; + $check_graph['rtt'] .= ' DEF:DS1=' . $rrd_filename . ':rtmax:AVERAGE '; + $check_graph['rtt'] .= ' LINE1.25:DS1#' . \LibreNMS\Config::get('graph_colours.mixed.1') . ":'" . str_pad(substr('Round Trip Max', 0, 15), 15) . "' "; + $check_graph['rtt'] .= ' GPRINT:DS1:LAST:%5.2lf%s '; + $check_graph['rtt'] .= ' GPRINT:DS1:AVERAGE:%5.2lf%s '; + $check_graph['rtt'] .= ' GPRINT:DS1:MAX:%5.2lf%s\\l '; + $check_graph['rtt'] .= ' DEF:DS2=' . $rrd_filename . ':rtmin:AVERAGE '; + $check_graph['rtt'] .= ' LINE1.25:DS2#' . \LibreNMS\Config::get('graph_colours.mixed.2') . ":'" . str_pad(substr('Round Trip Min', 0, 15), 15) . "' "; + $check_graph['rtt'] .= ' GPRINT:DS2:LAST:%5.2lf%s '; + $check_graph['rtt'] .= ' GPRINT:DS2:AVERAGE:%5.2lf%s '; + $check_graph['rtt'] .= ' GPRINT:DS2:MAX:%5.2lf%s\\l '; -$check_graph['pl'] = ' DEF:DS0=' . $rrd_filename . ':pl:AVERAGE '; -$check_graph['pl'] .= ' AREA:DS0#' . \LibreNMS\Config::get('graph_colours.mixed.2') . ":'" . str_pad(substr('Packet Loss (%)', 0, 15), 15) . "' "; -$check_graph['pl'] .= ' GPRINT:DS0:LAST:%5.2lf%s '; -$check_graph['pl'] .= ' GPRINT:DS0:AVERAGE:%5.2lf%s '; -$check_graph['pl'] .= ' GPRINT:DS0:MAX:%5.2lf%s\\l '; + $check_graph['pl'] = ' DEF:DS0=' . $rrd_filename . ':pl:AVERAGE '; + $check_graph['pl'] .= ' AREA:DS0#' . \LibreNMS\Config::get('graph_colours.mixed.2') . ":'" . str_pad(substr('Packet Loss (%)', 0, 15), 15) . "' "; + $check_graph['pl'] .= ' GPRINT:DS0:LAST:%5.2lf%s '; + $check_graph['pl'] .= ' GPRINT:DS0:AVERAGE:%5.2lf%s '; + $check_graph['pl'] .= ' GPRINT:DS0:MAX:%5.2lf%s\\l '; +} diff --git a/includes/services/check_load.inc.php b/includes/services/check_load.inc.php index 3da4ac3f8a..386ae165ea 100644 --- a/includes/services/check_load.inc.php +++ b/includes/services/check_load.inc.php @@ -9,23 +9,25 @@ if ($service['service_param']) { $check_cmd = \LibreNMS\Config::get('nagios_plugins') . '/check_load ' . $params; -// Check DS is a json array of the graphs that are available -$check_ds = '{"load":""}'; +if (isset($rrd_filename)) { + // Check DS is a json array of the graphs that are available + $check_ds = '{"load":""}'; -// Build the graph data -$check_graph = []; -$check_graph['load'] = ' DEF:DS0=' . $rrd_filename . ':load1:AVERAGE '; -$check_graph['load'] .= ' LINE1.25:DS0#' . \LibreNMS\Config::get('graph_colours.mixed.0') . ":'" . str_pad(substr('Load 1', 0, 15), 15) . "' "; -$check_graph['load'] .= ' GPRINT:DS0:LAST:%5.2lf%s '; -$check_graph['load'] .= ' GPRINT:DS0:AVERAGE:%5.2lf%s '; -$check_graph['load'] .= ' GPRINT:DS0:MAX:%5.2lf%s\\l '; -$check_graph['load'] .= ' DEF:DS1=' . $rrd_filename . ':load5:AVERAGE '; -$check_graph['load'] .= ' LINE1.25:DS1#' . \LibreNMS\Config::get('graph_colours.mixed.1') . ":'" . str_pad(substr('Load 5', 0, 15), 15) . "' "; -$check_graph['load'] .= ' GPRINT:DS1:LAST:%5.2lf%s '; -$check_graph['load'] .= ' GPRINT:DS1:AVERAGE:%5.2lf%s '; -$check_graph['load'] .= ' GPRINT:DS1:MAX:%5.2lf%s\\l '; -$check_graph['load'] .= ' DEF:DS2=' . $rrd_filename . ':load15:AVERAGE '; -$check_graph['load'] .= ' LINE1.25:DS2#' . \LibreNMS\Config::get('graph_colours.mixed.2') . ":'" . str_pad(substr('Load 15', 0, 15), 15) . "' "; -$check_graph['load'] .= ' GPRINT:DS2:LAST:%5.2lf%s '; -$check_graph['load'] .= ' GPRINT:DS2:AVERAGE:%5.2lf%s '; -$check_graph['load'] .= ' GPRINT:DS2:MAX:%5.2lf%s\\l '; + // Build the graph data + $check_graph = []; + $check_graph['load'] = ' DEF:DS0=' . $rrd_filename . ':load1:AVERAGE '; + $check_graph['load'] .= ' LINE1.25:DS0#' . \LibreNMS\Config::get('graph_colours.mixed.0') . ":'" . str_pad(substr('Load 1', 0, 15), 15) . "' "; + $check_graph['load'] .= ' GPRINT:DS0:LAST:%5.2lf%s '; + $check_graph['load'] .= ' GPRINT:DS0:AVERAGE:%5.2lf%s '; + $check_graph['load'] .= ' GPRINT:DS0:MAX:%5.2lf%s\\l '; + $check_graph['load'] .= ' DEF:DS1=' . $rrd_filename . ':load5:AVERAGE '; + $check_graph['load'] .= ' LINE1.25:DS1#' . \LibreNMS\Config::get('graph_colours.mixed.1') . ":'" . str_pad(substr('Load 5', 0, 15), 15) . "' "; + $check_graph['load'] .= ' GPRINT:DS1:LAST:%5.2lf%s '; + $check_graph['load'] .= ' GPRINT:DS1:AVERAGE:%5.2lf%s '; + $check_graph['load'] .= ' GPRINT:DS1:MAX:%5.2lf%s\\l '; + $check_graph['load'] .= ' DEF:DS2=' . $rrd_filename . ':load15:AVERAGE '; + $check_graph['load'] .= ' LINE1.25:DS2#' . \LibreNMS\Config::get('graph_colours.mixed.2') . ":'" . str_pad(substr('Load 15', 0, 15), 15) . "' "; + $check_graph['load'] .= ' GPRINT:DS2:LAST:%5.2lf%s '; + $check_graph['load'] .= ' GPRINT:DS2:AVERAGE:%5.2lf%s '; + $check_graph['load'] .= ' GPRINT:DS2:MAX:%5.2lf%s\\l '; +} diff --git a/includes/services/check_mysql.inc.php b/includes/services/check_mysql.inc.php index aef3b3cf5a..44945ae9c3 100644 --- a/includes/services/check_mysql.inc.php +++ b/includes/services/check_mysql.inc.php @@ -8,90 +8,92 @@ if ($service['service_param']) { } $check_cmd = \LibreNMS\Config::get('nagios_plugins') . '/check_mysql -H ' . $service['hostname'] . ' ' . $dbname . ' ' . $service['service_param']; -// Check DS is a json array of the graphs that are available -$check_ds = '{"mysqlqueries":"c","mysql":"c","mysqluptime":"c","mysqlQcache":"c"}'; +if (isset($rrd_filename)) { + // Check DS is a json array of the graphs that are available + $check_ds = '{"mysqlqueries":"c","mysql":"c","mysqluptime":"c","mysqlQcache":"c"}'; -// Build the graph data -$check_graph = []; -$mixed_colours = \LibreNMS\Config::get('graph_colours.mixed'); + // Build the graph data + $check_graph = []; + $mixed_colours = \LibreNMS\Config::get('graph_colours.mixed'); -$check_graph['mysqlqueries'] = ' DEF:DS0=' . $rrd_filename . ':Queries:AVERAGE '; -$check_graph['mysqlqueries'] .= ' LINE1.25:DS0#' . $mixed_colours[1] . ":'" . str_pad(substr('Queries', 0, 19), 19) . "' "; -$check_graph['mysqlqueries'] .= ' GPRINT:DS0:LAST:%0.0lf '; -$check_graph['mysqlqueries'] .= ' GPRINT:DS0:AVERAGE:%0.0lf '; -$check_graph['mysqlqueries'] .= ' GPRINT:DS0:MAX:%0.0lf\\l '; -$check_graph['mysqlqueries'] .= ' DEF:DS1=' . $rrd_filename . ':Questions:AVERAGE '; -$check_graph['mysqlqueries'] .= ' LINE1.25:DS1#' . $mixed_colours[2] . ":'" . str_pad(substr('Questions', 0, 19), 19) . "' "; -$check_graph['mysqlqueries'] .= ' GPRINT:DS1:LAST:%0.0lf '; -$check_graph['mysqlqueries'] .= ' GPRINT:DS1:AVERAGE:%0.0lf '; -$check_graph['mysqlqueries'] .= ' GPRINT:DS1:MAX:%0.0lf\\l '; + $check_graph['mysqlqueries'] = ' DEF:DS0=' . $rrd_filename . ':Queries:AVERAGE '; + $check_graph['mysqlqueries'] .= ' LINE1.25:DS0#' . $mixed_colours[1] . ":'" . str_pad(substr('Queries', 0, 19), 19) . "' "; + $check_graph['mysqlqueries'] .= ' GPRINT:DS0:LAST:%0.0lf '; + $check_graph['mysqlqueries'] .= ' GPRINT:DS0:AVERAGE:%0.0lf '; + $check_graph['mysqlqueries'] .= ' GPRINT:DS0:MAX:%0.0lf\\l '; + $check_graph['mysqlqueries'] .= ' DEF:DS1=' . $rrd_filename . ':Questions:AVERAGE '; + $check_graph['mysqlqueries'] .= ' LINE1.25:DS1#' . $mixed_colours[2] . ":'" . str_pad(substr('Questions', 0, 19), 19) . "' "; + $check_graph['mysqlqueries'] .= ' GPRINT:DS1:LAST:%0.0lf '; + $check_graph['mysqlqueries'] .= ' GPRINT:DS1:AVERAGE:%0.0lf '; + $check_graph['mysqlqueries'] .= ' GPRINT:DS1:MAX:%0.0lf\\l '; -$check_graph['mysql'] = ' DEF:DS0=' . $rrd_filename . ':Connections:AVERAGE '; -$check_graph['mysql'] .= ' LINE1.25:DS0#' . $mixed_colours[0] . ":'" . str_pad(substr('Connections', 0, 19), 19) . "' "; -$check_graph['mysql'] .= ' GPRINT:DS0:LAST:%5.2lf%s '; -$check_graph['mysql'] .= ' GPRINT:DS0:AVERAGE:%5.2lf%s '; -$check_graph['mysql'] .= ' GPRINT:DS0:MAX:%5.2lf%s\\l '; -$check_graph['mysql'] .= ' DEF:DS1=' . $rrd_filename . ':Open_files:AVERAGE '; -$check_graph['mysql'] .= ' LINE1.25:DS1#' . $mixed_colours[3] . ":'" . str_pad(substr('Open_files', 0, 19), 19) . "' "; -$check_graph['mysql'] .= ' GPRINT:DS1:LAST:%0.0lf '; -$check_graph['mysql'] .= ' GPRINT:DS1:AVERAGE:%0.0lf '; -$check_graph['mysql'] .= ' GPRINT:DS1:MAX:%0.0lf\\l '; -$check_graph['mysql'] .= ' DEF:DS2=' . $rrd_filename . ':Open_tables:AVERAGE '; -$check_graph['mysql'] .= ' LINE1.25:DS2#' . $mixed_colours[4] . ":'" . str_pad(substr('Open_tables', 0, 19), 19) . "' "; -$check_graph['mysql'] .= ' GPRINT:DS2:LAST:%0.0lf '; -$check_graph['mysql'] .= ' GPRINT:DS2:AVERAGE:%0.0lf '; -$check_graph['mysql'] .= ' GPRINT:DS2:MAX:%0.0lf\\l '; -$check_graph['mysql'] .= ' DEF:DS3=' . $rrd_filename . ':Table_locks_waited:AVERAGE '; -$check_graph['mysql'] .= ' LINE1.25:DS3#' . $mixed_colours[5] . ":'" . str_pad(substr('Table_locks_waited', 0, 19), 19) . "' "; -$check_graph['mysql'] .= ' GPRINT:DS3:LAST:%0.0lf '; -$check_graph['mysql'] .= ' GPRINT:DS3:AVERAGE:%0.0lf '; -$check_graph['mysql'] .= ' GPRINT:DS3:MAX:%0.0lf\\l '; -$check_graph['mysql'] .= ' DEF:DS4=' . $rrd_filename . ':Threads_connected:AVERAGE '; -$check_graph['mysql'] .= ' LINE1.25:DS4#' . $mixed_colours[6] . ":'" . str_pad(substr('Threads_connected', 0, 19), 19) . "' "; -$check_graph['mysql'] .= ' GPRINT:DS4:LAST:%0.0lf '; -$check_graph['mysql'] .= ' GPRINT:DS4:AVERAGE:%0.0lf '; -$check_graph['mysql'] .= ' GPRINT:DS4:MAX:%0.0lf\\l '; -$check_graph['mysql'] .= ' DEF:DS5=' . $rrd_filename . ':Threads_running:AVERAGE '; -$check_graph['mysql'] .= ' LINE1.25:DS5#' . $mixed_colours[7] . ":'" . str_pad(substr('Threads_running', 0, 19), 19) . "' "; -$check_graph['mysql'] .= ' GPRINT:DS5:LAST:%0.0lf '; -$check_graph['mysql'] .= ' GPRINT:DS5:AVERAGE:%0.0lf '; -$check_graph['mysql'] .= ' GPRINT:DS5:MAX:%0.0lf\\l '; + $check_graph['mysql'] = ' DEF:DS0=' . $rrd_filename . ':Connections:AVERAGE '; + $check_graph['mysql'] .= ' LINE1.25:DS0#' . $mixed_colours[0] . ":'" . str_pad(substr('Connections', 0, 19), 19) . "' "; + $check_graph['mysql'] .= ' GPRINT:DS0:LAST:%5.2lf%s '; + $check_graph['mysql'] .= ' GPRINT:DS0:AVERAGE:%5.2lf%s '; + $check_graph['mysql'] .= ' GPRINT:DS0:MAX:%5.2lf%s\\l '; + $check_graph['mysql'] .= ' DEF:DS1=' . $rrd_filename . ':Open_files:AVERAGE '; + $check_graph['mysql'] .= ' LINE1.25:DS1#' . $mixed_colours[3] . ":'" . str_pad(substr('Open_files', 0, 19), 19) . "' "; + $check_graph['mysql'] .= ' GPRINT:DS1:LAST:%0.0lf '; + $check_graph['mysql'] .= ' GPRINT:DS1:AVERAGE:%0.0lf '; + $check_graph['mysql'] .= ' GPRINT:DS1:MAX:%0.0lf\\l '; + $check_graph['mysql'] .= ' DEF:DS2=' . $rrd_filename . ':Open_tables:AVERAGE '; + $check_graph['mysql'] .= ' LINE1.25:DS2#' . $mixed_colours[4] . ":'" . str_pad(substr('Open_tables', 0, 19), 19) . "' "; + $check_graph['mysql'] .= ' GPRINT:DS2:LAST:%0.0lf '; + $check_graph['mysql'] .= ' GPRINT:DS2:AVERAGE:%0.0lf '; + $check_graph['mysql'] .= ' GPRINT:DS2:MAX:%0.0lf\\l '; + $check_graph['mysql'] .= ' DEF:DS3=' . $rrd_filename . ':Table_locks_waited:AVERAGE '; + $check_graph['mysql'] .= ' LINE1.25:DS3#' . $mixed_colours[5] . ":'" . str_pad(substr('Table_locks_waited', 0, 19), 19) . "' "; + $check_graph['mysql'] .= ' GPRINT:DS3:LAST:%0.0lf '; + $check_graph['mysql'] .= ' GPRINT:DS3:AVERAGE:%0.0lf '; + $check_graph['mysql'] .= ' GPRINT:DS3:MAX:%0.0lf\\l '; + $check_graph['mysql'] .= ' DEF:DS4=' . $rrd_filename . ':Threads_connected:AVERAGE '; + $check_graph['mysql'] .= ' LINE1.25:DS4#' . $mixed_colours[6] . ":'" . str_pad(substr('Threads_connected', 0, 19), 19) . "' "; + $check_graph['mysql'] .= ' GPRINT:DS4:LAST:%0.0lf '; + $check_graph['mysql'] .= ' GPRINT:DS4:AVERAGE:%0.0lf '; + $check_graph['mysql'] .= ' GPRINT:DS4:MAX:%0.0lf\\l '; + $check_graph['mysql'] .= ' DEF:DS5=' . $rrd_filename . ':Threads_running:AVERAGE '; + $check_graph['mysql'] .= ' LINE1.25:DS5#' . $mixed_colours[7] . ":'" . str_pad(substr('Threads_running', 0, 19), 19) . "' "; + $check_graph['mysql'] .= ' GPRINT:DS5:LAST:%0.0lf '; + $check_graph['mysql'] .= ' GPRINT:DS5:AVERAGE:%0.0lf '; + $check_graph['mysql'] .= ' GPRINT:DS5:MAX:%0.0lf\\l '; -$check_graph['mysqluptime'] = ' DEF:DS0=' . $rrd_filename . ':Uptime:LAST '; -$check_graph['mysqluptime'] .= ' CDEF:cuptime=DS0,86400,/'; -$check_graph['mysqluptime'] .= " 'COMMENT:Days Current Minimum Maximum Average\\n'"; -$check_graph['mysqluptime'] .= ' AREA:cuptime#EEEEEE:Uptime'; -$check_graph['mysqluptime'] .= ' LINE1.25:cuptime#36393D:'; -$check_graph['mysqluptime'] .= ' GPRINT:cuptime:LAST:%6.2lf GPRINT:cuptime:MIN:%6.2lf'; -$check_graph['mysqluptime'] .= ' GPRINT:cuptime:MAX:%6.2lf GPRINT:cuptime:AVERAGE:%6.2lf\\l'; + $check_graph['mysqluptime'] = ' DEF:DS0=' . $rrd_filename . ':Uptime:LAST '; + $check_graph['mysqluptime'] .= ' CDEF:cuptime=DS0,86400,/'; + $check_graph['mysqluptime'] .= " 'COMMENT:Days Current Minimum Maximum Average\\n'"; + $check_graph['mysqluptime'] .= ' AREA:cuptime#EEEEEE:Uptime'; + $check_graph['mysqluptime'] .= ' LINE1.25:cuptime#36393D:'; + $check_graph['mysqluptime'] .= ' GPRINT:cuptime:LAST:%6.2lf GPRINT:cuptime:MIN:%6.2lf'; + $check_graph['mysqluptime'] .= ' GPRINT:cuptime:MAX:%6.2lf GPRINT:cuptime:AVERAGE:%6.2lf\\l'; -$check_graph['mysqlQcache'] = ' DEF:DS0=' . $rrd_filename . ':Qcache_free_memory:AVERAGE '; -$check_graph['mysqlQcache'] .= ' LINE1.25:DS0#' . $mixed_colours[0] . ":'" . str_pad(substr('Qcache_free_memory', 0, 19), 19) . "' "; -$check_graph['mysqlQcache'] .= ' GPRINT:DS0:LAST:%9.2lf%s '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS0:AVERAGE:%9.2lf%s '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS0:MAX:%9.2lf%s\\l '; -$check_graph['mysqlQcache'] .= ' DEF:DS1=' . $rrd_filename . ':Qcache_hits:AVERAGE '; -$check_graph['mysqlQcache'] .= ' LINE1.25:DS1#' . $mixed_colours[1] . ":'" . str_pad(substr('Qcache_hits', 0, 19), 19) . "' "; -$check_graph['mysqlQcache'] .= ' GPRINT:DS1:LAST:%9.2lf '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS1:AVERAGE:%9.2lf '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS1:MAX:%9.2lf\\l '; -$check_graph['mysqlQcache'] .= ' DEF:DS2=' . $rrd_filename . ':Qcache_inserts:AVERAGE '; -$check_graph['mysqlQcache'] .= ' LINE1.25:DS2#' . $mixed_colours[2] . ":'" . str_pad(substr('Qcache_inserts', 0, 19), 19) . "' "; -$check_graph['mysqlQcache'] .= ' GPRINT:DS2:LAST:%9.2lf '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS2:AVERAGE:%9.2lf '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS2:MAX:%9.2lf\\l '; -$check_graph['mysqlQcache'] .= ' DEF:DS3=' . $rrd_filename . ':Qcache_lowmem_prune:AVERAGE '; -$check_graph['mysqlQcache'] .= ' LINE1.25:DS3#' . $mixed_colours[3] . ":'" . str_pad(substr('Qcache_lowmem_prune', 0, 19), 19) . "' "; -$check_graph['mysqlQcache'] .= ' GPRINT:DS3:LAST:%9.2lf '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS3:AVERAGE:%9.2lf '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS3:MAX:%9.2lf\\l '; -$check_graph['mysqlQcache'] .= ' DEF:DS4=' . $rrd_filename . ':Qcache_not_cached:AVERAGE '; -$check_graph['mysqlQcache'] .= ' LINE1.25:DS4#' . $mixed_colours[4] . ":'" . str_pad(substr('Qcache_not_cached', 0, 19), 19) . "' "; -$check_graph['mysqlQcache'] .= ' GPRINT:DS4:LAST:%9.2lf '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS4:AVERAGE:%9.2lf '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS4:MAX:%9.2lf\\l '; -$check_graph['mysqlQcache'] .= ' DEF:DS5=' . $rrd_filename . ':Qcache_queries_in_c:AVERAGE '; -$check_graph['mysqlQcache'] .= ' LINE1.25:DS5#' . $mixed_colours[5] . ":'" . str_pad(substr('Qcache_queries_in_c', 0, 19), 19) . "' "; -$check_graph['mysqlQcache'] .= ' GPRINT:DS5:LAST:%9.2lf '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS5:AVERAGE:%9.2lf '; -$check_graph['mysqlQcache'] .= ' GPRINT:DS5:MAX:%9.2lf\\l '; + $check_graph['mysqlQcache'] = ' DEF:DS0=' . $rrd_filename . ':Qcache_free_memory:AVERAGE '; + $check_graph['mysqlQcache'] .= ' LINE1.25:DS0#' . $mixed_colours[0] . ":'" . str_pad(substr('Qcache_free_memory', 0, 19), 19) . "' "; + $check_graph['mysqlQcache'] .= ' GPRINT:DS0:LAST:%9.2lf%s '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS0:AVERAGE:%9.2lf%s '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS0:MAX:%9.2lf%s\\l '; + $check_graph['mysqlQcache'] .= ' DEF:DS1=' . $rrd_filename . ':Qcache_hits:AVERAGE '; + $check_graph['mysqlQcache'] .= ' LINE1.25:DS1#' . $mixed_colours[1] . ":'" . str_pad(substr('Qcache_hits', 0, 19), 19) . "' "; + $check_graph['mysqlQcache'] .= ' GPRINT:DS1:LAST:%9.2lf '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS1:AVERAGE:%9.2lf '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS1:MAX:%9.2lf\\l '; + $check_graph['mysqlQcache'] .= ' DEF:DS2=' . $rrd_filename . ':Qcache_inserts:AVERAGE '; + $check_graph['mysqlQcache'] .= ' LINE1.25:DS2#' . $mixed_colours[2] . ":'" . str_pad(substr('Qcache_inserts', 0, 19), 19) . "' "; + $check_graph['mysqlQcache'] .= ' GPRINT:DS2:LAST:%9.2lf '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS2:AVERAGE:%9.2lf '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS2:MAX:%9.2lf\\l '; + $check_graph['mysqlQcache'] .= ' DEF:DS3=' . $rrd_filename . ':Qcache_lowmem_prune:AVERAGE '; + $check_graph['mysqlQcache'] .= ' LINE1.25:DS3#' . $mixed_colours[3] . ":'" . str_pad(substr('Qcache_lowmem_prune', 0, 19), 19) . "' "; + $check_graph['mysqlQcache'] .= ' GPRINT:DS3:LAST:%9.2lf '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS3:AVERAGE:%9.2lf '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS3:MAX:%9.2lf\\l '; + $check_graph['mysqlQcache'] .= ' DEF:DS4=' . $rrd_filename . ':Qcache_not_cached:AVERAGE '; + $check_graph['mysqlQcache'] .= ' LINE1.25:DS4#' . $mixed_colours[4] . ":'" . str_pad(substr('Qcache_not_cached', 0, 19), 19) . "' "; + $check_graph['mysqlQcache'] .= ' GPRINT:DS4:LAST:%9.2lf '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS4:AVERAGE:%9.2lf '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS4:MAX:%9.2lf\\l '; + $check_graph['mysqlQcache'] .= ' DEF:DS5=' . $rrd_filename . ':Qcache_queries_in_c:AVERAGE '; + $check_graph['mysqlQcache'] .= ' LINE1.25:DS5#' . $mixed_colours[5] . ":'" . str_pad(substr('Qcache_queries_in_c', 0, 19), 19) . "' "; + $check_graph['mysqlQcache'] .= ' GPRINT:DS5:LAST:%9.2lf '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS5:AVERAGE:%9.2lf '; + $check_graph['mysqlQcache'] .= ' GPRINT:DS5:MAX:%9.2lf\\l '; +}