diff --git a/README.md b/README.md index aa1a318..f12560b 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,69 @@ make all etc....but some of us (me) prefers to have a software package, to organize software installation/update/removal. +@@ -8,3 +8,8 @@ + + http://pnp4nagios.sourceforge.net or: + http://docs.pnp4nagios.org/ + +## pnp-metrics-api ### + +https://github.com/lingej/pnp-metrics-api +README.md + +# pnp-metrics-api +## Usage examples +### CURL +#### Query metrics of a service on a specific host +``` +curl -s -u ':' -H "Content-Type: application/json" -X POST -d ' +{ + "targets":[ + { + "host":"host1.example.org", + "service":"_HOST_", + "perflabel":"rta", + "type":"AVERAGE" + }, + { + "host":"host2.example.org", + "service":"_HOST_", + "perflabel":"rta", + "type":"AVERAGE" + } + ], + "start":'UNIXEPOCHTIMESTAMP_START', + "end":'UNIXEPOCHTIMESTAMP_END' +}' https://example.org/pnp4nagios/index.php/api/metrics +``` +#### List all hosts +``` +curl -s -u ':' https://example.org/pnp4nagios/index.php/api/hosts +``` + +#### List services of a host +``` +curl -s -u ':' -H "Content-Type: application/json" -X POST -d ' +{ + "host":"host.example.org" +}' https://example.org/pnp4nagios/index.php/api/services +``` + +You can use regular expressions for host lists: + +``` +curl -s -u ':' -H "Content-Type: application/json" -X POST -d ' +{ + "host":"/^local" +}' https://example.org/pnp4nagios/index.php/api/services +``` + + +#### List labels of a service of specific host +``` +curl -s -u ':' -H "Content-Type: application/json" -X POST -d ' +{ + "host":"host.example.org", + "service":"_HOST_" +}' https://example.org/pnp4nagios/index.php/api/labels +``` diff --git a/configure.ac b/configure.ac index 015c49f..8d6ecee 100755 --- a/configure.ac +++ b/configure.ac @@ -491,7 +491,7 @@ fi AC_SUBST(nagios_user) AC_SUBST(nagios_grp) -INSTALL_OPTS="-o $nagios_user -g $nagios_grp" +INSTALL_OPTS="" AC_SUBST(INSTALL_OPTS) # diff --git a/debian/patches/adjust-template-path b/debian/patches/adjust-template-path index 2e18a6e..2681c7e 100644 --- a/debian/patches/adjust-template-path +++ b/debian/patches/adjust-template-path @@ -4,7 +4,7 @@ Author: Sven Velt , Sebastian Harl .php @@ -15,7 +15,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ # # Link back to check_mk´s multisite ( http://mathias-kettner.de/checkmk_multisite.html ) -@@ -278,4 +279,10 @@ +@@ -291,3 +292,9 @@ '#F6E8C3','#C7EAE5','#DFC27D','#80CDC1','#BF812D','#35978F','#8C510A','#01665E'); $scheme['mixed3'] = array ('#67001F','#80CDC1','#B2182B','#35978F','#D6604D','#01665E','#F4A582','#003C30', '#FDDBC7','#92C5DE','#D1E5F0','#2166AC','#4393C3','#8C510A','#053061','#BF812D'); @@ -25,4 +25,4 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +} else if (file_exists('/etc/pnp4nagios/config.nagios4.php')) { + include '/etc/pnp4nagios/config.nagios4.php'; +} - ?> + diff --git a/debian/patches/fix-nagios-url b/debian/patches/fix-nagios-url index b24804a..b6935d9 100644 --- a/debian/patches/fix-nagios-url +++ b/debian/patches/fix-nagios-url @@ -3,10 +3,10 @@ Author: Sven Velt Forwarded: not-needed --- a/sample-config/pnp/config.php.in -+++ b/sample-config/pnp/config.php.in -@@ -89,7 +89,7 @@ $conf['temp'] = "/var/tmp"; ++++ b/sample-config/config_samples/config.php.in +@@ -100,7 +100,7 @@ # - # Link back to Nagios or Thruk ( www.thruk.org ) + # Link back to Nagios or Thruk ( www.thruk.org ) # -$conf['nagios_base'] = "/nagios/cgi-bin"; +$conf['nagios_base'] = "/cgi-bin/nagios4"; diff --git a/debian/patches/fix-npcd-path b/debian/patches/fix-npcd-path index f32dfdd..9e9ca07 100644 --- a/debian/patches/fix-npcd-path +++ b/debian/patches/fix-npcd-path @@ -3,7 +3,7 @@ Author: Sven Velt Forwarded: not-needed --- a/sample-config/pnp/npcd.cfg-sample.in -+++ b/sample-config/pnp/npcd.cfg-sample.in ++++ b/sample-config/config_samples/npcd.cfg.in @@ -76,7 +76,7 @@ # perfdata_spool_dir = # diff --git a/debian/patches/install_opts b/debian/patches/install_opts index 9dd42cb2..574327b 100644 --- a/debian/patches/install_opts +++ b/debian/patches/install_opts @@ -5,12 +5,12 @@ Last-Update: 2014-10-26 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/configure.ac +++ b/configure.ac -@@ -116,7 +116,7 @@ +@@ -491,7 +491,7 @@ + + AC_SUBST(nagios_user) AC_SUBST(nagios_grp) - AC_DEFINE_UNQUOTED(DEFAULT_NAGIOS_USER,"$nagios_user") - AC_DEFINE_UNQUOTED(DEFAULT_NAGIOS_GROUP,"$nagios_grp") -INSTALL_OPTS="-o $nagios_user -g $nagios_grp" +INSTALL_OPTS="" AC_SUBST(INSTALL_OPTS) - # Checks for programs. + # diff --git a/debian/patches/pnp-metrics-api b/debian/patches/pnp-metrics-api index d446d2d..b29b1cc 100644 --- a/debian/patches/pnp-metrics-api +++ b/debian/patches/pnp-metrics-api @@ -1,19 +1,20 @@ -diff -uNr pnp4nagios.orig/README pnp4nagios-0.6.26/README ---- pnp4nagios.orig/README 2017-08-21 17:52:37.000000000 +0200 -+++ pnp4nagios-0.6.26/README 2017-10-20 17:29:21.680000000 +0200 -@@ -8,3 +8,8 @@ +diff -uNr pnp4nagios.orig/README.md pnp4nagios-0.6.26/README.md +--- pnp4nagios.orig/README.md 1970-01-01 01:00:00.000000000 +0100 ++++ pnp4nagios-0.6.26/README.md 2017-10-20 17:02:31.336000000 +0200 +@@ -65,3 +65,69 @@ + etc....but some of us (me) prefers to have a software package, to organize + software installation/update/removal. - http://pnp4nagios.sourceforge.net or: - http://docs.pnp4nagios.org/ ++@@ -8,3 +8,8 @@ ++ ++ http://pnp4nagios.sourceforge.net or: ++ http://docs.pnp4nagios.org/ + +## pnp-metrics-api ### + +https://github.com/lingej/pnp-metrics-api +README.md -diff -uNr pnp4nagios.orig/README.md pnp4nagios-0.6.26/README.md ---- pnp4nagios.orig/README.md 1970-01-01 01:00:00.000000000 +0100 -+++ pnp4nagios-0.6.26/README.md 2017-10-20 17:02:31.336000000 +0200 -@@ -0,0 +1,56 @@ ++ +# pnp-metrics-api +## Usage examples +### CURL @@ -29,7 +30,7 @@ diff -uNr pnp4nagios.orig/README.md pnp4nagios-0.6.26/README.md + "type":"AVERAGE" + }, + { -+ "host":"host2.example.org", ++ "host":"host2.example.org", + "service":"_HOST_", + "perflabel":"rta", + "type":"AVERAGE" diff --git a/debian/patches/series b/debian/patches/series index 1c6c2d2..a3c9b01 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,4 +1,3 @@ -apache-fix-path-to-userfile fix-npcd-path fix-nagios-url adjust-template-path diff --git a/sample-config/config_samples/config.php.in b/sample-config/config_samples/config.php.in index dcc8d71..568b83c 100644 --- a/sample-config/config_samples/config.php.in +++ b/sample-config/config_samples/config.php.in @@ -100,7 +100,8 @@ $conf['temp'] = "/tmp"; # # Link back to Nagios or Thruk ( www.thruk.org ) # -$conf['nagios_base'] = "/nagios/cgi-bin"; +## Debian: please see /etc/pnp4nagios/config..php +##$conf['nagios_base'] = "/cgi-bin/nagios4"; # # Link back to check_mk´s multisite ( http://mathias-kettner.de/checkmk_multisite.html ) @@ -291,3 +292,9 @@ $scheme['mixed2'] = array ('#b2182b','#2166ac','#d6604d','#4393c3','#f4a582',' '#F6E8C3','#C7EAE5','#DFC27D','#80CDC1','#BF812D','#35978F','#8C510A','#01665E'); $scheme['mixed3'] = array ('#67001F','#80CDC1','#B2182B','#35978F','#D6604D','#01665E','#F4A582','#003C30', '#FDDBC7','#92C5DE','#D1E5F0','#2166AC','#4393C3','#8C510A','#053061','#BF812D'); + +if (file_exists('/etc/pnp4nagios/config.icinga.php')) { + include '/etc/pnp4nagios/config.icinga.php'; +} else if (file_exists('/etc/pnp4nagios/config.nagios4.php')) { + include '/etc/pnp4nagios/config.nagios4.php'; +} diff --git a/sample-config/config_samples/npcd.cfg.in b/sample-config/config_samples/npcd.cfg.in index cbff179..a90e338 100644 --- a/sample-config/config_samples/npcd.cfg.in +++ b/sample-config/config_samples/npcd.cfg.in @@ -76,7 +76,7 @@ log_level = 0 # perfdata_spool_dir = # -perfdata_spool_dir = @PERFDATA_SPOOL_DIR@ +perfdata_spool_dir = @PERFDATA_SPOOL_DIR@/npcd/ # Execute following command for each found file @@ -163,7 +163,7 @@ pid_file=@piddir@/npcd.pid # perfdata_file = # -perfdata_file = @localstatedir@/perfdata.dump +perfdata_file = @PERFDATA_SPOOL_DIR@/nagios/perfdata.dump # perfdata_spool_filename - declare the destination diff --git a/share/pnp/media/js/jquery.imgareaselect.min.js b/share/pnp/media/js/jquery.imgareaselect.min.js deleted file mode 100644 index 0a01bda..0000000 --- a/share/pnp/media/js/jquery.imgareaselect.min.js +++ /dev/null @@ -1 +0,0 @@ -(function($){var abs=Math.abs,max=Math.max,min=Math.min,round=Math.round;function div(){return $('
')}$.imgAreaSelect=function(img,options){var $img=$(img),imgLoaded,$box=div(),$area=div(),$border=div().add(div()).add(div()).add(div()),$outer=div().add(div()).add(div()).add(div()),$handles=$([]),$areaOpera,left,top,imgOfs={left:0,top:0},imgWidth,imgHeight,$parent,parOfs={left:0,top:0},zIndex=0,position='absolute',startX,startY,scaleX,scaleY,resizeMargin=10,resize,minWidth,minHeight,maxWidth,maxHeight,aspectRatio,shown,x1,y1,x2,y2,selection={x1:0,y1:0,x2:0,y2:0,width:0,height:0},docElem=document.documentElement,$p,d,i,o,w,h,adjusted;function viewX(x){return x+imgOfs.left-parOfs.left}function viewY(y){return y+imgOfs.top-parOfs.top}function selX(x){return x-imgOfs.left+parOfs.left}function selY(y){return y-imgOfs.top+parOfs.top}function evX(event){return event.pageX-parOfs.left}function evY(event){return event.pageY-parOfs.top}function getSelection(noScale){var sx=noScale||scaleX,sy=noScale||scaleY;return{x1:round(selection.x1*sx),y1:round(selection.y1*sy),x2:round(selection.x2*sx),y2:round(selection.y2*sy),width:round(selection.x2*sx)-round(selection.x1*sx),height:round(selection.y2*sy)-round(selection.y1*sy)}}function setSelection(x1,y1,x2,y2,noScale){var sx=noScale||scaleX,sy=noScale||scaleY;selection={x1:round(x1/sx||0),y1:round(y1/sy||0),x2:round(x2/sx||0),y2:round(y2/sy||0)};selection.width=selection.x2-selection.x1;selection.height=selection.y2-selection.y1}function adjust(){if(!$img.width())return;imgOfs={left:round($img.offset().left),top:round($img.offset().top)};imgWidth=$img.innerWidth();imgHeight=$img.innerHeight();imgOfs.top+=($img.outerHeight()-imgHeight)>>1;imgOfs.left+=($img.outerWidth()-imgWidth)>>1;minWidth=options.minWidth||0;minHeight=options.minHeight||0;maxWidth=min(options.maxWidth||1<<24,imgWidth);maxHeight=min(options.maxHeight||1<<24,imgHeight);if($().jquery=='1.3.2'&&position=='fixed'&&!docElem['getBoundingClientRect']){imgOfs.top+=max(document.body.scrollTop,docElem.scrollTop);imgOfs.left+=max(document.body.scrollLeft,docElem.scrollLeft)}parOfs=$.inArray($parent.css('position'),['absolute','relative'])+1?{left:round($parent.offset().left)-$parent.scrollLeft(),top:round($parent.offset().top)-$parent.scrollTop()}:position=='fixed'?{left:$(document).scrollLeft(),top:$(document).scrollTop()}:{left:0,top:0};left=viewX(0);top=viewY(0);if(selection.x2>imgWidth||selection.y2>imgHeight)doResize()}function update(resetKeyPress){if(!shown)return;$box.css({left:viewX(selection.x1),top:viewY(selection.y1)}).add($area).width(w=selection.width).height(h=selection.height);$area.add($border).add($handles).css({left:0,top:0});$border.width(max(w-$border.outerWidth()+$border.innerWidth(),0)).height(max(h-$border.outerHeight()+$border.innerHeight(),0));$($outer[0]).css({left:left,top:top,width:selection.x1,height:imgHeight});$($outer[1]).css({left:left+selection.x1,top:top,width:w,height:selection.y1});$($outer[2]).css({left:left+selection.x2,top:top,width:imgWidth-selection.x2,height:imgHeight});$($outer[3]).css({left:left+selection.x1,top:top+selection.y2,width:w,height:imgHeight-selection.y2});w-=$handles.outerWidth();h-=$handles.outerHeight();switch($handles.length){case 8:$($handles[4]).css({left:w>>1});$($handles[5]).css({left:w,top:h>>1});$($handles[6]).css({left:w>>1,top:h});$($handles[7]).css({top:h>>1});case 4:$handles.slice(1,3).css({left:w});$handles.slice(2,4).css({top:h})}if(resetKeyPress!==false){if($.imgAreaSelect.keyPress!=docKeyPress)$(document).unbind($.imgAreaSelect.keyPress,$.imgAreaSelect.onKeyPress);if(options.keys)$(document)[$.imgAreaSelect.keyPress]($.imgAreaSelect.onKeyPress=docKeyPress)}if($.browser.msie&&$border.outerWidth()-$border.innerWidth()==2){$border.css('margin',0);setTimeout(function(){$border.css('margin','auto')},0)}}function doUpdate(resetKeyPress){adjust();update(resetKeyPress);x1=viewX(selection.x1);y1=viewY(selection.y1);x2=viewX(selection.x2);y2=viewY(selection.y2)}function hide($elem,fn){options.fadeSpeed?$elem.fadeOut(options.fadeSpeed,fn):$elem.hide()}function areaMouseMove(event){var x=selX(evX(event))-selection.x1,y=selY(evY(event))-selection.y1;if(!adjusted){adjust();adjusted=true;$box.one('mouseout',function(){adjusted=false})}resize='';if(options.resizable){if(y<=options.resizeMargin)resize='n';else if(y>=selection.height-options.resizeMargin)resize='s';if(x<=options.resizeMargin)resize+='w';else if(x>=selection.width-options.resizeMargin)resize+='e'}$box.css('cursor',resize?resize+'-resize':options.movable?'move':'');if($areaOpera)$areaOpera.toggle()}function docMouseUp(event){$('body').css('cursor','');if(options.autoHide||selection.width*selection.height==0)hide($box.add($outer),function(){$(this).hide()});$(document).unbind('mousemove',selectingMouseMove);$box.mousemove(areaMouseMove);options.onSelectEnd(img,getSelection())}function areaMouseDown(event){if(event.which!=1)return false;adjust();if(resize){$('body').css('cursor',resize+'-resize');x1=viewX(selection[/w/.test(resize)?'x2':'x1']);y1=viewY(selection[/n/.test(resize)?'y2':'y1']);$(document).mousemove(selectingMouseMove).one('mouseup',docMouseUp);$box.unbind('mousemove',areaMouseMove)}else if(options.movable){startX=left+selection.x1-evX(event);startY=top+selection.y1-evY(event);$box.unbind('mousemove',areaMouseMove);$(document).mousemove(movingMouseMove).one('mouseup',function(){options.onSelectEnd(img,getSelection());$(document).unbind('mousemove',movingMouseMove);$box.mousemove(areaMouseMove)})}else $img.mousedown(event);return false}function fixAspectRatio(xFirst){if(aspectRatio)if(xFirst){x2=max(left,min(left+imgWidth,x1+abs(y2-y1)*aspectRatio*(x2>x1||-1)));y2=round(max(top,min(top+imgHeight,y1+abs(x2-x1)/aspectRatio*(y2>y1||-1))));x2=round(x2)}else{y2=max(top,min(top+imgHeight,y1+abs(x2-x1)/aspectRatio*(y2>y1||-1)));x2=round(max(left,min(left+imgWidth,x1+abs(y2-y1)*aspectRatio*(x2>x1||-1))));y2=round(y2)}}function doResize(){x1=min(x1,left+imgWidth);y1=min(y1,top+imgHeight);if(abs(x2-x1)left+imgWidth)x1=left+imgWidth-minWidth}if(abs(y2-y1)top+imgHeight)y1=top+imgHeight-minHeight}x2=max(left,min(x2,left+imgWidth));y2=max(top,min(y2,top+imgHeight));fixAspectRatio(abs(x2-x1)maxWidth){x2=x1-maxWidth*(x2maxHeight){y2=y1-maxHeight*(y2=0)$handles.width(5).height(5);if(o=options.borderWidth)$handles.css({borderWidth:o,borderStyle:'solid'});styleOptions($handles,{borderColor1:'border-color',borderColor2:'background-color',borderOpacity:'opacity'})}scaleX=options.imageWidth/imgWidth||1;scaleY=options.imageHeight/imgHeight||1;if(newOptions.x1!=null){setSelection(newOptions.x1,newOptions.y1,newOptions.x2,newOptions.y2);newOptions.show=!newOptions.hide}if(newOptions.keys)options.keys=$.extend({shift:1,ctrl:'resize'},newOptions.keys);$outer.addClass(options.classPrefix+'-outer');$area.addClass(options.classPrefix+'-selection');for(i=0;i++<4;)$($border[i-1]).addClass(options.classPrefix+'-border'+i);styleOptions($area,{selectionColor:'background-color',selectionOpacity:'opacity'});styleOptions($border,{borderOpacity:'opacity',borderWidth:'border-width'});styleOptions($outer,{outerColor:'background-color',outerOpacity:'opacity'});if(o=options.borderColor1)$($border[0]).css({borderStyle:'solid',borderColor:o});if(o=options.borderColor2)$($border[1]).css({borderStyle:'dashed',borderColor:o});$box.append($area.add($border).add($areaOpera).add($handles));if($.browser.msie){if(o=$outer.css('filter').match(/opacity=([0-9]+)/))$outer.css('opacity',o[1]/100);if(o=$border.css('filter').match(/opacity=([0-9]+)/))$border.css('opacity',o[1]/100)}if(newOptions.hide)hide($box.add($outer));else if(newOptions.show&&imgLoaded){shown=true;$box.add($outer).fadeIn(options.fadeSpeed||0);doUpdate()}aspectRatio=(d=(options.aspectRatio||'').split(/:/))[0]/d[1];$img.add($outer).unbind('mousedown',imgMouseDown);if(options.disable||options.enable===false){$box.unbind('mousemove',areaMouseMove).unbind('mousedown',areaMouseDown);$(window).unbind('resize',windowResize)}else{if(options.enable||options.disable===false){if(options.resizable||options.movable)$box.mousemove(areaMouseMove).mousedown(areaMouseDown);$(window).resize(windowResize)}if(!options.persistent)$img.add($outer).mousedown(imgMouseDown)}options.enable=options.disable=undefined}this.remove=function(){setOptions({disable:true});$box.add($outer).remove()};this.getOptions=function(){return options};this.setOptions=setOptions;this.getSelection=getSelection;this.setSelection=setSelection;this.update=doUpdate;$p=$img;while($p.length){zIndex=max(zIndex,!isNaN($p.css('z-index'))?$p.css('z-index'):zIndex);if($p.css('position')=='fixed')position='fixed';$p=$p.parent(':not(body)')}zIndex=options.zIndex||zIndex;if($.browser.msie)$img.attr('unselectable','on');$.imgAreaSelect.keyPress=$.browser.msie||$.browser.safari?'keydown':'keypress';if($.browser.opera)$areaOpera=div().css({width:'100%',height:'100%',position:'absolute',zIndex:zIndex+2||2});$box.add($outer).css({visibility:'hidden',position:position,overflow:'hidden',zIndex:zIndex||'0'});$box.css({zIndex:zIndex+2||2});$area.add($border).css({position:'absolute',fontSize:0});img.complete||img.readyState=='complete'||!$img.is('img')?imgLoad():$img.one('load',imgLoad);if($.browser.msie&&$.browser.version>=9)img.src=img.src};$.fn.imgAreaSelect=function(options){options=options||{};this.each(function(){if($(this).data('imgAreaSelect')){if(options.remove){$(this).data('imgAreaSelect').remove();$(this).removeData('imgAreaSelect')}else $(this).data('imgAreaSelect').setOptions(options)}else if(!options.remove){if(options.enable===undefined&&options.disable===undefined)options.enable=true;$(this).data('imgAreaSelect',new $.imgAreaSelect(this,options))}});if(options.instance)return $(this).data('imgAreaSelect');return this}})(jQuery); \ No newline at end of file