interfacetable_v3t
interfacetable_v3t copied to clipboard
grapherdisplay option added
by debeu (http://www.tontonitch.com/phpbb/viewtopic.php?f=3&t=3050)
thanks for the plugin. I added the option grapherdisplay to overwrite the hostdiplay argument in grapher url for pnp4nagios (atm only). Problem is that if you use hostdisplay argument with $hostname$ and you use two services with different options for one host the webpage will overwritte everytime - so you have to use hostdiplay with for example $hostname$- $servicedesc$, but then you grapher url is wrong.
--- check_interface_table_v3t.pl 2016-08-29 12:30:00.520062822 +0200
+++ check_interface_table_v3t-new.pl 2016-08-29 12:57:11.533933707 +0200
@@ -4991,10 +4991,17 @@ sub GenerateInterfaceTableData {
$servicename =~ s/[()'"]//g;
$servicename =~ s/,/./g;
if ($ghOptions{'grapher'} eq "pnp4nagios") {
- $CellContent .= '<a class=\'tips\' ' .
- 'href="' . $ghOptions{'grapherurl'} . '/index.php/graph?host=' . $ghOptions{'hostdisplay'} . '&srv=' . $servicename . '" ' .
- 'rel="' . $ghOptions{'grapherurl'} . '/index.php/popup?host=' . $ghOptions{'hostdisplay'} . '&srv=' . $servicename . '">' .
- '<img src="../img/chart.png" alt="Trends" /></a>';
+ if ($ghOptions{'grapherdisplay'} eq '') {
+ $CellContent .= '<a class=\'tips\' ' .
+ 'href="' . $ghOptions{'grapherurl'} . '/index.php/graph?host=' . $ghOptions{'hostdisplay'} . '&srv=' . $servicename . '" ' .
+ 'rel="' . $ghOptions{'grapherurl'} . '/index.php/popup?host=' . $ghOptions{'hostdisplay'} . '&srv=' . $servicename . '">' .
+ '<img src="../img/chart.png" alt="Trends" /></a>';
+ } else {
+ $CellContent .= '<a class=\'tips\' ' .
+ 'href="' . $ghOptions{'grapherurl'} . '/index.php/graph?host=' . $ghOptions{'grapherdisplay'} . '&srv=' . $servicename . '" ' .
+ 'rel="' . $ghOptions{'grapherurl'} . '/index.php/popup?host=' . $ghOptions{'grapherdisplay'} . '&srv=' . $servicename . '">' .
+ '<img src="../img/chart.png" alt="Trends" /></a>';
+ }
} elsif ($ghOptions{'grapher'} eq "nagiosgrapher") {
$CellContent .= '<a href="' .
#$ghOptions{'grapherurl'} . '/graphs.cgi?host=' . $ghOptions{'hostdisplay'} . '&srv=' . $servicename .
@@ -6203,6 +6210,9 @@ sub print_usage () {
--grapherurl (optional)
Graphing system url. Default values are:
Ex: /pnp4nagios
+ --grapherdisplay (optional)
+ Graphing alias for URL
+ Ex: --grapherdisplay HOSTNAME
--portperfunit (optional)
In/out traffic in perfdata could be reported in bits (counters) or in bps (calculated value).
Using bps avoid abnormal load values to be plotted on the graphs.
@@ -6393,6 +6403,7 @@ sub check_options () {
'perfdataservicedesc=s', # servicedescription in Nagios/Icinga so that PNP uses the correct name for its files
'grapher|g=s', # graphing system. Can be pnp4nagios, nagiosgrapher, netwaysgrapherv2 or ingraph
'grapherurl=s', # graphing system url. By default, this is adapted for pnp4nagios standard install: /pnp4nagios
+ 'grapherdisplay=s',
#-------- SNMP related ----------#
'host=s', # SNMP host target
'domain=s', # SNMP transport domain
@@ -6491,6 +6502,7 @@ sub check_options () {
'perfdataservicedesc', => undef,
'grapher' => "pnp4nagios",
'grapherurl' => "/pnp4nagios",
+ 'grapherdisplay' => '',
#------- other features ---------#
'config' => '',
'css' => "icinga", # Used css stylesheet. Can be classic, icinga or nagiosxi.
@@ -6580,6 +6592,9 @@ sub check_options () {
} else {
$ghOptions{'hostdisplay'} = "$commandline{hostquery}";
}
+ if (exists $commandline{grapherdisplay}) {
+ $ghOptions{'grapherdisplay'} = "$commandline{grapherdisplay}";
+ }
if (exists $commandline{statedir}) {
$ghOptions{'statedir'} = "$commandline{statedir}";
}