Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnp4nagios update for php5.6 to php8.0 #10

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7d5d297
utf8.php and data.php changes for php8
Sep 11, 2022
a296171
add systemd startup for npcd spec file edits
Sep 11, 2022
3b004b8
rrdtool.php now sets env XDG_CACHE_HOME for rrdtool, to
Sep 12, 2022
e43e00f
more php8 fixes, systemd file for npcd
Sep 12, 2022
5d91f7d
fix to 'basket' display
Sep 19, 2022
978e0c8
pdf generation fix
Sep 19, 2022
e61de0a
increment release number
Sep 19, 2022
470f033
magic-quotes was deprecated (php 5?) and removed php7.4? so take out
Sep 19, 2022
2c3d173
mod to process_perfdata.pl to reduce annoying temp errors
Nov 1, 2022
a5515c1
remove various compile warnings from modern gcc
Nov 1, 2022
f4db120
typo fix
Nov 1, 2022
ebf58b5
add file locking for process_perfdata stats file updates
Dec 10, 2022
eb7fc56
fix perl
Dec 10, 2022
d84ba10
Fix bugs with process_perfdata
Dec 10, 2022
4d88768
update spec file, added a dependency
Dec 16, 2022
4170626
change build configuration to use git-build-rpm package
Dec 17, 2022
1cc54c0
fixes
Dec 17, 2022
9fadcbc
update to README regarding rpm build instructions
Dec 17, 2022
c479790
more minor packaging stuff
Dec 17, 2022
89185bd
more packaging improvements
Dec 23, 2022
e58895b
fix internal stats race in perfdata.pl
Dec 25, 2022
04a7a77
logwatch config files
Dec 25, 2022
8dbc4be
fix prot on logwatch executable
Dec 25, 2022
0feed26
minor fix to logwatch script
Dec 26, 2022
69d6d9e
fix logwatch script permissions *again*
Dec 26, 2022
63b5582
fixes for dealing with "deprecated" features throwing errors in php 8.2
celane Aug 18, 2023
7e9de04
php 8.2 deprecates turning a "false" variable into an array,
celane Aug 18, 2023
c534eed
update Changelog
celane Aug 18, 2023
0ac766b
Merge branch 'russellvt:master' into master
celane Aug 18, 2023
69d0484
typical php8.2 fixes for docs.php
celane Aug 19, 2023
2c901fc
Merge branch 'master' of https://github.com/celane/pnp4nagios
celane Aug 19, 2023
ac017fc
increment release number
celane Aug 19, 2023
4b4086c
Terminate pid file with newline; startd complaining.
celane Aug 19, 2023
65f87b3
small updates to configure (warnings, version #)
celane Aug 20, 2023
deaefb7
Update ajax.php
celane Aug 28, 2023
d196613
Update README.md
celane Sep 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ man/npcd.8

*.swp
*.swo

pnp4nagios*.rpm
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
**pnp-0.6.26-2 09/18/2022
* various php8 fixes
* rrdtools needs env XDG_CACHE_HOME for fontconfig
* fix so that 'bucket' display works
* fix so that pdf generation works

**pnp-0.6.?? ??/??/2017**
* Bugfix: Fix for CVE-2017-16834

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,17 @@ This repository is no longer maintained!
I am a long time Nagios/Icinga/Monitoring/Devops Professional. I've been
"the toolsguy" long from "devops" was even a "new" term.



## build RPM from git

The spec file is in the "dist" subdirectory. Install git-build-rpm (it's on
github) and, as an example:

cd (main directory of this git package; where this README.md file is located)
git build-rpm --rpm-dir /home/local/lane/rpmbuild --dist .fc35

The --rpm-dir option is to keep the .srpm file from the build, the
--dist option is to avoid the longwinded "-%{version}-%{release}%{timestamp}.%{dist}..." package name.


25 changes: 25 additions & 0 deletions contrib/fedora/logwatch/conf/logfiles/pnp4nagios.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
##########################################################################
# $Id$
##########################################################################

########################################################
# This was written and is maintained by:
# Chuck Lane <[email protected]>
#
########################################################

# What actual file? Defaults to LogPath if not absolute path....
LogFile = pnp4nagios/perfdata.log
Logfile = pnp4nagios/npcd.log

# If the archives are searched, here is one or more line
# (optionally containing wildcards) that tell where they are...
#If you use a "-" in naming add that as well -mgt
Archive = pnp4nagios/perfdata.log?[0-9]+
Archive = pnp4nagios/perfdata.log?[0-9]+.gz
Archive = pnp4nagios/npcd.log.[0-9]+
Archive = pnp4nagios/npcd.log.[0-9]+.gz


*ApplyEuroDate =
# vi: shiftwidth=3 tabstop=3 et
21 changes: 21 additions & 0 deletions contrib/fedora/logwatch/conf/services/pnp4nagios.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# You can put comments anywhere you want to. They are effective for the
# rest of the line.

# this is in the format of <name> = <value>. Whitespace at the beginning
# and end of the lines is removed. Whitespace before and after the = sign
# is removed. Everything is case *insensitive*.

# Yes = True = On = 1
# No = False = Off = 0

Title = pnp4nagios-messages

# Which logfile group...
LogFile = pnp4nagios

# *OnlyService = vsftpd
#*RemoveHeaders =


# vi: shiftwidth=3 tabstop=3 et
71 changes: 71 additions & 0 deletions contrib/fedora/logwatch/scripts/services/pnp4nagios
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/perl
##########################################################################
# $Id: $
##########################################################################
# $Log: $
# Rev for pnp4nagios 0.6.26 2022/10/23 [email protected]
##########################################################################

use strict;
use Logwatch ':all';

my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0;
my $DebugCounter = 0;

my @OtherList = ();

if ( $Debug >= 5 ) {
print STDERR "\n\nDEBUG: Inside pnp4nagios Filter \n\n";
$DebugCounter = 1;
}

my $line = 0;
#my $date = '\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d \[\d+\] \[\d+\]';
while (defined(my $ThisLine = <STDIN>)) {
if ( $Debug >= 5 ) {
print STDERR "DEBUG($DebugCounter): $ThisLine";
$DebugCounter++;
}
chomp($ThisLine);
$ThisLine =~ s/^File truncated// if $line == 0;
$line++;

if (
($ThisLine =~ /Found Performance Data for/) or
($ThisLine =~ /\d+ lines processed/) or
($ThisLine =~ /\/var\/spool\/pnp4nagios\/service-perfdata\.\d+-PID-\d+ deleted/) or
($ThisLine =~ /\/var\/spool\/pnp4nagios\/host-perfdata\.\d+-PID-\d+ deleted/) or
($ThisLine =~ /PNP exiting \(runtime/) or
($ThisLine =~ /process_perfdata.pl-[\.\d]+ starting in BULK Mode called by (NPCD|Nagios)/) or
($ThisLine =~ /process_perfdata.pl-[\.\d]+ starting in SYNC Mode/) or
($ThisLine =~ /process_perfdata.pl-[\.\d]+ starting in STDIN Mode/) or
($ThisLine =~ /NPCD: Found \d+ files in/) or
($ThisLine =~ /NPCD: ThreadCounter \d+\/\d+ File is/) or
($ThisLine =~ /NPCD: Regular File: (host|service)-perfdata\.\d+/) or
($ThisLine =~ /NPCD: A thread was started on thread_counter = \d+/) or
($ThisLine =~ /NPCD: Processing file (host|service)-perfdata\.\d+ with ID \d+ - going to exec/) or
($ThisLine =~ /NPCD: Have to wait: Filecounter = \d+ - thread_counter = \d+/) or
($ThisLine =~ /NPCD: No more files to process\.\.\. waiting for \d+ seconds/) or
0 # this line prevents blame-shifting as lines are added above
)
{
if ( $Debug >= 6 ) {
print STDERR "DEBUG($DebugCounter): line ignored\n";
}
} else
{
# Report any unmatched entries...
push @OtherList, "$ThisLine\n";
}
}

###########################################################

if ($#OtherList >= 0) {
print "\n**Unmatched Entries**\n";
print @OtherList;
}

exit(0);

# vi: shiftwidth=3 tabstop=3 syntax=perl et
17 changes: 17 additions & 0 deletions contrib/fedora/npcd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=npcd rrd processor for pnp4nagios
Documentation=http://docs.pnp4nagios.org/
After=network.target local-fs.target

[Service]
Type=forking
User=nagios
Group=nagios
PIDFile=/run/nagios/npcd.pid
Environment="CONFIG_FILE=/etc/pnp4nagios/npcd.cfg"
EnvironmentFile=-/etc/sysconfig/npcd
ExecStart=/usr/sbin/npcd -d -f ${CONFIG_FILE}
ExecStop=/bin/kill -s QUIT $MAINPID

[Install]
WantedBy=nagios.service
5 changes: 5 additions & 0 deletions contrib/fedora/npcd.sysconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
#
# if the config file is in a different location, change it here
#
#CONFIG_FILE=/etc/pnp4nagios/npcd.cfg
76 changes: 76 additions & 0 deletions contrib/fedora/pnp4nagios-README.fedora
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
* Default Mode

/etc/nagios/nagios.cfg

process_performance_data=1
service_perfdata_command=process-service-perfdata

/etc/nagios/commands.cfg

define command {
command_name process-service-perfdata
command_line /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl
}

define command {
command_name process-host-perfdata
command_line /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl -d HOSTPERFDATA
}


* Bulk Mode

/etc/nagios/nagios.cfg :

process_performance_data=1
#
# service performance data
#
service_perfdata_file=/var/spool/nagios/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file

/etc/nagios/commands.cfg :

define command{
command_name process-service-perfdata-file
command_line $USER1$/process_perfdata.pl --bulk=/var/spool/nagios/service-perfdata
}

define command{
command_name process-host-perfdata-file
command_line $USER1$/process_perfdata.pl --bulk=/var/spool/nagios/host-perfdata
}


* Bulk Mode with NPCD

npcd daemon needs to be started :
service npcd start
chkconfig npcd on

The configuration is identical to the bulk mode except for the used command.

/etc/nagios/commands.cfg :

define command{
command_name process-service-perfdata-file
command_line /bin/mv /var/spool/nagios/service-perfdata /var/spool/pnp4nagios/service-perfdata.$TIMET$
}

define command{
command_name process-host-perfdata-file
command_line /bin/mv /var/spool/nagios/host-perfdata /var/spool/pnp4nagios/service-perfdata.$TIMET$
}


* Nagios integration

/etc/nagios/hostextinfo.cfg :

define hostextinfo {
host_name localhost
action_url /pnp4nagios/graph?host=$HOSTNAME$
}
103 changes: 103 additions & 0 deletions contrib/fedora/pnp4nagios-npcd.sysvinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/sh
#
# npcd Nagios Performancedata C Daemon
#
# chkconfig: - 98 02
# description: Nagios Performancedata C Daemon

### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description:
# Description:
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

exec="/usr/sbin/npcd"
prog="npcd"
config="/etc/pnp4nagios/npcd.cfg"

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon $exec -f $config -d
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}

stop() {
echo -n $"Stopping $prog: "
killproc $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {
stop
start
}

reload() {
restart
}

force_reload() {
restart
}

rh_status() {
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}


case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
7 changes: 7 additions & 0 deletions contrib/fedora/pnp4nagios.logrotate.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/var/log/pnp4nagios/*.log {
compress
missingok
notifempty
rotate 5
size 100k
}
Loading