Imported Upstream version 4.4.3

This commit is contained in:
Mario Fetka 2019-04-18 17:09:18 +02:00
parent dac8330c0a
commit 797bccfa31
190 changed files with 15702 additions and 7150 deletions

13
.gitignore vendored
View File

@ -24,9 +24,6 @@ nbproject/
*.o
*.la
*.lo
*.gcda
*.gcno
*.gcov
*.a
*.so
cgi/run*
@ -36,8 +33,14 @@ core.[1-9]*
*.pre-indent
*.swp
*.gcda
*.gcno
*.gcov
coverage-report/
nagioscore.info-file
html/angularjs/angular-1.3.9
html/angularjs/ui-utils-0.2.1
html/bootstrap-3.3.0
html/angularjs/ui-utils-0.2.3
html/bootstrap-3.3.7
html/d3
html/index.php

159
.travis.yml Normal file
View File

@ -0,0 +1,159 @@
language: c
sudo: true
matrix:
include:
- os: linux
dist: trusty
addons:
apt:
packages:
- apache2
- build-essential
- gcovr
- gperf
- lcov
- libgd-dev
- php5
- php5-gd
- unzip
- valgrind
env:
- MATRIX_EVAL="CC=gcc && CXX=g++"
- os: linux
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- apache2
- build-essential
- gcovr
- gperf
- g++-5
- lcov
- libgd-dev
- php5
- php5-gd
- unzip
- valgrind
env:
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
- os: linux
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- apache2
- build-essential
- gcovr
- gperf
- g++-6
- lcov
- libgd-dev
- php5
- php5-gd
- unzip
- valgrind
env:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
- os: linux
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- apache2
- build-essential
- gcovr
- gperf
- g++-7
- lcov
- libgd-dev
- php5
- php5-gd
- unzip
- valgrind
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
- os: linux
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- apache2
- build-essential
- gcovr
- gperf
- g++-8
- lcov
- libgd-dev
- php5
- php5-gd
- unzip
- valgrind
env:
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
- os: linux
dist: trusty
addons:
apt:
sources:
- llvm-toolchain-trusty-5.0
packages:
- apache2
- build-essential
- clang-5.0
- gcovr
- gperf
- lcov
- libgd-dev
- php5
- php5-gd
- unzip
- valgrind
env:
- MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"
- os: linux
dist: trusty
addons:
apt:
sources:
- llvm-toolchain-trusty-6.0
- ubuntu-toolchain-r-test
packages:
- apache2
- build-essential
- clang-6.0
- gcovr
- gperf
- g++-4.9
- lcov
- libgd-dev
- php5
- php5-gd
- unzip
- valgrind
env:
- MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"
before_install:
- eval "${MATRIX_EVAL}"
script:
- ./configure --enable-testing
- make test
- gcovr -r .

View File

@ -155,7 +155,7 @@ When you submit a Pull Request, make sure you follow the guidelines:
* Keep commit messages as concise as possible.
* Update the appropriate files in regards to your changes:
* `CHANGES`
* `Changelog`
* `THANKS`

View File

@ -3,6 +3,92 @@ Nagios Core 4 Change Log
########################
4.4.3 - 2019-01-15
------------------
FIXES
* Fixed services sending recovery emails when they recover if host in down state (#572) (Scott Wilkerson)
* Fixed a make error when building on the aarch64 architecture (#598) (Gareth Randall)
* Fixed --with-cgibindir and --with-webdir to actually set values given (#585) (lawsontyler)
* Fixed soft recovery states for services (#575) (Jake Omann)
* Fixed XSS vulnerability in Alert Summary report (CVE-2018-18245) (Jake Omann)
* Fixed services in soft states sometimes not switching into hard states (#576) (Jake Omann)
* Fixed last_state_change to update when a state goes from soft -> hard state (#592) (Jake Omann)
* Fixed Map link always being set to undefined host and don't show link for Nagios Process root note (#539) (Jake Omann)
* Fixed notifications sending when services went into hard state on a down or unreachable host (#584) (Jake Omann)
* Fixed log_host_retries not logging the host soft state checks (#599) (Jake Omann)
* Fixed stalking_options N option to properly log only when a notification is actually sent (#604) (Jake Omann)
* Fixed issue with service status totals being zero when servicegroup=all on servicegroup status page (#579) (Jake Omann)
* Fixed escalation notifications logic and recovery notifications not going out (#582) (Jake Omann)
* Fixed not finding child index causing duplicate hosts showing in the Map (#471) (Jake Omann)
* Fixed Map configuration popup checkboxes not working and Root Node not populating (#543) (Jake Omann)
* Fixed cleanup and deinit of neb modules on reload (#573) (Jake Omann)
4.4.2 - 2018-08-16
------------------
FIXES
* Fix comment data being duplicated after a `service nagios reload` or similar (#549) (Bryan Heden)
* Fix check_interval and retry_interval not changing at the appropriate times (#551) (Scott Wilkerson)
* Fixed passive checks sending recovery email when host was previously UP (#552) (Scott Wilkerson)
* Fixed flapping comments duplication on nagios reload (#554) (Christian Jung)
* Fix for CVE-2018-13441, CVE-2018-13458, CVE-2018-13457 null pointer dereference (Trevor McDonald)
* Fixed syntax error in file: default-init.in (#558) (Christian Zettel)
* Reset current notification number and state flags when the host recovers, reset all service variables when they recover fixes (#557) (Scott Wilkerson)
* Fixed wrong counting of service status totals when showing servicegroup details (#548) (Christian Zettel, Bryan Heden)
* Fixed avail.cgi not printing CSV output when checkbox is checked (for any type: host/service/hostgroup/servicegroup) (#570) (Bryan Heden)
* Fixed nagios not logging SOFT state changes after 1 (Scott Wilkerson)
4.4.1 - 2018-06-25
------------------
FIXES
* Revert some macro->kvvec changes causing problems when `enable_environment_macros` was enabled (Bryan Heden)
* Adjust `process_macro_r` function logic so that it handles macros properly (Bryan Heden)
* Fix spec file for systemd (Karsten Weiss, Fr3dY, Bryan Heden)
* Fix bug where `ssize_t` typedef to int on some systems (Bryan Heden)
4.4.0 - 2018-06-19
------------------
ENHANCEMENTS
* new status for check dependencies (John Frickson)
* Allow more flexible requirements for comments (John Frickson)
* Add a `statusCRITICALACK` class for the status column (John Frickson)
* CSV output based on groups (all options) (John Frickson)
* New Macro(s) to generate URL for host / service object to be used in notifications (John Frickson)
* New Macro(s) to determine if host/service notifications are enabled (#419) (Bryan Heden)
* New Macro(s) for obtaining the host/service notification periods (#350) (Bryan Heden)
* enable_page_tour interface option (Bryan Heden)
* Code cleanups in important sections (Workers, Handling Results) (Bryan Heden)
* Automatic mail program detection (with same /bin/mail failback) (Bryan Heden)
* Incorporated [autoconf-macros](https://github.com/NagiosEnterprises/autoconf-macros) into Core (Bryan Heden)
* Lots of enhancements/additions to configure/make process. (Bryan Heden)
* Moved all files to startup/
* Added upstart job
* Added system limit detection (RLIMIT_NPROC) to check for anticipated fork() failures (#434) (Bryan Heden)
* Added stalking on notifications (`N` or `notifications` option when specifying `stalking_options`) (#342) (Bryan Heden)
* Added automatic `systemctl daemon-reload` and `initctl reload-configuration` where applicable on `make install-init` (Bryan Heden)
* Added case-insentive command submission. (#373) (Bryan Heden)
* Enabled `check_external_commands` by default (Bryan Heden)
FIXES
* Command line macro detection skips potential macros with no ending dollar sign (Bryan Heden, Jake Omann)
* Fixed a lockup condition sometimes encountered on shutdown or restart (Aaron Beck)
* Fixed negative time offset calculations computing incorrectly sometimes (bbeutel)
* Fixed reloads causing defunct (zombie) processes (#441) (Bryan Heden)
* Fixed wait3(), wait4() implementations (replaced with waitpid()) (#326) (Bryan Heden)
* Fixed additive inheritance not testing for duplicates in hosts/services/(+escalations) (#392) (Bryan Heden)
* Fixed very very (around 600k chars or greater) large plugin output crashing Nagios (#432) (Bryan Heden)
* Fixed first_notification_delay not beeing calculated from last_hard_state_change (#425) (Christian Zettel)
* Fixed duplicate downtime ID occuring from downtimes in retention file (#506) (Franz [feisenko])
* Fixed segfault when navbarsearch was used in status.cgi for something other than a host (#489) (Bryan Heden)
* Fixed some miscellaneous ./configure issues on Solaris (Bryan Heden, Troy Lea)
* Fixed "Locate host on map" link (#496) (Troy Lea)
* Fixed service groups defined with unknown service members (that aren't first in the list) not erroring out (#500) (Bryan Heden)
* Fixed tac.cgi to have consistent behavior with the other cgis (#481) (Bryan Heden, Matt Capra)
* Fixed clear_host/service_flapping command logic to broker/notify properly (#525) (Bryan Heden, Karsten Weiss)
4.3.4 - 2017-08-24
------------------
* Improved config file parsing (Mark Felder)
@ -15,7 +101,7 @@ Nagios Core 4 Change Log
------------------
* xodtemplate.c wrong option-deprecation code warning (alex2grad / John Frickson)
* On-demand host check always use cached host state (John Frickson)
* 'á' causes Serivce Status Information to not be displayed (John Frickson)
* 'á' causes Service Status Information to not be displayed (John Frickson)
* New Macro(s) to generate URL for host / service object (John Frickson)
* Fix minor map issues (Troy Lea)
* Fix lockfile issues (Bryan Heden)
@ -25,7 +111,7 @@ Nagios Core 4 Change Log
4.3.2 - 2017-05-09
------------------
FIXED
FIXES
* Every 15sec /var/log/messages is flooded with "nagios: set_environment_var" (John Frickson)
* Changed release date to ISO format (yyyy-mm-dd) (John Frickson)
* `make all` fails if unzip is not installed (John Frickson)
@ -410,5 +496,5 @@ FIXES
4.0.0 - 09/20/2013
------------------
See http://nagios.sourceforge.net/docs/nagioscore/4/en/whatsnew.html for a
See https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/whatsnew.html for a
list of the changes in Nagios Core 4

View File

@ -27,11 +27,11 @@ LOGDIR=@localstatedir@
CHECKRESULTDIR=@CHECKRESULTDIR@
CFGDIR=@sysconfdir@
BINDIR=@bindir@
CGIDIR=@sbindir@
CGIDIR=@cgibindir@
LIBEXECDIR=@libexecdir@
LIBDIR=@libdir@
INCLUDEDIR=@includedir@/nagios
HTMLDIR=@datadir@
HTMLDIR=@webdir@
datarootdir=@datarootdir@
LN_S=@LN_S@
INSTALL=@INSTALL@
@ -39,9 +39,16 @@ INSTALL_OPTS=@INSTALL_OPTS@
COMMAND_OPTS=@COMMAND_OPTS@
HTTPD_CONF=@HTTPD_CONF@
LN_HTTPD_SITES_ENABLED=@LN_HTTPD_SITES_ENABLED@
INIT_DIR=@init_dir@
INIT_DIR=@initdir@
INIT_OPTS=@INIT_OPTS@
CGICFGDIR=$(CGIDIR)
NAGIOS_USER=@nagios_user@
NAGIOS_GRP=@nagios_grp@
DIST=@dist_type@
SRC_INIT=@src_init@
INIT_FILE=@initname@
INIT_TYPE=@init_type@
USE_EVENTBROKER=@USE_EVENTBROKER@
USE_LIBTAP=@USE_LIBTAP@
@ -55,9 +62,17 @@ CP=@CP@
none:
@echo "Please supply a command line argument (i.e. 'make all'). Other targets are:"
@echo " nagios cgis contrib modules workers"
@echo " clean"
@echo " install install-base install-cgis install-html install-exfoliation install-config install-init install-commandmode fullinstall"
@echo " test"
@echo " install install-base"
@echo " install-cgis install-html"
@echo " install-webconf install-config"
@echo " install-init install-daemoninit"
@echo " install-commandmode install-groups-users"
@echo " install-exfoliation install-classicui"
@echo " install-basic install-unstripped"
@echo " fullinstall"
# @echo " uninstall"
@echo " clean"
# FreeBSD make does not support -C option, so we'll use the Apache style... (patch by Stanley Hopcroft 12/27/1999)
@ -82,8 +97,11 @@ all:
@echo "*** Compile finished ***"
@echo ""
@echo "If the main program and CGIs compiled without any errors, you"
@echo "can continue with installing Nagios as follows (type 'make'"
@echo "without any arguments for a list of all possible options):"
@echo "can continue with testing or installing Nagios as follows (type"
@echo "'make' without any arguments for a list of all possible options):"
@echo ""
@echo " make test"
@echo " - This runs the test suite"
@echo ""
@echo " make install"
@echo " - This installs the main program, CGIs, and HTML files"
@ -91,6 +109,13 @@ all:
@echo " make install-init"
@echo " - This installs the init script in $(DESTDIR)$(INIT_DIR)"
@echo ""
@echo " make install-daemoninit"
@echo " - This will initialize the init script"
@echo " in $(DESTDIR)$(INIT_DIR)"
@echo ""
@echo " make install-groups-users"
@echo " - This adds the users and groups if they do not exist"
@echo ""
@echo " make install-commandmode"
@echo " - This installs and configures permissions on the"
@echo " directory for holding the external command file"
@ -183,6 +208,11 @@ clean:
cd $(SRC_WORKERS) && $(MAKE) $@
rm -f *.cfg core
rm -f *~ *.*~ */*~ */*.*~ */*/*.*~
rm -f nagioscore.info-file
rm -f *.gcno */*.gcno */*/*.gcno
rm -f *.gcda */*.gcda */*/*.gcda
rm -f *.gcov */*.gcov */*/*.gcov
rm -rf coverage-report
distclean: clean
cd $(SRC_LIB) && $(MAKE) $@
@ -197,7 +227,7 @@ distclean: clean
cd $(SRC_TTAP) && $(MAKE) $@
cd $(SRC_WORKERS) && $(MAKE) $@
rm -f sample-config/*.cfg sample-config/*.conf sample-config/template-object/*.cfg
rm -f daemon-init openrc-init pkginfo
rm -f daemon-init daemon-service daemon-openrc pkginfo
rm -f Makefile subst
rm -f config.log config.status config.cache
rm -f tags
@ -222,6 +252,16 @@ tap/src/tap.o:
test-perl: cgis
cd t && $(MAKE) test
coverage: test
@if ! which lcov >/dev/null 2>&1; then \
echo "ERROR: You must install lcov and genhtml first"; \
else \
lcov -c -d . -o nagioscore.info-file; \
genhtml nagioscore.info-file -o coverage-report; \
echo "Your coverage report is in coverage-report/index.html"; \
fi
install-html:
cd $(SRC_HTM) && $(MAKE) install
$(MAKE) install-exfoliation
@ -270,7 +310,6 @@ install-basic:
@echo " - This installs sample config files in $(DESTDIR)$(CFGDIR)"
@echo ""
install-config:
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(CFGDIR)
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(CFGDIR)/objects
@ -294,6 +333,9 @@ install-config:
@echo "services, hosts, etc. to fit your particular needs."
@echo ""
install-groups-users:
@autoconf-macros/add_group_user $(DIST) $(NAGIOS_USER) $(NAGIOS_GRP) 1
install-webconf:
$(INSTALL) -m 644 sample-config/httpd.conf $(DESTDIR)$(HTTPD_CONF)/nagios.conf
if [ $(LN_HTTPD_SITES_ENABLED) -eq 1 ]; then \
@ -338,11 +380,32 @@ install-classicui:
@echo "NOTE: Use 'make install-exfoliation' to use new Nagios theme";
@echo ""
install-init: install-daemoninit
install-daemoninit:
install-init:
$(INSTALL) -m 755 -d $(INIT_OPTS) $(DESTDIR)$(INIT_DIR)
$(INSTALL) -m 755 $(INIT_OPTS) daemon-init $(DESTDIR)$(INIT_DIR)/nagios
$(INSTALL) -m 755 $(INIT_OPTS) startup/$(SRC_INIT) $(DESTDIR)$(INIT_DIR)/$(INIT_FILE)
install-daemoninit: install-init
@if [ x$(INIT_TYPE) = xsysv ]; then \
if which chkconfig >/dev/null 2>&1; then \
chkconfig --add nagios; \
elif which update-rc.d >/dev/null 2>&1; then \
update-rc.d nagios defaults; \
fi \
elif [ x$(INIT_TYPE) = xsystemd ]; then \
if which systemctl >/dev/null 2>&1; then \
systemctl daemon-reload; \
systemctl enable nagios.service; \
fi; \
chmod 0644 $(INIT_DIR)/$(INIT_FILE); \
elif [ x$(INIT_TYPE) = xupstart ]; then \
if which initctl >/dev/null 2>&1; then \
initctl reload-configuration; \
fi \
elif [ x$(INIT_TYPE) = xopenrc ]; then \
if which rc-update >/dev/null 2>&1; then \
rc-update add nagios default; \
fi \
fi
@echo ""
@echo "*** Init script installed ***"

1
README
View File

@ -1 +0,0 @@
README.asciidoc

View File

@ -1,5 +1,10 @@
Nagios 4.x README
=================
Nagios 4.x
==========
![Nagios!](https://www.nagios.com/wp-content/uploads/2015/05/Nagios-Black-500x124.png)
[![Build Status](https://travis-ci.org/NagiosEnterprises/nagioscore.svg?branch=master)](https://travis-ci.org/NagiosEnterprises/nagioscore)
Nagios is a host/service/network monitoring program written in C and
released under the GNU General Public License, version 2. CGI programs
@ -10,7 +15,7 @@ Visit the Nagios homepage at https://www.nagios.org for documentation,
new releases, bug reports, information on discussion forums, and more.
https://www.nagios.org/about/features/[Features]
[Features](https://www.nagios.org/about/features/)
-----------------------------------------------
* Monitoring of network services (via SMTP, POP3, HTTP, PING, etc).
* Monitoring of host resources (processor load, disk usage, etc.).
@ -30,9 +35,9 @@ https://www.nagios.org/about/features/[Features]
Changes
-------
See the
https://raw.githubusercontent.com/NagiosEnterprises/nagioscore/master/Changelog[Changelog]
[Changelog](https://raw.githubusercontent.com/NagiosEnterprises/nagioscore/master/Changelog)
for a summary of important changes and fixes, or the
https://github.com/NagiosEnterprises/nagioscore/commits/master[commit history]
[commit history](https://github.com/NagiosEnterprises/nagioscore/commits/master)
for more detail.
@ -43,16 +48,16 @@ Latest releases can be downloaded from https://www.nagios.org/download/
Installation
------------
http://nagios.sourceforge.net/docs/nagioscore/4/en/quickstart.html[Quickstart installation guides]
[Quickstart installation guides](http://nagios.sourceforge.net/docs/nagioscore/4/en/quickstart.html)
are available to help you get Nagios up and monitoring.
Documentation & Support
-----------------------
* http://nagios.sourceforge.net/docs/nagioscore/4/en/[User Guide]
* https://library.nagios.com/library/products/nagioscore/[Nagios Core Documentation Library]
* https://support.nagios.com/forum/viewforum.php?f=7[Support Forums]
* https://www.nagios.org/support/[Additional Support Resources]
* [User Guide](http://nagios.sourceforge.net/docs/nagioscore/4/en/)
* [Nagios Core Documentation Library](https://library.nagios.com/library/products/nagioscore/)
* [Support Forums](https://support.nagios.com/forum/viewforum.php?f=7)
* [Additional Support Resources](https://www.nagios.org/support/)
Contributing
@ -60,13 +65,11 @@ Contributing
The Nagios source code is hosted on GitHub:
https://github.com/NagiosEnterprises/nagioscore
Do you have an idea or feature request to make Nagios better? Join or
start a discussion on the
https://support.nagios.com/forum/viewforum.php?f=34[Nagios Core Development forum].
Bugs can be reported by
https://github.com/NagiosEnterprises/nagioscore/issues/new[opening an
issue on GitHub]. If you have identified a security related issue in
Nagios, please contact security@nagios.com.
Do you have an idea or feature request to make Nagios better? Join or start a
discussion on the [Nagios Core Development forum](https://support.nagios.com/forum/viewforum.php?f=34).
Bugs can be reported by [opening an issue on GitHub](https://github.com/NagiosEnterprises/nagioscore/issues/new).
If you have identified a security related issue in Nagios, please contact
security@nagios.com.
Patches and GitHub pull requests are welcome. Pull requests on GitHub
link commits in version control to review and discussion of the
@ -76,5 +79,5 @@ who was involved.
Created by Ethan Galstad, the success of Nagios has been due to the
fantastic community members that support it and provide bug reports,
patches, and great ideas. See the
https://raw.githubusercontent.com/NagiosEnterprises/nagioscore/master/THANKS[THANKS file]
[THANKS file](https://raw.githubusercontent.com/NagiosEnterprises/nagioscore/master/THANKS)
for some of the many who have contributed since 1999.

8
THANKS
View File

@ -8,6 +8,7 @@ few of the many members that have contributed to Nagios in various ways
since 1999. If I missed your name, misspelled it or otherwise got it
wrong, please let me know.
* Aaron Beck
* Adam Bowen
* Ahmon Dancy
* Alain Radix
@ -53,8 +54,10 @@ wrong, please let me know.
* Chris Kolquist
* Chris Rothecker
* Chris Witterholt
* Christian Jung
* Christian Masopust
* Christian Mies
* Christian Zettel
* Christoph Biedl
* Christoph Kron
* Christoph Maser
@ -89,10 +92,12 @@ wrong, please let me know.
* Evan Winter
* Felipe Almeida
* Florian Weimer
* Fr3dY
* Fran Boon
* Franky Van Liedekerke
* Frederic Schaer
* Frederic Van Espen
* Gareth Randall
* Garry Cook
* Gary Berger
* Gary Miller
@ -185,9 +190,11 @@ wrong, please let me know.
* Luiz Felipe R E
* Luke Ross
* Emmanuel Dreyfus
* Manuel Lanctot
* Marc Powell
* Marcus Fleige
* Marcus Hildenbrand
* Mario Trangoni
* Mark DeTrano
* Mark Felder
* Mark Frost
@ -320,6 +327,7 @@ wrong, please let me know.
* Todd Wheeler
* Tom Bertelson
* Tom De Blende
* Tom Ryder
* Tom Welsh
* Tomer Okavi
* Ton Voon

7
aclocal.m4 vendored Executable file
View File

@ -0,0 +1,7 @@
m4_include([autoconf-macros/ax_nagios_get_os])
m4_include([autoconf-macros/ax_nagios_get_distrib])
m4_include([autoconf-macros/ax_nagios_get_init])
m4_include([autoconf-macros/ax_nagios_get_inetd])
m4_include([autoconf-macros/ax_nagios_get_paths])
m4_include([autoconf-macros/ax_nagios_get_files])
m4_include([autoconf-macros/ax_nagios_get_ssl])

1
autoconf-macros/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
nbproject/

View File

@ -0,0 +1,7 @@
1.0.1
-----
* Fix bug determining inetd,xinetd if neither are running (Bryan Heden)
1.0.0
-----
* Initial Release (John Frickson)

264
autoconf-macros/LICENSE Normal file
View File

@ -0,0 +1,264 @@
The GNU General Public License, Version 2, June 1991 (GPLv2)
============================================================
> Copyright (C) 1989, 1991 Free Software Foundation, Inc.
> 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
--------
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public License is intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users. This General Public License applies to most
of the Free Software Foundation's software and to any other program whose
authors commit to using it. (Some other Free Software Foundation software is
covered by the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom to
distribute copies of free software (and charge for this service if you wish),
that you receive source code or can get it if you want it, that you can change
the software or use pieces of it in new free programs; and that you know you can
do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny
you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of the
software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a
fee, you must give the recipients all the rights that you have. You must make
sure that they, too, receive or can get the source code. And you must show them
these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer
you this license which gives you legal permission to copy, distribute and/or
modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If the
software is modified by someone else and passed on, we want its recipients to
know that what they have is not the original, so that any problems introduced by
others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish
to avoid the danger that redistributors of a free program will individually
obtain patent licenses, in effect making the program proprietary. To prevent
this, we have made it clear that any patent must be licensed for everyone's free
use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
Terms And Conditions For Copying, Distribution And Modification
---------------------------------------------------------------
**0.** This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms of
this General Public License. The "Program", below, refers to any such program or
work, and a "work based on the Program" means either the Program or any
derivative work under copyright law: that is to say, a work containing the
Program or a portion of it, either verbatim or with modifications and/or
translated into another language. (Hereinafter, translation is included without
limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by
this License; they are outside its scope. The act of running the Program is not
restricted, and the output from the Program is covered only if its contents
constitute a work based on the Program (independent of having been made by
running the Program). Whether that is true depends on what the Program does.
**1.** You may copy and distribute verbatim copies of the Program's source code
as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this License
and to the absence of any warranty; and give any other recipients of the Program
a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at
your option offer warranty protection in exchange for a fee.
**2.** You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute such
modifications or work under the terms of Section 1 above, provided that you also
meet all of these conditions:
* **a)** You must cause the modified files to carry prominent notices stating
that you changed the files and the date of any change.
* **b)** You must cause any work that you distribute or publish, that in whole
or in part contains or is derived from the Program or any part thereof, to
be licensed as a whole at no charge to all third parties under the terms of
this License.
* **c)** If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use in the
most ordinary way, to print or display an announcement including an
appropriate copyright notice and a notice that there is no warranty (or
else, saying that you provide a warranty) and that users may redistribute
the program under these conditions, and telling the user how to view a copy
of this License. (Exception: if the Program itself is interactive but does
not normally print such an announcement, your work based on the Program is
not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be reasonably
considered independent and separate works in themselves, then this License, and
its terms, do not apply to those sections when you distribute them as separate
works. But when you distribute the same sections as part of a whole which is a
work based on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the entire whole,
and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise the
right to control the distribution of derivative or collective works based on the
Program.
In addition, mere aggregation of another work not based on the Program with the
Program (or with a work based on the Program) on a volume of a storage or
distribution medium does not bring the other work under the scope of this
License.
**3.** You may copy and distribute the Program (or a work based on it, under
Section 2) in object code or executable form under the terms of Sections 1 and 2
above provided that you also do one of the following:
* **a)** Accompany it with the complete corresponding machine-readable source
code, which must be distributed under the terms of Sections 1 and 2 above on
a medium customarily used for software interchange; or,
* **b)** Accompany it with a written offer, valid for at least three years, to
give any third party, for a charge no more than your cost of physically
performing source distribution, a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of Sections 1
and 2 above on a medium customarily used for software interchange; or,
* **c)** Accompany it with the information you received as to the offer to
distribute corresponding source code. (This alternative is allowed only for
noncommercial distribution and only if you received the program in object
code or executable form with such an offer, in accord with Subsection b
above.)
The source code for a work means the preferred form of the work for making
modifications to it. For an executable work, complete source code means all the
source code for all modules it contains, plus any associated interface
definition files, plus the scripts used to control compilation and installation
of the executable. However, as a special exception, the source code distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
If distribution of executable or object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the source code
from the same place counts as distribution of the source code, even though third
parties are not compelled to copy the source along with the object code.
**4.** You may not copy, modify, sublicense, or distribute the Program except as
expressly provided under this License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will automatically terminate
your rights under this License. However, parties who have received copies, or
rights, from you under this License will not have their licenses terminated so
long as such parties remain in full compliance.
**5.** You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Program or its derivative works. These actions are prohibited by law if you do
not accept this License. Therefore, by modifying or distributing the Program (or
any work based on the Program), you indicate your acceptance of this License to
do so, and all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
**6.** Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these terms and
conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.
**7.** If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), conditions
are imposed on you (whether by court order, agreement or otherwise) that
contradict the conditions of this License, they do not excuse you from the
conditions of this License. If you cannot distribute so as to satisfy
simultaneously your obligations under this License and any other pertinent
obligations, then as a consequence you may not distribute the Program at all.
For example, if a patent license would not permit royalty-free redistribution of
the Program by all those who receive copies directly or indirectly through you,
then the only way you could satisfy both it and this License would be to refrain
entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and the
section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or
other property right claims or to contest validity of any such claims; this
section has the sole purpose of protecting the integrity of the free software
distribution system, which is implemented by public license practices. Many
people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose that
choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
**8.** If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Program under this License may add an explicit
geographical distribution limitation excluding those countries, so that
distribution is permitted only in or among countries not thus excluded. In such
case, this License incorporates the limitation as if written in the body of this
License.
**9.** The Free Software Foundation may publish revised and/or new versions of
the General Public License from time to time. Such new versions will be similar
in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Program does not specify a version number of this License, you may choose any
version ever published by the Free Software Foundation.
**10.** If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software Foundation,
write to the Free Software Foundation; we sometimes make exceptions for this.
Our decision will be guided by the two goals of preserving the free status of
all derivatives of our free software and of promoting the sharing and reuse of
software generally.
No Warranty
-----------
**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

1
autoconf-macros/LICENSE.md Symbolic link
View File

@ -0,0 +1 @@
LICENSE

199
autoconf-macros/README.md Normal file
View File

@ -0,0 +1,199 @@
autoconf-macros
===============
The purpose of Nagios autoconf-macros is to have a central place for
autoconf macros that can be maintained in one place, but be used by any
of the Nagios software. It is intended to be used as a git subtree.
See the [Usage](#usage) and [References](#references) sections below.
Since this project will be included in several parent projects, any
changes must be as project-neutral as possible.
Make sure to check out the [CHANGELOG](CHANGELOG.md) for relevant
information, as well.
Contents
--------
The collection consists of the following macros:
### AX_NAGIOS_GET_OS alias AC_NAGIOS_GET_OS
> Output Variable : `opsys`
This macro detects the operating system, and transforms it into a generic
label. The most common OS's that use Nagios software are recognized and
used in subsequent macros.
### AX_NAGIOS_GET_DISTRIB_TYPE alias AC_NAGIOS_GET_DISTRIB_TYPE
> Output Variables : `dist_type`, `dist_ver`
This macro detects the distribution type. For Linux, this would be rh
(for Red Hat and derivatives), suse (OpenSUSE, SLES, derivatives), gentoo
(Gentoo and derivatives), debian (Debian and derivatives), and so on.
For BSD, this would be openbsd, netbsd, freebsd, dragonfly, etc. It can
also be aix, solaris, osx, and so on for Unix operating systems.
### AX_NAGIOS_GET_INIT alias AC_NAGIOS_GET_INIT
> Output Variable : `init_type`
This macro detects what software is used to start daemons on bootup
or on request, generally knows as the "init system". The init_type
will generally be one of sysv (many), bsd (Slackware), newbsd (*BSD),
launchd (OS X), smf10 or smf11 (Solaris), systemd (newer Linux),
gentoo (older Gentoo), upstart (several), or unknown.
### AX_NAGIOS_GET_INETD alias AC_NAGIOS_GET_INETD
> Output Variable : `inetd_type`
This macro detects what software is used to start daemons or services
on demand, which historically has been "inetd". The inetd_type
will generally be one of inetd, xinetd, launchd (OS X), smf10 or smf11
(Solaris), systemd (newer Linux), upstart (several), or unknown.
### AX_NAGIOS_GET_PATHS alias AC_NAGIOS_GET_PATHS
> Output Variables : **many!**
This macro determines the installation paths for binaries, config files,
PID files, and so on. For a "standard" install of Nagios, NRPE, NDO Utils,
etc., most will be in the /usr/local/nagios hierarchy with startup files
located in /etc. For distributions or software repositories, the
"--enable-install-method=os" option can be used. This will determine the
O/S dependent directories, such as /usr/bin, /usr/sbin, /var/lib/nagios,
/usr/lib/nagios, etc. or for OS X, /Library/LaunchDaemons.
### AX_NAGIOS_GET_FILES alias AC_NAGIOS_GET_FILES
> Output Variables : `src_init`, `src_inetd`, `src_tmpfile`
Each Nagios project will have a top-level directory named "/startup/".
In that directory will be "*.in" files for the various "init_type" and
"inetd_type" systems. This macro will determine which file(s) from
that directory will be needed.
### AX_NAGIOS_GET_SSL alias AC_NAGIOS_GET_SSL
> Output Variables : `HAVE_KRB5_H`, `HAVE_SSL`, `SSL_INC_DIR`, `SSL_LIB_DIR`, `CFLAGS`, `LDFLAGS`, `LIBS`
This macro checks various directories for SSL libraries and header files.
The searches are based on known install locations on various operating
systems and distributions, for openssl, gnutls-openssl, and nss_compat_ossl.
If it finds the headers and libraries, it will then do an `AC_LINK_IFELSE`
on a simple program to make sure a compile and link will work correctly.
Usage
-----
This repo is intended to be used as a git subtree, so changes will
automatically propagate, and still be reasonably easy to use.
* First, Create, checkout, clone, or branch your project. If you do an
`ls -AF` it might look something like this:
.git/ .gitignore ChangeLog LICENSE Makefile.in
README configure.ac include/ src/
* Then make a reference to _this_ project inside your project.
git remote add autoconf-macros git@github.com:NagiosEnterprises/autoconf-macros
git subtree add --prefix=macros/ autoconf-macros master
* After executing the above two commands, if you do an `ls -AF` now,
it should look like this:
.git/ .gitignore ChangeLog LICENSE Makefile.in
README configure.ac include/ macros/ src/
* The `macros/` directory has been added.
* Now do a `git push` to save everything.
* If you make any changes to autoconf-macros, commit them separately
from any parent-project changes to keep from polluting the commit
history with unrelated comments.
* To submit your changes to autoconf-macros:
git subtree push --prefix=macros autoconf-macros peters-updates
This will create a new branch called `peters-updates`. You then need to
create a _pull request_ to get your changes merged into autoconf-macros
master.
* To get the latest version of `autoconf-macros` into your parent project:
git subtgree pull --squash --prefix=macros autoconf-macros master
References
----------
Now that autoconf-macros is available to your project, you will need to
reference it.
* Create (or add these lines to) file `YourProject/aclocal.m4`
m4_include([macros/ax_nagios_get_os])
m4_include([macros/ax_nagios_get_distrib])
m4_include([macros/ax_nagios_get_init])
m4_include([macros/ax_nagios_get_inetd])
m4_include([macros/ax_nagios_get_paths])
m4_include([macros/ax_nagios_get_files])
m4_include([macros/ax_nagios_get_ssl])
* In your `YourProject/configure.ac` add the following lines. A good place
to put them would be right after any `AC_PROG_*` entries:
AC_NAGIOS_GET_OS
AC_NAGIOS_GET_DISTRIB_TYPE
AC_NAGIOS_GET_INIT
AC_NAGIOS_GET_INETD
AC_NAGIOS_GET_PATHS
AC_NAGIOS_GET_FILES
* If you need SSL functionality, add the following to `YourProject/configure.ac`
where you want to check for SSL:
AC_NAGIOS_GET_SSL
* You will now be able to reference any of the variables in `config.h.in`
and any files listed in the `AC_CONFIG_FILES` macro in `configure.ac`.
License Notice
--------------
Copyright (c) 2016-2017 Nagios Enterprises, LLC
This work is made available to you under the terms of Version 2 of
the GNU General Public License. A copy of that license should have
been provided with this software, but in any event can be obtained
from http://www.fsf.org.
This work is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 or visit their web page on the internet at
http://www.fsf.org.
Questions?
----------
If you have questions about this addon, or problems getting things
working, first try searching the nagios-users mailing list archives.
Details on searching the list archives can be found at
http://www.nagios.org
If you don't find an answer there, post a message in the Nagios
Plugin Development forum at https://support.nagios.com/forum/viewforum.php?f=35

164
autoconf-macros/add_group_user Executable file
View File

@ -0,0 +1,164 @@
#!/bin/sh
#----------------------
# Initialize variables
#----------------------
dist="$1"
uid="$2"
gid="$3"
rc=0
#------------------------------------------------------------------
# Determine if the user should be created with a shell environment
# 0 = no shell (more secure)
# 1 = shell (less secure but sometimes required)
#------------------------------------------------------------------
shell=0
if [ $# -eq 4 ]; then
if [ x$4 = x1 ]; then
shell=1
fi
fi
#-------------------------------------
# Check if the specified group exists
#-------------------------------------
group_exists(){
case $dist in
osx) rc=`dscl . -read /Groups/$gid >/dev/null 2>&1; echo $?` ;;
hpux) rc=`grget -n $gid >/dev/null 2>&1; echo $?` ;;
aix) rc=`lsgroup -a $gid >/dev/null 2>&1; echo $?` ;;
*) rc=`getent group $gid > /dev/null 2>&1; echo $?` ;;
esac
echo $rc
}
#------------------------
# Add the specified user
#------------------------
add_user(){
rc=`id "$uid" > /dev/null 2>&1; echo $?`
if test $rc -eq 0; then
echo "User $uid already exists" > /dev/stderr
echo 0
return
fi
case $dist in
aix)
echo useradd -g $gid $uid > /dev/stderr
rc=`useradd -g $gid $uid; echo $?`
;;
hpux)
echo useradd -m -g $gid $uid > /dev/stderr
rc=`useradd -m -g $gid $uid; echo $?`
;;
solaris)
echo useradd -m -d /export/home/$uid -g $gid $uid > /dev/stderr
rc=`useradd -m -d /export/home/$uid -g $gid $uid; echo $?`
;;
osx)
newid=`dscl . -list /Users UniqueID | tr -s ' ' | cut -d' ' -f2 | sort -n | tail -1`
newid=`expr 1 + $newid`
echo dscl . -create /Users/$uid > /dev/stderr
dscl . -create /Users/$uid
echo dscl . -create /Users/$uid UniqueID $newid > /dev/stderr
dscl . -create /Users/$uid UniqueID $newid
if [ $shell = 0 ]; then
echo dscl . -create /Users/$uid UserShell /usr/bin/false > /dev/stderr
dscl . -create /Users/$uid UserShell /usr/bin/false
fi
echo dscl . -create /Users/$uid PrimaryGroupID 20 > /dev/stderr
dscl . -create /Users/$uid PrimaryGroupID 20
echo dscl . -append /Groups/$gid GroupMembership $uid > /dev/stderr
rc=`dscl . -append /Groups/$gid GroupMembership $uid; echo $?`
;;
freebsd)
if [ $shell = 0 ]; then
echo pw add user $uid -g $gid -s /usr/bin/false > /dev/stderr
rc=`pw add user $uid -g $gid -s /usr/bin/false; echo $?`
else
echo pw add user $uid -g $gid > /dev/stderr
rc=`pw add user $uid -g $gid; echo $?`
fi
;;
netbsd|openbsd)
echo useradd -g $gid $uid > /dev/stderr
rc=`useradd -g $gid $uid; echo $?`
;;
*)
if [ $shell = 0 ]; then
echo useradd -r -g $gid $uid > /dev/stderr
rc=`useradd -r -g $gid $uid; echo $?`
else
echo useradd -g $gid $uid > /dev/stderr
rc=`useradd -g $gid $uid; echo $?`
fi
;;
esac
echo $rc
}
#-------------------------
# Add the specified group
#-------------------------
add_group(){
rc=`group_exists`
if test $rc -eq 0; then
echo "Group $gid already exists" > /dev/stderr
echo 0
return
fi
case $dist in
aix)
echo mkgroup $gid > /dev/stderr
rc=`mkgroup "$gid"; echo $?`
;;
hpux|solaris)
echo groupadd $gid > /dev/stderr
rc=`groupadd "$gid"; echo $?`
;;
osx)
newid=`dscl . -list /Groups gid | tr -s ' ' | cut -d' ' -f2 | sort -n | tail -1`
newid=`expr 1 + $newid`
echo dscl . -create /Groups/$gid gid $newid > /dev/stderr
rc=`dscl . -create /Groups/$gid gid $newid; echo $?`
;;
freebsd)
echo pw add group $gid > /dev/stderr
rc=`pw add group $gid; echo $?`
;;
netbsd|openbsd)
echo groupadd $gid > /dev/stderr
rc=`groupadd $gid; echo $?`
;;
*)
echo groupadd -r $gid > /dev/stderr
rc=`groupadd -r $gid; echo $?`
;;
esac
echo $rc
}
rc=`add_group`
if test $rc -ne 0; then
exit 1;
fi
rc=`add_user`
exit $rc

View File

@ -0,0 +1,160 @@
# ===========================================================================
# SYNOPSIS
#
# AX_NAGIOS_GET_DISTRIB_TYPE
#
# DESCRIPTION
#
# This macro determines the O/S distribution of the computer it is run on.
# $dist_type will be set and will be one of:
# unknown (could not be determined)
# freebsd, netbsd, openbsd, dragonfly, etc (The BSDs)
# suse, rh, debian, gentoo (and possibly their descendants)
# Other major Linux distributions (and possibly their descendants)
# The O/S name for the rest
#
# LICENSE
#
# Copyright (c) 2016 Nagios Core Development Team
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
# ===========================================================================
AU_ALIAS([AC_NAGIOS_GET_DISTRIB_TYPE], [AX_NAGIOS_GET_DISTRIB_TYPE])
AC_DEFUN([AX_NAGIOS_GET_DISTRIB_TYPE],
[
AC_SUBST(dist_type)
AC_SUBST(dist_ver)
#
# Get user hints for possible cross-compile
#
AC_MSG_CHECKING(what the distribution type is )
AC_ARG_WITH(dist-type, AC_HELP_STRING([--with-dist-type=type],
[specify distribution type (suse, rh, debian, etc.)]),
[
#
# Run this if --with was specified
#
if test "x$withval" = x -o x$withval = xno; then
dist_type_wanted=yes
else
dist_type_wanted=no
dist_type="$withval"
dist_ver="unknown"
AC_MSG_RESULT($dist_type)
fi
], [
#
# Run this if --with was not specified
#
dist_type_wanted=yes
])
if test x$dist_type = xno; then
dist_type_wanted=yes
elif test x$dist_type = xyes; then
AC_MSG_ERROR([you must enter a distribution type if '--with-dist-type' is specified])
fi
#
# Determine distribution type if it wasn't supplied
#
dist_ver="unknown"
if test $dist_type_wanted=yes; then
dist_type="unknown"
if test "$opsys" != "linux"; then
dist_type="$opsys"
AS_CASE([$opsys],
[bsd],
dist_type=`uname -s | tr ["[A-Z]" "[a-z]"]`
dist_ver=`uname -r`,
[aix],
dist_ver="`uname -v`.`uname -r`",
[hp-ux],
dist_ver=`uname -r | cut -d'.' -f1-3`,
[solaris],
dist_ver=`uname -r | cut -d'.' -f2`,
[*],
dist_ver=$OSTYPE
)
else
if test -r "/etc/gentoo-release"; then
dist_type="gentoo"
dist_ver=`cat /etc/gentoo-release`
elif test -r "/etc/os-release"; then
. /etc/os-release
if test x"$ID_LIKE" != x; then
dist_type=`echo $ID_LIKE | cut -d' ' -f1 | tr ["[A-Z]" "[a-z]"]`
elif test x"$ID" = xol; then
dist_type=rh
else
dist_type=`echo $ID | tr ["[A-Z]" "[a-z]"]`
fi
if test x"$dist_type" = sles; then
dist_type=suse
fi
if test x"$VERSION_ID" != x; then
dist_ver=$VERSION_ID
elif test x"$VERSION" != x; then
dist_ver=`echo $VERSION | cut -d'.' -f1 | tr -d [:alpha:][:blank:][:punct:]`
fi
elif test -r "/etc/redhat-release"; then
dist_type=rh
dist_ver=`cat /etc/redhat-release`
elif test -r "/etc/debian_version"; then
dist_type="debian"
if test -r "/etc/lsb-release"; then
. /etc/lsb-release
dist_ver=`echo "$DISTRIB_RELEASE"`
else
dist_ver=`cat /etc/debian_version`
fi
elif test -r "/etc/SuSE-release"; then
dist_type=suse
dist_ver=`grep VERSION /etc/SuSE-release`
fi
fi
if test "$dist_ver" != "unknown"; then
dist_ver=`echo "$dist_ver" | cut -d'.' -f1 | tr -d [:alpha:][:blank:][:punct:]`
fi
fi
AC_MSG_RESULT($dist_type)
])

View File

@ -0,0 +1,131 @@
# ===========================================================================
# SYNOPSIS
#
# AX_NAGIOS_GET_FILES
#
# DESCRIPTION
#
# This macro figures out which init and/or inetd files to use based
# on the results of the AX_NAGIOS_GET_OS, AX_NAGIOS_GET_DISTRIB_TYPE,
# AX_NAGIOS_GET_INIT and AX_NAGIOS_GET_INETD macros. It will select
# the appropriate files(s) from the 'startup' directory and copy it.
#
# LICENSE
#
# Copyright (c) 2016 Nagios Core Development Team
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
# ===========================================================================
AU_ALIAS([AC_NAGIOS_GET_FILES], [AX_NAGIOS_GET_FILES])
AC_DEFUN([AX_NAGIOS_GET_FILES],
[
AC_SUBST(src_init)
AC_SUBST(src_inetd)
AC_SUBST(src_tmpfile)
AC_SUBST(bsd_enable)
src_inetd=""
src_init=""
bsd_enable=""
AC_MSG_CHECKING(for which init file to use )
AS_CASE([$init_type],
[sysv],
src_init=default-init,
[systemd],
src_tmpfile=tmpfile.conf
src_init=default-service,
[bsd],
src_init=bsd-init,
[newbsd],
if test $dist_type = freebsd ; then
bsd_enable="_enable"
src_init=default-init
elif test $dist_type = openbsd ; then
bsd_enable="_flags"
src_init=openbsd-init
elif test $dist_type = netbsd ; then
bsd_enable=""
src_init=newbsd-init
fi,
# [gentoo],
[openrc],
src_init=openrc-init,
[smf*],
src_init="solaris-init.xml"
src_inetd="solaris-inetd.xml",
[upstart],
if test $dist_type = rh ; then
src_init=rh-upstart-init
else
src_init=upstart-init
fi,
[launchd],
src_init="mac-init.plist",
[*],
src_init="unknown"
)
AC_MSG_RESULT($src_init)
AC_MSG_CHECKING(for which inetd files to use )
if test x$src_inetd = x; then
AS_CASE([$inetd_type],
[inetd*],
src_inetd=default-inetd,
[xinetd],
src_inetd=default-xinetd,
[systemd],
src_inetd=default-socket,
[launchd],
src_inetd="mac-inetd.plist",
[*],
src_inetd="unknown"
)
fi
AC_MSG_RESULT($src_inetd)
])

View File

@ -0,0 +1,146 @@
# ===========================================================================
# SYNOPSIS
#
# AX_NAGIOS_GET_INETD
#
# DESCRIPTION
#
# This macro determines whether inetd or xinetd is being used
# The argument are:
# the init type as determined by AX_NAGIOS_GET_INIT
# $inetd_type will be set and will be one of:
# unknown (could not be determined)
# launchd (Mac OS X)
# smf10 (Solaris)
# smf11 (Solaris)
# upstart (Older Debian)
# xinetd (Most Linux, BSD)
# inetd (The rest)
#
# LICENSE
#
# Copyright (c) 2016 Nagios Core Development Team
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
# ===========================================================================
AU_ALIAS([AC_NAGIOS_GET_INETD], [AX_NAGIOS_GET_INETD])
AC_DEFUN([AX_NAGIOS_GET_INETD],
[
AC_SUBST(inetd_type)
#
# Get user hints for possible cross-compile
#
AC_MSG_CHECKING(what inetd is being used )
AC_ARG_WITH(inetd_type, AC_HELP_STRING([--with-inetd-type=type],
[which super-server the system runs (inetd, xinetd, systemd, launchd,
smf10, smf11, etc.)]),
[
inetd_type_wanted=yes
#
# Run this if --with was specified
#
if test "x$withval" = x -o x$withval = xno; then
inetd_type_wanted=yes
else
inetd_type_wanted=no
inetd_type="$withval"
AC_MSG_RESULT($inetd_type)
fi
], [
#
# Run this if --with was not specified
#
inetd_type_wanted=yes
])
if test x$inetd_type = xno; then
inetd_type_wanted=yes
elif test x$inetd_type = xyes; then
AC_MSG_ERROR([you must enter an inetd type if '--with-inetd-type' is specified])
fi
#
# Determine inetd type if it wasn't supplied
#
if test $inetd_type_wanted = yes; then
inetd_disabled=""
AS_CASE([$dist_type],
[solaris],
if test x"$init_type" = "xsmf10" -o x"$init_type" = "xsmf11"; then
inetd_type="$init_type"
else
inetd_type="inetd"
fi,
[*bsd*],
inetd_type=`ps -A -o comm -c | grep inetd`,
[osx],
inetd_type=`launchd`,
[aix|hp-ux],
inetd_type=`UNIX95= ps -A -o comm | grep inetd | head -1`,
[*],
inetd_type=[`ps -C "inetd,xinetd" -o fname | grep -vi COMMAND | head -1`])
if test x"$inetd_type" = x; then
if test -f /etc/xinetd.conf -a -d /etc/xinetd.d; then
inetd_disabled="(Not running)"
inetd_type=xinetd
elif test -f /etc/inetd.conf -o -f /usr/sbin/inetd; then
inetd_type=inetd
inetd_disabled="(Not running)"
fi
fi
if test x"$inetd_type" = x; then
if test x"$init_type" = "xupstart"; then
inetd_type="upstart"
fi
fi
if test x"$inetd_type" = x; then
if test x"$init_type" = "xsystemd"; then
inetd_type="systemd"
else
inetd_type="unknown"
fi
fi
if test -n "$inetd_disabled"; then
AC_MSG_RESULT($inetd_type $inetd_disabled)
else
AC_MSG_RESULT($inetd_type)
fi
fi
])

View File

@ -0,0 +1,200 @@
# ===========================================================================
# SYNOPSIS
#
# AX_NAGIOS_GET_INIT
#
# DESCRIPTION
#
# This macro determines the O/S distribution of the computer it is run on.
# $init_type will be set and will be one of:
# unknown (could not be determined)
# launchd (Mac OS X)
# bsd (Slackware Linux)
# newbsd (FreeBSD, OpenBSD, NetBSD, Dragonfly, etc)
# smf10 (Solaris)
# smf11 (Solaris)
# systemd (Linux SystemD)
# gentoo (Older Gentoo)
# openrc (Recent Gentoo and some others)
# upstart (Older Debian)
# sysv (The rest)
#
# LICENSE
#
# Copyright (c) 2016 Nagios Core Development Team
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
# ===========================================================================
AU_ALIAS([AC_NAGIOS_GET_INIT], [AX_NAGIOS_GET_INIT])
AC_DEFUN([AX_NAGIOS_GET_INIT],
[
AC_SUBST(init_type)
#
# Get user hints for possible cross-compile
#
AC_MSG_CHECKING(what init system is being used )
AC_ARG_WITH(init_type,AC_HELP_STRING([--with-init-type=type],
[specify init type (bsd, sysv, systemd, launchd, smf10, smf11, upstart,
openrc, etc.)]),
[
#
# Run this if --with was specified
#
if test "x$withval" = x -o x$withval = xno; then
init_type_wanted=yes
else
init_type_wanted=no
init_type="$withval"
AC_MSG_RESULT($init_type)
fi
], [
#
# Run this if --with was not specified
#
init_type_wanted=yes
])
if test x$init_type = xno; then
init_type_wanted=yes
elif test x$init_type = xyes; then
AC_MSG_ERROR([you must enter an init type if '--with-init-type' is specified])
fi
#
# Determine init type if it wasn't supplied
#
if test $init_type_wanted = yes; then
init_type=""
if test x"$opsys" = x; then
init_type="unknown"
init_type_wanted=no
elif test x"$dist_type" = x; then
init_type="unknown"
init_type_wanted=no
elif test "$opsys" = "osx"; then
init_type="launchd"
init_type_wanted=no
elif test "$opsys" = "bsd"; then
init_type="newbsd"
init_type_wanted=no
elif test "$dist_type" = "solaris"; then
if test -d "/lib/svc/manifest"; then
init_type="smf11"
init_type_wanted=no
elif test -d "/lib/svc/monitor"; then
init_type="smf10"
init_type_wanted=no
else
init_type="sysv"
init_type_wanted=no
fi
elif test "$dist_type" = "slackware"; then
init_type="bsd"
init_type_wanted=no
elif test "$dist_type" = "aix"; then
init_type="bsd"
init_type_wanted=no
elif test "$dist_type" = "hp-ux"; then
init_type="unknown"
init_type_wanted=no
fi
fi
PSCMD="ps -p1 -o args"
if test $dist_type = solaris; then
PSCMD="env UNIX95=1; ps -p1 -o args"
fi
if test "$init_type_wanted" = yes; then
pid1=`$PSCMD | grep -vi COMMAND | cut -d' ' -f1`
if test x"$pid1" = "x"; then
init_type="unknown"
init_type_wanted=no
fi
if `echo $pid1 | grep "systemd" > /dev/null`; then
init_type="systemd"
init_type_wanted=no
fi
if test "$init_type_wanted" = yes; then
if test "$pid1" = "init"; then
if test -e "/sbin/init"; then
pid1="/sbin/init";
elif test -e "/usr/sbin/init"; then
pid1="/usr/sbin/init"
else
init_type="unknown"
init_type_wanted=no
fi
fi
if test -L "$pid1"; then
pid1=`readlink "$pid1"`
fi
fi
if test "$init_type_wanted" = yes; then
if `echo $pid1 | grep "systemd" > /dev/null`; then
init_type="systemd"
init_type_wanted=no
elif test -f "/sbin/rc"; then
if test -f /sbin/runscript; then
init_type_wanted=no
if `/sbin/start-stop-daemon -V | grep "OpenRC" > /dev/null`; then
init_type="openrc"
else
init_type="gentoo"
fi
fi
fi
fi
if test "$init_type_wanted" = yes; then
if test "$pid1" = "/sbin/init" -o "$pid1" = "/usr/sbin/init"; then
if `$pid1 --version 2>/dev/null | grep "upstart" >/dev/null`; then
init_type="upstart"
init_type_wanted=no
elif test -f "/etc/rc" -a ! -L "/etc/rc"; then
init_type="newbsd"
init_type_wanted=no
else
init_type="sysv"
init_type_wanted=no
fi
fi
fi
if test "$init_type_wanted" = yes; then
init_type="unknown"
fi
fi
AC_MSG_RESULT($init_type)
])

View File

@ -0,0 +1,101 @@
# ===========================================================================
# SYNOPSIS
#
# AX_NAGIOS_GET_OS
#
# DESCRIPTION
#
# This macro determines the operating system of the computer it is run on.
#
# LICENSE
#
# Copyright (c) 2016 Nagios Core Development Team
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
# ===========================================================================
AU_ALIAS([AC_NAGIOS_GET_OS], [AX_NAGIOS_GET_OS])
AC_DEFUN([AX_NAGIOS_GET_OS],
[
AC_SUBST(opsys)
AC_SUBST(arch)
#
# Get user hints
#
AC_MSG_CHECKING(what the operating system is )
AC_ARG_WITH(opsys, AC_HELP_STRING([--with-opsys=OS],
[specify operating system (linux, osx, bsd, solaris, irix, cygwin,
aix, hp-ux, etc.)]),
[
#
# Run this if --with was specified
#
if test "x$withval" = x -o x$withval = xno; then
opsys_wanted=yes
else
opsys_wanted=no
opsys="$withval"
AC_MSG_RESULT($opsys)
fi
], [
#
# Run this if --with was not specified
#
opsys_wanted=yes
])
if test x$opsys = xno; then
opsys=""
opsys_wanted=yes
elif test x$opsys = xyes; then
AC_MSG_ERROR([you must enter an O/S type if '--with-opsys' is specified])
fi
#
# Determine operating system if it wasn't supplied
#
if test $opsys_wanted=yes; then
opsys=`uname -s | tr ["[A-Z]" "[a-z]"]`
if test x"$opsys" = "x"; then opsys="unknown"; fi
AS_CASE([$opsys],
[darwin*], opsys="osx",
[*bsd*], opsys="bsd",
[dragonfly], opsys="bsd",
[sunos], opsys="solaris",
[gnu/hurd], opsys="linux",
[irix*], opsys="irix",
[cygwin*], opsys="cygwin",
[mingw*], opsys="mingw",
[msys*], opsys="msys")
fi
arch=`uname -m | tr ["[A-Z]" "[a-z]"]`
AC_MSG_RESULT($opsys)
])

View File

@ -0,0 +1,783 @@
# ===========================================================================
# SYNOPSIS
#
# AX_NAGIOS_GET_PATHS
#
# DESCRIPTION
#
# This macro figures out the installation & run paths for various systems
# The argument are:
# the O/S determined by the AX_NAGIOS_GET_OS macro.
# the distribution type as determined by AX_NAGIOS_GET_DISTRIB_TYPE
# the init type as determined by AX_NAGIOS_GET_INIT
# the inetd type as determined by AX_NAGIOS_GET_INETD
#
# LICENSE
#
# Copyright (c) 2016 Nagios Core Development Team
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
# ===========================================================================
AU_ALIAS([AC_NAGIOS_GET_PATHS], [AX_NAGIOS_GET_PATHS])
AC_DEFUN([AX_NAGIOS_GET_PATHS],
[
AC_SUBST(pkgsysconfdir)
AC_SUBST(objsysconfdir)
AC_SUBST(initname)
AC_SUBST(inetdname)
AC_SUBST(pluginsdir)
AC_SUBST(brokersdir)
AC_SUBST(cgibindir)
AC_SUBST(webdir)
AC_SUBST(privatesysconfdir)
AC_SUBST(pkglocalstatedir)
AC_SUBST(logdir)
AC_SUBST(piddir)
AC_SUBST(pipedir)
AC_SUBST(spooldir)
AC_SUBST(initdir)
AC_SUBST(initdiroverridden)
AC_SUBST(inetddir)
AC_SUBST(tmpfilesd)
AC_SUBST(subsyslockdir)
AC_SUBST(subsyslockfile)
if test x$DBG_PATHS != x; then
echo
echo Incoming paths:
echo " prefix $prefix"
echo " exec_prefix $exec_prefix"
echo " bindir $bindir"
echo " libexecdir $libexecdir"
echo " sysconfdir $sysconfdir"
echo " localstatedir $localstatedir"
echo " datarootdir $datarootdir"
echo " datadir $datadir"
echo " localedir $localedir"
echo
fi
AC_MSG_CHECKING(for which paths to use )
AC_ARG_ENABLE(install_method,
AC_HELP_STRING([--enable-install-method=<method>],
[sets the install method to use: 'default' (the default) will install to
/usr/local/nagios, 'os' will try to determine which method to use based
on OS type and distribution. Fine tuning using the '--bindir', etc.
overrides above will still work]),
install_method=$enableval,
install_method=default
)
AC_ARG_ENABLE(showdirs_only,
AC_HELP_STRING([--enable-showdirs-only=yes],
[This option will cause 'configure' to stop after determining the install
locations based on '--enable-install-method', so you can see the
destinations before a full './configure', 'make', 'make install'
process.]),
showdirs_only=$enableval,
showdirs_only=no
)
AS_CASE([$install_method],
[yes], install_method="os",
[no], install_method="default",
[default|os], :,
[*], echo >&6; AC_MSG_ERROR(['--enable-install-method=$install_method' is invalid])
)
if test $showdirs_only != "no"; then showdirs_only="yes"; fi
AS_CASE([$dist_type],
[*solaris*|*hp-ux*|*aix*|*osx*], opsys=unix)
# Does this package need to know:
need_cgi=no # where the cgi-bin directory is
need_web=no # where the website directory is
need_brk=no # where the event broker modules directory is
need_plg=no # where the plugins directory is
need_pipe=no # where the pipe directory is
need_spl=no # where the spool directory is
need_loc=no # where the locale directory is
need_log_subdir=no # where the loc sub-directory is
need_etc_subdir=no # where the etc sub-directory is
need_pls_dir=no # where the package locate state directory is
if test x"$INIT_PROG" = x; then
INIT_PROG="$PKG_NAME"
fi
AS_CASE([$PKG_NAME],
[nagios],
need_log_subdir=yes
need_etc_subdir=yes
need_pls_dir=yes
need_brk=yes
need_pipe=yes
need_spl=yes
need_loc=yes
need_cgi=yes
need_web=yes,
[ndoutils],
need_brk=yes
need_spl=yes,
[nrpe],
need_plg=yes,
[nsca],
need_cgi=no,
[plugins],
need_loc=yes
need_plg=yes
)
AC_ARG_WITH(pkgsysconfdir, AC_HELP_STRING([--with-pkgsysconfdir=DIR],
[where configuration files should be placed]),
if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
pkgsysconfdir="$withval"
fi)
AC_ARG_WITH(objsysconfdir, AC_HELP_STRING([--with-objsysconfdir=DIR],
[where object configuration files should be placed]),
if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
objsysconfdir="$withval"
fi)
AC_ARG_WITH(privatesysconfdir, AC_HELP_STRING([--with-privatesysconfdir=DIR],
[where private configuration files should be placed]),
if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
privatesysconfdir="$withval"
fi)
AC_ARG_WITH(webdir, AC_HELP_STRING([--with-webdir=DIR],
[where the website files should be placed]),
if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
webdir="$withval"
fi)
AC_ARG_WITH(pluginsdir, AC_HELP_STRING([--with-pluginsdir=DIR],
[where the plugins should be placed]),
if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
pluginsdir="$withval"
fi)
AC_ARG_WITH(brokersdir, AC_HELP_STRING([--with-brokersdir=DIR],
[where the broker modules should be placed]),
if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
brokersdir="$withval"
fi)
AC_ARG_WITH(cgibindir, AC_HELP_STRING([--with-cgibindir=DIR],
[where the CGI programs should be placed]),
if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
cgibindir="$withval"
fi)
AC_ARG_WITH(logdir, AC_HELP_STRING([--with-logdir=DIR],
[where log files should be placed]),
if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
logdir="$withval"
fi)
AC_ARG_WITH(piddir, AC_HELP_STRING([--with-piddir=DIR],
[where the PID file should be placed]),
if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
piddir="$withval"
fi)
AC_ARG_WITH(pipedir, AC_HELP_STRING([--with-pipedir=DIR],
[where socket and pipe files should be placed]),
if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
pipedir="$withval"
fi)
#
# Setup the base directory
#
if test $install_method = "default"; then
if test $opsys = "unix"; then
if test x"$prefix" = "xNONE"; then prefix="/usr/local/nagios"; fi
else
if test x"$prefix" = "xNONE"; then prefix=${ac_default_prefix}; fi
fi
datarootdir=${datarootdir="$prefix"}
else
if test x"$datadir" = x'${datarootdir}'; then AS_UNSET(datadir); fi
if test x"$sysconfdir" = x'${prefix}/etc'; then AS_UNSET(sysconfdir); fi
if test x"$prefix" = "xNONE"; then
if test $dist_type = freebsd -o $dist_type = openbsd -o $dist_type = osx; then
prefix="/usr/local"
elif test $dist_type = netbsd; then
prefix="/usr/pkg"
else
prefix="/usr"
fi
fi
if test x"$exec_prefix" = "xNONE"; then exec_prefix=$prefix; fi
if test x"$localstatedir" = x'${prefix}/var'; then
if test $dist_type = "osx"; then
localstatedir="/private/var"
else
localstatedir="/var"
fi
fi
if test $opsys = "unix"; then
if test x"$datarootdir" = x'${prefix}/share'; then
if test $dist_type = "hp-ux"; then
datarootdir="/usr/local/share"
if test x"$libexecdir" = x'${exec_prefix}/libexec'; then
libexecdir="/usr/nagios"
fi
elif test $dist_type = "osx"; then
datarootdir="/usr/local/share"
if test x"$libexecdir" = x'${exec_prefix}/libexec'; then
libexecdir="/usr/local/nagios"
fi
elif test x"$libexecdir" = x'${exec_prefix}/libexec'; then
libexecdir="/usr/lib/nagios"
fi
fi
if test $dist_type = "osx"; then
if test x"$libexecdir" = x'${exec_prefix}/libexec'; then
libexecdir="/usr/local/libexec/nagios"
fi
fi
elif test $opsys = "bsd"; then
if test x"$libexecdir" = x'${exec_prefix}/libexec'; then
libexecdir=${exec_prefix}/libexec/nagios;
fi
elif test x"$libexecdir" = x'${exec_prefix}/lib'; then
libexecdir=${libexecdir}/nagios;
elif test x"$libexecdir" = x'${exec_prefix}/libexec'; then
libexecdir=${exec_prefix}/lib/nagios;
fi
fi
if test x"$exec_prefix" = "xNONE"; then exec_prefix=${prefix}; fi
tmpfilesd=${tmpfilesd="/usr/lib/tmpfiles.d"}
if test ! -d "$tmpfilesd"; then
tmpfilesd="N/A"
else
tmpfilesd="$tmpfilesd/$INIT_PROG.conf"
fi
subsyslockdir=${subsyslockdir="/run"}
if test ! -d "$subsyslockdir"; then
subsyslockdir="N/A"
subsyslockfile="N/A"
else
subsyslockfile="$subsyslockdir/$INIT_PROG.lock"
fi
if test "$need_loc" = no; then
localedir="N/A"
fi
if test $install_method = "default" ; then
#
# Do the default setup
#
datadir=${datadir="$datarootdir"}
if test $need_web = yes; then
webdir=${webdir="$datadir"}
else
webdir="N/A"
fi
if test $opsys = "unix"; then
sysconfdir=${sysconfdir="/etc/opt"}
fi
pkgsysconfdir=${pkgsysconfdir="$sysconfdir"}
if test $need_etc_subdir = yes; then
objsysconfdir=${objsysconfdir="$pkgsysconfdir/objects"}
else
objsysconfdir="N/A"
fi
privatesysconfdir=${privatesysconfdir="$pkgsysconfdir"}
logdir=${logdir="$localstatedir"}
piddir=${piddir="$localstatedir"}
if test "$need_pipe" = yes; then
pipedir=${pipedir="$localstatedir/rw"}
else
pipedir="N/A"
fi
if test "$need_pls_dir" = yes; then
pkglocalstatedir=${pkglocalstatedir="$localstatedir"}
else
pkglocalstatedir="N/A"
fi
if test "$need_spl" = yes; then
spooldir=${spooldir="$localstatedir/var"}
else
spooldir="N/A"
fi
if test $need_brk = yes; then
brokersdir=${brokersdir="$bindir"}
else
brokersdir="N/A"
fi
if test $need_plg = yes; then
pluginsdir=${pluginsdir="$libexecdir"}
else
pluginsdir="N/A"
fi
if test $need_cgi = yes; then
cgibindir=${cgibindir="$prefix/sbin"}
else
cgibindir="N/A"
fi
elif test $opsys = "linux"; then
#
# Linux "Standard" install
#
install_method="$install_method : FHS"
datadir=${datadir="$datarootdir/nagios"}
if test $need_web = yes; then
webdir=${webdir="$datadir/html"}
else
webdir="N/A"
fi
sysconfdir=${sysconfdir="/etc"}
pkgsysconfdir=${pkgsysconfdir="$sysconfdir/nagios"}
if test $need_etc_subdir = yes; then
objsysconfdir=${objsysconfdir="$pkgsysconfdir/objects"}
else
objsysconfdir="N/A"
fi
privatesysconfdir=${privatesysconfdir="$pkgsysconfdir/private"}
if test $need_log_subdir = yes; then
logdir=${logdir="$localstatedir/log/$INIT_PROG"}
else
logdir=${logdir="$localstatedir/log"}
fi
piddir=${piddir="$localstatedir/run/${INIT_PROG}"}
if test "$need_pipe" = yes; then
pipedir=${pipedir="$localstatedir/run/${INIT_PROG}"}
else
pipedir="N/A"
fi
if test "$need_pls_dir" = yes; then
pkglocalstatedir=${pkglocalstatedir="$localstatedir/lib/$INIT_PROG"}
else
pkglocalstatedir="N/A"
fi
if test "$need_spl" = yes; then
spooldir=${spooldir="$localstatedir/spool/$INIT_PROG"}
else
spooldir="N/A"
fi
if test $need_brk = yes; then
brokersdir=${brokersdir="$libexecdir/brokers"}
else
brokersdir="N/A"
fi
if test $need_plg = yes; then
pluginsdir=${pluginsdir="$libexecdir/plugins"}
else
pluginsdir="N/A"
fi
if test $need_cgi = yes; then
cgibindir=${cgibindir="$libexecdir/cgi-bin"}
else
cgibindir="N/A"
fi
elif test $opsys = "unix"; then
#
# "Standard" Unix install
#
install_method="$install_method : Unix Standard"
if test $dist_type = osx; then
install_method="$install_method : OS X Standard"
fi
datadir=${datadir="$datarootdir/nagios"}
if test $need_web = yes; then
webdir=${webdir="$datadir/html"}
else
webdir="N/A"
fi
if test $dist_type = osx; then
sysconfdir=${sysconfdir="/private/etc"}
else
sysconfdir=${sysconfdir="/etc"}
fi
pkgsysconfdir=${pkgsysconfdir="$sysconfdir/nagios"}
if test $need_etc_subdir = yes; then
objsysconfdir=${objsysconfdir="$pkgsysconfdir/objects"}
else
objsysconfdir="N/A"
fi
privatesysconfdir=${privatesysconfdir="$pkgsysconfdir/private"}
if test "$need_pls_dir" = yes; then
pkglocalstatedir=${pkglocalstatedir="$localstatedir/lib/$INIT_PROG"}
else
pkglocalstatedir="N/A"
fi
if test "$need_loc" = yes; then
localedir=${localedir="/usr/local/share/locale/<lang>/LC_MESSAGES/nagios-plugins.mo"}
fi
if test "$need_spl" = yes; then
spooldir=${spooldir="$localstatedir/spool/$INIT_PROG"}
else
spooldir="N/A"
fi
if test $need_brk = yes; then
brokersdir=${brokersdir="$libexecdir/brokers"}
else
brokersdir="N/A"
fi
if test $need_plg = yes; then
pluginsdir=${pluginsdir="$libexecdir/plugins"}
else
pluginsdir="N/A"
fi
if test $need_cgi = yes; then
cgibindir=${cgibindir="$libexecdir/cgi-bin"}
else
cgibindir="N/A"
fi
AS_CASE([$dist_type],
[*hp-ux*],
piddir=${piddir="$pkgsysconfdir"}
pipedir=${pipedir="$pkglocalstatedir"}
logdir=${logdir="$pkglocalstatedir/log"},
[*],
piddir=${piddir="$localstatedir/run/${INIT_PROG}"}
if test "$need_pipe" = yes; then
pipedir=${pipedir="$localstatedir/run/${INIT_PROG}"}
else
pipedir="N/A"
fi
if test $need_log_subdir = yes; then
logdir=${logdir="$localstatedir/log/$INIT_PROG"}
else
logdir=${logdir="$localstatedir/log"}
fi
)
elif test $opsys = "bsd"; then
#
# "Standard" BSD install
#
install_method="$install_method : BSD"
if test $dist_type = freebsd -o $dist_type = openbsd; then
prefix=${prefix="/usr/local"}
exec_prefix=${exec_prefix="/usr/local"}
if test $dist_type = freebsd; then
install_method="$install_method : FreeBSD"
else
install_method="$install_method : OpenBSD"
fi
elif test $dist_type = netbsd; then
prefix=${prefix="/usr/pkg"}
exec_prefix=${exec_prefix="/usr/pkg"}
install_method="$install_method : NetBSD"
fi
datadir=${datadir="$datarootdir/nagios"}
if test $need_web = yes -o $need_cgi = yes; then
if test $dist_type = freebsd; then
webdir=${webdir="$prefix/www/nagios"}
elif test $dist_type = netbsd; then
webdir=${webdir="$prefix/share/nagios"}
elif test $dist_type = openbsd; then
webdir=${webdir="/var/www/nagios"}
fi
else
webdir="N/A"
fi
if test $dist_type = freebsd; then
sysconfdir=${sysconfdir="/usr/local/etc"}
else
sysconfdir=${sysconfdir="/etc"}
fi
pkgsysconfdir=${pkgsysconfdir="$sysconfdir/nagios"}
if test $need_etc_subdir = yes; then
objsysconfdir=${objsysconfdir="$pkgsysconfdir/objects"}
else
objsysconfdir="N/A"
fi
privatesysconfdir=${privatesysconfdir="$pkgsysconfdir/private"}
if test "$need_pls_dir" = yes; then
pkglocalstatedir=${pkglocalstatedir="$localstatedir/lib/$INIT_PROG"}
else
pkglocalstatedir="N/A"
fi
if test "$need_loc" = yes; then
localedir=${localedir="/usr/local/share/locale/<lang>/LC_MESSAGES/nagios-plugins.mo"}
fi
if test "$need_spl" = yes; then
spooldir=${spooldir="$localstatedir/spool/$INIT_PROG"}
else
spooldir="N/A"
fi
if test $need_brk = yes; then
brokersdir=${brokersdir="$libexecdir/brokers"}
else
brokersdir="N/A"
fi
if test $need_plg = yes; then
pluginsdir=${pluginsdir="$libexecdir/plugins"}
else
pluginsdir="N/A"
fi
if test $need_cgi = yes; then
if test $dist_type = freebsd; then
cgibindir=${cgibindir="$webdir/cgi-bin"}
elif test $dist_type = netbsd; then
cgibindir=${pluginsdir="$libexecdir/cgi-bin"}
elif test $dist_type = openbsd; then
cgibindir=${pluginsdir="/var/www/cgi-bin/nagios"}
fi
else
cgibindir="N/A"
fi
piddir=${piddir="$localstatedir/run/${INIT_PROG}"}
if test "$need_pipe" = yes; then
pipedir=${pipedir="$localstatedir/run/${INIT_PROG}"}
else
pipedir="N/A"
fi
if test $need_log_subdir = yes; then
logdir=${logdir="$localstatedir/log/$INIT_PROG"}
else
logdir=${logdir="$localstatedir/log"}
fi
else
#
# Unknown install
#
install_method="unknown"
webdir=unknown
pkgsysconfdir=unknown
objsysconfdir=unknown
privatesysconfdir=unknown
logdir=unknown
piddir=unknown
pipedir=unknown
pkglocalstatedir=unknown
spooldir=unknown
brokersdir=unknown
pluginsdir=unknown
cgibindir=unknown
fi
eval prefix=$prefix
eval exec_prefix=$exec_prefix
eval bindir=$bindir
eval datarootdir=$datarootdir
eval datadir=$datadir
eval libexecdir=$libexecdir
eval brokersdir=$brokersdir
eval pluginsdir=$pluginsdir
eval cgibindir=$cgibindir
eval localstatedir=$localstatedir
eval pkglocalstatedir=$pkglocalstatedir
eval webdir=$webdir
eval localedir=$localedir
eval sysconfdir=$sysconfdir
eval pkgsysconfdir=$pkgsysconfdir
eval piddir=$piddir
# We test systemd first because in case
# someone tries to install Nagios on a
# system with a newer version, that doesn't
# have the defined versions ..we can just
# (hopefully) fall back to SysV
# And if that doesn't work, well...
AS_CASE([$init_type],
[systemd],
if test -d "/lib/systemd/system"; then
initdir=${initdir="/lib/systemd/system"}
elif test -d "/usr/lib/systemd/system"; then
initdir=${initdir="/usr/lib/systemd/system"}
elif test -d "/usr/local/lib/systemd/system"; then
initdir=${initdir="/usr/local/lib/systemd/system"}
elif test -d "/run/systemd/system"; then
initdir=${initdir="/run/systemd/system"}
elif test -d "/etc/systemd/system"; then
initdir=${initdir="/etc/systemd/system"}
elif test -d "/etc/systemd/user"; then
initdir=${initdir="/etc/systemd/user"}
elif test -d "/run/systemd/user"; then
initdir=${initdir="/run/systemd/user"}
elif test -d "/usr/lib/systemd/user"; then
initdir=${initdir="/usr/lib/systemd/user"}
elif test -d "/usr/local/lib/systemd/user"; then
initdir=${initdir="/usr/local/lib/systemd/user"}
elif test -d "/usr/share/systemd/user"; then
initdir=${initdir="/usr/share/systemd/user"}
elif test -d "/usr/local/share/systemd/user"; then
initdir=${initdir="/usr/local/share/systemd/user"}
elif test -d "$HOME/.config/systemd/user"; then
initdir=${initdir="$HOME/.config/systemd/user"}
elif test -d "$HOME/.local/share/systemd/user"; then
initdir=${initdir="$HOME/.local/share/systemd/user"}
elif test -d "$XDG_CONFIG_HOME/systemd/user/"; then
initdir=${initdir="$XDG_CONFIG_HOME/systemd/user/"}
elif test -d "$XDG_RUNTIME_DIR/systemd/user/"; then
initdir=${initdir="$XDG_RUNTIME_DIR/systemd/user/"}
elif test -d "$XDG_DATA_HOME/systemd/user/"; then
initdir=${initdir="$XDG_DATA_HOME/systemd/user/"}
else
init_type="sysv"
fi
initname=${initname="$INIT_PROG.service"},
)
#
# Init scripts/files
#
AS_CASE([$init_type],
[sysv],
if test $dist_type = "hp-ux"; then
initdir=${initdir="/sbin/init.d"}
else
initdir=${initdir="/etc/init.d"}
fi
initname=${initname="$INIT_PROG"}
initconfdir=${initconfdir="/etc/conf.d"}
initconf=${initconf="$initconfdir/$INIT_PROG"},
[bsd],
if test $dist_type = "aix"; then
initdir=${initdir="/sbin/rc.d/init.d"}
initname=${initname="$INIT_PROG"}
else
initdir=${initdir="/etc/rc.d"}
initname=${initname="rc.$INIT_PROG"}
fi,
[newbsd],
initdir=${initdir="/usr/local/etc/rc.d"}
initname=${initname="$INIT_PROG"},
[gentoo],
initdir=${initdir="/etc/init.d"}
initname=${initname="$INIT_PROG"}
initconfdir=${initconfdir="/etc/init.d"}
initconf=${initconf="$initconfdir/$INIT_PROG"},
[openrc],
initdir=${initdir="/etc/init.d"}
initname=${initname="$INIT_PROG"}
initconfdir=${initconfdir="/etc/conf.d"}
initconf=${initconf="$initconfdir/$INIT_PROG"},
[smf*],
if test $init_type = smf10; then
initdir=${initdir="/var/svc/manifest/network/nagios"}
else
initdir=${initdir="/lib/svc/manifest/network/nagios"}
fi
initname=${initname="$INIT_PROG.xml"}
initconfdir=unknown
initconf=unknown,
[upstart],
initdir=${initdir="/etc/init"}
initname=${initname="$INIT_PROG.conf"}
initconfdir=${initconfdir="/etc/default"}
initconf=${initconf="$initconfdir/$INIT_PROG"},
[launchd],
initdir=${initdir="/Library/LaunchDaemons"}
initname=${initname="org.nagios.$INIT_PROG.plist"},
# initconfdir=${initconfdir="/private/etc"}
# initconf=${initconf="$initconfdir/$INIT_PROG"},
[systemd],
init_type=systemd,
[*],
initdir=unknown
initname=unknown)
# Now see if they supplied any overwriting values
initdiroverridden=no
AC_ARG_WITH(initdir,
AC_HELP_STRING([--with-initdir=<path>],
[overrides path for initdir]),
initdir=$withval
initdiroverridden=yes,
initdir=$initdir
)
#
# Inetd (per connection) scripts/files
#
AS_CASE([$inetd_type],
[inetd*],
inetddir=${inetddir="/etc"}
inetdname=${inetdname="inetd.conf"},
[xinetd],
inetddir=${inetddir="/etc/xinetd.d"}
inetdname=${inetdname="$INIT_PROG"},
[systemd],
if test $dist_type = "debian"; then
inetddir=${inetddir="/lib/systemd/system"}
else
inetddir=${inetddir="/usr/lib/systemd/system"}
fi
netdname=${inetdname="$INIT_PROG.socket"},
[smf*],
if test $init_type = smf10; then
inetddir=${inetddir="/var/svc/manifest/network/nagios"}
else
inetddir=${inetddir="/lib/svc/manifest/network/nagios"}
fi
inetdname=${inetdname="$INIT_PROG.xml"},
# [upstart],
# inetddir=${inetddir="/etc/init.d"}
# inetdname=${inetdname="$INIT_PROG"},
[launchd],
inetddir=${inetddir="/Library/LaunchDaemons"}
inetdname=${inetdname="org.nagios.$INIT_PROG.plist"},
[*],
inetddir=${inetddir="unknown"}
inetdname=${inetdname="unknown"})
AC_MSG_RESULT($install_method)
])

View File

@ -0,0 +1,303 @@
# ===========================================================================
# SYNOPSIS
#
# AX_NAGIOS_GET_SSL
#
# DESCRIPTION
#
# This macro finds the openssl binary, the header files directory and
# the library files directory. It will also search for the gnutls
# compatibility library/headers and the nss compatibility library/headers.
#
# LICENSE
#
# Copyright (c) 2016 Nagios Core Development Team
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
# ===========================================================================
AU_ALIAS([AC_NAGIOS_GET_SSL], [AX_NAGIOS_GET_SSL])
AC_DEFUN([AX_NAGIOS_GET_SSL],
[
# -------------------------------
# SSL library and include paths
# -------------------------------
SSL_TYPE=openssl
try_pkg_config=1
ssl_dir=
ssl_inc_dir=
ssl_lib_dir=
SSL_INC_DIR=
SSL_INC_PREFIX=
SSL_HDR=
SSL_LIB_DIR=
AC_SUBST(HAVE_SSL)
AC_SUBST(SSL_TYPE)
AC_SUBST(SSL_INC_DIR)
AC_SUBST(SSL_HDR)
AC_SUBST(SSL_INC_PREFIX)
AC_SUBST(SSL_LIB_DIR)
# gnutls/openssl.h
# nss_compat_ossl/nss_compat_ossl.h
dnl # Which type - openssl, gnutls-openssl, nss
dnl AC_ARG_WITH([ssl-type],
dnl dnl AS_HELP_STRING([--with-ssl-type=TYPE],[replace TYPE with gnutls or nss to use one of these instead of openssl]),
dnl AS_HELP_STRING([--with-ssl-type=TYPE],[replace TYPE with gnutls to use that instead of openssl]),
dnl [SSL_TYPE=$withval])
AC_ARG_WITH([ssl],
AS_HELP_STRING([--with-ssl=DIR],[sets location of the SSL installation]),
[ssl_dir=$withval])
AC_ARG_WITH([ssl-inc],
AS_HELP_STRING([--with-ssl-inc=DIR],
[sets location of the SSL include files]),
[ssl_inc_dir=$withval])
AC_ARG_WITH([ssl-lib],
AS_HELP_STRING([--with-ssl-lib=DIR],[sets location of the SSL libraries]),
[ssl_lib_dir=$withval])
if test x$ssl_inc_dir != x -o x$ssl_lib_dir != x; then
try_pkg_config=0
fi
AC_ARG_WITH([kerberos-inc],
AS_HELP_STRING([--with-kerberos-inc=DIR],
[sets location of the Kerberos include files]),
[kerberos_inc_dir=$withval])
if test x$SSL_TYPE = xyes; then
SSL_TYPE=openssl
fi
dflt_hdrs="$ssl_inc_dir $ssl_dir $ssl_inc_dir/include $ssl_dir/include \
/usr/local/opt/{BBB} /usr/include/{BBB} /usr/local/include/{BBB} \
/usr/local/{AAA} /usr/local/{BBB} /usr/lib/{AAA} /usr/lib/{BBB} \
/usr/{AAA} /usr/pkg /usr/local /usr /usr/freeware/lib/{BBB} \
/usr/sfw /usr/sfw/include /opt/{BBB}"
dflt_libs="$ssl_lib_dir {ssldir} {ssldir}/lib {ssldir}/lib64 /usr/lib64 \
/usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu \
/usr/local/lib /usr/lib/{AAA} /usr/{AAA}/lib /usr/{BBB}/lib \
/usr/pkg/lib /usr/freeware/lib/{BBB} /usr/sfw/lib /opt/freeware/lib \
/opt/{BBB}/lib/hpux64 /opt/{BBB}/lib/pa20_64 /opt/{BBB}/lib/hpux32 \
/opt/{BBB}/lib /opt/{BBB}";
AS_CASE([$SSL_TYPE],
[no], [SSL_TYPE=NONE],
[yes|openssl],
[ssl_hdr_dirs=`echo "$dflt_hdrs" | sed -e 's/{AAA}/ssl/g' | sed -e 's/{BBB}/openssl/g'`
ssl_lib_dirs=`echo "$dflt_libs" | sed -e 's/{AAA}/ssl/g' | sed -e 's/{BBB}/openssl/g'`
SSL_INC_PREFIX=openssl
SSL_HDR=ssl.h
ssl_lib=libssl],
[gnutls],
[ssl_hdr_dirs=`echo "$dflt_hdrs" | sed -e 's/{AAA}/gnutls/g' | sed -e 's/{BBB}/gnutls/g'`
ssl_lib_dirs=`echo "$dflt_libs" | sed -e 's/{AAA}/gnutls/g' | sed -e 's/{BBB}/gnutls/g'`
SSL_INC_PREFIX=gnutls
SSL_TYPE=gnutls_compat
SSL_HDR=compat.h
ssl_lib=libgnutls],
[nss],
[ssl_hdr_dirs=`echo "$dflt_hdrs" | sed -e 's/{AAA}/nss_compat_ossl/g' | sed -e 's/{BBB}/nss_compat_ossl/g'`
ssl_lib_dirs=`echo "$dflt_libs" | sed -e 's/{AAA}/nss_compat_ossl/g' | sed -e 's/{BBB}/nss_compat_ossl/g'`
SSL_HDR=nss_compat_ossl.h
ssl_lib=libnss_compat],
[*], echo >&6; AC_MSG_ERROR(['--with-ssl-type=$SSL_TYPE' is invalid])
)
# Check for SSL support
if test x$SSL_TYPE != xNONE; then
found_ssl=no
# RedHat 8.0 and 9.0 include openssl compiled with kerberos,
# so we must include header file
# Must come before openssl checks for Redhat EL 3
AC_MSG_CHECKING(for Kerberos include files)
found_kerberos=no
for dir in $kerberos_inc_dir /usr/kerberos/include /usr/include/krb5 \
/usr/include; do
kerbdir="$dir"
if test -f "$dir/krb5.h"; then
found_kerberos=yes
CFLAGS="$CFLAGS -I$kerbdir"
AC_DEFINE_UNQUOTED(HAVE_KRB5_H,[1],[Have the krb5.h header file])
break
fi
done
if test x_$found_kerberos != x_yes; then
AC_MSG_WARN(could not find include files)
else
AC_MSG_RESULT(found Kerberos include files in $kerbdir)
fi
# First, try using pkg_config
AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
if test x"$PKG_CONFIG" != x -a $try_pkg_config -ne 0 ; then
cflags=`$PKG_CONFIG $SSL_TYPE --cflags-only-I 2>/dev/null`
if test $? -eq 0; then
CFLAGS="$CFLAGS $cflags"
LDFLAGS="$LDFLAGS `$PKG_CONFIG $SSL_TYPE --libs-only-L 2>/dev/null`"
LIBS="$LIBS `$PKG_CONFIG $SSL_TYPE --libs-only-l 2>/dev/null`"
found_ssl=yes
AC_DEFINE_UNQUOTED(HAVE_SSL,[1],[Have SSL support])
fi
fi
if test x_$found_ssl != x_yes; then
# Find the SSL Headers
AC_MSG_CHECKING(for SSL headers)
for dir in $ssl_hdr_dirs; do
if test "$dir" = "/include"; then
continue
fi
ssldir="$dir"
if test -f "$dir/include/$SSL_INC_PREFIX/$SSL_HDR"; then
found_ssl=yes
CFLAGS="$CFLAGS -I$dir/include/$SSL_INC_PREFIX -I$ssldir/include"
SSL_INC_DIR="$dir/include/$SSL_INC_PREFIX"
break
fi
if test -f "$dir/include/$SSL_HDR"; then
found_ssl=yes
if test "$SSL_HDR" != compat.h ; then
SSL_INC_PREFIX=""
fi
CFLAGS="$CFLAGS -I$dir/include"
SSL_INC_DIR="$dir/include"
break
fi
if test -f "$dir/$SSL_HDR"; then
found_ssl=yes
SSL_INC_PREFIX=""
CFLAGS="$CFLAGS -I$dir"
SSL_INC_DIR="$dir"
break
fi
if test -f "$dir/$SSL_INC_PREFIX/$SSL_HDR"; then
found_ssl=yes
CFLAGS="$CFLAGS -I$dir/$SSL_INC_PREFIX"
SSL_INC_DIR="$dir/$SSL_INC_PREFIX"
ssldir="$dir/.."
break
fi
done
if test x_$found_ssl != x_yes; then
AC_MSG_ERROR(Cannot find ssl headers)
else
AC_MSG_RESULT(found in $ssldir)
# Now try and find SSL libraries
AC_MSG_CHECKING(for SSL libraries)
found_ssl=no
ssl_lib_dirs=`echo "$ssl_lib_dirs" | sed -e "s|{ssldir}|$ssldir|g"`
if test "`uname -s`" = "Darwin" ; then
soext="dylib"
elif test "`uname -s`" = "HP-UX" ; then
if test x$arch = "xia64"; then
soext="so"
else
soext="sl"
fi
elif test "`uname -s`" = "AIX" ; then
soext="a"
else
soext="so"
fi
for dir in $ssl_lib_dirs; do
if test -f "$dir/$ssl_lib.$soext"; then
found_ssl=yes
SSL_LIB_DIR="$dir"
break
fi
done
if test x_$found_ssl != x_yes; then
AC_MSG_ERROR(Cannot find ssl libraries)
else
AC_MSG_RESULT(found in $SSL_LIB_DIR)
LDFLAGS="$LDFLAGS -L$SSL_LIB_DIR";
LIBS="$LIBS -l`echo $ssl_lib | sed -e 's/^lib//'` -lcrypto";
AC_DEFINE_UNQUOTED(HAVE_SSL,[1],[Have SSL support])
fi
fi
fi
if test x$found_ssl = xyes ; then
if test -n "$SSL_INC_PREFIX" ; then
SSL_INC_PREFIX="${SSL_INC_PREFIX}/"
fi
# try to compile and link to see if SSL is set up properly
AC_MSG_CHECKING([whether compiling and linking against SSL works])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <${SSL_INC_PREFIX}${SSL_HDR}>], [SSL_new(NULL)])],
[
AC_MSG_RESULT([yes])
$1
], [
AC_MSG_ERROR([no])
$2
])
fi
if test x$found_ssl = xyes -a x$need_dh = xyes; then
# Find the openssl program
if test x$need_dh = xyes; then
AC_PATH_PROG(sslbin,openssl,value-if-not-found,$ssl_dir/sbin$PATH_SEPARATOR$ssl_dir/bin$PATH_SEPARATOR$PATH)
AC_DEFINE(USE_SSL_DH)
# Generate DH parameters
if test -f "$sslbin"; then
echo ""
echo "*** Generating DH Parameters for SSL/TLS ***"
# awk to strip off meta data at bottom of dhparam output
$sslbin dhparam -C 2048 | awk '/^-----/ {exit} {print}' > include/dh.h
fi
fi
fi
fi
])

View File

@ -14,13 +14,13 @@ CC=@CC@
CFLAGS=-Wall -I.. @CFLAGS@ @DEFS@ -DNSCORE
# Compiler flags for use with gprof
#CFLAGS=-pg -DHAVE_CONFIG_H -DNSCORE
#CFLAGS=-pg -I.. -DHAVE_CONFIG_H -DNSCORE
# Compiler flags for use with Valgrind
#CFLAGS=-O0 -g -DHAVE_CONFIG_H -DNSCORE
#CFLAGS=-O0 -I.. -g -DHAVE_CONFIG_H -DNSCORE
# Compiler flags for optimization (overrides default)
#CFLAGS=-O3 -Wall -fno-strict-aliasing -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -DHAVE_CONFIG_H -DNSCORE
#CFLAGS=-O3 -Wall -I.. -fno-strict-aliasing -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -DHAVE_CONFIG_H -DNSCORE
# Compiler flags for optimization (complements default)
#CFLAGS_WARN=-Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs
@ -36,8 +36,8 @@ exec_prefix=@exec_prefix@
LOGDIR=@localstatedir@
CFGDIR=@sysconfdir@
BINDIR=@bindir@
CGIDIR=@sbindir@
HTMLDIR=@datarootdir@
CGIDIR=@cgibindir@
HTMLDIR=@webdir@
INSTALL=@INSTALL@
INSTALL_OPTS=@INSTALL_OPTS@
COMMAND_OPTS=@COMMAND_OPTS@
@ -92,7 +92,7 @@ DDATAHDRS=
DDATADEPS=$(DDATALIBS)
OBJS=$(BROKER_O) $(SRC_COMMON)/shared.o nerd.o query-handler.o workers.o checks.o config.o commands.o events.o flapping.o logging.o macros-base.o netutils.o notifications.o sehandlers.o utils.o $(RDATALIBS) $(CDATALIBS) $(ODATALIBS) $(SDATALIBS) $(PDATALIBS) $(DDATALIBS) $(BASEEXTRALIBS)
OBJS=$(BROKER_O) $(SRC_COMMON)/shared.o @NERD_O@ query-handler.o workers.o checks.o config.o commands.o events.o flapping.o logging.o macros-base.o netutils.o notifications.o sehandlers.o utils.o $(RDATALIBS) $(CDATALIBS) $(ODATALIBS) $(SDATALIBS) $(PDATALIBS) $(DDATALIBS) $(BASEEXTRALIBS)
OBJDEPS=$(ODATADEPS) $(ODATADEPS) $(RDATADEPS) $(CDATADEPS) $(SDATADEPS) $(PDATADEPS) $(DDATADEPS) $(BROKER_H)
all: nagios nagiostats

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -136,7 +136,7 @@ int read_main_config_file(char *main_config_file) {
continue;
/* get the variable name */
if((temp_ptr = my_strtok(input, "=")) == NULL) {
if((temp_ptr = my_strtok_with_free(input, "=", FALSE)) == NULL) {
asprintf(&error_message, "NULL variable");
error = TRUE;
break;
@ -148,7 +148,7 @@ int read_main_config_file(char *main_config_file) {
}
/* get the value */
if((temp_ptr = my_strtok(NULL, "\n")) == NULL) {
if((temp_ptr = my_strtok_with_free(NULL, "\n", FALSE)) == NULL) {
asprintf(&error_message, "NULL value");
error = TRUE;
break;
@ -158,6 +158,7 @@ int read_main_config_file(char *main_config_file) {
error = TRUE;
break;
}
temp_ptr = my_strtok_with_free(NULL, "\n", TRUE);
strip(variable);
strip(value);
@ -176,8 +177,12 @@ int read_main_config_file(char *main_config_file) {
}
else if(!strcmp(variable, "website_url")) {
int lth;
my_free(website_url);
website_url = strdup(value);
lth = strlen(website_url);
if (website_url[lth-1] == '/')
website_url[lth-1] = '\0';
}
else if(!strcmp(variable, "loadctl_options"))
@ -925,7 +930,7 @@ int read_main_config_file(char *main_config_file) {
break;
}
}
else if(!strcmp(variable, "status_update_interval")) {
status_update_interval = atoi(value);
@ -1177,6 +1182,38 @@ int read_main_config_file(char *main_config_file) {
else if(!strcmp(variable,"host_down_disable_service_checks")) {
host_down_disable_service_checks = strtoul(value, NULL, 0);
}
else if(!strcmp(variable,"service_skip_check_dependency_status")) {
service_skip_check_dependency_status = atoi(value);
if(service_skip_check_dependency_status < -1 || service_skip_check_dependency_status > 3) {
asprintf(&error_message, "Illegal value for service_skip_check_dependency_status");
error = TRUE;
break;
}
}
else if(!strcmp(variable,"service_skip_check_parent_status")) {
service_skip_check_parent_status = atoi(value);
if(service_skip_check_parent_status < -1 || service_skip_check_parent_status > 3) {
asprintf(&error_message, "Illegal value for service_skip_check_parent_status");
error = TRUE;
break;
}
}
else if(!strcmp(variable,"service_skip_check_host_down_status")) {
service_skip_check_host_down_status = atoi(value);
if(service_skip_check_host_down_status < -1 || service_skip_check_host_down_status > 3) {
asprintf(&error_message, "Illegal value for service_skip_check_host_down_status");
error = TRUE;
break;
}
}
else if(!strcmp(variable,"host_skip_check_dependency_status")) {
host_skip_check_dependency_status = atoi(value);
if(host_skip_check_dependency_status < -1 || host_skip_check_dependency_status > 3) {
asprintf(&error_message, "Illegal value for host_skip_check_dependency_status");
error = TRUE;
break;
}
}
/* we don't know what this variable is... */
else {
asprintf(&error_message, "UNKNOWN VARIABLE");
@ -1320,7 +1357,7 @@ int read_resource_file(char *resource_file) {
strip(input);
/* get the variable name */
if((temp_ptr = my_strtok(input, "=")) == NULL) {
if((temp_ptr = my_strtok_with_free(input, "=", FALSE)) == NULL) {
logit(NSLOG_CONFIG_ERROR, TRUE, "Error: NULL variable - Line %d of resource file '%s'", current_line, resource_file);
error = TRUE;
break;
@ -1331,7 +1368,7 @@ int read_resource_file(char *resource_file) {
}
/* get the value */
if((temp_ptr = my_strtok(NULL, "\n")) == NULL) {
if((temp_ptr = my_strtok_with_free(NULL, "\n", FALSE)) == NULL) {
logit(NSLOG_CONFIG_ERROR, TRUE, "Error: NULL variable value - Line %d of resource file '%s'", current_line, resource_file);
error = TRUE;
break;
@ -1340,6 +1377,7 @@ int read_resource_file(char *resource_file) {
error = TRUE;
break;
}
temp_ptr = my_strtok_with_free(NULL, "\n", TRUE);
/* what should we do with the variable/value pair? */

View File

@ -757,65 +757,72 @@ int init_event_queue(void)
unsigned int size;
size = num_objects.hosts + num_objects.services;
if(size < 4096)
if (size < 4096) {
size = 4096;
}
nagios_squeue = squeue_create(size);
return 0;
}
/* schedule a new timed event */
timed_event *schedule_new_event(int event_type, int high_priority, time_t run_time, int recurring, unsigned long event_interval, void *timing_func, int compensate_for_time_change, void *event_data, void *event_args, int event_options) {
timed_event *new_event;
char run_time_string[MAX_DATETIME_LENGTH] = "";
timed_event *schedule_new_event(int event_type, int high_priority, time_t run_time,
int recurring, unsigned long event_interval, void *timing_func,
int compensate_for_time_change, void *event_data, void *event_args, int event_options)
{
timed_event * new_event = NULL;
char run_time_string[MAX_DATETIME_LENGTH] = "";
log_debug_info(DEBUGL_FUNCTIONS, 0, "schedule_new_event()\n");
get_datetime_string(&run_time, run_time_string, MAX_DATETIME_LENGTH,
SHORT_DATE_TIME);
log_debug_info(DEBUGL_EVENTS, 0, "New Event Details:\n");
log_debug_info(DEBUGL_EVENTS, 0, " Type: EVENT_%s\n",
EVENT_TYPE_STR(event_type));
log_debug_info(DEBUGL_EVENTS, 0, " High Priority: %s\n",
( high_priority ? "Yes" : "No"));
log_debug_info(DEBUGL_EVENTS, 0, " Run Time: %s\n",
run_time_string);
log_debug_info(DEBUGL_EVENTS, 0, " Recurring: %s\n",
( recurring ? "Yes" : "No"));
log_debug_info(DEBUGL_EVENTS, 0, " Event Interval: %lu\n",
event_interval);
log_debug_info(DEBUGL_EVENTS, 0, " Compensate for Time Change: %s\n",
( compensate_for_time_change ? "Yes" : "No"));
log_debug_info(DEBUGL_EVENTS, 0, " Event Options: %d\n",
event_options);
get_datetime_string(&run_time, run_time_string, MAX_DATETIME_LENGTH, SHORT_DATE_TIME);
new_event = (timed_event *)calloc(1, sizeof(timed_event));
if(new_event != NULL) {
new_event->event_type = event_type;
new_event->event_data = event_data;
new_event->event_args = event_args;
new_event->event_options = event_options;
new_event->run_time = run_time;
new_event->recurring = recurring;
new_event->event_interval = event_interval;
new_event->timing_func = timing_func;
new_event->compensate_for_time_change = compensate_for_time_change;
new_event->priority = high_priority;
}
else
return NULL;
if (new_event != NULL) {
log_debug_info(DEBUGL_EVENTS, 0, " Event ID: %p\n", new_event);
new_event->event_type = event_type;
new_event->event_data = event_data;
new_event->event_args = event_args;
new_event->event_options = event_options;
new_event->run_time = run_time;
new_event->recurring = recurring;
new_event->event_interval = event_interval;
new_event->timing_func = timing_func;
new_event->compensate_for_time_change = compensate_for_time_change;
new_event->priority = high_priority;
}
else {
return NULL;
}
log_debug_info(DEBUGL_FUNCTIONS, 0,
"schedule_new_event()\n"
"New Event Details:\n"
" Event ID: %p\n"
" Type: EVENT_%s\n"
" High Priority: %d\n"
" Run Time: %s\n"
" Recurring: %d\n"
" Event Interval: %lu\n"
" Compensate for Time Change: %d\n"
" Event Options: %d\n",
new_event,
EVENT_TYPE_STR(event_type),
high_priority,
run_time_string,
recurring,
event_interval,
compensate_for_time_change,
event_options);
/* add the event to the event list */
add_event(nagios_squeue, new_event);
return new_event;
}
}
/* reschedule an event in order of execution time */
void reschedule_event(squeue_t *sq, timed_event *event) {
void reschedule_event(squeue_t *sq, timed_event *event)
{
time_t current_time = 0L;
time_t (*timingfunc)(void);
@ -826,84 +833,99 @@ void reschedule_event(squeue_t *sq, timed_event *event) {
/* use custom timing function */
if(event->timing_func != NULL) {
timingfunc = event->timing_func;
timingfunc = event->timing_func;
event->run_time = (*timingfunc)();
}
}
/* normal recurring events */
else {
event->run_time = event->run_time + event->event_interval;
time(&current_time);
if(event->run_time < current_time)
if(event->run_time < current_time) {
event->run_time = current_time;
}
}
}
/* add the event to the event list */
add_event(sq, event);
return;
}
}
/* add an event to list ordered by execution time */
void add_event(squeue_t *sq, timed_event *event) {
void add_event(squeue_t *sq, timed_event *event)
{
log_debug_info(DEBUGL_FUNCTIONS, 0, "add_event()\n");
if(event->sq_event) {
if (event->sq_event != NULL) {
logit(NSLOG_RUNTIME_ERROR, TRUE,
"Error: Adding %s event that seems to already be scheduled\n",
EVENT_TYPE_STR(event->event_type));
remove_event(sq, event);
}
if(event->priority) {
if (event->priority > 0) {
event->sq_event = squeue_add_usec(sq, event->run_time, event->priority - 1, event);
}
}
else {
event->sq_event = squeue_add(sq, event->run_time, event);
}
if(!event->sq_event) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Failed to add event to squeue '%p' with prio %u: %s\n",
sq, event->priority, strerror(errno));
}
}
if(sq == nagios_squeue)
if (event->sq_event == NULL) {
logit(NSLOG_RUNTIME_ERROR, TRUE,
"Error: Failed to add event to squeue '%p' with prio %u: %s\n",
sq, event->priority, strerror(errno));
}
/* this specifies + just to ensure different than `-1` visually */
if (sq == nagios_squeue) {
track_events(event->event_type, +1);
}
#ifdef USE_EVENT_BROKER
else {
/* send event data to broker */
broker_timed_event(NEBTYPE_TIMEDEVENT_ADD, NEBFLAG_NONE, NEBATTR_NONE, event, NULL);
}
}
#endif
return;
}
}
/* remove an event from the queue */
void remove_event(squeue_t *sq, timed_event *event) {
void remove_event(squeue_t *sq, timed_event *event)
{
#ifdef USE_EVENT_BROKER
/* send event data to broker */
broker_timed_event(NEBTYPE_TIMEDEVENT_REMOVE, NEBFLAG_NONE, NEBATTR_NONE, event, NULL);
#endif
if(!event || !event->sq_event)
if (event == NULL || event->sq_event == NULL) {
return;
}
if (sq)
if (sq != NULL) {
squeue_remove(sq, event->sq_event);
else
}
else {
logit(NSLOG_RUNTIME_ERROR, TRUE,
"Error: remove_event() called for %s event with NULL sq parameter\n",
EVENT_TYPE_STR(event->event_type));
"Error: remove_event() called for %s event with NULL sq parameter\n",
EVENT_TYPE_STR(event->event_type));
}
if(sq == nagios_squeue)
if (sq == nagios_squeue) {
track_events(event->event_type, -1);
}
event->sq_event = NULL; /* mark this event as unscheduled */
/* mark this event as unscheduled */
event->sq_event = NULL;
/*
* if we catch an event from the queue which gets removed when
@ -915,89 +937,122 @@ void remove_event(squeue_t *sq, timed_event *event) {
*/
if (event == current_event) {
current_event = NULL;
}
}
}
static int should_run_event(timed_event *temp_event)
{
int run_event = TRUE; /* default action is to execute the event */
/* default action is to execute the event */
int run_event = TRUE;
int nudge_seconds = 0;
/* we only care about jobs that cause processes to run */
if (temp_event->event_type != EVENT_HOST_CHECK &&
temp_event->event_type != EVENT_SERVICE_CHECK)
{
if (temp_event->event_type != EVENT_HOST_CHECK
&& temp_event->event_type != EVENT_SERVICE_CHECK) {
return TRUE;
}
/* if we can't spawn any more jobs, don't bother */
if (!wproc_can_spawn(&loadctl)) {
wproc_reap(1, 1); /* Try to reap one job for one msec. */
if (wproc_can_spawn(&loadctl) <= 0) {
/* Try to reap one job for one msec. */
wproc_reap(1, 1);
return FALSE;
}
/* run a few checks before executing a service check... */
if(temp_event->event_type == EVENT_SERVICE_CHECK) {
if (temp_event->event_type == EVENT_SERVICE_CHECK) {
service *temp_service = (service *)temp_event->event_data;
/* forced checks override normal check logic */
if((temp_service->check_options & CHECK_OPTION_FORCE_EXECUTION))
if((temp_service->check_options & CHECK_OPTION_FORCE_EXECUTION)) {
return TRUE;
}
/* don't run a service check if we're already maxed out on the number of parallel service checks... */
if(max_parallel_service_checks != 0 && (currently_running_service_checks >= max_parallel_service_checks)) {
if (max_parallel_service_checks != 0
&& currently_running_service_checks >= max_parallel_service_checks) {
nudge_seconds = ranged_urand(NUDGE_MIN, NUDGE_MAX);
logit(NSLOG_RUNTIME_WARNING, TRUE, "\tMax concurrent service checks (%d) has been reached. Nudging %s:%s by %d seconds...\n", max_parallel_service_checks, temp_service->host_name, temp_service->description, nudge_seconds);
logit(NSLOG_RUNTIME_WARNING, TRUE,
"\tMax concurrent service checks (%d) has been reached."
" Nudging %s:%s by %d seconds...\n",
max_parallel_service_checks, temp_service->host_name,
temp_service->description, nudge_seconds);
run_event = FALSE;
}
/* don't run a service check if active checks are disabled */
if(execute_service_checks == FALSE) {
log_debug_info(DEBUGL_EVENTS | DEBUGL_CHECKS, 1, "We're not executing service checks right now, so we'll skip check event for service '%s;%s'.\n", temp_service->host_name, temp_service->description);
if (execute_service_checks == FALSE) {
log_debug_info(DEBUGL_EVENTS | DEBUGL_CHECKS, 1,
"We're not executing service checks right now, so we'll skip check event for service '%s;%s'.\n",
temp_service->host_name, temp_service->description);
run_event = FALSE;
}
/* reschedule the check if we can't run it now */
if(run_event == FALSE) {
if (run_event == FALSE) {
remove_event(nagios_squeue, temp_event);
if(nudge_seconds) {
/* We nudge the next check time when it is due to too many concurrent service checks */
/* We nudge the next check time when it is
due to too many concurrent service checks */
if (nudge_seconds) {
temp_service->next_check = (time_t)(temp_service->next_check + nudge_seconds);
}
/* Otherwise just schedule as normal */
else {
temp_service->next_check += check_window(temp_service);
}
temp_event->run_time = temp_service->next_check;
reschedule_event(nagios_squeue, temp_event);
update_service_status(temp_service, FALSE);
run_event = FALSE;
}
}
/* run a few checks before executing a host check... */
else if(temp_event->event_type == EVENT_HOST_CHECK) {
else if (temp_event->event_type == EVENT_HOST_CHECK) {
host *temp_host = (host *)temp_event->event_data;
/* forced checks override normal check logic */
if((temp_host->check_options & CHECK_OPTION_FORCE_EXECUTION))
if ((temp_host->check_options & CHECK_OPTION_FORCE_EXECUTION)) {
return TRUE;
}
/* don't run a host check if active checks are disabled */
if(execute_host_checks == FALSE) {
log_debug_info(DEBUGL_EVENTS | DEBUGL_CHECKS, 1, "We're not executing host checks right now, so we'll skip host check event for host '%s'.\n", temp_host->name);
if (execute_host_checks == FALSE) {
log_debug_info(DEBUGL_EVENTS | DEBUGL_CHECKS, 1,
"We're not executing host checks right now, so we'll skip host check event for host '%s'.\n",
temp_host->name);
run_event = FALSE;
}
/* reschedule the host check if we can't run it right now */
if(run_event == FALSE) {
if (run_event == FALSE) {
remove_event(nagios_squeue, temp_event);
temp_host->next_check += check_window(temp_host);
temp_event->run_time = temp_host->next_check;
reschedule_event(nagios_squeue, temp_event);
update_host_status(temp_host, FALSE);
run_event = FALSE;
}
}

View File

@ -308,10 +308,12 @@ void set_service_flap(service *svc, double percent_change, double high_threshold
/* log a notice - this one is parsed by the history CGI */
logit(NSLOG_RUNTIME_WARNING, FALSE, "SERVICE FLAPPING ALERT: %s;%s;STARTED; Service appears to have started flapping (%2.1f%% change >= %2.1f%% threshold)\n", svc->host_name, svc->description, percent_change, high_threshold);
/* add a non-persistent comment to the service */
asprintf(&temp_buffer, "Notifications for this service are being suppressed because it was detected as having been flapping between different states (%2.1f%% change >= %2.1f%% threshold). When the service state stabilizes and the flapping stops, notifications will be re-enabled.", percent_change, high_threshold);
add_new_service_comment(FLAPPING_COMMENT, svc->host_name, svc->description, time(NULL), "(Nagios Process)", temp_buffer, 0, COMMENTSOURCE_INTERNAL, FALSE, (time_t)0, &(svc->flapping_comment_id));
my_free(temp_buffer);
if (svc->flapping_comment_id == 0) {
/* add a non-persistent comment to the service */
asprintf(&temp_buffer, "Notifications for this service are being suppressed because it was detected as having been flapping between different states (%2.1f%% change >= %2.1f%% threshold). When the service state stabilizes and the flapping stops, notifications will be re-enabled.", percent_change, high_threshold);
add_new_service_comment(FLAPPING_COMMENT, svc->host_name, svc->description, time(NULL), "(Nagios Process)", temp_buffer, 0, COMMENTSOURCE_INTERNAL, FALSE, (time_t)0, &(svc->flapping_comment_id));
my_free(temp_buffer);
}
/* set the flapping indicator */
svc->is_flapping = TRUE;
@ -396,10 +398,12 @@ void set_host_flap(host *hst, double percent_change, double high_threshold, doub
/* log a notice - this one is parsed by the history CGI */
logit(NSLOG_RUNTIME_WARNING, FALSE, "HOST FLAPPING ALERT: %s;STARTED; Host appears to have started flapping (%2.1f%% change > %2.1f%% threshold)\n", hst->name, percent_change, high_threshold);
/* add a non-persistent comment to the host */
asprintf(&temp_buffer, "Notifications for this host are being suppressed because it was detected as having been flapping between different states (%2.1f%% change > %2.1f%% threshold). When the host state stabilizes and the flapping stops, notifications will be re-enabled.", percent_change, high_threshold);
add_new_host_comment(FLAPPING_COMMENT, hst->name, time(NULL), "(Nagios Process)", temp_buffer, 0, COMMENTSOURCE_INTERNAL, FALSE, (time_t)0, &(hst->flapping_comment_id));
my_free(temp_buffer);
if (hst->flapping_comment_id == 0) {
/* add a non-persistent comment to the host */
asprintf(&temp_buffer, "Notifications for this host are being suppressed because it was detected as having been flapping between different states (%2.1f%% change > %2.1f%% threshold). When the host state stabilizes and the flapping stops, notifications will be re-enabled.", percent_change, high_threshold);
add_new_host_comment(FLAPPING_COMMENT, hst->name, time(NULL), "(Nagios Process)", temp_buffer, 0, COMMENTSOURCE_INTERNAL, FALSE, (time_t)0, &(hst->flapping_comment_id));
my_free(temp_buffer);
}
/* set the flapping indicator */
hst->is_flapping = TRUE;

View File

@ -180,6 +180,8 @@ static int nagios_core_worker(const char *path)
}
enter_worker(sd, start_cmd);
free_worker_memory(WPROC_FORCE);
free_memory(get_global_macros());
return 0;
}
@ -345,6 +347,7 @@ int main(int argc, char **argv) {
printf("along with this program; if not, write to the Free Software\n");
printf("Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n");
cleanup();
exit(OK);
}
@ -374,6 +377,7 @@ int main(int argc, char **argv) {
printf("the mailing lists, and commercial support options for Nagios.\n");
printf("\n");
cleanup();
exit(ERROR);
}
@ -384,7 +388,10 @@ int main(int argc, char **argv) {
*/
config_file = nspath_absolute(argv[optind], NULL);
if(config_file == NULL) {
printf("Error allocating memory.\n");
cleanup();
exit(ERROR);
}
@ -426,6 +433,7 @@ int main(int argc, char **argv) {
result = read_main_config_file(config_file);
if(result != OK) {
printf(" Error processing main config file!\n\n");
cleanup();
exit(EXIT_FAILURE);
}
@ -435,6 +443,7 @@ int main(int argc, char **argv) {
/* drop privileges */
if((result = drop_privileges(nagios_user, nagios_group)) == ERROR) {
printf(" Failed to drop privileges. Aborting.");
cleanup();
exit(EXIT_FAILURE);
}
@ -444,6 +453,7 @@ int main(int argc, char **argv) {
*/
if (!verify_config && test_configured_paths() == ERROR) {
printf(" One or more path problems detected. Aborting.\n");
cleanup();
exit(EXIT_FAILURE);
}
@ -468,6 +478,7 @@ int main(int argc, char **argv) {
printf(" may have been removed or modified in this version. Make sure to read\n");
printf(" the HTML documentation regarding the config files, as well as the\n");
printf(" 'Whats New' section to find out what has changed.\n\n");
cleanup();
exit(EXIT_FAILURE);
}
@ -488,6 +499,7 @@ int main(int argc, char **argv) {
printf(" may have been removed or modified in this version. Make sure to read\n");
printf(" the HTML documentation regarding the config files, as well as the\n");
printf(" 'Whats New' section to find out what has changed.\n\n");
cleanup();
exit(EXIT_FAILURE);
}
@ -534,8 +546,9 @@ int main(int argc, char **argv) {
/* make valgrind shut up about still reachable memory */
neb_free_module_list();
free(config_file_dir);
free(config_file);
cleanup();
my_free(config_file);
my_free(config_file_dir);
exit(result);
}
@ -556,17 +569,20 @@ int main(int argc, char **argv) {
if (!nagios_binary_path) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Unable to allocate memory for nagios_binary_path\n");
cleanup();
exit(EXIT_FAILURE);
}
if (!(nagios_iobs = iobroker_create())) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Failed to create IO broker set: %s\n",
strerror(errno));
cleanup();
exit(EXIT_FAILURE);
}
/* keep monitoring things until we get a shutdown command */
do {
/* reset internal book-keeping (in case we're restarting) */
wproc_num_workers_spawned = wproc_num_workers_online = 0;
caught_signal = sigshutdown = FALSE;
@ -583,6 +599,7 @@ int main(int argc, char **argv) {
result = read_main_config_file(config_file);
if (result != OK) {
logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Failed to process config file '%s'. Aborting\n", config_file);
cleanup();
exit(EXIT_FAILURE);
}
timing_point("Main config file read\n");
@ -592,7 +609,7 @@ int main(int argc, char **argv) {
program_start = time(NULL);
my_free(mac->x[MACRO_PROCESSSTARTTIME]);
asprintf(&mac->x[MACRO_PROCESSSTARTTIME], "%llu", (unsigned long long)program_start);
/* enter daemon mode (unless we're restarting...) */
if(daemon_mode == TRUE && sigrestart == FALSE) {
@ -621,11 +638,13 @@ int main(int argc, char **argv) {
if (test_path_access(nagios_binary_path, X_OK)) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: failed to access() %s: %s\n", nagios_binary_path, strerror(errno));
logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Spawning workers will be impossible. Aborting.\n");
cleanup();
exit(EXIT_FAILURE);
}
if (test_configured_paths() == ERROR) {
/* error has already been logged */
cleanup();
exit(EXIT_FAILURE);
}
@ -664,8 +683,11 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
timing_point("Query handler initialized\n");
#ifdef ENABLE_NERD
nerd_init();
timing_point("NERD initialized\n");
#endif
/* initialize check workers */
if(init_workers(num_check_workers) < 0) {
@ -690,6 +712,7 @@ int main(int argc, char **argv) {
/* if we're dumping core, we must remove all dl-files */
if (daemon_dumps_core)
neb_unload_all_modules(NEBMODULE_FORCE_UNLOAD, NEBMODULE_NEB_SHUTDOWN);
cleanup();
exit(EXIT_FAILURE);
}
timing_point("Modules loaded\n");
@ -733,6 +756,14 @@ int main(int argc, char **argv) {
}
timing_point("Object configuration parsed and understood\n");
#ifdef DETECT_RLIMIT_PROBLEM
/* lets do a quick system limit detection
to determine if we're likely to run into any
problems. */
rlimit_problem_detection(num_check_workers);
timing_point("Limit detection");
#endif
/* write the objects.cache file */
fcache_objects(object_cache_file);
@ -747,7 +778,7 @@ int main(int argc, char **argv) {
broker_program_state(NEBTYPE_PROCESS_START, NEBFLAG_NONE, NEBATTR_NONE, NULL);
#endif
/* initialize status data unless we're starting */
/* initialize status data only if we're starting (no restarts) */
if(sigrestart == FALSE) {
initialize_status_data(config_file);
timing_point("Status data initialized\n");
@ -821,7 +852,7 @@ int main(int argc, char **argv) {
qh_deinit(qh_socket_path ? qh_socket_path : DEFAULT_QUERY_SOCKET);
/* 03/01/2007 EG Moved from sighandler() to prevent FUTEX locking problems under NPTL */
/* 03/21/2007 EG SIGSEGV signals are still logged in sighandler() so we don't loose them */
/* 03/21/2007 EG SIGSEGV signals are still logged in sighandler() so we don't lose them */
/* did we catch a signal? */
if(caught_signal == TRUE) {
@ -849,7 +880,10 @@ int main(int argc, char **argv) {
/* clean up the scheduled downtime data */
cleanup_downtime_data();
/* clean up the status data unless we're restarting */
/* clean up comment data */
free_comment_data();
/* clean up the status data if we are not restarting */
if(sigrestart == FALSE) {
cleanup_status_data(TRUE);
}
@ -857,6 +891,7 @@ int main(int argc, char **argv) {
free_worker_memory(WPROC_FORCE);
/* shutdown stuff... */
if(sigshutdown == TRUE) {
shutdown_command_file_worker();
iobroker_destroy(nagios_iobs, IOBROKER_CLOSE_SOCKETS);
nagios_iobs = NULL;
@ -864,8 +899,22 @@ int main(int argc, char **argv) {
logit(NSLOG_PROCESS_INFO, TRUE, "Successfully shutdown... (PID=%d)\n", (int)getpid());
}
/* clean up after ourselves */
cleanup();
/* try and collect any zombie processes */
if (sigrestart == TRUE) {
int status = 0;
pid_t child_pid;
log_debug_info(DEBUGL_PROCESS, 1, "Calling waitpid() on all children...\n");
while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0) {
log_debug_info(DEBUGL_PROCESS, 2, " * child PID: (%d), status: (%d)\n", child_pid, status);
}
log_debug_info(DEBUGL_PROCESS, 1, "All children have been wait()ed on\n");
cleanup();
}
/* close debug log */
close_debug_log();
@ -877,6 +926,7 @@ int main(int argc, char **argv) {
unlink(lock_file);
/* free misc memory */
cleanup();
my_free(lock_file);
my_free(config_file);
my_free(config_file_dir);

View File

@ -1,3 +1,4 @@
#ifdef ENABLE_NERD
/*
* Nagios Event Radio Dispatcher
*
@ -7,6 +8,10 @@
*
* This code uses the eventbroker api to get its data, which means
* we're finally eating our own dogfood in that respect.
*
* Note: Disabled by default as of 4.4.0
* ./configure --enable-nerd
* to enable!
*/
#define _GNU_SOURCE 1
@ -493,3 +498,5 @@ int nerd_init(void)
logit(NSLOG_INFO_MESSAGE, TRUE, "nerd: Fully initialized and ready to rock!\n");
return 0;
}
#endif

View File

@ -54,7 +54,7 @@ const char *notification_reason_name(unsigned int reason_type)
"CUSTOM"
};
if (reason_type < sizeof(names))
if (reason_type < ARRAY_SIZE(names))
return names[reason_type];
return "(unknown)";
@ -106,7 +106,7 @@ int service_notification(service *svc, int type, char *not_author, char *not_dat
if (temp_host->scheduled_downtime_depth > 0 || svc->scheduled_downtime_depth > 0)
svc->next_notification = current_time;
}
return OK;
return ERROR;
}
log_debug_info(DEBUGL_NOTIFICATIONS, 0, "Notification viability test passed.\n");
@ -222,7 +222,7 @@ int service_notification(service *svc, int type, char *not_author, char *not_dat
/* set the notification number macro */
asprintf(&mac.x[MACRO_SERVICENOTIFICATIONNUMBER], "%d", svc->current_notification_number);
/* the $NOTIFICATIONNUMBER$ macro is maintained for backward compatability */
/* the $NOTIFICATIONNUMBER$ macro is maintained for backward compatibility */
mac.x[MACRO_NOTIFICATIONNUMBER] = strdup(mac.x[MACRO_SERVICENOTIFICATIONNUMBER]);
/* set the notification id macro */
@ -342,7 +342,6 @@ int check_service_notification_viability(service *svc, int type, int options) {
timeperiod *temp_period;
time_t current_time;
time_t timeperiod_start;
time_t first_problem_time;
log_debug_info(DEBUGL_FUNCTIONS, 0, "check_service_notification_viability()\n");
@ -547,15 +546,20 @@ int check_service_notification_viability(service *svc, int type, int options) {
/* see if enough time has elapsed for first notification (Mathias Sundman) */
/* 10/02/07 don't place restrictions on recoveries or non-normal notifications, must use last time ok (or program start) in calculation */
/* it is reasonable to assume that if the service was never up, the program start time should be used in this calculation */
if(type == NOTIFICATION_NORMAL && svc->current_notification_number == 0 && svc->current_state != STATE_OK) {
/* check if delay of notifications is activated (ccztux) */
if(type == NOTIFICATION_NORMAL
&& svc->first_notification_delay > 0
&& svc->current_notification_number == 0
&& svc->current_state != STATE_OK)
{
time_t last_problem_time = svc->last_hard_state_change > 0 ? svc->last_hard_state_change : program_start;
first_problem_time = svc->last_time_ok > 0 ? svc->last_time_ok : program_start;
if(current_time < first_problem_time + (time_t)(svc->first_notification_delay * interval_length)) {
/* determine the time to use of the last problem point */
if(current_time < last_problem_time + (time_t)(svc->first_notification_delay * interval_length)) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "Not enough time has elapsed since the service changed to a non-OK state, so we should not notify about this problem yet\n");
return ERROR;
}
}
}
/* if this service is currently flapping, don't send the notification */
if(svc->is_flapping == TRUE) {
@ -563,29 +567,6 @@ int check_service_notification_viability(service *svc, int type, int options) {
return ERROR;
}
/***** RECOVERY NOTIFICATIONS ARE GOOD TO GO AT THIS POINT *****/
if(svc->current_state == STATE_OK)
return OK;
/* don't notify contacts about this service problem again if the notification interval is set to 0 */
if(svc->no_more_notifications == TRUE) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "We shouldn't re-notify contacts about this service problem.\n");
return ERROR;
}
/* if the host is down or unreachable, don't notify contacts about service failures */
if(temp_host->current_state != STATE_UP && temp_host->state_type == HARD_STATE) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "The host is either down or unreachable, so we won't notify contacts about this service.\n");
return ERROR;
}
/* don't notify if we haven't waited long enough since the last time (and the service is not marked as being volatile) */
if((current_time < svc->next_notification) && svc->is_volatile == FALSE) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "We haven't waited long enough to re-notify contacts about this service.\n");
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "Next valid notification time: %s", ctime(&svc->next_notification));
return ERROR;
}
/* if this service is currently in a scheduled downtime period, don't send the notification */
if(svc->scheduled_downtime_depth > 0) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "This service is currently in a scheduled downtime, so we won't send notifications.\n");
@ -610,6 +591,25 @@ int check_service_notification_viability(service *svc, int type, int options) {
return ERROR;
}
/* don't notify contacts about this service problem again if the notification interval is set to 0 */
if(svc->no_more_notifications == TRUE) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "We shouldn't re-notify contacts about this service problem.\n");
return ERROR;
}
/* if the host is down or unreachable, don't notify contacts about service failures */
if(temp_host->current_state != STATE_UP && temp_host->state_type == HARD_STATE) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "The host is either down or unreachable, so we won't notify contacts about this service.\n");
return ERROR;
}
/* don't notify if we haven't waited long enough since the last time (and the service is not marked as being volatile) */
if((current_time < svc->next_notification) && svc->is_volatile == FALSE) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "We haven't waited long enough to re-notify contacts about this service.\n");
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "Next valid notification time: %s", ctime(&svc->next_notification));
return ERROR;
}
return OK;
}
@ -1066,7 +1066,7 @@ int host_notification(host *hst, int type, char *not_author, char *not_data, int
/* check viability of sending out a host notification */
if(check_host_notification_viability(hst, type, options) == ERROR) {
log_debug_info(DEBUGL_NOTIFICATIONS, 0, "Notification viability test failed. No notification will be sent out.\n");
return OK;
return ERROR;
}
log_debug_info(DEBUGL_NOTIFICATIONS, 0, "Notification viability test passed.\n");
@ -1179,7 +1179,7 @@ int host_notification(host *hst, int type, char *not_author, char *not_data, int
/* set the notification number macro */
asprintf(&mac.x[MACRO_HOSTNOTIFICATIONNUMBER], "%d", hst->current_notification_number);
/* the $NOTIFICATIONNUMBER$ macro is maintained for backward compatability */
/* the $NOTIFICATIONNUMBER$ macro is maintained for backward compatibility */
mac.x[MACRO_NOTIFICATIONNUMBER] = strdup(mac.x[MACRO_HOSTNOTIFICATIONNUMBER]);
/* set the notification id macro */
@ -1296,7 +1296,6 @@ int host_notification(host *hst, int type, char *not_author, char *not_data, int
int check_host_notification_viability(host *hst, int type, int options) {
time_t current_time;
time_t timeperiod_start;
time_t first_problem_time;
log_debug_info(DEBUGL_FUNCTIONS, 0, "check_host_notification_viability()\n");
@ -1470,15 +1469,21 @@ int check_host_notification_viability(host *hst, int type, int options) {
/* see if enough time has elapsed for first notification (Mathias Sundman) */
/* 10/02/07 don't place restrictions on recoveries or non-normal notifications, must use last time up (or program start) in calculation */
/* it is reasonable to assume that if the host was never up, the program start time should be used in this calculation */
if(type == NOTIFICATION_NORMAL && hst->current_notification_number == 0 && hst->current_state != HOST_UP) {
/* check if delay of notifications is activated (ccztux) */
if(type == NOTIFICATION_NORMAL
&& hst->first_notification_delay > 0
&& hst->current_notification_number == 0
&& hst->current_state != STATE_OK)
{
first_problem_time = hst->last_time_up > 0 ? hst->last_time_up : program_start;
time_t last_problem_time = hst->last_hard_state_change > 0 ? hst->last_hard_state_change : program_start;
if(current_time < first_problem_time + (time_t)(hst->first_notification_delay * interval_length)) {
/* determine the time to use of the last problem point */
if(current_time < last_problem_time + (time_t)(hst->first_notification_delay * interval_length)) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "Not enough time has elapsed since the host changed to a non-UP state (or since program start), so we shouldn't notify about this problem yet.\n");
return ERROR;
}
}
}
}
/* if this host is currently flapping, don't send the notification */
if(hst->is_flapping == TRUE) {
@ -1486,10 +1491,6 @@ int check_host_notification_viability(host *hst, int type, int options) {
return ERROR;
}
/***** RECOVERY NOTIFICATIONS ARE GOOD TO GO AT THIS POINT *****/
if(hst->current_state == HOST_UP)
return OK;
/* if this host is currently in a scheduled downtime period, don't send the notification */
if(hst->scheduled_downtime_depth > 0) {
log_debug_info(DEBUGL_NOTIFICATIONS, 1, "This host is currently in a scheduled downtime, so we won't send notifications.\n");

View File

@ -24,12 +24,20 @@ static dkhash_table *qh_table;
/* the echo service. stupid, but useful for testing */
static int qh_echo(int sd, char *buf, unsigned int len)
{
if (!strcmp(buf, "help")) {
int result = 0;
if (buf == NULL || !strcmp(buf, "help")) {
nsock_printf_nul(sd,
"Query handler that simply echoes back what you send it.");
return 0;
}
(void)write(sd, buf, len);
result = write(sd, buf, len);
if (result == -1) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: qh_echo() error on write(sd,buf=[%s],len=%d): %s\n", buf, len, strerror(errno));
}
return 0;
}
@ -41,22 +49,28 @@ static struct query_handler *qh_find_handler(const char *name)
/* subset of http error codes */
const char *qh_strerror(int code)
{
if (code < 0)
if (code < 0) {
return "Low-level system error";
}
if (code == 100)
if (code == 100) {
return "Continue";
if (code == 101)
}
if (code == 101) {
return "Switching protocols";
}
if (code < 300)
if (code < 300) {
return "OK";
}
if (code < 400)
if (code < 400) {
return "Redirected (possibly deprecated address)";
}
switch (code) {
/* client errors */
/* client errors */
case 400: return "Bad request";
case 401: return "Unauthorized";
case 403: return "Forbidden (disabled by config)";
@ -72,36 +86,48 @@ const char *qh_strerror(int code)
case 413: return "Request too large";
case 414: return "Request-URI too long";
/* server errors */
/* server errors */
case 500: return "Internal server error";
case 501: return "Not implemented";
case 502: return "Bad gateway";
case 503: return "Service unavailable";
case 504: return "Gateway timeout";
case 505: return "Version not supported";
}
return "Unknown error";
}
static int qh_input(int sd, int events, void *ioc_)
{
iocache *ioc = (iocache *)ioc_;
iocache * ioc = (iocache *) ioc_;
int result = 0;
/*
input on main socket, so accept one
this is when a worker initially connects
we create the iocache and then register
that to a new socket descriptor and this function
so that ioc_ != NULL next time
*/
if (sd == qh_listen_sock) {
/* input on main socket, so accept one */
if(sd == qh_listen_sock) {
struct sockaddr sa;
socklen_t slen = 0;
int nsd;
int nsd = 0;
memset(&sa, 0, sizeof(sa)); /* shut valgrind up */
/* shut valgrind up */
memset(&sa, 0, sizeof(sa));
nsd = accept(sd, &sa, &slen);
if(qh_max_running && qh_running >= qh_max_running) {
if (qh_max_running && qh_running >= qh_max_running) {
nsock_printf(nsd, "503: Server full");
close(nsd);
return 0;
}
if(!(ioc = iocache_create(16384))) {
ioc = iocache_create(16384);
if (ioc == NULL) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: Failed to create iocache for inbound request\n");
nsock_printf(nsd, "500: Internal server error");
close(nsd);
@ -112,7 +138,8 @@ static int qh_input(int sd, int events, void *ioc_)
* @todo: Stash the iocache and the socket in some
* addressable list so we can release them on deinit
*/
if(iobroker_register(nagios_iobs, nsd, ioc, qh_input) < 0) {
result = iobroker_register(nagios_iobs, nsd, ioc, qh_input);
if (result < 0) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: Failed to register input socket %d with I/O broker: %s\n", nsd, strerror(errno));
iocache_destroy(ioc);
close(nsd);
@ -124,17 +151,26 @@ static int qh_input(int sd, int events, void *ioc_)
qh_running++;
return 0;
}
/*
this is when an existing connection
sends more data after they've already made
the connection
*/
else {
int result;
unsigned long len;
unsigned int query_len = 0;
char *buf, *space;
struct query_handler *qh;
char *handler = NULL, *query = NULL;
unsigned long len = 0;
unsigned int query_len = 0;
struct query_handler * qh = NULL;
char * buf = NULL;
char * space = NULL;
char * handler = NULL;
char * query = NULL;
result = iocache_read(ioc, sd);
/* disconnect? */
if(result == 0 || (result < 0 && errno == EPIPE)) {
if (result == 0 || (result < 0 && errno == EPIPE)) {
iocache_destroy(ioc);
iobroker_close(nagios_iobs, sd);
qh_running--;
@ -152,8 +188,9 @@ static int qh_input(int sd, int events, void *ioc_)
/* Use data up to the first nul byte */
buf = iocache_use_delim(ioc, "\0", 1, &len);
if(!buf)
if (buf == NULL) {
return 0;
}
/* Identify handler part and any magic query bytes */
if (*buf == '@' || *buf == '#') {
@ -161,18 +198,18 @@ static int qh_input(int sd, int events, void *ioc_)
}
/* Locate query (if any) */
if((space = strchr(buf, ' '))) {
space = strchr(buf, ' ');
if (space != NULL) {
*space = 0;
query = space + 1;
query_len = len - ((unsigned long)query - (unsigned long)buf);
} else {
query = "";
query_len = 0;
query_len = len - (unsigned long)(query - buf);
}
/* locate the handler */
if(!(qh = qh_find_handler(handler))) {
/* not found. that's a 404 */
qh = qh_find_handler(handler);
/* not found. that's a 404 */
if (qh == NULL) {
nsock_printf(sd, "404: %s: No such handler", handler);
iobroker_close(nagios_iobs, sd);
iocache_destroy(ioc);
@ -180,16 +217,20 @@ static int qh_input(int sd, int events, void *ioc_)
}
/* strip trailing newlines */
while (query_len > 0 && (query[query_len - 1] == 0 || query[query_len - 1] == '\n'))
query[--query_len] = 0;
while (query_len > 0
&& (query[query_len - 1] == 0 || query[query_len - 1] == '\n')) {
query[--query_len] = 0;
}
/* now pass the query to the handler */
if ((result = qh->handler(sd, query, query_len)) >= 100) {
result = qh->handler(sd, query, query_len);
if (result >= 100) {
nsock_printf_nul(sd, "%d: %s", result, qh_strerror(result));
}
if(result >= 300 || *buf == '#') {
/* error code or one-shot query */
/* error code or one-shot query */
if (result >= 300 || *buf == '#') {
iobroker_close(nagios_iobs, sd);
iocache_destroy(ioc);
return 0;
@ -197,34 +238,53 @@ static int qh_input(int sd, int events, void *ioc_)
/* check for magic handler codes */
switch (result) {
case QH_CLOSE: /* oneshot handler */
case -1: /* general error */
/* oneshot handler */
case QH_CLOSE:
/* general error */
case -1:
iobroker_close(nagios_iobs, sd);
/* fallthrough */
case QH_TAKEOVER: /* handler takes over */
case 101: /* switch protocol (takeover + message) */
/* fallthrough */
/* handler takes over */
case QH_TAKEOVER:
/* switch protocol (takeover + message) */
case 101:
iocache_destroy(ioc);
break;
}
}
return 0;
}
int qh_deregister_handler(const char *name)
{
struct query_handler *qh, *next, *prev;
struct query_handler *qh = NULL;
struct query_handler *next = NULL;
struct query_handler *prev = NULL;
if (!(qh = dkhash_remove(qh_table, name, NULL)))
qh = dkhash_remove(qh_table, name, NULL);
if (qh != NULL) {
return 0;
}
next = qh->next_qh;
prev = qh->prev_qh;
if (next)
if (next != NULL) {
next->prev_qh = prev;
if (prev)
}
if (prev != NULL) {
prev->next_qh = next;
else
}
else {
qhandlers = next;
}
free(qh);
@ -233,44 +293,50 @@ int qh_deregister_handler(const char *name)
int qh_register_handler(const char *name, const char *description, unsigned int options, qh_handler handler)
{
struct query_handler *qh;
int result;
struct query_handler *qh = NULL;
int result = 0;
if(!name)
if (name == NULL) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: Failed to register handler with no name\n");
return -1;
}
if(!handler) {
if (handler == NULL) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: Failed to register handler '%s': No handler function specified\n", name);
return -1;
}
if(strlen(name) > 128) {
if (strlen(name) > 128) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: Failed to register handler '%s': Name too long\n", name);
return -ENAMETOOLONG;
}
/* names must be unique */
if(qh_find_handler(name)) {
if (qh_find_handler(name)) {
logit(NSLOG_RUNTIME_WARNING, TRUE, "qh: Handler '%s' registered more than once\n", name);
return -1;
}
if (!(qh = calloc(1, sizeof(*qh)))) {
qh = calloc(1, sizeof(*qh));
if (qh == NULL) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: Failed to allocate memory for handler '%s'\n", name);
return -errno;
}
qh->name = name;
qh->description = description;
qh->handler = handler;
qh->options = options;
qh->next_qh = qhandlers;
if (qhandlers)
qh->name = name;
qh->description = description;
qh->handler = handler;
qh->options = options;
qh->next_qh = qhandlers;
if (qhandlers) {
qhandlers->prev_qh = qh;
qhandlers = qh;
}
qhandlers = qh;
result = dkhash_insert(qh_table, qh->name, NULL, qh);
if(result < 0) {
if (result < 0) {
logit(NSLOG_RUNTIME_ERROR, TRUE,
"qh: Failed to insert query handler '%s' (%p) into hash table %p (%d): %s\n",
name, qh, qh_table, result, strerror(errno));
@ -283,27 +349,29 @@ int qh_register_handler(const char *name, const char *description, unsigned int
void qh_deinit(const char *path)
{
struct query_handler *qh, *next;
struct query_handler *qh = NULL;
for (qh = qhandlers; qh != NULL; qh = qh->next_qh) {
for(qh = qhandlers; qh; qh = next) {
next = qh->next_qh;
qh_deregister_handler(qh->name);
}
dkhash_destroy(qh_table);
qh_table = NULL;
qhandlers = NULL;
if(!path)
if (path == NULL) {
return;
}
unlink(path);
}
static int qh_help(int sd, char *buf, unsigned int len)
{
struct query_handler *qh;
struct query_handler *qh = NULL;
if (!*buf || !strcmp(buf, "help")) {
if (buf == NULL || !strcmp(buf, "help")) {
nsock_printf_nul(sd,
" help <name> show help for handler <name>\n"
" help list list registered handlers\n");
@ -311,16 +379,22 @@ static int qh_help(int sd, char *buf, unsigned int len)
}
if (!strcmp(buf, "list")) {
for (qh = qhandlers; qh; qh = qh->next_qh) {
for (qh = qhandlers; qh != NULL; qh = qh->next_qh) {
nsock_printf(sd, "%-10s %s\n", qh->name, qh->description ? qh->description : "(No description available)");
}
nsock_printf(sd, "%c", 0);
return 0;
}
if (!(qh = qh_find_handler(buf))) {
qh = qh_find_handler(buf);
if (qh == NULL) {
nsock_printf_nul(sd, "No handler named '%s' is registered\n", buf);
} else if (qh->handler(sd, "help", 4) > 200) {
nsock_printf_nul(sd, "The handler %s doesn't have any help yet.", buf);
}
@ -331,8 +405,10 @@ static int qh_core(int sd, char *buf, unsigned int len)
{
char *space;
if (!*buf || !strcmp(buf, "help")) {
nsock_printf_nul(sd, "Query handler for manipulating nagios core.\n"
if (buf == NULL || !strcmp(buf, "help")) {
nsock_printf_nul(sd,
"Query handler for manipulating nagios core.\n"
"Available commands:\n"
" loadctl Print information about current load control settings\n"
" loadctl <options> Configure nagios load control.\n"
@ -340,13 +416,21 @@ static int qh_core(int sd, char *buf, unsigned int len)
" returned above.\n"
" squeuestats scheduling queue statistics\n"
);
return 0;
}
if ((space = memchr(buf, ' ', len)))
space = memchr(buf, ' ', len);
if (space != NULL) {
*(space++) = 0;
if (!space && !strcmp(buf, "loadctl")) {
nsock_printf_nul
(sd, "jobs_max=%u;jobs_min=%u;"
}
if (space == NULL) {
if (!strcmp(buf, "loadctl")) {
nsock_printf_nul(sd,
"jobs_max=%u;jobs_min=%u;"
"jobs_running=%u;jobs_limit=%u;"
"load=%.2f;"
"backoff_limit=%.2f;backoff_change=%u;"
@ -359,15 +443,23 @@ static int qh_core(int sd, char *buf, unsigned int len)
loadctl.backoff_limit, loadctl.backoff_change,
loadctl.rampup_limit, loadctl.rampup_change,
loadctl.nproc_limit, loadctl.nofile_limit,
loadctl.options, loadctl.changes);
return 0;
loadctl.options, loadctl.changes
);
return 0;
}
else if (!strcmp(buf, "squeuestats")) {
return dump_event_stats(sd);
}
}
if (!space && !strcmp(buf, "squeuestats"))
return dump_event_stats(sd);
/* space != NULL: */
else {
len -= (unsigned long)(space - buf);
if (space) {
len -= (unsigned long)space - (unsigned long)buf;
if (!strcmp(buf, "loadctl")) {
return set_loadctl_options(space, len) == OK ? 200 : 400;
}
@ -379,12 +471,15 @@ static int qh_core(int sd, char *buf, unsigned int len)
int qh_init(const char *path)
{
int result, old_umask;
int result = 0;
int old_umask = 0;
if(qh_listen_sock >= 0)
if (qh_listen_sock >= 0) {
iobroker_close(nagios_iobs, qh_listen_sock);
}
if (path == NULL) {
if(!path) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: query_socket is NULL. What voodoo is this?\n");
return ERROR;
}
@ -393,17 +488,25 @@ int qh_init(const char *path)
errno = 0;
qh_listen_sock = nsock_unix(path, NSOCK_TCP | NSOCK_UNLINK);
umask(old_umask);
if(qh_listen_sock < 0) {
if (qh_listen_sock < 0) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: Failed to init socket '%s'. %s: %s\n",
path, nsock_strerror(qh_listen_sock), strerror(errno));
return ERROR;
}
/* plugins shouldn't have this socket */
(void)fcntl(qh_listen_sock, F_SETFD, FD_CLOEXEC);
result = fcntl(qh_listen_sock, F_SETFD, FD_CLOEXEC);
if (result == -1) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: Failed to fcntl() query handler socket\n");
}
/* most likely overkill, but it's small, so... */
if(!(qh_table = dkhash_create(1024))) {
qh_table = dkhash_create(1024);
if (qh_table == NULL) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: Failed to create hash table\n");
close(qh_listen_sock);
return ERROR;
@ -411,7 +514,8 @@ int qh_init(const char *path)
errno = 0;
result = iobroker_register(nagios_iobs, qh_listen_sock, NULL, qh_input);
if(result < 0) {
if (result < 0) {
dkhash_destroy(qh_table);
close(qh_listen_sock);
logit(NSLOG_RUNTIME_ERROR, TRUE, "qh: Failed to register socket with io broker: %s; errno=%d: %s\n", iobroker_strerror(result), errno, strerror(errno));
@ -421,10 +525,20 @@ int qh_init(const char *path)
logit(NSLOG_INFO_MESSAGE, FALSE, "qh: Socket '%s' successfully initialized\n", path);
/* now register our the in-core handlers */
if(!qh_register_handler("core", "Nagios Core control and info", 0, qh_core))
result = qh_register_handler("core", "Nagios Core control and info", 0, qh_core);
if (result == OK) {
logit(NSLOG_INFO_MESSAGE, FALSE, "qh: core query handler registered\n");
qh_register_handler("echo", "The Echo Service - What You Put Is What You Get", 0, qh_echo);
qh_register_handler("help", "Help for the query handler", 0, qh_help);
}
result = qh_register_handler("echo", "The Echo Service - What You Put Is What You Get", 0, qh_echo);
if (result == OK) {
logit(NSLOG_INFO_MESSAGE, FALSE, "qh: echo service query handler registered\n");
}
result = qh_register_handler("help", "Help for the query handler", 0, qh_help);
if (result == OK) {
logit(NSLOG_INFO_MESSAGE, FALSE, "qh: help for the query handler registered\n");
}
return 0;
}

View File

@ -25,14 +25,22 @@
#include "../include/objects.h"
#include "../include/statusdata.h"
#include "../include/comments.h"
#include "../include/downtime.h"
#include "../include/macros.h"
#include "../include/nagios.h"
#include "../include/netutils.h"
#include "../include/perfdata.h"
#include "../include/broker.h"
#include "../include/nebmods.h"
#include "../include/nebmodules.h"
#include "../include/workers.h"
#include "../xdata/xodtemplate.h"
#include <sys/time.h>
#include <sys/resource.h>
/* global variables only used by the daemon */
char *nagios_binary_path = NULL;
char *config_file = NULL;
@ -194,6 +202,10 @@ char *website_url;
int allow_empty_hostgroup_assignment;
int host_down_disable_service_checks;
int service_skip_check_dependency_status;
int service_skip_check_parent_status;
int service_skip_check_host_down_status;
int host_skip_check_dependency_status;
/*** perfdata variables ***/
int perfdata_timeout;
@ -376,6 +388,10 @@ void init_main_cfg_vars(int first_time) {
allow_empty_hostgroup_assignment =
DEFAULT_ALLOW_EMPTY_HOSTGROUP_ASSIGNMENT;
host_down_disable_service_checks = FALSE;
service_skip_check_dependency_status = -1;
service_skip_check_parent_status = -1;
service_skip_check_host_down_status = -1;
host_skip_check_dependency_status = -1;
perfdata_timeout = 0;
host_perfdata_command = NULL;
service_perfdata_command = NULL;
@ -1426,6 +1442,9 @@ time_t calculate_time_from_day_of_month(int year, int month, int monthday) {
day--;
/* make the new time */
t.tm_sec = 0;
t.tm_min = 0;
t.tm_hour = 0;
t.tm_mon = month;
t.tm_year = year;
t.tm_mday = day;
@ -1617,6 +1636,7 @@ void setup_sighandler(void) {
sigaction(SIGHUP, &sig_action, NULL);
if(daemon_dumps_core == FALSE && daemon_mode == TRUE)
sigaction(SIGSEGV, &sig_action, NULL);
sig_action.sa_flags = SA_NOCLDWAIT;
#else /* HAVE_SIGACTION */
signal(SIGPIPE, SIG_IGN);
signal(SIGQUIT, sighandler);
@ -1701,7 +1721,7 @@ void my_system_sighandler(int sig) {
/* Handle the SIGXFSZ signal. A SIGXFSZ signal is received when a file exceeds
the maximum allowable size either as dictated by the fzise parameter in
the maximum allowable size either as dictated by the fsize parameter in
/etc/security/limits.conf (ulimit -f) or by the maximum size allowed by
the filesystem */
void handle_sigxfsz(int sig) {
@ -1824,36 +1844,48 @@ static long long check_file_size(char *path, unsigned long fudge,
/************************ DAEMON FUNCTIONS ************************/
/******************************************************************/
int daemon_init(void) {
pid_t pid = -1;
int pidno = 0;
int lockfile = 0;
int val = 0;
char buf[256];
struct flock lock;
int daemon_init(void)
{
pid_t pid = -1;
int pidno = 0;
int lockfile = 0;
int val = 0;
char buf[256] = { 0 };
char *homedir = NULL;
char *cp;
char *cp = NULL;
struct flock lock;
#ifdef RLIMIT_CORE
struct rlimit limit;
#endif
/* change working directory. scuttle home if we're dumping core */
if(daemon_dumps_core == TRUE) {
if (daemon_dumps_core == TRUE) {
homedir = getenv("HOME");
if (homedir && *homedir)
if (homedir && *homedir) {
chdir(homedir);
}
else if (log_file && *log_file) {
homedir = strdup(log_file);
cp = strrchr(homedir, '/');
if (cp)
if (cp) {
*cp = '\0';
else
}
else {
strcpy(homedir, "/");
}
chdir(homedir);
free(homedir);
} else
} else {
chdir("/");
}
}
umask(S_IWGRP | S_IWOTH);
@ -1871,43 +1903,77 @@ int daemon_init(void) {
lockfile = open(lock_file, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
if(lockfile < 0) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Failed to obtain lock on file %s: %s\n", lock_file, strerror(errno));
logit(NSLOG_PROCESS_INFO | NSLOG_RUNTIME_ERROR, TRUE, "Bailing out due to errors encountered while attempting to daemonize... (PID=%d)", (int)getpid());
if (lockfile < 0) {
logit(NSLOG_RUNTIME_ERROR, TRUE,
"Failed to obtain lock on file %s: %s\n", lock_file, strerror(errno));
logit(NSLOG_PROCESS_INFO | NSLOG_RUNTIME_ERROR, TRUE,
"Bailing out due to errors encountered while attempting to daemonize... (PID=%d)", (int)getpid());
cleanup();
exit(ERROR);
}
}
/* see if we can read the contents of the lockfile */
if((val = read(lockfile, buf, (size_t)10)) < 0) {
val = read(lockfile, buf, (size_t)10);
if (val < 0) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Lockfile exists but cannot be read");
cleanup();
exit(ERROR);
}
}
/* we read something - check the PID */
if(val > 0) {
if((val = sscanf(buf, "%d", &pidno)) < 1) {
if (val > 0) {
val = sscanf(buf, "%d", &pidno);
if (val < 1) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Lockfile '%s' does not contain a valid PID (%s)", lock_file, buf);
cleanup();
exit(ERROR);
}
}
}
pid = (pid_t)pidno;
if (val == 1) {
/* check for SIGHUP */
if (pid == getpid()) {
close(lockfile);
return OK;
}
/* check for SIGHUP */
if(val == 1 && (pid = (pid_t)pidno) == getpid()) {
close(lockfile);
return OK;
/* send a signal to see if pid alive */
val = kill(pid, 0);
/* is this process alive? */
if (val == 0) {
logit(NSLOG_RUNTIME_ERROR, TRUE,
"Lockfile '%s' contains PID of running process (%d)", lock_file, pidno);
cleanup();
exit(ERROR);
}
}
/* exit on errors... */
if((pid = fork()) < 0)
pid = fork();
if (pid < 0) {
return(ERROR);
}
/* parent process goes away.. */
else if((int)pid != 0)
else if (pid != 0) {
iobroker_destroy(nagios_iobs, IOBROKER_CLOSE_SOCKETS);
cleanup();
cleanup_performance_data();
cleanup_downtime_data();
my_free(lock_file);
my_free(config_file);
my_free(config_file_dir);
my_free(nagios_binary_path);
exit(OK);
}
/* child continues... */
@ -1915,21 +1981,29 @@ int daemon_init(void) {
setsid();
/* place a file lock on the lock file */
lock.l_type = F_WRLCK;
lock.l_start = 0;
lock.l_type = F_WRLCK;
lock.l_start = 0;
lock.l_whence = SEEK_SET;
lock.l_len = 0;
if(fcntl(lockfile, F_SETLK, &lock) < 0) {
if(errno == EACCES || errno == EAGAIN) {
lock.l_len = 0;
val = fcntl(lockfile, F_SETLK, &lock);
if (val < 0) {
if (errno == EACCES || errno == EAGAIN) {
fcntl(lockfile, F_GETLK, &lock);
logit(NSLOG_RUNTIME_ERROR, TRUE, "Lockfile '%s' looks like its already held by another instance of Nagios (PID %d). Bailing out...", lock_file, (int)lock.l_pid);
}
else
logit(NSLOG_RUNTIME_ERROR, TRUE, "Cannot lock lockfile '%s': %s. Bailing out...", lock_file, strerror(errno));
logit(NSLOG_RUNTIME_ERROR, TRUE,
"Lockfile '%s' looks like its already held by another instance of Nagios (PID %d). Bailing out...",
lock_file, (int)lock.l_pid);
}
else {
logit(NSLOG_RUNTIME_ERROR, TRUE,
"Cannot lock lockfile '%s': %s. Bailing out...",
lock_file, strerror(errno));
}
cleanup();
exit(ERROR);
}
}
/* prevent daemon from dumping a core file... */
#ifdef RLIMIT_CORE
@ -1937,7 +2011,7 @@ int daemon_init(void) {
getrlimit(RLIMIT_CORE, &limit);
limit.rlim_cur = 0;
setrlimit(RLIMIT_CORE, &limit);
}
}
#endif
/* write PID to lockfile... */
@ -1957,7 +2031,7 @@ int daemon_init(void) {
#endif
return OK;
}
}
@ -2094,12 +2168,13 @@ int process_check_result_queue(char *dirname) {
return ERROR;
}
log_debug_info(DEBUGL_CHECKS, 1, "Starting to read check result queue '%s'...\n", dirname);
log_debug_info(DEBUGL_CHECKS, 0, "Starting to read check result queue '%s'...\n", dirname);
start = time(NULL);
/* process all files in the directory... */
while((dirfile = readdir(dirp)) != NULL) {
/* bail out if we encountered a signal */
if (sigshutdown == TRUE || sigrestart == TRUE) {
log_debug_info(DEBUGL_CHECKS, 0, "Breaking out of check result reaper: signal encountered\n");
@ -2116,7 +2191,13 @@ int process_check_result_queue(char *dirname) {
snprintf(file, sizeof(file), "%s/%s", dirname, dirfile->d_name);
file[sizeof(file) - 1] = '\x0';
/* process this if it's a check result file... */
/* process this if it's a check result file...
remember it needs to be in the format of
filename = cXXXXXX
where X is any integer
there must also be a filename present
okfile = cXXXXXX.ok
where the XXXXXX is the same as in the filename */
x = strlen(dirfile->d_name);
if(x == 7 && dirfile->d_name[0] == 'c') {
@ -2152,8 +2233,10 @@ int process_check_result_queue(char *dirname) {
result = process_check_result_file(file);
/* break out if we encountered an error */
if(result == ERROR)
if(result == ERROR) {
log_debug_info(DEBUGL_CHECKS, 0, "Encountered an error processing the check result file\n");
break;
}
check_result_files++;
}
@ -2161,6 +2244,8 @@ int process_check_result_queue(char *dirname) {
closedir(dirp);
log_debug_info(DEBUGL_CHECKS, 0, "Finished reaping %d check results\n", check_result_files);
return check_result_files;
}
@ -2213,17 +2298,21 @@ int process_check_result(check_result *cr)
/* static char *unescape_check_result_file_output(char*); */
/* reads check result(s) from a file */
int process_check_result_file(char *fname) {
mmapfile *thefile = NULL;
char *input = NULL;
char *var = NULL;
char *val = NULL;
int process_check_result_file(char *fname)
{
mmapfile *thefile = NULL;
char *input = NULL;
char *var = NULL;
char *val = NULL;
char *vartok = NULL;
char *valtok = NULL;
char *v1 = NULL, *v2 = NULL;
time_t current_time;
check_result cr;
if(fname == NULL)
if (fname == NULL) {
return ERROR;
}
init_check_result(&cr);
cr.engine = &nagios_spool_check_engine;
@ -2233,102 +2322,142 @@ int process_check_result_file(char *fname) {
log_debug_info(DEBUGL_CHECKS, 1, "Processing check result file: '%s'\n", fname);
/* open the file for reading */
if((thefile = mmap_fopen(fname)) == NULL) {
thefile = mmap_fopen(fname);
if (thefile == NULL) {
/* try removing the file - zero length files can't be mmap()'ed, so it might exist */
log_debug_info(DEBUGL_CHECKS, 1, "Failed to open check result file for reading: '%s'\n", fname);
delete_check_result_file(fname);
return ERROR;
}
}
/* read in all lines from the file */
while(1) {
/* free memory */
my_free(input);
my_free(var);
my_free(val);
/* read the next line */
if((input = mmap_fgets_multiline(thefile)) == NULL)
input = mmap_fgets_multiline(thefile);
if (input == NULL) {
break;
}
/* skip comments */
if(input[0] == '#')
if (input[0] == '#') {
continue;
}
/* empty line indicates end of record */
else if(input[0] == '\n') {
else if (input[0] == '\n') {
/* do we have the minimum amount of data? */
if(cr.host_name != NULL && cr.output != NULL) {
if (cr.host_name != NULL && cr.output != NULL) {
/* process the check result */
process_check_result(&cr);
}
}
/* cleanse for next check result */
free_check_result(&cr);
init_check_result(&cr);
cr.output_file = fname;
}
}
if((var = my_strtok(input, "=")) == NULL)
vartok = my_strtok_with_free(input, "=", FALSE);
if (vartok == NULL) {
continue;
if((val = my_strtok(NULL, "\n")) == NULL)
}
valtok = my_strtok_with_free(NULL, "\n", FALSE);
if (valtok == NULL) {
vartok = my_strtok_with_free(NULL, NULL, TRUE);
continue;
}
/* clean up some memory before we go any further */
var = strdup(vartok);
val = strdup(valtok);
vartok = my_strtok_with_free(NULL, NULL, TRUE);
log_debug_info(DEBUGL_CHECKS, 2, " * %25s: %s\n", var, val);
/* found the file time */
if(!strcmp(var, "file_time")) {
if (!strcmp(var, "file_time")) {
/* file is too old - ignore check results it contains and delete it */
/* this will only work as intended if file_time comes before check results */
if(max_check_result_file_age > 0 && (current_time - (strtoul(val, NULL, 0)) > max_check_result_file_age)) {
if ((max_check_result_file_age > 0)
&& (current_time - (strtoul(val, NULL, 0)) > max_check_result_file_age)) {
log_debug_info(DEBUGL_CHECKS, 1,
"Skipping check_result because file_time is %s and max cr file age is %lu",
val, max_check_result_file_age);
break;
}
}
}
/* else we have check result data */
else {
if(!strcmp(var, "host_name"))
if (!strcmp(var, "host_name")) {
cr.host_name = (char *)strdup(val);
else if(!strcmp(var, "service_description")) {
}
else if (!strcmp(var, "service_description")) {
cr.service_description = (char *)strdup(val);
cr.object_check_type = SERVICE_CHECK;
}
else if(!strcmp(var, "check_type"))
}
else if (!strcmp(var, "check_type")) {
cr.check_type = atoi(val);
else if(!strcmp(var, "check_options"))
}
else if (!strcmp(var, "check_options")) {
cr.check_options = atoi(val);
else if(!strcmp(var, "scheduled_check"))
}
else if (!strcmp(var, "scheduled_check")) {
cr.scheduled_check = atoi(val);
else if(!strcmp(var, "reschedule_check"))
}
else if (!strcmp(var, "reschedule_check")) {
cr.reschedule_check = atoi(val);
else if(!strcmp(var, "latency"))
}
else if (!strcmp(var, "latency")) {
cr.latency = strtod(val, NULL);
else if(!strcmp(var, "start_time")) {
if((v1 = strtok(val, ".")) == NULL)
}
else if (!strcmp(var, "start_time") || !strcmp(var, "finish_time")) {
v1 = strtok(val, ".");
if (v1 == NULL) {
continue;
if((v2 = strtok(NULL, "\n")) == NULL)
continue;
cr.start_time.tv_sec = strtoul(v1, NULL, 0);
cr.start_time.tv_usec = strtoul(v2, NULL, 0);
}
else if(!strcmp(var, "finish_time")) {
if((v1 = strtok(val, ".")) == NULL)
v2 = strtok(NULL, "\n");
if (v2 == NULL) {
continue;
if((v2 = strtok(NULL, "\n")) == NULL)
continue;
cr.finish_time.tv_sec = strtoul(v1, NULL, 0);
cr.finish_time.tv_usec = strtoul(v2, NULL, 0);
}
else if(!strcmp(var, "early_timeout"))
if (!strcmp(var, "start_time")) {
cr.start_time.tv_sec = strtoul(v1, NULL, 0);
cr.start_time.tv_usec = strtoul(v2, NULL, 0);
}
else {
cr.finish_time.tv_sec = strtoul(v1, NULL, 0);
cr.finish_time.tv_usec = strtoul(v2, NULL, 0);
}
}
else if (!strcmp(var, "early_timeout")) {
cr.early_timeout = atoi(val);
else if(!strcmp(var, "exited_ok"))
}
else if (!strcmp(var, "exited_ok")) {
cr.exited_ok = atoi(val);
else if(!strcmp(var, "return_code"))
}
else if (!strcmp(var, "return_code")) {
cr.return_code = atoi(val);
else if(!strcmp(var, "output"))
}
else if (!strcmp(var, "output")) {
/* Interpolate "\\\\" and "\\n" escape sequences to the literal
* characters they represent. This converts from the single line
* format used to store the output in a checkresult file, to the
@ -2338,14 +2467,21 @@ int process_check_result_file(char *fname) {
cr.output = unescape_check_result_output(val);
}
}
}
my_free(var);
my_free(val);
log_debug_info(DEBUGL_CHECKS, 2, " **************\n");
/* do we have the minimum amount of data? */
if(cr.host_name != NULL && cr.output != NULL) {
if (cr.host_name != NULL && cr.output != NULL) {
/* process check result */
process_check_result(&cr);
}
else {
/* log a debug message */
log_debug_info(DEBUGL_CHECKS, 1, "Minimum amount of data not present; Skipped check result file: '%s'\n", fname);
}
@ -2359,74 +2495,79 @@ int process_check_result_file(char *fname) {
delete_check_result_file(fname);
return OK;
}
}
/* deletes as check result file, as well as its ok-to-go file */
int delete_check_result_file(char *fname) {
int delete_check_result_file(char *fname)
{
char *temp_buffer = NULL;
int result = OK;
int result = OK;
/* delete the result file */
result = unlink(fname);
/* delete the ok-to-go file */
asprintf(&temp_buffer, "%s.ok", fname);
result |= unlink(temp_buffer);
my_free(temp_buffer);
return result;
}
}
/* initializes a host/service check result */
int init_check_result(check_result *info) {
if(info == NULL)
int init_check_result(check_result *info)
{
if (info == NULL) {
return ERROR;
}
/* reset vars */
info->object_check_type = HOST_CHECK;
info->host_name = NULL;
info->object_check_type = HOST_CHECK;
info->host_name = NULL;
info->service_description = NULL;
info->check_type = CHECK_TYPE_ACTIVE;
info->check_options = CHECK_OPTION_NONE;
info->scheduled_check = FALSE;
info->reschedule_check = FALSE;
info->output_file_fp = NULL;
info->latency = 0.0;
info->start_time.tv_sec = 0;
info->start_time.tv_usec = 0;
info->finish_time.tv_sec = 0;
info->check_type = CHECK_TYPE_ACTIVE;
info->check_options = CHECK_OPTION_NONE;
info->scheduled_check = FALSE;
info->reschedule_check = FALSE;
info->output_file_fp = NULL;
info->latency = 0.0;
info->start_time.tv_sec = 0;
info->start_time.tv_usec = 0;
info->finish_time.tv_sec = 0;
info->finish_time.tv_usec = 0;
info->early_timeout = FALSE;
info->exited_ok = TRUE;
info->return_code = 0;
info->output = NULL;
info->source = NULL;
info->engine = NULL;
info->early_timeout = FALSE;
info->exited_ok = TRUE;
info->return_code = 0;
info->output = NULL;
info->source = NULL;
info->engine = NULL;
return OK;
}
}
/* frees memory associated with a host/service check result */
int free_check_result(check_result *info) {
if(info == NULL)
int free_check_result(check_result *info)
{
if (info == NULL) {
return OK;
}
my_free(info->host_name);
my_free(info->service_description);
my_free(info->output);
return OK;
}
}
/******************************************************************/
@ -3307,6 +3448,7 @@ char *get_program_modification_date(void) {
/* do some cleanup before we exit */
void cleanup(void) {
xodtemplate_free_memory();
#ifdef USE_EVENT_BROKER
/* unload modules */
@ -3332,8 +3474,6 @@ void free_memory(nagios_macros *mac) {
/* free all allocated memory for the object definitions */
free_object_data();
/* free memory allocated to comments */
free_comment_data();
/* free event queue data */
@ -3386,22 +3526,31 @@ void free_memory(nagios_macros *mac) {
mac->x[MACRO_TEMPFILE] = NULL; /* assigned from temp_file */
my_free(temp_path);
mac->x[MACRO_TEMPPATH] = NULL; /*assigned from temp_path */
my_free(check_result_path);
my_free(command_file);
mac->x[MACRO_COMMANDFILE] = NULL; /* assigned from command_file */
my_free(check_result_path);
my_free(log_archive_path);
my_free(website_url);
my_free(status_file);
my_free(retention_file);
for (i = 0; i < MAX_USER_MACROS; i++) {
my_free(macro_user[i]);
}
/* these have no other reference */
my_free(mac->x[MACRO_PROCESSSTARTTIME]);
my_free(mac->x[MACRO_EVENTSTARTTIME]);
my_free(mac->x[MACRO_ADMINEMAIL]);
my_free(mac->x[MACRO_ADMINPAGER]);
my_free(mac->x[MACRO_RESOURCEFILE]);
my_free(mac->x[MACRO_OBJECTCACHEFILE]);
my_free(mac->x[MACRO_MAINCONFIGFILE]);
my_free(mac->x[MACRO_RETENTIONDATAFILE]);
my_free(mac->x[MACRO_HOSTPERFDATAFILE]);
my_free(mac->x[MACRO_STATUSDATAFILE]);
my_free(mac->x[MACRO_SERVICEPERFDATAFILE]);
return;
}
@ -3504,3 +3653,129 @@ int reset_variables(void) {
return OK;
}
/* try and detect any problems with sys limits
we're specifically interested in NPROC
but could easily add NOFILE here if necessary */
#ifdef DETECT_RLIMIT_PROBLEM
void rlimit_problem_detection(int desired_workers) {
log_debug_info(DEBUGL_PROCESS, 2, "rlimit_problem_detection()\n");
struct rlimit rlim;
int ilim;
host * temp_host = NULL;
service * temp_service = NULL;
/* how many times a worker forks/execs to run a plugin */
int forks_per_worker_per_check = 2;
/* time period to calculate over (in minutes) */
int time_period_calc = 5;
/* how many processes do we just want to account for? */
int arbitrary_user_processes = 300;
double checks_per_time_period = 0.0;
double this_interval = 0.0;
int total_num_procs = 0;
/* first, we grab the NPROC limit, then we check if it isn't unlimited
if it isn't, but the max is, then we set the soft limit to the max
if that doesn't work, or the max isn't unlimited, then we try and
calculate what the current usage is really, and how many workers
we expect to have, and calculate what our usage (generally) is
going to be */
ilim = getrlimit(RLIMIT_NPROC, &rlim);
if (ilim != 0) {
/* nothing we can do here, so just let it keep moving along */
logit(NSLOG_PROCESS_INFO, TRUE, "WARNING: getrlimit(RLIMIT_NPROC) failed with errno: %s\n", strerror(errno));
return;
}
if (rlim.rlim_cur == RLIM_INFINITY) {
/* we won't have any problems due to fork constraints */
log_debug_info(DEBUGL_PROCESS, 0, " * RLIMIT_NPROC is unlimited, no need to continue checking.\n");
return;
}
desired_workers = get_desired_workers(desired_workers);
/* calculate the amount of checks
and the worst-case (estimation) frequency in which they repeat */
for (temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
this_interval = 0;
if (!(temp_host->checks_enabled)) {
continue;
}
/* get the smallest possible */
if (temp_host->check_interval > temp_host->retry_interval
&& temp_host->retry_interval != 0) {
this_interval = temp_host->retry_interval;
} else {
this_interval = temp_host->check_interval;
}
/* get them on an average scale (5 min) */
if (this_interval > 0) {
this_interval = ceil((double) time_period_calc / this_interval);
}
checks_per_time_period += this_interval;
}
for (temp_service = service_list; temp_service != NULL; temp_service = temp_service->next) {
this_interval = 0;
if (!(temp_service->checks_enabled)) {
continue;
}
/* get the smallest possible */
if (temp_service->check_interval > temp_service->retry_interval
&& temp_service->retry_interval != 0) {
this_interval = temp_service->retry_interval;
} else {
this_interval = temp_service->check_interval;
}
/* get them on an average scale (5 min) */
if (this_interval > 0) {
this_interval = ceil(time_period_calc / this_interval);
}
checks_per_time_period += this_interval;
}
total_num_procs = checks_per_time_period * forks_per_worker_per_check;
total_num_procs += desired_workers;
total_num_procs += arbitrary_user_processes;
log_debug_info(DEBUGL_PROCESS, 0, " * total_num_procs is: %d\n", total_num_procs);
log_debug_info(DEBUGL_PROCESS, 0, " * using forks_per_worker_per_check: %d\n", forks_per_worker_per_check);
log_debug_info(DEBUGL_PROCESS, 0, " * using desired_workers: %d\n", desired_workers);
log_debug_info(DEBUGL_PROCESS, 0, " * using arbitrary_user_processes: %d\n", arbitrary_user_processes);
if (rlim.rlim_cur > total_num_procs) {
log_debug_info(DEBUGL_PROCESS, 0, " * RLIMIT_NPROC is %d, total max estimated processes is %d, everything looks okay!\n",
(int) rlim.rlim_cur, total_num_procs);
} else {
/* just warn the user - no need to bail out */
logit(NSLOG_RUNTIME_WARNING, TRUE, "WARNING: RLIMIT_NPROC is %d, total max estimated processes is %d! You should increase your limits (ulimit -u, or limits.conf)\n",
(int) rlim.rlim_cur, total_num_procs);
}
}
#endif

View File

@ -73,17 +73,38 @@ extern struct kvvec * macros_to_kvv(nagios_macros *);
static const char *wpjob_type_name(unsigned int type)
{
switch (type) {
case WPJOB_CHECK: return "CHECK";
case WPJOB_NOTIFY: return "NOTIFY";
case WPJOB_OCSP: return "OCSP";
case WPJOB_OCHP: return "OCHP";
case WPJOB_GLOBAL_SVC_EVTHANDLER: return "GLOBAL SERVICE EVENTHANDLER";
case WPJOB_SVC_EVTHANDLER: return "SERVICE EVENTHANDLER";
case WPJOB_GLOBAL_HOST_EVTHANDLER: return "GLOBAL HOST EVENTHANDLER";
case WPJOB_HOST_EVTHANDLER: return "HOST EVENTHANDLER";
case WPJOB_CALLBACK: return "CALLBACK";
case WPJOB_HOST_PERFDATA: return "HOST PERFDATA";
case WPJOB_SVC_PERFDATA: return "SERVICE PERFDATA";
case WPJOB_CHECK:
return "CHECK";
case WPJOB_NOTIFY:
return "NOTIFY";
case WPJOB_OCSP:
return "OCSP";
case WPJOB_OCHP:
return "OCHP";
case WPJOB_GLOBAL_SVC_EVTHANDLER:
return "GLOBAL SERVICE EVENTHANDLER";
case WPJOB_SVC_EVTHANDLER:
return "SERVICE EVENTHANDLER";
case WPJOB_GLOBAL_HOST_EVTHANDLER:
return "GLOBAL HOST EVENTHANDLER";
case WPJOB_HOST_EVTHANDLER:
return "HOST EVENTHANDLER";
case WPJOB_CALLBACK:
return "CALLBACK";
case WPJOB_HOST_PERFDATA:
return "HOST PERFDATA";
case WPJOB_SVC_PERFDATA:
return "SERVICE PERFDATA";
}
return "UNKNOWN";
}
@ -93,16 +114,21 @@ static void wproc_logdump_buffer(int level, int show, const char *prefix, char *
char *ptr, *eol;
unsigned int line = 1;
if (!buf || !*buf)
if (!buf || !*buf) {
return;
}
for (ptr = buf; ptr && *ptr; ptr = eol ? eol + 1 : NULL) {
if ((eol = strchr(ptr, '\n')))
if ((eol = strchr(ptr, '\n'))) {
*eol = 0;
}
logit(level, show, "%s line %.02d: %s\n", prefix, line++, ptr);
if (eol)
if (eol) {
*eol = '\n';
else
}
else {
break;
}
}
}
@ -113,13 +139,17 @@ void wproc_reap(int jobs, int msecs)
gettimeofday(&start, NULL);
while (jobs > 0 && msecs > 0) {
int inputs = iobroker_poll(nagios_iobs, msecs);
if (inputs < 0) return;
if (inputs < 0) {
return;
}
jobs -= inputs; /* One input is roughly equivalent to one job. */
struct timeval now;
gettimeofday(&now, NULL);
msecs -= tv_delta_msec(&start, &now);
start = now;
}
@ -131,20 +161,24 @@ int wproc_can_spawn(struct load_control *lc)
time_t now;
/* if no load control is enabled, we can safely run this job */
if (!(lc->options & LOADCTL_ENABLED))
if (!(lc->options & LOADCTL_ENABLED)) {
return 1;
}
now = time(NULL);
if (lc->last_check + lc->check_interval > now) {
lc->last_check = now;
if (getloadavg(lc->load, 3) < 0)
if (getloadavg(lc->load, 3) < 0) {
return lc->jobs_limit > lc->jobs_running;
}
if (lc->load[0] > lc->backoff_limit) {
old = lc->jobs_limit;
lc->jobs_limit -= lc->backoff_change;
}
else if (lc->load[0] < lc->rampup_limit) {
old = lc->jobs_limit;
lc->jobs_limit += lc->rampup_change;
@ -153,6 +187,7 @@ int wproc_can_spawn(struct load_control *lc)
if (lc->jobs_limit > lc->jobs_max) {
lc->jobs_limit = lc->jobs_max;
}
else if (lc->jobs_limit < lc->jobs_min) {
logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Tried to set jobs_limit to %u, below jobs_min (%u)\n",
lc->jobs_limit, lc->jobs_min);
@ -184,19 +219,28 @@ static struct wproc_job *get_job(struct wproc_worker *wp, int job_id)
static struct wproc_list *get_wproc_list(const char *cmd)
{
struct wproc_list *wp_list;
char *cmd_name = NULL, *slash = NULL, *space;
struct wproc_list *wp_list = NULL;
char *cmd_name = NULL;
char *slash = NULL;
char *space = NULL;
if (!specialized_workers)
if (!specialized_workers) {
return &workers;
}
/* first, look for a specialized worker for this command */
if ((space = strchr(cmd, ' ')) != NULL) {
int namelen = (unsigned long)space - (unsigned long)cmd;
space = strchr(cmd, ' ');
if (space != NULL) {
int namelen = (unsigned long) space - (unsigned long) cmd;
cmd_name = calloc(1, namelen + 1);
/* not exactly optimal, but what the hells */
if (!cmd_name)
if (!cmd_name) {
return &workers;
}
memcpy(cmd_name, cmd, namelen);
slash = strrchr(cmd_name, '/');
}
@ -208,47 +252,85 @@ static struct wproc_list *get_wproc_list(const char *cmd)
if (wp_list != NULL) {
log_debug_info(DEBUGL_CHECKS, 1, "Found specialized worker(s) for '%s'", (slash && *slash != '/') ? slash : cmd_name);
}
if (cmd_name)
if (cmd_name) {
free(cmd_name);
}
return wp_list ? wp_list : &workers;
if (wp_list) {
return wp_list;
}
return &workers;
}
static struct wproc_worker *get_worker(const char *cmd)
{
struct wproc_list *wp_list;
struct wproc_list *wp_list = NULL;
if (!cmd)
log_debug_info(DEBUGL_WORKERS, 0, "get_worker()\n");
if (!cmd) {
log_debug_info(DEBUGL_WORKERS, 1, " * cmd is null, bailing\n");
return NULL;
}
wp_list = get_wproc_list(cmd);
if (!wp_list || !wp_list->wps || !wp_list->len)
if (!wp_list) {
log_debug_info(DEBUGL_WORKERS, 1, " * wp_list is null, bailing\n");
return NULL;
}
if (!wp_list->wps) {
log_debug_info(DEBUGL_WORKERS, 1, " * wp_list->wps is null, bailing\n");
return NULL;
}
if (!wp_list->len) {
log_debug_info(DEBUGL_WORKERS, 2, " * wp_list->len is <= 0, bailing\n");
return NULL;
}
return wp_list->wps[wp_list->idx++ % wp_list->len];
}
static struct wproc_job *create_job(int type, void *arg, time_t timeout, const char *cmd)
{
struct wproc_job *job;
struct wproc_worker *wp;
struct wproc_job *job = NULL;
struct wproc_worker *wp = NULL;
int result = 0;
log_debug_info(DEBUGL_WORKERS, 0, "create_job()\n");
wp = get_worker(cmd);
if (!wp)
if (wp == NULL) {
return NULL;
}
job = calloc(1, sizeof(*job));
if (!job) {
if (job == NULL) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Failed to allocate memory for worker job: %s\n", strerror(errno));
return NULL;
}
job->wp = wp;
job->id = get_job_id(wp);
job->type = type;
job->arg = arg;
job->wp = wp;
job->id = get_job_id(wp);
job->type = type;
job->arg = arg;
job->timeout = timeout;
if (fanout_add(wp->jobs, job->id, job) < 0 || !(job->command = strdup(cmd))) {
result = fanout_add(wp->jobs, job->id, job);
if (result < 0) {
log_debug_info(DEBUGL_WORKERS, 1, " * Can't add job to wp->jobs, bailing\n");
free(job);
return NULL;
}
job->command = strdup(cmd);
if (job->command == NULL) {
log_debug_info(DEBUGL_WORKERS, 1, " * job command can't be null, bailing\n");
free(job);
return NULL;
}
@ -260,26 +342,48 @@ static void run_job_callback(struct wproc_job *job, struct wproc_result *wpres,
{
wproc_callback_job *cj;
if (!job || !job->arg)
log_debug_info(DEBUGL_WORKERS, 0, "run_job_callback()\n");
if (job == NULL) {
log_debug_info(DEBUGL_WORKERS, 1, " * job is null, bailing\n");
return;
}
if (job->arg == NULL) {
log_debug_info(DEBUGL_WORKERS, 1, " * job arg is null, bailing\n");
return;
}
cj = (struct wproc_callback_job *)job->arg;
if (!cj->callback)
if (cj->callback == NULL) {
log_debug_info(DEBUGL_WORKERS, 1, " * callback_job callback is null, bailing\n");
return;
}
cj->callback(wpres, cj->data, val);
cj->callback = NULL;
}
static void destroy_job(struct wproc_job *job)
{
if (!job)
if (job == NULL) {
log_debug_info(DEBUGL_WORKERS, 1, " * destroy_job -> job is null, bailing\n");
return;
}
log_debug_info(DEBUGL_WORKERS, 0, "destroy_job(%d=%s)\n", job->type, wpjob_type_name(job->type));
switch (job->type) {
case WPJOB_CHECK:
free_check_result(job->arg);
free(job->arg);
break;
case WPJOB_NOTIFY:
case WPJOB_OCSP:
case WPJOB_OCHP:
@ -294,20 +398,25 @@ static void destroy_job(struct wproc_job *job)
case WPJOB_SVC_PERFDATA:
/* these require nothing special */
break;
case WPJOB_CALLBACK:
/* call with NULL result to make callback clean things up */
run_job_callback(job, NULL, 0);
break;
default:
logit(NSLOG_RUNTIME_WARNING, TRUE, "wproc: Unknown job type: %d\n", job->type);
break;
}
my_free(job->command);
if (job->wp) {
if (job->wp != NULL) {
log_debug_info(DEBUGL_WORKERS, 1, " * removing job->wp\n");
fanout_remove(job->wp->jobs, job->id);
job->wp->jobs_running--;
}
loadctl.jobs_running--;
free(job);
@ -320,8 +429,10 @@ static void fo_destroy_job(void *job)
static int wproc_is_alive(struct wproc_worker *wp)
{
if (!wp || !wp->pid)
if (wp == NULL || wp->pid <= 0) {
return 0;
}
if (kill(wp->pid, 0) == 0 && iobroker_is_registered(nagios_iobs, wp->sd))
return 1;
return 0;
@ -329,18 +440,22 @@ static int wproc_is_alive(struct wproc_worker *wp)
static int wproc_destroy(struct wproc_worker *wp, int flags)
{
int i = 0, force = 0, self;
int i = 0;
int force = 0;
int self = 0;
if (!wp)
if (!wp) {
return 0;
}
force = !!(flags & WPROC_FORCE);
self = getpid();
/* master retains workers through restarts */
if (self == nagios_pid && !force)
if (self == nagios_pid && !force) {
return 0;
}
/* free all memory when either forcing or a worker called us */
iocache_destroy(wp->ioc);
@ -350,8 +465,9 @@ static int wproc_destroy(struct wproc_worker *wp, int flags)
wp->jobs = NULL;
/* workers must never control other workers, so they return early */
if (self != nagios_pid)
if (self != nagios_pid) {
return 0;
}
/* kill(0, SIGKILL) equals suicide, so we avoid it */
if (wp->pid) {
@ -374,39 +490,54 @@ static int remove_specialized(void *data)
{
if (data == to_remove) {
return DKHASH_WALK_REMOVE;
} else if (to_remove == NULL) {
}
else if (to_remove == NULL) {
/* remove all specialised workers and their lists */
struct wproc_list *h = data;
int i;
for (i=0;i<h->len;i++) {
for (i = 0; i < h->len; i++) {
/* not sure what WPROC_FORCE is actually for.
* Nagios does *not* retain workers across
* restarts, as stated in wproc_destroy?
*/
wproc_destroy(h->wps[i], WPROC_FORCE);
}
h->len = 0;
free(h->wps);
free(h);
return DKHASH_WALK_REMOVE;
}
return 0;
}
/* remove worker from job assignment list */
static void remove_worker(struct wproc_worker *worker)
{
unsigned int i, j = 0;
unsigned int i = 0;
unsigned int j = 0;
struct wproc_list *wpl = worker->wp_list;
for (i = 0; i < wpl->len; i++) {
if (wpl->wps[i] == worker)
if (wpl->wps[i] == worker) {
continue;
}
wpl->wps[j++] = wpl->wps[i];
}
wpl->len = j;
if (!specialized_workers || wpl->len)
if (specialized_workers == NULL || wpl->len > 0) {
return;
}
to_remove = wpl;
dkhash_walk_data(specialized_workers, remove_specialized);
@ -438,22 +569,28 @@ void free_worker_memory(int flags)
to_remove = NULL;
dkhash_walk_data(specialized_workers, remove_specialized);
dkhash_destroy(specialized_workers);
specialized_workers = NULL; /* Don't leave pointers to freed memory. */
/* Don't leave pointers to freed memory. */
specialized_workers = NULL;
}
static int str2timeval(char *str, struct timeval *tv)
{
char *ptr, *ptr2;
char *ptr = NULL;
char *ptr2 = NULL;
tv->tv_sec = strtoul(str, &ptr, 10);
if (ptr == str) {
tv->tv_sec = tv->tv_usec = 0;
return -1;
}
if (*ptr == '.' || *ptr == ',') {
ptr2 = ptr + 1;
tv->tv_usec = strtoul(ptr2, &ptr, 10);
}
return 0;
}
@ -462,29 +599,32 @@ static int handle_worker_check(wproc_result *wpres, struct wproc_worker *wp, str
int result = ERROR;
check_result *cr = (check_result *)job->arg;
memcpy(&cr->rusage, &wpres->rusage, sizeof(wpres->rusage));
cr->start_time.tv_sec = wpres->start.tv_sec;
cr->start_time.tv_usec = wpres->start.tv_usec;
cr->finish_time.tv_sec = wpres->stop.tv_sec;
cr->start_time.tv_sec = wpres->start.tv_sec;
cr->start_time.tv_usec = wpres->start.tv_usec;
cr->finish_time.tv_sec = wpres->stop.tv_sec;
cr->finish_time.tv_usec = wpres->stop.tv_usec;
if (WIFEXITED(wpres->wait_status)) {
cr->return_code = WEXITSTATUS(wpres->wait_status);
} else {
}
else {
cr->return_code = STATE_UNKNOWN;
}
if (wpres->outstd && *wpres->outstd) {
cr->output = strdup(wpres->outstd);
} else if (wpres->outerr) {
}
else if (wpres->outerr) {
asprintf(&cr->output, "(No output on stdout) stderr: %s", wpres->outerr);
} else {
}
else {
cr->output = NULL;
}
cr->early_timeout = wpres->early_timeout;
cr->exited_ok = wpres->exited_ok;
cr->engine = NULL;
cr->source = wp->name;
cr->exited_ok = wpres->exited_ok;
cr->engine = NULL;
cr->source = wp->name;
process_check_result(cr);
free_check_result(cr);
@ -554,42 +694,6 @@ static int parse_worker_result(wproc_result *wpres, struct kvvec *kvv)
case WPRES_runtime:
/* ignored */
break;
case WPRES_ru_utime:
str2timeval(value, &wpres->rusage.ru_utime);
break;
case WPRES_ru_stime:
str2timeval(value, &wpres->rusage.ru_stime);
break;
case WPRES_ru_minflt:
wpres->rusage.ru_minflt = atoi(value);
break;
case WPRES_ru_majflt:
wpres->rusage.ru_majflt = atoi(value);
break;
case WPRES_ru_nswap:
wpres->rusage.ru_nswap = atoi(value);
break;
case WPRES_ru_inblock:
wpres->rusage.ru_inblock = atoi(value);
break;
case WPRES_ru_oublock:
wpres->rusage.ru_oublock = atoi(value);
break;
case WPRES_ru_msgsnd:
wpres->rusage.ru_msgsnd = atoi(value);
break;
case WPRES_ru_msgrcv:
wpres->rusage.ru_msgrcv = atoi(value);
break;
case WPRES_ru_nsignals:
wpres->rusage.ru_nsignals = atoi(value);
break;
case WPRES_ru_nvcsw:
wpres->rusage.ru_nsignals = atoi(value);
break;
case WPRES_ru_nivcsw:
wpres->rusage.ru_nsignals = atoi(value);
break;
default:
logit(NSLOG_RUNTIME_WARNING, TRUE, "wproc: Recognized but unhandled result variable: %s=%s\n", key, value);
@ -622,8 +726,8 @@ static int handle_worker_result(int sd, int events, void *arg)
static struct kvvec kvv = KVVEC_INITIALIZER;
struct wproc_worker *wp = (struct wproc_worker *)arg;
if(iocache_capacity(wp->ioc) == 0) {
logit(NSLOG_RUNTIME_WARNING, TRUE, "wproc: iocache_capacity() is 0 for worker %s.\n", wp->name);
if((ret = iocache_capacity(wp->ioc)) < 0) {
logit(NSLOG_RUNTIME_WARNING, TRUE, "wproc: iocache_capacity() is %d for worker %s.\n", ret, wp->name);
}
ret = iocache_read(wp->ioc, wp->sd);
@ -954,21 +1058,7 @@ static int spawn_core_worker(void)
return ret;
}
int init_workers(int desired_workers)
{
specialized_workers = dkhash_create(512);
if (!specialized_workers) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "wproc: Failed to allocate specialized worker table.\n");
return -1;
}
/* Register our query handler before launching workers, so other workers
* can join us whenever they're ready. */
if (!qh_register_handler("wproc", "Worker process management and info", 0, wproc_query_handler))
logit(NSLOG_INFO_MESSAGE, TRUE, "wproc: Successfully registered manager as @wproc with query handler\n");
else
logit(NSLOG_RUNTIME_ERROR, TRUE, "wproc: Failed to register manager with query handler\n");
int get_desired_workers(int desired_workers) {
if (desired_workers <= 0) {
int cpus = online_cpus(); /* Always at least 1 CPU. */
@ -992,6 +1082,28 @@ int init_workers(int desired_workers)
}
}
}
return desired_workers;
}
/* if this function is updated, the function rlimit_problem_detection()
must be updated as well */
int init_workers(int desired_workers)
{
specialized_workers = dkhash_create(512);
if (!specialized_workers) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "wproc: Failed to allocate specialized worker table.\n");
return -1;
}
/* Register our query handler before launching workers, so other workers
* can join us whenever they're ready. */
if (!qh_register_handler("wproc", "Worker process management and info", 0, wproc_query_handler))
logit(NSLOG_INFO_MESSAGE, TRUE, "wproc: Successfully registered manager as @wproc with query handler\n");
else
logit(NSLOG_RUNTIME_ERROR, TRUE, "wproc: Failed to register manager with query handler\n");
desired_workers = get_desired_workers(desired_workers);
wproc_num_workers_desired = desired_workers;
if (workers_alive() == desired_workers)
@ -1001,8 +1113,10 @@ int init_workers(int desired_workers)
if (desired_workers < (int)workers.len)
return -1;
while (desired_workers-- > 0)
spawn_core_worker();
while (desired_workers-- > 0) {
int worker_pid = spawn_core_worker();
log_debug_info(DEBUGL_WORKERS, 2, "Spawned new worker with pid: (%d)\n", worker_pid);
}
return 0;
}
@ -1014,21 +1128,33 @@ int init_workers(int desired_workers)
*/
static int wproc_run_job(struct wproc_job *job, nagios_macros *mac)
{
static struct kvvec kvv = KVVEC_INITIALIZER;
struct kvvec_buf *kvvb;
struct kvvec *env_kvvp = NULL;
static struct kvvec kvv = KVVEC_INITIALIZER;
struct kvvec_buf *kvvb = NULL;
struct kvvec *env_kvvp = NULL;
struct kvvec_buf *env_kvvb = NULL;
struct wproc_worker *wp;
int ret, result = OK;
ssize_t written = 0;
struct wproc_worker *wp = NULL;
int ret = OK;
int result = OK;
ssize_t written = 0;
if (!job || !job->wp)
log_debug_info(DEBUGL_WORKERS, 1, "wproc_run_job()\n");
if (job == NULL) {
log_debug_info(DEBUGL_WORKERS, 1, " * failed because job was null\n");
return ERROR;
}
if (job->wp == NULL) {
log_debug_info(DEBUGL_WORKERS, 1, " * failed because job worker process was null\n");
return ERROR;
}
wp = job->wp;
if (!kvvec_init(&kvv, 4)) /* job_id, type, command and timeout */
/* job_id, type, command and timeout */
if (!kvvec_init(&kvv, 4)) {
return ERROR;
}
kvvec_addkv(&kvv, "job_id", (char *)mkstr("%d", job->id));
kvvec_addkv(&kvv, "type", (char *)mkstr("%d", job->type));
@ -1036,37 +1162,53 @@ static int wproc_run_job(struct wproc_job *job, nagios_macros *mac)
kvvec_addkv(&kvv, "timeout", (char *)mkstr("%u", job->timeout));
/* Add the macro environment variables */
if(mac) {
if (mac != NULL) {
env_kvvp = macros_to_kvv(mac);
if(NULL != env_kvvp) {
if (env_kvvp != NULL) {
env_kvvb = kvvec2buf(env_kvvp, '=', '\n', 0);
if(NULL == env_kvvb) {
if (env_kvvb == NULL) {
kvvec_destroy(env_kvvp, KVVEC_FREE_KEYS);
}
else {
kvvec_addkv_wlen(&kvv, "env", strlen("env"), env_kvvb->buf,
env_kvvb->buflen);
/* no reason to call strlen("env")
when we know it's 3 characters */
kvvec_addkv_wlen(&kvv, "env", 3, env_kvvb->buf, env_kvvb->buflen);
}
}
}
kvvb = build_kvvec_buf(&kvv);
/* ret = write(wp->sd, kvvb->buf, kvvb->bufsize); */
ret = nwrite(wp->sd, kvvb->buf, kvvb->bufsize, &written);
if (ret != (int)kvvb->bufsize) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "wproc: '%s' seems to be choked. ret = %d; bufsize = %lu: written = %lu; errno = %d (%s)\n",
wp->name, ret, kvvb->bufsize, written, errno, strerror(errno));
if (ret != (int) kvvb->bufsize) {
logit(NSLOG_RUNTIME_ERROR, TRUE,
"wproc: '%s' seems to be choked. ret = %d; bufsize = %lu: written = %lu; errno = %d (%s)\n",
wp->name, ret, kvvb->bufsize, (long unsigned int) written, errno, strerror(errno));
destroy_job(job);
result = ERROR;
} else {
wp->jobs_running++;
wp->jobs_started++;
loadctl.jobs_running++;
}
if(NULL != env_kvvp) kvvec_destroy(env_kvvp, KVVEC_FREE_KEYS);
if(NULL != env_kvvb) {
if (env_kvvp != NULL) {
kvvec_destroy(env_kvvp, KVVEC_FREE_KEYS);
}
if (env_kvvb != NULL) {
free(env_kvvb->buf);
free(env_kvvb);
}
free(kvvb->buf);
free(kvvb);

View File

@ -15,8 +15,8 @@ exec_prefix=@exec_prefix@
LOGDIR=@localstatedir@
CFGDIR=@sysconfdir@
BINDIR=@bindir@
CGIDIR=@sbindir@
HTMLDIR=@datarootdir@
CGIDIR=@cgibindir@
HTMLDIR=@webdir@
INSTALL=@INSTALL@
INSTALL_OPTS=@INSTALL_OPTS@
COMMAND_OPTS=@COMMAND_OPTS@

View File

@ -638,7 +638,7 @@ int main(void) {
reset_cgi_vars();
/* read the CGI configuration file */
result = read_cgi_config_file(get_cgi_config_location());
result = read_cgi_config_file(get_cgi_config_location(), NULL);
if(result == ERROR) {
json_object_append_object(json_root, "result",
json_result(query_time, THISCGI,
@ -1083,7 +1083,7 @@ int process_cgivars(json_object *json_root, archive_json_cgi_data *cgi_data,
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* We set these each iteration because they could change with each
iteration */
@ -3291,7 +3291,7 @@ int get_initial_downtime_state(au_linked_list *log_entries, time_t start_time,
return initial_state;
}
else {
/* If we dont' have a downtime state yet, the first downtime
/* If we don't have a downtime state yet, the first downtime
state we encounter will be opposite the initial downtime
state */
if(AU_LOGTYPE_NOTIFICATION == current_log_entry->entry_type) {

File diff suppressed because it is too large Load Diff

View File

@ -88,6 +88,7 @@ int service_status_has_been_read = FALSE;
int program_status_has_been_read = FALSE;
int refresh_rate = DEFAULT_REFRESH_RATE;
int enable_page_tour = TRUE;
int result_limit = 100;
int escape_html_tags = FALSE;
@ -187,6 +188,8 @@ void reset_cgi_vars(void) {
refresh_rate = DEFAULT_REFRESH_RATE;
enable_page_tour = TRUE;
default_statusmap_layout_method = 0;
default_statusmap_layout_method = 0;
@ -268,7 +271,7 @@ const char *get_cmd_file_location(void) {
/*read the CGI configuration file */
int read_cgi_config_file(const char *filename) {
int read_cgi_config_file(const char *filename, read_config_callback callback) {
char *input = NULL;
mmapfile *thefile;
char *var = NULL;
@ -314,6 +317,9 @@ int read_cgi_config_file(const char *filename) {
else if(!strcmp(var, "refresh_rate"))
refresh_rate = atoi(val);
else if(!strcmp(var, "enable_page_tour"))
enable_page_tour = (atoi(val) > 0) ? TRUE : FALSE;
/* page limit added 2/1/2012 -MG */
else if(!strcmp(var, "result_limit"))
result_limit = atoi(val);
@ -442,6 +448,8 @@ int read_cgi_config_file(const char *filename) {
ack_no_send = (atoi(val) > 0) ? TRUE : FALSE;
else if(!strcmp(var, "tac_cgi_hard_only"))
tac_cgi_hard_only = (atoi(val) > 0) ? TRUE : FALSE;
else if (callback)
(*callback)(var,val);
}
for(p = illegal_output_chars; p && *p; p++)
@ -694,7 +702,7 @@ void cgi_init(void (*doc_header)(int), void (*doc_footer)(void), int object_opti
init_shared_cfg_vars(1);
/* read the CGI configuration file */
result = read_cgi_config_file(get_cgi_config_location());
result = read_cgi_config_file(get_cgi_config_location(), NULL);
if(result == ERROR) {
doc_header(FALSE);
cgi_config_file_error(get_cgi_config_location());

396
cgi/cmd.c
View File

@ -29,8 +29,6 @@
#include "../include/cgiauth.h"
#include "../include/getcgi.h"
extern const char *extcmd_get_name(int id);
extern char main_config_file[MAX_FILENAME_LENGTH];
extern char url_html_path[MAX_FILENAME_LENGTH];
extern char url_images_path[MAX_FILENAME_LENGTH];
@ -98,10 +96,12 @@ authdata current_authdata;
void show_command_help(int);
void request_command_data(int);
void commit_command_data(int);
int print_comment_field(int cmd_id);
int commit_command(int);
int write_command_to_file(char *);
void clean_comment_data(char *);
void cgicfg_callback(const char*, const char*);
void document_header(int);
void document_footer(void);
int process_cgivars(void);
@ -124,7 +124,7 @@ int main(void) {
reset_cgi_vars();
/* read the CGI configuration file */
result = read_cgi_config_file(get_cgi_config_location());
result = read_cgi_config_file(get_cgi_config_location(), cgicfg_callback);
if(result == ERROR) {
document_header(FALSE);
if(content_type == WML_CONTENT)
@ -256,6 +256,30 @@ int main(void) {
}
void cgicfg_callback(const char *var, const char *val)
{
struct nagios_extcmd *ecmd;
const char *cp = val;
if (strncmp(var, "CMT_", 4))
return;
ecmd = extcmd_get_command_name(&var[4]);
if (!ecmd)
return;
if (!isdigit(*val))
return;
ecmd->cmt_opt = atoi(val);
while (isdigit(*cp) || *cp == ',' || *cp == ' ' || *cp == '\t')
++cp;
if (!*cp)
return;
ecmd->default_comment = strdup(cp);
strip_html_brackets(ecmd->default_comment);
}
void document_header(int use_stylesheet) {
@ -326,7 +350,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {
@ -1004,12 +1028,7 @@ void request_command_data(int cmd) {
printf("<tr><td CLASS='optBoxItem'>Persistent%s:</td><td><b>", (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM) ? " Comment" : "");
printf("<INPUT TYPE='checkbox' NAME='persistent' %s>", (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM) ? "" : "CHECKED");
printf("</b></td></tr>\n");
printf("<tr><td CLASS='optBoxRequiredItem'>Author (Your Name):</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='com_author' VALUE='%s' %s>", escape_string(comment_author), (lock_author_names == TRUE) ? "READONLY DISABLED" : "");
printf("</b></td></tr>\n");
printf("<tr><td CLASS='optBoxRequiredItem'>Comment:</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='com_data' VALUE='%s' SIZE=40>", escape_string(comment_data));
printf("</b></td></tr>\n");
print_comment_field(cmd);
break;
case CMD_ADD_SVC_COMMENT:
@ -1030,12 +1049,7 @@ void request_command_data(int cmd) {
printf("<tr><td CLASS='optBoxItem'>Persistent%s:</td><td><b>", (cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM) ? " Comment" : "");
printf("<INPUT TYPE='checkbox' NAME='persistent' %s>", (cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM) ? "" : "CHECKED");
printf("</b></td></tr>\n");
printf("<tr><td CLASS='optBoxRequiredItem'>Author (Your Name):</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='com_author' VALUE='%s' %s>", escape_string(comment_author), (lock_author_names == TRUE) ? "READONLY DISABLED" : "");
printf("</b></td></tr>\n");
printf("<tr><td CLASS='optBoxRequiredItem'>Comment:</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='com_data' VALUE='%s' SIZE=40>", escape_string(comment_data));
printf("</b></td></tr>\n");
print_comment_field(cmd);
break;
case CMD_DEL_HOST_COMMENT:
@ -1052,6 +1066,7 @@ void request_command_data(int cmd) {
printf("<tr><td CLASS='optBoxRequiredItem'>Notification Delay (minutes from now):</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='not_dly' VALUE='%d'>", notification_delay);
printf("</b></td></tr>\n");
print_comment_field(cmd);
break;
case CMD_DELAY_SVC_NOTIFICATION:
@ -1063,6 +1078,7 @@ void request_command_data(int cmd) {
printf("<tr><td CLASS='optBoxRequiredItem'>Notification Delay (minutes from now):</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='not_dly' VALUE='%d'>", notification_delay);
printf("</b></td></tr>\n");
print_comment_field(cmd);
break;
case CMD_SCHEDULE_SVC_CHECK:
@ -1081,6 +1097,7 @@ void request_command_data(int cmd) {
printf("<tr><td CLASS='optBoxRequiredItem'>Check Time:</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='start_time' VALUE='%s'>", buffer);
printf("</b></td></tr>\n");
print_comment_field(cmd);
printf("<tr><td CLASS='optBoxItem'>Force Check:</td><td><b>");
printf("<INPUT TYPE='checkbox' NAME='force_check' %s>", (force_check == TRUE) ? "CHECKED" : "");
printf("</b></td></tr>\n");
@ -1107,6 +1124,7 @@ void request_command_data(int cmd) {
printf("<tr><td CLASS='optBoxRequiredItem'>Service:</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='service' VALUE='%s'>", escape_string(service_desc));
printf("</b></td></tr>\n");
print_comment_field(cmd);
break;
case CMD_ENABLE_HOST_SVC_CHECKS:
@ -1133,6 +1151,7 @@ void request_command_data(int cmd) {
printf("<tr><td CLASS='optBoxRequiredItem'>Host Name:</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='host' VALUE='%s'>", escape_string(host_name));
printf("</b></td></tr>\n");
print_comment_field(cmd);
if(cmd == CMD_ENABLE_HOST_SVC_CHECKS || cmd == CMD_DISABLE_HOST_SVC_CHECKS || cmd == CMD_ENABLE_HOST_SVC_NOTIFICATIONS || cmd == CMD_DISABLE_HOST_SVC_NOTIFICATIONS) {
printf("<tr><td CLASS='optBoxItem'>%s For Host Too:</td><td><b>", (cmd == CMD_ENABLE_HOST_SVC_CHECKS || cmd == CMD_ENABLE_HOST_SVC_NOTIFICATIONS) ? "Enable" : "Disable");
printf("<INPUT TYPE='checkbox' NAME='ahas'>");
@ -1167,7 +1186,8 @@ void request_command_data(int cmd) {
case CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS:
case CMD_START_OBSESSING_OVER_HOST_CHECKS:
case CMD_STOP_OBSESSING_OVER_HOST_CHECKS:
printf("<tr><td CLASS='optBoxItem' colspan=2>There are no options for this command.<br>Click the 'Commit' button to submit the command.</td></tr>");
if (print_comment_field(cmd) == FALSE)
printf("<tr><td CLASS='optBoxItem' colspan=2>There are no options for this command.<br>Click the 'Commit' button to submit the command.</td></tr>");
break;
case CMD_PROCESS_HOST_CHECK_RESULT:
@ -1214,12 +1234,7 @@ void request_command_data(int cmd) {
printf("<tr><td CLASS='optBoxRequiredItem'>Service:</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='service' VALUE='%s'>", escape_string(service_desc));
}
printf("<tr><td CLASS='optBoxRequiredItem'>Author (Your Name):</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='com_author' VALUE='%s' %s>", escape_string(comment_author), (lock_author_names == TRUE) ? "READONLY DISABLED" : "");
printf("</b></td></tr>\n");
printf("<tr><td CLASS='optBoxRequiredItem'>Comment:</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='com_data' VALUE='%s' SIZE=40>", escape_string(comment_data));
printf("</b></td></tr>\n");
print_comment_field(cmd);
printf("<tr><td CLASS='optBoxItem'><br></td></tr>\n");
@ -1303,6 +1318,7 @@ void request_command_data(int cmd) {
printf("<INPUT TYPE='checkbox' NAME='ahas'>");
printf("</b></td></tr>\n");
}
print_comment_field(cmd);
break;
case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
@ -1319,6 +1335,7 @@ void request_command_data(int cmd) {
printf("<INPUT TYPE='checkbox' NAME='ahas'>");
printf("</b></td></tr>\n");
}
print_comment_field(cmd);
break;
case CMD_DEL_HOST_DOWNTIME:
@ -1326,6 +1343,7 @@ void request_command_data(int cmd) {
printf("<tr><td CLASS='optBoxRequiredItem'>Scheduled Downtime ID:</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='down_id' VALUE='%lu'>", downtime_id);
printf("</b></td></tr>\n");
print_comment_field(cmd);
break;
@ -1344,12 +1362,7 @@ void request_command_data(int cmd) {
printf("<INPUT TYPE='TEXT' NAME='servicegroup' VALUE='%s'>", escape_string(servicegroup_name));
printf("</b></td></tr>\n");
}
printf("<tr><td CLASS='optBoxRequiredItem'>Author (Your Name):</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='com_author' VALUE='%s' %s>", escape_string(comment_author), (lock_author_names == TRUE) ? "READONLY DISABLED" : "");
printf("</b></td></tr>\n");
printf("<tr><td CLASS='optBoxRequiredItem'>Comment:</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='com_data' VALUE='%s' SIZE=40>", escape_string(comment_data));
printf("</b></td></tr>\n");
print_comment_field(cmd);
time(&t);
get_time_string(&t, buffer, sizeof(buffer) - 1, SHORT_DATE_TIME);
printf("<tr><td CLASS='optBoxRequiredItem'>Start Time:</td><td><b>");
@ -1402,12 +1415,7 @@ void request_command_data(int cmd) {
printf("<INPUT TYPE='checkbox' NAME='broadcast_notification' ");
printf("</b></td></tr>\n");
printf("<tr><td CLASS='optBoxRequiredItem'>Author (Your Name):</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='com_author' VALUE='%s' %s>", escape_string(comment_author), (lock_author_names == TRUE) ? "READONLY DISABLED" : "");
printf("</b></td></tr>\n");
printf("<tr><td CLASS='optBoxRequiredItem'>Comment:</td><td><b>");
printf("<INPUT TYPE='TEXT' NAME='com_data' VALUE='%s' SIZE=40>", escape_string(comment_data));
printf("</b></td></tr>\n");
print_comment_field(cmd);
break;
default:
@ -1443,6 +1451,33 @@ void request_command_data(int cmd) {
}
int print_comment_field(int cmd_id)
{
char *reqtext = "optBoxItem";
char *comment = comment_data;
struct nagios_extcmd *ecmd = extcmd_get_command_id(cmd_id);
if (!ecmd || ecmd->cmt_opt == 0)
return FALSE;
if (ecmd->cmt_opt == 2)
reqtext = "optBoxRequiredItem";
if (!comment || !*comment) {
if (ecmd->default_comment)
comment = ecmd->default_comment;
}
printf("<tr><td CLASS='%s'>Author (Your Name):</td><td><b>", reqtext);
printf("<INPUT TYPE='TEXT' NAME='com_author' VALUE='%s' %s>", escape_string(comment_author), (lock_author_names == TRUE) ? "READONLY DISABLED" : "");
printf("</b></td></tr>\n");
printf("<tr><td CLASS='%s'>Comment:</td><td><b>", reqtext);
printf("<INPUT TYPE='TEXT' NAME='com_data' VALUE='%s' SIZE=40>", escape_string(comment));
printf("</b></td></tr>\n");
return TRUE;
}
void commit_command_data(int cmd) {
char *error_string = NULL;
int result = OK;
@ -1454,7 +1489,7 @@ void commit_command_data(int cmd) {
scheduled_downtime *temp_downtime;
servicegroup *temp_servicegroup = NULL;
contact *temp_contact = NULL;
struct nagios_extcmd *ecmd = extcmd_get_command_id(cmd);
/* get authentication information */
get_authentication_information(&current_authdata);
@ -1462,57 +1497,46 @@ void commit_command_data(int cmd) {
/* get name to use for author */
if(lock_author_names == TRUE) {
temp_contact = find_contact(current_authdata.username);
if(temp_contact != NULL && temp_contact->alias != NULL)
if(temp_contact != NULL && temp_contact->alias != NULL) {
comment_author = temp_contact->alias;
else
}
else {
comment_author = current_authdata.username;
}
}
if (ecmd->cmt_opt == 2 && *comment_data == '\0') {
if(!error_string) {
error_string = strdup("Comment was not entered");
}
}
clean_comment_data(comment_data);
if (*comment_data != '\0' && *comment_author == '\0') {
if(!error_string) {
error_string = strdup("Author was not entered");
}
}
clean_comment_data(comment_author);
switch(cmd) {
case CMD_ADD_HOST_COMMENT:
case CMD_ACKNOWLEDGE_HOST_PROBLEM:
/* make sure we have author name, and comment data... */
if(!strcmp(comment_author, "")) {
if(!error_string)
error_string = strdup("Author was not entered");
}
if(!strcmp(comment_data, "")) {
if(!error_string)
error_string = strdup("Comment was not entered");
}
/* clean up the comment data */
clean_comment_data(comment_author);
clean_comment_data(comment_data);
/* see if the user is authorized to issue a command... */
temp_host = find_host(host_name);
if(is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE)
if(is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE) {
authorized = TRUE;
}
break;
case CMD_ADD_SVC_COMMENT:
case CMD_ACKNOWLEDGE_SVC_PROBLEM:
/* make sure we have author name, and comment data... */
if(!strcmp(comment_author, "")) {
if(!error_string)
error_string = strdup("Author was not entered");
}
if(!strcmp(comment_data, "")) {
if(!error_string)
error_string = strdup("Comment was not entered");
}
/* clean up the comment data */
clean_comment_data(comment_author);
clean_comment_data(comment_data);
/* see if the user is authorized to issue a command... */
temp_service = find_service(host_name, service_desc);
if(is_authorized_for_service_commands(temp_service, &current_authdata) == TRUE)
if(is_authorized_for_service_commands(temp_service, &current_authdata) == TRUE) {
authorized = TRUE;
}
break;
case CMD_DEL_HOST_COMMENT:
@ -1520,27 +1544,32 @@ void commit_command_data(int cmd) {
/* check the sanity of the comment id */
if(comment_id == 0) {
if(!error_string)
if(!error_string) {
error_string = strdup("Comment id cannot be 0");
}
}
/* find the comment */
if(cmd == CMD_DEL_HOST_COMMENT)
if(cmd == CMD_DEL_HOST_COMMENT) {
temp_comment = find_host_comment(comment_id);
else
}
else {
temp_comment = find_service_comment(comment_id);
}
/* see if the user is authorized to issue a command... */
if(cmd == CMD_DEL_HOST_COMMENT && temp_comment != NULL) {
temp_host = find_host(temp_comment->host_name);
if(is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE)
if(is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE) {
authorized = TRUE;
}
}
if(cmd == CMD_DEL_SVC_COMMENT && temp_comment != NULL) {
temp_service = find_service(temp_comment->host_name, temp_comment->service_description);
if(is_authorized_for_service_commands(temp_service, &current_authdata) == TRUE)
if(is_authorized_for_service_commands(temp_service, &current_authdata) == TRUE) {
authorized = TRUE;
}
}
/* free comment data */
free_comment_data();
@ -1552,27 +1581,32 @@ void commit_command_data(int cmd) {
/* check the sanity of the downtime id */
if(downtime_id == 0) {
if(!error_string)
if(!error_string) {
error_string = strdup("Downtime id cannot be 0");
}
}
/* find the downtime entry */
if(cmd == CMD_DEL_HOST_DOWNTIME)
if(cmd == CMD_DEL_HOST_DOWNTIME) {
temp_downtime = find_host_downtime(downtime_id);
else
}
else {
temp_downtime = find_service_downtime(downtime_id);
}
/* see if the user is authorized to issue a command... */
if(cmd == CMD_DEL_HOST_DOWNTIME && temp_downtime != NULL) {
temp_host = find_host(temp_downtime->host_name);
if(is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE)
if(is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE) {
authorized = TRUE;
}
}
if(cmd == CMD_DEL_SVC_DOWNTIME && temp_downtime != NULL) {
temp_service = find_service(temp_downtime->host_name, temp_downtime->service_description);
if(is_authorized_for_service_commands(temp_service, &current_authdata) == TRUE)
if(is_authorized_for_service_commands(temp_service, &current_authdata) == TRUE) {
authorized = TRUE;
}
}
/* free downtime data */
free_downtime_data();
@ -1599,52 +1633,39 @@ void commit_command_data(int cmd) {
case CMD_STOP_OBSESSING_OVER_SVC:
case CMD_CLEAR_SVC_FLAPPING_STATE:
/* make sure we have author name and comment data... */
if(cmd == CMD_SCHEDULE_SVC_DOWNTIME) {
if(!strcmp(comment_data, "")) {
if(!error_string)
error_string = strdup("Comment was not entered");
}
else if(!strcmp(comment_author, "")) {
if(!error_string)
error_string = strdup("Author was not entered");
}
}
/* see if the user is authorized to issue a command... */
temp_service = find_service(host_name, service_desc);
if(is_authorized_for_service_commands(temp_service, &current_authdata) == TRUE)
if(is_authorized_for_service_commands(temp_service, &current_authdata) == TRUE) {
authorized = TRUE;
}
/* make sure we have passive check info (if necessary) */
if(cmd == CMD_PROCESS_SERVICE_CHECK_RESULT && !strcmp(plugin_output, "")) {
if(!error_string)
if(!error_string) {
error_string = strdup("Plugin output cannot be blank");
}
}
/* make sure we have a notification delay (if necessary) */
if(cmd == CMD_DELAY_SVC_NOTIFICATION && notification_delay <= 0) {
if(!error_string)
if(!error_string) {
error_string = strdup("Notification delay must be greater than 0");
}
/* clean up the comment data if scheduling downtime */
if(cmd == CMD_SCHEDULE_SVC_DOWNTIME) {
clean_comment_data(comment_author);
clean_comment_data(comment_data);
}
}
/* make sure we have check time (if necessary) */
if(cmd == CMD_SCHEDULE_SVC_CHECK && start_time == (time_t)0) {
if(!error_string)
if(!error_string) {
error_string = strdup("Start time must be non-zero or bad format has been submitted.");
}
}
/* make sure we have start/end times for downtime (if necessary) */
if(cmd == CMD_SCHEDULE_SVC_DOWNTIME && (start_time == (time_t)0 || end_time == (time_t)0 || end_time < start_time)) {
if(!error_string)
if(!error_string) {
error_string = strdup("Start or end time not valid");
}
}
break;
@ -1672,8 +1693,9 @@ void commit_command_data(int cmd) {
case CMD_STOP_OBSESSING_OVER_HOST_CHECKS:
/* see if the user is authorized to issue a command... */
if(is_authorized_for_system_commands(&current_authdata) == TRUE)
if(is_authorized_for_system_commands(&current_authdata) == TRUE) {
authorized = TRUE;
}
break;
case CMD_ENABLE_HOST_SVC_CHECKS:
@ -1704,52 +1726,39 @@ void commit_command_data(int cmd) {
case CMD_STOP_OBSESSING_OVER_HOST:
case CMD_CLEAR_HOST_FLAPPING_STATE:
/* make sure we have author name and comment data... */
if(cmd == CMD_SCHEDULE_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOST_SVC_DOWNTIME) {
if(!strcmp(comment_data, "")) {
if(!error_string)
error_string = strdup("Comment was not entered");
}
else if(!strcmp(comment_author, "")) {
if(!error_string)
error_string = strdup("Author was not entered");
}
}
/* see if the user is authorized to issue a command... */
temp_host = find_host(host_name);
if(is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE)
if(is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE) {
authorized = TRUE;
/* clean up the comment data if scheduling downtime */
if(cmd == CMD_SCHEDULE_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOST_SVC_DOWNTIME) {
clean_comment_data(comment_author);
clean_comment_data(comment_data);
}
}
/* make sure we have a notification delay (if necessary) */
if(cmd == CMD_DELAY_HOST_NOTIFICATION && notification_delay <= 0) {
if(!error_string)
if(!error_string) {
error_string = strdup("Notification delay must be greater than 0");
}
}
/* make sure we have start/end times for downtime (if necessary) */
if((cmd == CMD_SCHEDULE_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOST_SVC_DOWNTIME) && (start_time == (time_t)0 || end_time == (time_t)0 || start_time > end_time)) {
if(!error_string)
if(!error_string) {
error_string = strdup("Start or end time not valid");
}
}
/* make sure we have check time (if necessary) */
if((cmd == CMD_SCHEDULE_HOST_CHECK || cmd == CMD_SCHEDULE_HOST_SVC_CHECKS) && start_time == (time_t)0) {
if(!error_string)
if(!error_string) {
error_string = strdup("Start time must be non-zero or bad format has been submitted.");
}
}
/* make sure we have passive check info (if necessary) */
if(cmd == CMD_PROCESS_HOST_CHECK_RESULT && !strcmp(plugin_output, "")) {
if(!error_string)
if(!error_string) {
error_string = strdup("Plugin output cannot be blank");
}
}
break;
@ -1762,34 +1771,18 @@ void commit_command_data(int cmd) {
case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
/* make sure we have author and comment data */
if(cmd == CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME) {
if(!strcmp(comment_data, "")) {
if(!error_string)
error_string = strdup("Comment was not entered");
}
else if(!strcmp(comment_author, "")) {
if(!error_string)
error_string = strdup("Author was not entered");
}
}
/* make sure we have start/end times for downtime */
if((cmd == CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME) && (start_time == (time_t)0 || end_time == (time_t)0 || start_time > end_time)) {
if(!error_string)
if(!error_string) {
error_string = strdup("Start or end time not valid");
}
}
/* see if the user is authorized to issue a command... */
temp_hostgroup = find_hostgroup(hostgroup_name);
if(is_authorized_for_hostgroup_commands(temp_hostgroup, &current_authdata) == TRUE)
if(is_authorized_for_hostgroup_commands(temp_hostgroup, &current_authdata) == TRUE) {
authorized = TRUE;
/* clean up the comment data if scheduling downtime */
if(cmd == CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME) {
clean_comment_data(comment_author);
clean_comment_data(comment_data);
}
}
break;
@ -1802,67 +1795,52 @@ void commit_command_data(int cmd) {
case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
/* make sure we have author and comment data */
if(cmd == CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME) {
if(!strcmp(comment_data, "")) {
if(!error_string)
error_string = strdup("Comment was not entered");
}
else if(!strcmp(comment_author, "")) {
if(!error_string)
error_string = strdup("Author was not entered");
}
}
/* make sure we have start/end times for downtime */
if((cmd == CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME) && (start_time == (time_t)0 || end_time == (time_t)0 || start_time > end_time)) {
if(!error_string)
if(!error_string) {
error_string = strdup("Start or end time not valid");
}
}
/* see if the user is authorized to issue a command... */
temp_servicegroup = find_servicegroup(servicegroup_name);
if(is_authorized_for_servicegroup_commands(temp_servicegroup, &current_authdata) == TRUE)
if(is_authorized_for_servicegroup_commands(temp_servicegroup, &current_authdata) == TRUE) {
authorized = TRUE;
}
break;
case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
case CMD_SEND_CUSTOM_SVC_NOTIFICATION:
/* make sure we have author and comment data */
if(!strcmp(comment_data, "")) {
if(!error_string)
error_string = strdup("Comment was not entered");
}
else if(!strcmp(comment_author, "")) {
if(!error_string)
error_string = strdup("Author was not entered");
}
/* see if the user is authorized to issue a command... */
if(cmd == CMD_SEND_CUSTOM_HOST_NOTIFICATION) {
temp_host = find_host(host_name);
if(is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE)
if(is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE) {
authorized = TRUE;
}
}
else {
temp_service = find_service(host_name, service_desc);
if(is_authorized_for_service_commands(temp_service, &current_authdata) == TRUE)
if(is_authorized_for_service_commands(temp_service, &current_authdata) == TRUE) {
authorized = TRUE;
}
}
break;
default:
if(!error_string) error_string = strdup("An error occurred while processing your command!");
if(!error_string) {
error_string = strdup("An error occurred while processing your command!");
}
}
/* to be safe, we are going to REQUIRE that the authentication functionality is enabled... */
if(use_authentication == FALSE) {
if(content_type == WML_CONTENT)
if(content_type == WML_CONTENT) {
printf("<p>Error: Authentication is not enabled!</p>\n");
}
else {
printf("<P>\n");
printf("<DIV CLASS='errorMessage'>Sorry Dave, I can't let you do that...</DIV><br>");
@ -1873,42 +1851,44 @@ void commit_command_data(int cmd) {
printf("<strong>Read the section on CGI authentication in the HTML documentation to learn how you can enable authentication and why you should want to.</strong>\n");
printf("</DIV>\n");
printf("</P>\n");
}
}
}
/* the user is not authorized to issue the given command */
else if(authorized == FALSE) {
if(content_type == WML_CONTENT)
if(content_type == WML_CONTENT) {
printf("<p>Error: You're not authorized to commit that command!</p>\n");
}
else {
printf("<P><DIV CLASS='errorMessage'>Sorry, but you are not authorized to commit the specified command.</DIV></P>\n");
printf("<P><DIV CLASS='errorDescription'>Read the section of the documentation that deals with authentication and authorization in the CGIs for more information.<BR><BR>\n");
printf("<A HREF='javascript:window.history.go(-2)'>Return from whence you came</A></DIV></P>\n");
}
}
}
/* some error occurred (data was probably missing) */
else if(error_string) {
if(content_type == WML_CONTENT)
if(content_type == WML_CONTENT) {
printf("<p>%s</p>\n", error_string);
}
else {
printf("<P><DIV CLASS='errorMessage'>%s</DIV></P>\n", error_string);
free(error_string);
printf("<P><DIV CLASS='errorDescription'>Go <A HREF='javascript:window.history.go(-1)'>back</A> and verify that you entered all required information correctly.<BR>\n");
printf("<A HREF='javascript:window.history.go(-2)'>Return from whence you came</A></DIV></P>\n");
}
}
}
/* if Nagios isn't checking external commands, don't do anything... */
else if(check_external_commands == FALSE) {
if(content_type == WML_CONTENT)
if(content_type == WML_CONTENT) {
printf("<p>Error: Nagios is not checking external commands!</p>\n");
}
else {
printf("<P><DIV CLASS='errorMessage'>Sorry, but Nagios is currently not checking for external commands, so your command will not be committed!</DIV></P>\n");
printf("<P><DIV CLASS='errorDescription'>Read the documentation for information on how to enable external commands...<BR><BR>\n");
printf("<A HREF='javascript:window.history.go(-2)'>Return from whence you came</A></DIV></P>\n");
}
}
}
/* everything looks okay, so let's go ahead and commit the command... */
else {
@ -1917,27 +1897,29 @@ void commit_command_data(int cmd) {
result = commit_command(cmd);
if(result == OK) {
if(content_type == WML_CONTENT)
if(content_type == WML_CONTENT) {
printf("<p>Your command was submitted successfully...</p>\n");
}
else {
printf("<P><DIV CLASS='infoMessage'>Your command request was successfully submitted to Nagios for processing.<BR><BR>\n");
printf("Note: It may take a while before the command is actually processed.<BR><BR>\n");
printf("<A HREF='javascript:window.history.go(-2)'>Done</A></DIV></P>");
}
}
}
else {
if(content_type == WML_CONTENT)
if(content_type == WML_CONTENT) {
printf("<p>An error occurred while committing your command!</p>\n");
}
else {
printf("<P><DIV CLASS='errorMessage'>An error occurred while attempting to commit your command for processing.<BR><BR>\n");
printf("<A HREF='javascript:window.history.go(-2)'>Return from whence you came</A></DIV></P>\n");
}
}
}
return;
}
my_free(error_string);
}
__attribute__((format(printf, 2, 3)))
static int cmd_submitf(int id, const char *fmt, ...) {
char cmd[MAX_EXTERNAL_COMMAND_LENGTH];
@ -1968,6 +1950,13 @@ static int cmd_submitf(int id, const char *fmt, ...) {
return ERROR;
}
if (*comment_data != '\0') {
len2 = snprintf(cmd + len, sizeof(cmd) - len, ";%s;%s", comment_author, comment_data);
len += len2;
if(len2 < 0 || len >= sizeof(cmd))
return ERROR;
}
cmd[len] = 0; /* 0 <= len < sizeof(cmd) */
return write_command_to_file(cmd);
}
@ -2070,11 +2059,11 @@ int commit_command(int cmd) {
break;
case CMD_ADD_HOST_COMMENT:
result = cmd_submitf(cmd, "%s;%d;%s;%s", host_name, persistent_comment, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%d", host_name, persistent_comment);
break;
case CMD_ADD_SVC_COMMENT:
result = cmd_submitf(cmd, "%s;%s;%d;%s;%s", host_name, service_desc, persistent_comment, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%s;%d", host_name, service_desc, persistent_comment);
break;
case CMD_DEL_HOST_COMMENT:
@ -2136,11 +2125,11 @@ int commit_command(int cmd) {
break;
case CMD_ACKNOWLEDGE_HOST_PROBLEM:
result = cmd_submitf(cmd, "%s;%d;%d;%d;%s;%s", host_name, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%d;%d;%d", host_name, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment);
break;
case CMD_ACKNOWLEDGE_SVC_PROBLEM:
result = cmd_submitf(cmd, "%s;%s;%d;%d;%d;%s;%s", host_name, service_desc, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%s;%d;%d;%d", host_name, service_desc, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment);
break;
case CMD_PROCESS_SERVICE_CHECK_RESULT:
@ -2157,15 +2146,15 @@ int commit_command(int cmd) {
else if(child_options == 2)
cmd = CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;%lu;%lu;%s;%s", host_name, start_time, end_time, fixed, triggered_by, duration, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;%lu;%lu", host_name, start_time, end_time, fixed, triggered_by, duration);
break;
case CMD_SCHEDULE_HOST_SVC_DOWNTIME:
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;%lu;%lu;%s;%s", host_name, start_time, end_time, fixed, triggered_by, duration, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;%lu;%lu", host_name, start_time, end_time, fixed, triggered_by, duration);
break;
case CMD_SCHEDULE_SVC_DOWNTIME:
result = cmd_submitf(cmd, "%s;%s;%lu;%lu;%d;%lu;%lu;%s;%s", host_name, service_desc, start_time, end_time, fixed, triggered_by, duration, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%s;%lu;%lu;%d;%lu;%lu", host_name, service_desc, start_time, end_time, fixed, triggered_by, duration);
break;
case CMD_DEL_HOST_DOWNTIME:
@ -2180,11 +2169,11 @@ int commit_command(int cmd) {
break;
case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
result = cmd_submitf(cmd, "%s;%d;%s;%s", host_name, (force_notification | broadcast_notification), comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%d", host_name, (force_notification | broadcast_notification));
break;
case CMD_SEND_CUSTOM_SVC_NOTIFICATION:
result = cmd_submitf(cmd, "%s;%s;%d;%s;%s", host_name, service_desc, (force_notification | broadcast_notification), comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%s;%d", host_name, service_desc, (force_notification | broadcast_notification));
break;
@ -2214,13 +2203,13 @@ int commit_command(int cmd) {
break;
case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", hostgroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu", hostgroup_name, start_time, end_time, fixed, duration);
break;
case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", hostgroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu", hostgroup_name, start_time, end_time, fixed, duration);
if(affect_host_and_services == TRUE)
result |= cmd_submitf(CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME, "%s;%lu;%lu;%d;0;%lu;%s;%s", hostgroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
result |= cmd_submitf(CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME, "%s;%lu;%lu;%d;0;%lu", hostgroup_name, start_time, end_time, fixed, duration);
break;
@ -2250,13 +2239,13 @@ int commit_command(int cmd) {
break;
case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", servicegroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu", servicegroup_name, start_time, end_time, fixed, duration);
break;
case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", servicegroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu", servicegroup_name, start_time, end_time, fixed, duration);
if(affect_host_and_services == TRUE)
result |= cmd_submitf(CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME, "%s;%lu;%lu;%d;0;%lu;%s;%s", servicegroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
result |= cmd_submitf(CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME, "%s;%lu;%lu;%d;0;%lu", servicegroup_name, start_time, end_time, fixed, duration);
break;
default:
@ -2330,6 +2319,9 @@ void clean_comment_data(char *buffer) {
int x;
int y;
if (!buffer || !*buffer)
return;
y = (int)strlen(buffer);
for(x = 0; x < y; x++) {

View File

@ -340,7 +340,7 @@ int process_cgivars(void) {
variables = getcgivars();
to_expand[0] = '\0';
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {

View File

@ -1,26 +1,21 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "../include/common.h"
#include "../include/cgiutils.h"
struct nagios_extcmd {
const char *name;
int id;
/* size_t namelen;
int min_args;
int (*handler)(struct nagios_extcmd *, int, char **);
struct nagios_extcmd *next_handler;
*/
};
#define CMD_DEF(name, min_args, handler) \
{ #name, CMD_ ## name }
#define ALT_CMD_DEF(name)
#define CMD_DEF(name, cmd_opt, dflt_comment) \
{ #name, CMD_ ## name, cmd_opt, dflt_comment }
/* { #name, sizeof(#name) - 1, CMD_ ## name, min_args, handler, NULL } */
struct nagios_extcmd in_core_commands[] = {
CMD_DEF(NONE, 0, NULL),
CMD_DEF(ADD_HOST_COMMENT, 0, NULL),
CMD_DEF(ADD_HOST_COMMENT, 2, NULL),
CMD_DEF(DEL_HOST_COMMENT, 0, NULL),
CMD_DEF(ADD_SVC_COMMENT, 0, NULL),
CMD_DEF(ADD_SVC_COMMENT, 2, NULL),
CMD_DEF(DEL_SVC_COMMENT, 0, NULL),
CMD_DEF(ENABLE_SVC_CHECK, 0, NULL),
CMD_DEF(DISABLE_SVC_CHECK, 0, NULL),
@ -48,8 +43,8 @@ struct nagios_extcmd in_core_commands[] = {
CMD_DEF(PROCESS_SERVICE_CHECK_RESULT, 0, NULL),
CMD_DEF(SAVE_STATE_INFORMATION, 0, NULL),
CMD_DEF(READ_STATE_INFORMATION, 0, NULL),
CMD_DEF(ACKNOWLEDGE_HOST_PROBLEM, 0, NULL),
CMD_DEF(ACKNOWLEDGE_SVC_PROBLEM, 0, NULL),
CMD_DEF(ACKNOWLEDGE_HOST_PROBLEM, 2, NULL),
CMD_DEF(ACKNOWLEDGE_SVC_PROBLEM, 2, NULL),
CMD_DEF(START_EXECUTING_SVC_CHECKS, 0, NULL),
CMD_DEF(STOP_EXECUTING_SVC_CHECKS, 0, NULL),
CMD_DEF(START_ACCEPTING_PASSIVE_SVC_CHECKS, 0, NULL),
@ -70,8 +65,8 @@ struct nagios_extcmd in_core_commands[] = {
CMD_DEF(REMOVE_SVC_ACKNOWLEDGEMENT, 0, NULL),
CMD_DEF(SCHEDULE_FORCED_HOST_SVC_CHECKS, 0, NULL),
CMD_DEF(SCHEDULE_FORCED_SVC_CHECK, 0, NULL),
CMD_DEF(SCHEDULE_HOST_DOWNTIME, 0, NULL),
CMD_DEF(SCHEDULE_SVC_DOWNTIME, 0, NULL),
CMD_DEF(SCHEDULE_HOST_DOWNTIME, 2, NULL),
CMD_DEF(SCHEDULE_SVC_DOWNTIME, 2, NULL),
CMD_DEF(ENABLE_HOST_FLAP_DETECTION, 0, NULL),
CMD_DEF(DISABLE_HOST_FLAP_DETECTION, 0, NULL),
CMD_DEF(ENABLE_SVC_FLAP_DETECTION, 0, NULL),
@ -88,9 +83,9 @@ struct nagios_extcmd in_core_commands[] = {
CMD_DEF(DEL_SVC_DOWNTIME, 0, NULL),
CMD_DEF(ENABLE_PERFORMANCE_DATA, 0, NULL),
CMD_DEF(DISABLE_PERFORMANCE_DATA, 0, NULL),
CMD_DEF(SCHEDULE_HOSTGROUP_HOST_DOWNTIME, 0, NULL),
CMD_DEF(SCHEDULE_HOSTGROUP_SVC_DOWNTIME, 0, NULL),
CMD_DEF(SCHEDULE_HOST_SVC_DOWNTIME, 0, NULL),
CMD_DEF(SCHEDULE_HOSTGROUP_HOST_DOWNTIME, 2, NULL),
CMD_DEF(SCHEDULE_HOSTGROUP_SVC_DOWNTIME, 2, NULL),
CMD_DEF(SCHEDULE_HOST_SVC_DOWNTIME, 2, NULL),
CMD_DEF(PROCESS_HOST_CHECK_RESULT, 0, NULL),
CMD_DEF(START_EXECUTING_HOST_CHECKS, 0, NULL),
CMD_DEF(STOP_EXECUTING_HOST_CHECKS, 0, NULL),
@ -124,8 +119,8 @@ struct nagios_extcmd in_core_commands[] = {
CMD_DEF(DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS, 0, NULL),
CMD_DEF(ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS, 0, NULL),
CMD_DEF(DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS, 0, NULL),
CMD_DEF(SCHEDULE_SERVICEGROUP_HOST_DOWNTIME, 0, NULL),
CMD_DEF(SCHEDULE_SERVICEGROUP_SVC_DOWNTIME, 0, NULL),
CMD_DEF(SCHEDULE_SERVICEGROUP_HOST_DOWNTIME, 2, NULL),
CMD_DEF(SCHEDULE_SERVICEGROUP_SVC_DOWNTIME, 2, NULL),
CMD_DEF(CHANGE_GLOBAL_HOST_EVENT_HANDLER, 0, NULL),
CMD_DEF(CHANGE_GLOBAL_SVC_EVENT_HANDLER, 0, NULL),
CMD_DEF(CHANGE_HOST_EVENT_HANDLER, 0, NULL),
@ -162,8 +157,8 @@ struct nagios_extcmd in_core_commands[] = {
CMD_DEF(ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS, 0, NULL),
CMD_DEF(DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS, 0, NULL),
CMD_DEF(CHANGE_RETRY_HOST_CHECK_INTERVAL, 0, NULL),
CMD_DEF(SEND_CUSTOM_HOST_NOTIFICATION, 0, NULL),
CMD_DEF(SEND_CUSTOM_SVC_NOTIFICATION, 0, NULL),
CMD_DEF(SEND_CUSTOM_HOST_NOTIFICATION, 2, NULL),
CMD_DEF(SEND_CUSTOM_SVC_NOTIFICATION, 2, NULL),
CMD_DEF(CHANGE_HOST_NOTIFICATION_TIMEPERIOD, 0, NULL),
CMD_DEF(CHANGE_SVC_NOTIFICATION_TIMEPERIOD, 0, NULL),
CMD_DEF(CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD, 0, NULL),
@ -181,33 +176,37 @@ struct nagios_extcmd in_core_commands[] = {
# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
const char *extcmd_get_name(int id) {
struct nagios_extcmd* extcmd_get_command_id(int id)
{
unsigned int i;
for(i = 0; i < ARRAY_SIZE(in_core_commands); i++) {
struct nagios_extcmd *ecmd;
ecmd = &in_core_commands[i];
if(ecmd->id == id)
return ecmd->name;
return ecmd;
}
return NULL;
}
}
#ifdef ECMD_LIST_TESTING
int main(int argc, char **argv) {
int i, no_handler = 0;
struct nagios_extcmd* extcmd_get_command_name(const char *name)
{
unsigned int i;
for(i = 0; i < ARRAY_SIZE(in_core_commands); i++) {
struct nagios_extcmd *cmd = &in_core_commands[i];
if(!cmd->handler) {
no_handler++;
printf("%s has no handler\n", extcmd_get_name(i));
}
struct nagios_extcmd *ecmd;
ecmd = &in_core_commands[i];
if(!strcmp(ecmd->name, name))
return ecmd;
}
printf("%d of %d commands have no handler\n",
no_handler, ARRAY_SIZE(in_core_commands));
return 0;
}
#endif
return NULL;
}
const char *extcmd_get_name(int id) {
struct nagios_extcmd *ecmd = extcmd_get_command_id(id);
if (!ecmd)
return NULL;
return ecmd->name;
}

View File

@ -36,6 +36,7 @@ static nagios_macros *mac;
extern char nagios_process_info[MAX_INPUT_BUFFER];
extern int nagios_process_state;
extern int refresh_rate;
extern int enable_page_tour;
extern int buffer_stats[1][3];
extern int program_stats[MAX_CHECK_STATS_TYPES][3];
@ -561,7 +562,7 @@ void document_header(int use_stylesheet) {
else if(display_type == DISPLAY_SERVICE_INFO)
vidurl = "https://www.youtube.com/embed/f_knwQOS6FI";
if (vidurl) {
if (enable_page_tour == TRUE && vidurl) {
printf("<script type='text/javascript' src='%s%s'></script>\n", url_js_path, JQUERY_JS);
printf("<script type='text/javascript' src='%s%s'></script>\n", url_js_path, NAGFUNCS_JS);
printf("<script type='text/javascript'>\n");
@ -575,7 +576,7 @@ void document_header(int use_stylesheet) {
printf("vbox = new vidbox({pos:'lr',vidurl:'%s',text:vboxText,"
"vidid:vBoxId});\n", vidurl);
printf("});\n</script>\n");
}
}
printf("</head>\n");
@ -611,7 +612,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {
@ -1123,7 +1124,7 @@ void show_host_info(void) {
printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
#ifdef USE_STATUSMAP
printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Locate Host On Map' TITLE='Locate Host On Map'></td><td CLASS='command'><a href='%s?host=%s'>Locate host on map</a></td></tr>\n", url_images_path, STATUSMAP_ICON, STATUSMAP_CGI, url_encode(host_name));
printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Locate Host On Map' TITLE='Locate Host On Map'></td><td CLASS='command'><a href='%s?host=%s&root=%s'>Locate host on map</a></td></tr>\n", url_images_path, STATUSMAP_ICON, STATUSMAP_CGI, url_encode(host_name), url_encode(host_name));
#endif
if(temp_hoststatus->checks_enabled == TRUE) {
printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Active Checks Of This Host' TITLE='Disable Active Checks Of This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Disable active checks of this host</a></td></tr>\n", url_images_path, DISABLED_ICON, COMMAND_CGI, CMD_DISABLE_HOST_CHECK, url_encode(host_name));

View File

@ -42,8 +42,6 @@ void sanitize_cgi_input(char **cgivars) {
strptr[y] = '\x0';
}
return;
}
@ -101,8 +99,6 @@ void unescape_cgi_input(char *input) {
input[y] = input[x];
}
input[y] = '\x0';
return;
}
@ -275,7 +271,7 @@ char **getcgivars(void) {
}
/* terminate the list */
pairlist[paircount] = '\x0';
pairlist[paircount] = NULL;
/* extract the names and values from the pairlist */
cgivars = (char **)malloc((paircount * 2 + 1) * sizeof(char *));
@ -314,11 +310,11 @@ char **getcgivars(void) {
}
/* terminate the name-value list */
cgivars[paircount * 2] = '\x0';
cgivars[paircount * 2] = NULL;
/* free allocated memory */
free(cgiinput);
for(i = 0; pairlist[i] != NULL; i++)
for(i = 0; pairlist[i]; i++)
free(pairlist[i]);
free(pairlist);
@ -536,16 +532,14 @@ void free_accept_languages( accept_languages * langs) {
free( langs->languages);
}
free( langs);
return;
}
/* free() memory allocated to storing the CGI variables */
void free_cgivars(char **cgivars) {
register int x;
for(x = 0; cgivars[x] != '\x0'; x++)
for(x = 0; cgivars[x]; x++)
free(cgivars[x]);
return;
free(cgivars);
}

View File

@ -253,7 +253,7 @@ int main(int argc, char **argv) {
init_shared_cfg_vars(1);
/* read the CGI configuration file */
result = read_cgi_config_file(get_cgi_config_location());
result = read_cgi_config_file(get_cgi_config_location(), NULL);
if(result == ERROR) {
if(mode == CREATE_HTML) {
document_header(FALSE);
@ -1092,7 +1092,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {

View File

@ -334,7 +334,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1)

View File

@ -325,7 +325,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {

View File

@ -639,7 +639,7 @@ int main(void) {
reset_cgi_vars();
/* read the CGI configuration file */
result = read_cgi_config_file(get_cgi_config_location());
result = read_cgi_config_file(get_cgi_config_location(), NULL);
if(result == ERROR) {
json_object_append_object(json_root, "result",
json_result(query_time, THISCGI,
@ -1300,7 +1300,7 @@ int process_cgivars(json_object *json_root, object_json_cgi_data *cgi_data,
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* We set these each iteration because they could change with each
iteration */

View File

@ -221,7 +221,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {

View File

@ -206,7 +206,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {

View File

@ -32,6 +32,7 @@
extern int refresh_rate;
extern int result_limit;
extern int enable_page_tour;
extern char main_config_file[MAX_FILENAME_LENGTH];
extern char url_html_path[MAX_FILENAME_LENGTH];
@ -191,6 +192,7 @@ int display_header = TRUE;
int main(void) {
char *sound = NULL;
host *temp_host = NULL;
hostgroup *temp_hostgroup = NULL;
@ -236,7 +238,7 @@ int main(void) {
host_filter[regex_i++] = '$';
host_filter[regex_i] = '\0';
}
else {
else if (host_name != NULL) {
if((temp_host = find_host(host_name)) == NULL) {
for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
if(is_authorized_for_host(temp_host, &current_authdata) == FALSE)
@ -285,7 +287,6 @@ int main(void) {
}
if(display_header == TRUE) {
/* begin top table */
printf("<table class='headertable'>\n");
printf("<tr>\n");
@ -535,32 +536,34 @@ void document_header(int use_stylesheet) {
printf("<script type='text/javascript' src='%s%s'></script>\n", url_js_path, NAGFUNCS_JS);
/* JS function to append content to elements on page */
printf("<script type='text/javascript'>\n");
printf("var vbox, vBoxId='status%d%d', vboxText = "
"'<a href=https://www.nagios.com/tours target=_blank>"
"Click here to watch the entire Nagios Core 4 Tour!</a>';\n",
display_type, group_style_type);
printf("$(document).ready(function() {\n"
"$('#top_page_numbers').append($('#bottom_page_numbers').html() );\n");
if (display_type == DISPLAY_HOSTS)
vidurl = "https://www.youtube.com/embed/ahDIJcbSEFM";
else if(display_type == DISPLAY_SERVICEGROUPS) {
if (group_style_type == STYLE_HOST_DETAIL)
vidurl = "https://www.youtube.com/embed/nNiRr0hDZag";
else if (group_style_type == STYLE_OVERVIEW)
vidurl = "https://www.youtube.com/embed/MyvgTKLyQhA";
} else {
if (group_style_type == STYLE_OVERVIEW)
vidurl = "https://www.youtube.com/embed/jUDrjgEDb2A";
else if (group_style_type == STYLE_HOST_DETAIL)
vidurl = "https://www.youtube.com/embed/nNiRr0hDZag";
}
if (vidurl) {
printf("var user = '%s';\nvBoxId += ';' + user;",
current_authdata.username);
printf("vbox = new vidbox({pos:'lr',vidurl:'%s',text:vboxText,"
"vidid:vBoxId});\n", vidurl);
}
printf("});\n");
if (enable_page_tour == TRUE) {
printf("var vbox, vBoxId='status%d%d', vboxText = "
"'<a href=https://www.nagios.com/tours target=_blank>"
"Click here to watch the entire Nagios Core 4 Tour!</a>';\n",
display_type, group_style_type);
printf("$(document).ready(function() {\n"
"$('#top_page_numbers').append($('#bottom_page_numbers').html() );\n");
if (display_type == DISPLAY_HOSTS)
vidurl = "https://www.youtube.com/embed/ahDIJcbSEFM";
else if(display_type == DISPLAY_SERVICEGROUPS) {
if (group_style_type == STYLE_HOST_DETAIL)
vidurl = "https://www.youtube.com/embed/nNiRr0hDZag";
else if (group_style_type == STYLE_OVERVIEW)
vidurl = "https://www.youtube.com/embed/MyvgTKLyQhA";
} else {
if (group_style_type == STYLE_OVERVIEW)
vidurl = "https://www.youtube.com/embed/jUDrjgEDb2A";
else if (group_style_type == STYLE_HOST_DETAIL)
vidurl = "https://www.youtube.com/embed/nNiRr0hDZag";
}
if (vidurl) {
printf("var user = '%s';\nvBoxId += ';' + user;",
current_authdata.username);
printf("vbox = new vidbox({pos:'lr',vidurl:'%s',text:vboxText,"
"vidid:vBoxId});\n", vidurl);
}
printf("});\n");
}
printf("function set_limit(url) { \nthis.location = url+'&limit='+$('#limit').val();\n }\n");
printf("</script>\n");
@ -598,7 +601,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {
@ -870,13 +873,17 @@ void show_service_status_totals(void) {
count_service = 1;
}
else if(display_type == DISPLAY_SERVICEGROUPS) {
if(show_all_servicegroups == TRUE) {
if (show_all_servicegroups == TRUE) {
count_service = 1;
}
}
else if (is_service_member_of_servicegroup(find_servicegroup(servicegroup_name), temp_service) == FALSE) {
continue;
}
else if(is_host_member_of_servicegroup(find_servicegroup(servicegroup_name), temp_host) == TRUE) {
count_service = 1;
}
}
}
else if(display_type == DISPLAY_HOSTGROUPS && (show_all_hostgroups == TRUE || (is_host_member_of_hostgroup(find_hostgroup(hostgroup_name), temp_host) == TRUE)))
count_service = 1;
@ -1736,13 +1743,16 @@ void show_service_detail(void) {
}
else if(temp_status->status == SERVICE_CRITICAL) {
strncpy(status, "CRITICAL", sizeof(status));
status_class = "CRITICAL";
if(temp_status->problem_has_been_acknowledged == TRUE)
if(temp_status->problem_has_been_acknowledged == TRUE) {
status_class = "CRITICALACK";
status_bg_class = "BGCRITICALACK";
else if(temp_status->scheduled_downtime_depth > 0)
} else if(temp_status->scheduled_downtime_depth > 0) {
status_class = "CRITICAL";
status_bg_class = "BGCRITICALSCHED";
else
} else {
status_class = "CRITICAL";
status_bg_class = "BGCRITICAL";
}
}
status[sizeof(status) - 1] = '\x0';
@ -3219,7 +3229,7 @@ void show_servicegroup_service_totals_summary(servicegroup *temp_servicegroup) {
printf("<td class='miniStatusCRITICAL'><table border='0'>\n");
printf("<tr>\n");
printf("<td class='miniStatusCRITICAL'><a href='%s?servicegroup=%s&style=detail&servicestatustypes=%d&hoststatustypes=%d&serviceprops=%lu&hostprops=%lu'>%d CRITICAL</a>&nbsp:</td>\n", STATUS_CGI, url_encode(temp_servicegroup->group_name), SERVICE_CRITICAL, host_status_types, service_properties, host_properties, services_critical);
printf("<td class='miniStatusCRITICAL'><a href='%s?servicegroup=%s&style=detail&servicestatustypes=%d&hoststatustypes=%d&serviceprops=%lu&hostprops=%lu'>%d CRITICAL</a>&nbsp;</td>\n", STATUS_CGI, url_encode(temp_servicegroup->group_name), SERVICE_CRITICAL, host_status_types, service_properties, host_properties, services_critical);
printf("<td><table border='0'>\n");

View File

@ -769,7 +769,7 @@ int main(void) {
reset_cgi_vars();
/* read the CGI configuration file */
result = read_cgi_config_file(get_cgi_config_location());
result = read_cgi_config_file(get_cgi_config_location(), NULL);
if(result == ERROR) {
json_object_append_object(json_root, "result",
json_result(query_time, THISCGI,
@ -1284,7 +1284,7 @@ int process_cgivars(json_object *json_root, status_json_cgi_data *cgi_data,
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* We set these each iteration because they could change with each
iteration */

View File

@ -238,7 +238,7 @@ int main(int argc, char **argv) {
init_shared_cfg_vars(1);
/* read the CGI configuration file */
result = read_cgi_config_file(get_cgi_config_location());
result = read_cgi_config_file(get_cgi_config_location(), NULL);
if(result == ERROR) {
document_header(FALSE);
if(create_type == CREATE_HTML)
@ -408,7 +408,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {

View File

@ -113,7 +113,7 @@ int main(void) {
}
/* read the CGI configuration file */
result = read_cgi_config_file(get_cgi_config_location());
result = read_cgi_config_file(get_cgi_config_location(), NULL);
if(result == ERROR) {
printf("<P>Error: Could not open CGI configuration file '%s' for reading!</P>\n", get_cgi_config_location());
document_footer();
@ -228,7 +228,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {

View File

@ -139,7 +139,7 @@ int main(int argc, char **argv) {
init_shared_cfg_vars(1);
/* read the CGI configuration file */
result = read_cgi_config_file(get_cgi_config_location());
result = read_cgi_config_file(get_cgi_config_location(), NULL);
if(result == ERROR) {
document_header();
return ERROR;
@ -215,7 +215,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {
@ -907,14 +907,17 @@ void draw_host(host *temp_host) {
if(temp_host == NULL)
return;
/* see if user is authorized to view this host */
if(is_authorized_for_host(temp_host, &current_authdata) == FALSE)
return;
/* make sure we have the coordinates */
if(temp_host->have_3d_coords == FALSE)
return;
else {
x = temp_host->x_3d;
y = temp_host->y_3d;
z = temp_host->z_3d;
}
x = temp_host->x_3d;
y = temp_host->y_3d;
z = temp_host->z_3d;
/* make the host name safe for embedding in VRML */
vrml_safe_hostname = (char *)strdup(temp_host->name);
@ -926,10 +929,6 @@ void draw_host(host *temp_host) {
vrml_safe_hostname[a] = '_';
}
/* see if user is authorized to view this host */
if(is_authorized_for_host(temp_host, &current_authdata) == FALSE)
return;
/* get the status of the host */
temp_hoststatus = find_hoststatus(temp_host->name);

View File

@ -721,7 +721,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {
@ -1785,7 +1785,7 @@ void display_recent_alerts(void) {
printf("<td CLASS='data%s'>%s</td>", bgclass, (temp_event->state_type == AE_SOFT_STATE) ? "SOFT" : "HARD");
printf("<td CLASS='data%s'>%s</td>", bgclass, temp_event->event_info);
printf("<td CLASS='data%s'>%s</td>", bgclass, html_encode(temp_event->event_info, 1));
printf("</tr>\n");
}

View File

@ -66,6 +66,8 @@ extern servicestatus *servicestatus_list;
extern int nagios_process_state;
extern int enable_page_tour;
@ -86,7 +88,7 @@ int process_cgivars(void);
authdata current_authdata;
int embedded = FALSE;
int display_header = FALSE;
int display_header = TRUE;
hostoutage *hostoutage_list = NULL;
@ -302,17 +304,23 @@ void document_header(int use_stylesheet) {
}
printf("<script type='text/javascript' src='%s%s'></script>\n", url_js_path, JQUERY_JS);
printf("<script type='text/javascript' src='%s%s'></script>\n", url_js_path, NAGFUNCS_JS);
printf("<script type='text/javascript'>\nvar vbox, vBoxId='tac', "
"vboxText = '<a href=https://www.nagios.com/tours target=_blank>"
"Click here to watch the entire Nagios Core 4 Tour!</a>';\n");
printf("$(document).ready(function() {\n"
"var user = '%s';\nvBoxId += ';' + user;", current_authdata.username);
printf("vbox = new vidbox({pos:'lr',"
"vidurl:'https://www.youtube.com/embed/l20YRDhbOfA',text:vboxText,"
"vidid:vBoxId});");
printf("\n});\n</script>\n");
if (enable_page_tour == TRUE) {
printf("<script type='text/javascript' src='%s%s'></script>\n", url_js_path, NAGFUNCS_JS);
printf("<script type='text/javascript'>\nvar vbox, vBoxId='tac', "
"vboxText = '<a href=https://www.nagios.com/tours target=_blank>"
"Click here to watch the entire Nagios Core 4 Tour!</a>';\n");
printf("$(document).ready(function() {\n"
"var user = '%s';\nvBoxId += ';' + user;", current_authdata.username);
printf("vbox = new vidbox({pos:'lr',"
"vidurl:'https://www.youtube.com/embed/l20YRDhbOfA',text:vboxText,"
"vidid:vBoxId});");
printf("\n});\n</script>\n");
}
printf("</HEAD>\n");
printf("<BODY CLASS='tac' marginwidth=2 marginheight=2 topmargin=0 leftmargin=0 rightmargin=0>\n");
@ -346,7 +354,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {
@ -871,8 +879,6 @@ void display_tac_overview(void) {
/* left column */
printf("<td align=left valign=top width=50%%>\n");
display_info_table("Tactical Monitoring Overview", TRUE, &current_authdata);
printf("</td>\n");

View File

@ -268,7 +268,7 @@ int main(int argc, char **argv) {
init_shared_cfg_vars(1);
/* read the CGI configuration file */
result = read_cgi_config_file(get_cgi_config_location());
result = read_cgi_config_file(get_cgi_config_location(), NULL);
if(result == ERROR) {
if(mode == CREATE_HTML) {
document_header(FALSE);
@ -1299,7 +1299,7 @@ int process_cgivars(void) {
variables = getcgivars();
for(x = 0; variables[x] != NULL; x++) {
for(x = 0; variables[x]; x++) {
/* do some basic length checking on the variable identifier to prevent buffer overflows */
if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {

View File

@ -16,8 +16,8 @@ exec_prefix=@exec_prefix@
LOGDIR=@localstatedir@
CFGDIR=@sysconfdir@
BINDIR=@bindir@
CGIDIR=@sbindir@
HTMLDIR=@datarootdir@
CGIDIR=@cgibindir@
HTMLDIR=@webdir@
INSTALL=@INSTALL@
INSTALL_OPTS=@INSTALL_OPTS@
COMMAND_OPTS=@COMMAND_OPTS@

View File

@ -150,7 +150,7 @@ static int downtime_add(scheduled_downtime *dt)
prev_downtime_id = next_downtime_id;
if (!dt->downtime_id) {
dt->downtime_id = next_downtime_id++;
} else if (dt->downtime_id > next_downtime_id) {
} else if (dt->downtime_id >= next_downtime_id) {
next_downtime_id = dt->downtime_id + 1;
}
@ -1007,7 +1007,7 @@ static unsigned long get_next_downtime_id(void) {
unsigned long new_dt_id;
for (;;) {
new_dt_id = next_downtime_id++;
if (!find_downtime(ANY_DOWNTIME, next_downtime_id)) {
if (!find_downtime(ANY_DOWNTIME, new_dt_id)) {
return new_dt_id;
}
}

View File

@ -115,13 +115,15 @@ int process_macros_r(nagios_macros *mac, char *input_buffer, char **output_buffe
log_debug_info(DEBUGL_FUNCTIONS, 0, "process_macros_r()\n");
if(output_buffer == NULL)
if(output_buffer == NULL) {
return ERROR;
}
*output_buffer = (char *)strdup("");
if(input_buffer == NULL)
if(input_buffer == NULL) {
return ERROR;
}
in_macro = FALSE;
@ -137,13 +139,15 @@ int process_macros_r(nagios_macros *mac, char *input_buffer, char **output_buffe
temp_buffer = buf_ptr;
/* find the next delimiter - terminate preceding string and advance buffer pointer for next run */
if((delim_ptr = strchr(buf_ptr, '$'))) {
delim_ptr = strchr(buf_ptr, '$');
if(delim_ptr != NULL) {
delim_ptr[0] = '\x0';
buf_ptr = (char *)delim_ptr + 1;
}
}
/* no delimiter found - we already have the last of the buffer */
else
else {
buf_ptr = NULL;
}
log_debug_info(DEBUGL_MACROS, 2, " Processing part: '%s'\n", temp_buffer);
@ -158,44 +162,52 @@ int process_macros_r(nagios_macros *mac, char *input_buffer, char **output_buffe
log_debug_info(DEBUGL_MACROS, 2, " Not currently in macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
in_macro = TRUE;
}
}
/* looks like we're in a macro, so process it... */
else {
/* grab the macro value */
/* by default, we only free when instructed */
free_macro = FALSE;
/* grab the macro value */
result = grab_macro_value_r(mac, temp_buffer, &selected_macro, &macro_options, &free_macro);
log_debug_info(DEBUGL_MACROS, 2, " Processed '%s', Free: %d\n", temp_buffer, free_macro);
/* an error occurred - we couldn't parse the macro, so continue on */
if(result == ERROR) {
if (result != OK) {
log_debug_info(DEBUGL_MACROS, 0, " WARNING: An error occurred processing macro '%s'!\n", temp_buffer);
if(free_macro == TRUE)
if(free_macro == TRUE) {
my_free(selected_macro);
}
if (result == OK)
; /* do nothing special if things worked out ok */
/* an escaped $ is done by specifying two $$ next to each other */
else if(!strcmp(temp_buffer, "")) {
log_debug_info(DEBUGL_MACROS, 2, " Escaped $. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
*output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + 2);
strcat(*output_buffer, "$");
/* an escaped $ is done by specifying two $$ next to each other */
if(!strcmp(temp_buffer, "")) {
log_debug_info(DEBUGL_MACROS, 2, " Escaped $. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
*output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + 2);
strcat(*output_buffer, "$");
}
/* a non-macro, just some user-defined string between two $s */
else {
log_debug_info(DEBUGL_MACROS, 2, " Non-macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
/* a non-macro, just some user-defined string between two $s */
else {
log_debug_info(DEBUGL_MACROS, 2, " Non-macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
/* add the plain text to the end of the already processed buffer */
*output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + strlen(temp_buffer) + 3);
strcat(*output_buffer, "$");
strcat(*output_buffer, temp_buffer);
strcat(*output_buffer, "$");
/* add the plain text to the end of the already processed buffer */
*output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + strlen(temp_buffer) + 3);
strcat(*output_buffer, "$");
strcat(*output_buffer, temp_buffer);
/* just could have been a stray $ */
if (buf_ptr != NULL) {
strcat(*output_buffer, "$");
}
}
}
/* insert macro */
if(selected_macro != NULL) {
if (selected_macro != NULL) {
log_debug_info(DEBUGL_MACROS, 2, " Processed '%s', Free: %d, Cleaning options: %d\n", temp_buffer, free_macro, options);
/* URL encode the macro if requested - this allocates new memory */
@ -204,24 +216,26 @@ int process_macros_r(nagios_macros *mac, char *input_buffer, char **output_buffe
selected_macro = get_url_encoded_string(selected_macro);
if(free_macro == TRUE) {
my_free(original_macro);
}
free_macro = TRUE;
}
free_macro = TRUE;
}
/* some macros should sometimes be cleaned */
if(macro_options & options & (STRIP_ILLEGAL_MACRO_CHARS | ESCAPE_MACRO_CHARS)) {
char *cleaned_macro = NULL;
/* add the (cleaned) processed macro to the end of the already processed buffer */
if(selected_macro != NULL && (cleaned_macro = clean_macro_chars(selected_macro, options)) != NULL) {
*output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + strlen(cleaned_macro) + 1);
strcat(*output_buffer, cleaned_macro);
if(*cleaned_macro)
if(*cleaned_macro) {
my_free(cleaned_macro);
}
log_debug_info(DEBUGL_MACROS, 2, " Cleaned macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
}
}
}
/* others are not cleaned */
else {
@ -231,19 +245,20 @@ int process_macros_r(nagios_macros *mac, char *input_buffer, char **output_buffe
strcat(*output_buffer, selected_macro);
log_debug_info(DEBUGL_MACROS, 2, " Uncleaned macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
}
}
/* free memory if necessary (if we URL encoded the macro or we were told to do so by grab_macro_value()) */
if(free_macro == TRUE)
my_free(selected_macro);
log_debug_info(DEBUGL_MACROS, 2, " Just finished macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
}
in_macro = FALSE;
/* free memory if necessary (if we URL encoded the macro or we were told to do so by grab_macro_value()) */
if(free_macro == TRUE) {
my_free(selected_macro);
}
log_debug_info(DEBUGL_MACROS, 2, " Just finished macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
}
}
in_macro = FALSE;
} /* if(in_macro == TRUE) */
} /* while(buf_ptr) */
/* free copy of input buffer */
my_free(save_buffer);
@ -252,7 +267,7 @@ int process_macros_r(nagios_macros *mac, char *input_buffer, char **output_buffe
log_debug_info(DEBUGL_MACROS, 1, "**** END MACRO PROCESSING *************\n");
return OK;
}
}
int process_macros(char *input_buffer, char **output_buffer, int options) {
return process_macros_r(&global_macros, input_buffer, output_buffer, options);
@ -689,8 +704,8 @@ int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, char *ar
/* HOST MACROS */
/***************/
case MACRO_HOSTGROUPNAMES:
case MACRO_HOSTINFOURL:
*free_macro = TRUE;
case MACRO_HOSTINFOURL:
case MACRO_HOSTNAME:
case MACRO_HOSTALIAS:
case MACRO_HOSTADDRESS:
@ -738,6 +753,8 @@ int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, char *ar
case MACRO_LASTHOSTSTATEID:
case MACRO_HOSTIMPORTANCE:
case MACRO_HOSTANDSERVICESIMPORTANCE:
case MACRO_HOSTNOTIFICATIONENABLED:
case MACRO_HOSTNOTIFICATIONPERIOD:
/* a standard host macro */
if(arg2 == NULL) {
@ -801,12 +818,12 @@ int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, char *ar
/********************/
case MACRO_HOSTGROUPMEMBERS:
case MACRO_HOSTGROUPMEMBERADDRESSES:
*free_macro = TRUE;
case MACRO_HOSTGROUPNAME:
case MACRO_HOSTGROUPALIAS:
case MACRO_HOSTGROUPNOTES:
case MACRO_HOSTGROUPNOTESURL:
case MACRO_HOSTGROUPACTIONURL:
*free_macro = TRUE;
case MACRO_HOSTGROUPNAME:
case MACRO_HOSTGROUPALIAS:
/* a standard hostgroup macro */
/* use the saved hostgroup pointer */
@ -829,8 +846,8 @@ int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, char *ar
/* SERVICE MACROS */
/******************/
case MACRO_SERVICEGROUPNAMES:
case MACRO_SERVICEINFOURL:
*free_macro = TRUE;
case MACRO_SERVICEINFOURL:
case MACRO_SERVICEDESC:
case MACRO_SERVICESTATE:
case MACRO_SERVICESTATEID:
@ -872,6 +889,8 @@ int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, char *ar
case MACRO_LASTSERVICESTATE:
case MACRO_LASTSERVICESTATEID:
case MACRO_SERVICEIMPORTANCE:
case MACRO_SERVICENOTIFICATIONENABLED:
case MACRO_SERVICENOTIFICATIONPERIOD:
/* use saved service pointer */
if(arg1 == NULL && arg2 == NULL) {
@ -1717,6 +1736,12 @@ int grab_standard_host_macro_r(nagios_macros *mac, int macro_type, host *temp_ho
case MACRO_HOSTNOTIFICATIONID:
*output = (char *)mkstr("%lu", temp_host->current_notification_id);
break;
case MACRO_HOSTNOTIFICATIONENABLED:
*output = (char *)mkstr("%s", temp_host->notifications_enabled ? "YES" : "NO");
break;
case MACRO_HOSTNOTIFICATIONPERIOD:
*output = (char *)mkstr("%s", temp_host->notification_period);
break;
case MACRO_HOSTEVENTID:
*output = (char *)mkstr("%lu", temp_host->current_event_id);
break;
@ -1816,10 +1841,14 @@ int grab_standard_host_macro_r(nagios_macros *mac, int macro_type, host *temp_ho
host_services_value(temp_host));
break;
case MACRO_HOSTINFOURL:
*free_macro = TRUE;
buf1 = get_url_encoded_string(temp_host->name);
asprintf(output, "%s/cgi-bin/extinfo.cgi?type=1&host=%s",
website_url ? website_url : "website_url not set", buf1);
my_free(buf1);
if (buf1 != NULL) {
asprintf(output, "%s/cgi-bin/extinfo.cgi?type=1&host=%s",
website_url ? website_url : "website_url not set",
buf1);
free(buf1);
}
break;
#endif
@ -2107,6 +2136,12 @@ int grab_standard_service_macro_r(nagios_macros *mac, int macro_type, service *t
case MACRO_SERVICENOTIFICATIONID:
*output = (char *)mkstr("%lu", temp_service->current_notification_id);
break;
case MACRO_SERVICENOTIFICATIONENABLED:
*output = (char *)mkstr("%s", temp_service->notifications_enabled ? "YES" : "NO");
break;
case MACRO_SERVICENOTIFICATIONPERIOD:
*output = (char *)mkstr("%s", temp_service->notification_period);
break;
case MACRO_SERVICEEVENTID:
*output = (char *)mkstr("%lu", temp_service->current_event_id);
break;
@ -2154,19 +2189,18 @@ int grab_standard_service_macro_r(nagios_macros *mac, int macro_type, service *t
*output = (char *)mkstr("%u", temp_service->hourly_value);
break;
case MACRO_SERVICEINFOURL:
*free_macro = TRUE;
buf1 = get_url_encoded_string(temp_service->host_name);
buf2 = get_url_encoded_string(temp_service->description);
asprintf(output, "%s/cgi-bin/extinfo.cgi?type=2&host=%s&service=%s",
website_url ? website_url : "website_url not set",
buf1, buf2);
my_free(buf1);
my_free(buf2);
break;
my_free(buf1);
if (buf1 != NULL) {
if (buf2 != NULL) {
asprintf(output, "%s/cgi-bin/extinfo.cgi?type=2&host=%s&service=%s",
website_url ? website_url : "website_url not set",
buf1, buf2);
free(buf2);
}
free(buf1);
}
break;
#endif
@ -2194,6 +2228,7 @@ int grab_standard_service_macro_r(nagios_macros *mac, int macro_type, service *t
switch(macro_type) {
case MACRO_SERVICEACTIONURL:
case MACRO_SERVICENOTESURL:
*free_macro = TRUE;
process_macros_r(mac, *output, &temp_buffer, URL_ENCODE_MACRO_CHARS);
*output = temp_buffer;
break;
@ -2544,10 +2579,10 @@ char *get_url_encoded_string(char *input) {
(char)input[x] == '.' ||
(char)input[x] == '-' ||
(char)input[x] == '_' ||
(char)input[x] == '~')
{
(char)input[x] == '~') {
encoded_url_string[y++] = input[x];
}
}
/* anything else gets represented by its hex value */
else {
@ -2803,6 +2838,10 @@ int init_macrox_names(void) {
add_macrox_name(HOSTGROUPMEMBERADDRESSES);
add_macrox_name(HOSTINFOURL);
add_macrox_name(SERVICEINFOURL);
add_macrox_name(HOSTNOTIFICATIONENABLED);
add_macrox_name(SERVICENOTIFICATIONENABLED);
add_macrox_name(HOSTNOTIFICATIONPERIOD);
add_macrox_name(SERVICENOTIFICATIONPERIOD);
return OK;
}
@ -2933,6 +2972,7 @@ int clear_service_macros_r(nagios_macros *mac) {
my_free(mac->x[MACRO_SERVICENOTES]);
my_free(mac->x[MACRO_SERVICEGROUPNAMES]);
my_free(mac->x[MACRO_SERVICEINFOURL]);
/* clear custom service variables */
clear_custom_vars(&(mac->custom_service_vars));
@ -2957,6 +2997,7 @@ int clear_host_macros_r(nagios_macros *mac) {
/* numbers or by necessity autogenerated strings */
my_free(mac->x[MACRO_HOSTGROUPNAMES]);
my_free(mac->x[MACRO_HOSTINFOURL]);
/* clear custom host variables */
clear_custom_vars(&(mac->custom_host_vars));

View File

@ -81,6 +81,7 @@ static const struct flag_map service_flag_map[] = {
{ OPT_OK, 'o', "ok" },
{ OPT_RECOVERY, 'r', "recovery" },
{ OPT_PENDING, 'p', "pending" },
{ OPT_NOTIFICATIONS, 'N', "notifications" },
{ 0, 0, NULL },
};
@ -91,6 +92,7 @@ static const struct flag_map host_flag_map[] = {
{ OPT_RECOVERY, 'r', "recovery" },
{ OPT_DOWNTIME, 's', "downtime" },
{ OPT_PENDING, 'p', "pending" },
{ OPT_NOTIFICATIONS, 'N', "notifications" },
{ 0, 0, NULL },
};
@ -782,9 +784,6 @@ servicesmember *add_parent_service_to_service(service *svc, char *host_name, cha
if(!svc || !host_name || !description || !*host_name || !*description)
return NULL;
if((sm = calloc(1, sizeof(*sm))) == NULL)
return NULL;
if (strcmp(svc->host_name, host_name) == 0 && strcmp(svc->description, description) == 0) {
logit(NSLOG_CONFIG_ERROR, TRUE,
"Error: Host '%s' Service '%s' cannot be a child/parent of itself\n",
@ -792,6 +791,9 @@ servicesmember *add_parent_service_to_service(service *svc, char *host_name, cha
return NULL;
}
if((sm = calloc(1, sizeof(*sm))) == NULL)
return NULL;
if ((sm->host_name = strdup(host_name)) == NULL || (sm->service_description = strdup(description)) == NULL) {
/* there was an error copying (description is NULL now) */
my_free(sm->host_name);
@ -1201,6 +1203,7 @@ contact *add_contact(char *name, char *alias, char *email, char *pager, char **a
if(!new_contact)
return NULL;
new_contact->host_notification_period = htp ? (char *)strdup(htp->name) : NULL;
new_contact->service_notification_period = stp ? (char *)strdup(stp->name) : NULL;
new_contact->host_notification_period_ptr = htp;
@ -2678,6 +2681,8 @@ int free_object_data(void) {
if(this_host->address != this_host->name)
my_free(this_host->address);
my_free(this_host->name);
my_free(this_host->check_period);
my_free(this_host->notification_period);
#ifdef NSCORE
my_free(this_host->plugin_output);
my_free(this_host->long_plugin_output);
@ -2791,6 +2796,8 @@ int free_object_data(void) {
my_free(this_contact->name);
my_free(this_contact->email);
my_free(this_contact->pager);
my_free(this_contact->host_notification_period);
my_free(this_contact->service_notification_period);
for(j = 0; j < MAX_CONTACT_ADDRESSES; j++)
my_free(this_contact->address[j]);
@ -2857,7 +2864,9 @@ int free_object_data(void) {
if(this_service->display_name != this_service->description)
my_free(this_service->display_name);
my_free(this_service->description);
my_free(this_service->check_command);
my_free(this_service->check_command);
my_free(this_service->check_period);
my_free(this_service->notification_period);
#ifdef NSCORE
my_free(this_service->plugin_output);
my_free(this_service->long_plugin_output);

View File

@ -131,6 +131,44 @@ char *my_strtok(char *buffer, const char *tokens) {
return sequence_head;
}
/* fix the problem with my_strtok() strduping and causing intermittent memory leaks
* use as regular my_strtok, specifying FALSE for free_orig
* when done (before calling again), specify TRUE for free_orig for it to handle the free() */
char *my_strtok_with_free(char *buffer, const char *tokens, int free_orig) {
char *token_position = NULL;
char *sequence_head = NULL;
static char *my_strtok_buffer = NULL;
static char *original_my_strtok_buffer = NULL;
if(buffer != NULL) {
my_free(original_my_strtok_buffer);
if((my_strtok_buffer = (char *)strdup(buffer)) == NULL)
return NULL;
original_my_strtok_buffer = my_strtok_buffer;
}
else if (free_orig == TRUE) {
my_free(original_my_strtok_buffer);
return NULL;
}
sequence_head = my_strtok_buffer;
if(sequence_head[0] == '\x0')
return NULL;
token_position = strchr(my_strtok_buffer, tokens[0]);
if(token_position == NULL) {
my_strtok_buffer = strchr(my_strtok_buffer, '\x0');
return sequence_head;
}
token_position[0] = '\x0';
my_strtok_buffer = token_position + 1;
return sequence_head;
}
/* fixes compiler problems under Solaris, since strsep() isn't included */
/* this code is taken from the glibc source */
char *my_strsep(char **stringp, const char *delim) {

1761
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -10,9 +10,9 @@ AC_PREFIX_DEFAULT(/usr/local/nagios)
PKG_NAME=nagios
PKG_VERSION="4.3.4"
PKG_VERSION="4.4.3"
PKG_HOME_URL="https://www.nagios.org/"
PKG_REL_DATE="2017-08-24"
PKG_REL_DATE="2019-01-15"
dnl Figure out how to invoke "install" and what install options to use.
AC_PROG_INSTALL
@ -51,6 +51,50 @@ AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
AC_TYPE_GETGROUPS
dnl Get Nagios autoconf-macros
AC_NAGIOS_GET_OS
AC_NAGIOS_GET_DISTRIB_TYPE
AC_NAGIOS_GET_INIT
AC_NAGIOS_GET_INETD
AC_NAGIOS_GET_PATHS
AC_NAGIOS_GET_FILES
dnl We only have these options available so we need to make them work until there are more
if test "x$src_init" != "xdefault-init" -a \
"x$src_init" != "xdefault-service" -a \
"x$src_init" != "xopenrc-init" -a \
"x$src_init" != "xnewbsd-init" -a \
"x$src_init" != "xopenbsd-init" -a \
"x$src_init" != "xupstart-init"; then
src_init="default-init"
init_type="sysv"
initname="nagios"
if test "x$initdiroverridden" != "xyes"; then
initdir="/etc/init.d"
fi
fi
dnl We need to check for a lock file specified
dnl And if the built in check didn't work (the N/A)
dnl then we need to find one!
if test "x$subsyslockdir" = "xN/A"; then
if test -d "/var/run"; then
subsyslockdir="/var/run"
subsyslockfile="/var/run/$INIT_PROG.lock"
else
subsyslockdir="/usr/local/nagios/var/"
subsyslockfile="/usr/local/nagios/var/$INIT_PROG.lock"
fi
fi
AC_ARG_WITH(lockfile,
AC_HELP_STRING([--with-lockfile=<path>],
[sets path for lockfile]),
subsyslockfile=$withval,
subsyslockfile=$subsyslockfile
)
dnl Check for asprintf() and friends...
AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
@ -58,7 +102,7 @@ AC_TRY_LINK([#include <stdarg.h>
va_list ap1,ap2;], [va_copy(ap1,ap2);],
ac_cv_HAVE_VA_COPY=yes,
ac_cv_HAVE_VA_COPY=no)])
if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
if test "x$ac_cv_HAVE_VA_COPY" = "xyes"; then
AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
else
AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
@ -66,7 +110,7 @@ else
va_list ap1,ap2;], [__va_copy(ap1,ap2);],
ac_cv_HAVE___VA_COPY=yes,
ac_cv_HAVE___VA_COPY=no)])
if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
if test "x$ac_cv_HAVE___VA_COPY" = "xyes"; then
AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
fi
fi
@ -103,7 +147,7 @@ void foo(const char *format, ...) {
main() { foo("hello"); }
],
ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
if test "x$ac_cv_HAVE_C99_VSNPRINTF" = "xyes"; then
AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
fi
@ -113,11 +157,11 @@ AC_SUBST(SNPRINTF_O)
dnl Checks for library functions.
AC_SEARCH_LIBS([getservbyname],[nsl],
[if test "$ac_cv_search_getservbyname" != "none required"; then
[if test "x$ac_cv_search_getservbyname" != "xnone required"; then
SOCKETLIBS="$SOCKETLIBS -lnsl"
fi])
AC_SEARCH_LIBS([connect],[socket],
[if test "$ac_cv_search_connect" != "none required"; then
[if test "x$ac_cv_search_connect" != "xnone required"; then
SOCKETLIBS="$SOCKETLIBS -lsocket"
fi])
AC_SUBST(SOCKETLIBS)
@ -139,6 +183,7 @@ AC_SEARCH_LIBS(nanosleep,[rt posix4],,[
exit 1
])
dnl TODO: host_os needs changed to reflect AC_NAGIOS
case $host_os in
*bsd*|darwin*)
root_grp=wheel
@ -153,8 +198,27 @@ AC_SUBST(root_grp)
INIT_OPTS="-o root -g $root_grp"
AC_SUBST(INIT_OPTS)
dnl Just enable all of the testing things
dnl --enable-debugging --enable-coverage --with-this-user
dnl This is here because if not, the user override doesnt happen
ENABLE_TESTING=no
AC_ARG_ENABLE(testing,AC_HELP_STRING([--enable-testing],[DEBUGGING ONLY - Enable testing options]),
[ENABLE_TESTING=$enableval])
not_a_user="^^^^^"
AC_ARG_WITH(this_user,AC_HELP_STRING([--with-this-user],[sets all user/group info for current user running ./configure]),this_user=$USER,this_user=$not_a_user)
if test "x$ENABLE_TESTING" = "xyes"; then
this_user=$USER
fi
AC_ARG_WITH(nagios_user,AC_HELP_STRING([--with-nagios-user=<user>],[sets user name to run nagios]),nagios_user=$withval,nagios_user=nagios)
AC_ARG_WITH(nagios_group,AC_HELP_STRING([--with-nagios-group=<grp>],[sets group name to run nagios]),nagios_grp=$withval,nagios_grp=nagios)
if test "x$this_user" != "x$not_a_user"; then
nagios_user=$this_user
nagios_grp=$this_user
fi
AC_SUBST(nagios_user)
AC_SUBST(nagios_grp)
AC_DEFINE_UNQUOTED(DEFAULT_NAGIOS_USER,"$nagios_user",[user name to run nagios])
@ -164,6 +228,12 @@ AC_SUBST(INSTALL_OPTS)
AC_ARG_WITH(command_user,AC_HELP_STRING([--with-command-user=<user>],[sets user name for command access]),command_user=$withval,command_user=$nagios_user)
AC_ARG_WITH(command_group,AC_HELP_STRING([--with-command-group=<grp>],[sets group name for command access]),command_grp=$withval,command_grp=$nagios_grp)
if test "x$this_user" != "x$not_a_user"; then
command_user=$this_user
command_grp=$this_user
fi
AC_SUBST(command_user)
AC_SUBST(command_grp)
COMMAND_OPTS="-o $command_user -g $command_grp"
@ -177,15 +247,35 @@ AC_ARG_WITH(mail,
MAIL_PROG=$withval,
MAIL_PROG=no
)
if test x$MAIL_PROG = xno; then
if test "x$MAIL_PROG" = "xno"; then
AC_PATH_PROG(MAIL_PROG,mail)
fi
dnl Fix for systems that don't (yet) have mail/mailx installed...
if test x$MAIL_PROG = x; then
MAIL_PROG="/bin/mail"
if test "x$MAIL_PROG" = "x"; then
if which mail >/dev/null; then
MAIL_PROG=`which mail`
elif which sendmail >/dev/null; then
MAIL_PROG=`which sendmail`
else
MAIL_PROG="/bin/mail"
fi
fi
AC_SUBST(MAIL_PROG)
dnl Determine location of the rm binary
BIN_RM=`which rm`
if test $? -ne 0; then
BIN_RM='/bin/rm'
fi
AC_SUBST(BIN_RM)
dnl Determine location of the kill binary
BIN_KILL=`which kill`
if test $? -ne 0; then
BIN_KILL='/bin/kill'
fi
AC_SUBST(BIN_KILL)
dnl Check for location of Apache conf.d directory
HTTP_CONF=no
AC_ARG_WITH(httpd_conf,
@ -195,19 +285,19 @@ AC_ARG_WITH(httpd_conf,
HTTPD_CONF=no
)
LN_HTTPD_SITES_ENABLED=0
if test x$HTTPD_CONF = xno; then
if test -d /etc/httpd/conf.d; then
if test "x$HTTPD_CONF" = "xno"; then
if test -d "/etc/httpd/conf.d"; then
HTTPD_CONF="/etc/httpd/conf.d"
elif test -d /etc/apache2/conf.d; then
elif test -d "/etc/apache2/conf.d"; then
HTTPD_CONF="/etc/apache2/conf.d"
elif test -d /etc/apache2/sites-available; then
elif test -d "/etc/apache2/sites-available"; then
HTTPD_CONF="/etc/apache2/sites-available"
if test -d /etc/apache2/sites-enabled; then
if test -d "/etc/apache2/sites-enabled"; then
LN_HTTPD_SITES_ENABLED=1
fi
elif test -d /etc/apache2/sites-enabled; then
elif test -d "/etc/apache2/sites-enabled"; then
HTTPD_CONF="/etc/apache2/sites-enabled"
elif test -d /etc/apache/conf.d; then
elif test -d "/etc/apache/conf.d"; then
HTTPD_CONF="/etc/apache/conf.d"
else
HTTPD_CONF="/etc/httpd/conf.d"
@ -216,6 +306,16 @@ fi
AC_SUBST(HTTPD_CONF)
AC_SUBST(LN_HTTPD_SITES_ENABLED)
dnl Check if RLIMIT_PROC exists
AC_TRY_COMPILE([#ifdef __STDC__
#include <sys/time.h>
#include <sys/resource.h>
#endif],
[struct rlimit rlim;
int ilim = getrlimit(RLIMIT_NPROC, &rlim);],
[AC_DEFINE(DETECT_RLIMIT_PROBLEM,1,[System has RLIMIT_PROC]) AC_MSG_RESULT([checking for RLIMIT_PROC... yes])],
[AC_MSG_RESULT([checking for RLIMIT_PROC... no])])
dnl Location of check result path
CHECKRESULTDIR=no
AC_ARG_WITH(checkresult-dir,
@ -224,12 +324,13 @@ AC_ARG_WITH(checkresult-dir,
CHECKRESULTDIR=$withval,
CHECKRESULTDIR=no
)
if test x$CHECKRESULTDIR = xno; then
if test "x$CHECKRESULTDIR" = "xno"; then
CHECKRESULTDIR="$localstatedir/spool/checkresults"
fi
AC_SUBST(CHECKRESULTDIR)
dnl Location of check result path
dnl TODO: this should be moved to autoconf-macros
TMPDIR=no
AC_ARG_WITH(temp-dir,
AC_HELP_STRING([--with-temp-dir=<path>],
@ -237,54 +338,20 @@ AC_ARG_WITH(temp-dir,
TMPDIR=$withval,
TMPDIR=no
)
if test x$TMPDIR = xno; then
if test "x$TMPDIR" = "xno"; then
TMPDIR="/tmp"
fi
AC_SUBST(TMPDIR)
dnl Check for location of init scripts
init_dir=/etc/rc.d/init.d
if test -d /etc/rc.d/init.d; then
init_dir="/etc/rc.d/init.d"
elif test -d /usr/local/etc/rc.d; then
init_dir="/usr/local/etc/rc.d"
elif test -d /etc/rc.d; then
init_dir="/etc/rc.d"
elif test -d /etc/init.d; then
init_dir="/etc/init.d"
elif test -d /sbin/init.d; then
init_dir="/sbin/init.d"
fi
dnl User can override init script location
AC_ARG_WITH(init_dir,
AC_HELP_STRING([--with-init-dir=<path>],
[sets directory to place init script into]),
init_dir=$withval
)
AC_SUBST(init_dir)
dnl User can override lock file location
dnl Use the /var/run/ path by default
dnl and use /run if it is available
default_lockfile_path=/var/run/nagios.lock
if test -d /run; then
default_lockfile_path=/run/nagios.lock
fi
AC_ARG_WITH(lockfile,
AC_HELP_STRING([--with-lockfile=<path>],
[sets path for lock file (default: [/var]/run/nagios.lock)]),
lockfile=$withval,
lockfile=$default_lockfile_path
)
AC_SUBST(lockfile)
dnl Determine the library to be used by the iobroker
dnl epoll_*() is linux specific and was added to glibc 2.3.2, so we
dnl check for 2.4 and use epoll() if we're on that version or later.
dnl But we still need to set the variable GLIBC_NEWER_2_4 since
dnl it is used later in calculations perhaps by OSes not linux
GLIBC_NEWER_2_4=0
case $host_os in
linux*)
@ -304,7 +371,7 @@ linux*)
[GLIBC_NEWER_2_4=1; AC_MSG_RESULT(yes)],
[GLIBC_NEWER_2_4=0; AC_MSG_RESULT(no)]
)
if test $GLIBC_NEWER_2_4 -eq 1; then
if test "$GLIBC_NEWER_2_4" -eq 1; then
AC_CHECK_HEADER([sys/epoll.h])
fi
;;
@ -320,7 +387,7 @@ AC_ARG_WITH(iobroker,
case $IOBROKER_METHOD in
epoll*)
if test $GLIBC_NEWER_2_4 -eq 1 -a x$ac_cv_header_sys_epoll_h = xyes ; then
if test "$GLIBC_NEWER_2_4" -eq 1 -a "x$ac_cv_header_sys_epoll_h" = "xyes"; then
AC_DEFINE([IOBROKER_USES_EPOLL])
else
echo "\"epoll\" is not available as an iobroker method."
@ -329,7 +396,7 @@ epoll*)
fi
;;
poll*)
if test x$ac_cv_header_sys_poll_h = xyes -o x$ac_cv_header_poll_h = xyes ; then
if test "x$ac_cv_header_sys_poll_h" = "xyes" -o "x$ac_cv_header_poll_h" = "xyes"; then
AC_DEFINE([IOBROKER_USES_POLL])
else
echo "\"poll\" is not available as an iobroker method."
@ -338,7 +405,7 @@ poll*)
fi
;;
select*)
if test x$ac_cv_header_sys_select_h = xyes ; then
if test "x$ac_cv_header_sys_select_h" = "xyes"; then
AC_DEFINE([IOBROKER_USES_SELECT])
else
echo "\"select\" is not available as an iobroker method."
@ -347,13 +414,13 @@ select*)
fi
;;
none*)
if test $GLIBC_NEWER_2_4 -eq 1 -a x$ac_cv_header_sys_epoll_h = xyes ; then
if test "$GLIBC_NEWER_2_4" -eq 1 -a "x$ac_cv_header_sys_epoll_h" = "xyes"; then
AC_DEFINE([IOBROKER_USES_EPOLL])
IOBROKER_METHOD="epoll"
elif test x$ac_cv_header_sys_poll_h = xyes -o x$ac_cv_header_poll_h = xyes ; then
elif test "x$ac_cv_header_sys_poll_h" = "xyes" -o "x$ac_cv_header_poll_h" = "xyes"; then
AC_DEFINE([IOBROKER_USES_POLL])
IOBROKER_METHOD="poll"
elif test x$ac_cv_header_sys_select_h = xyes ; then
elif test "x$ac_cv_header_sys_select_h" = "xyes"; then
AC_DEFINE([IOBROKER_USES_SELECT])
IOBROKER_METHOD="select"
else
@ -362,8 +429,8 @@ none*)
fi
;;
*)
echo "\"$IOBROKER_METHOD\" is not a valid method for --with-iobroker"
exit 1
echo "\"$IOBROKER_METHOD\" is not a valid method for --with-iobroker"
exit 1
;;
esac
@ -381,7 +448,21 @@ AC_ARG_WITH(gd-inc,
)
TRYGD=yep
TRYGD=yes
dnl 'NERD' is now disabled by default. enable it for functionality
NERD=no
NERD_O=""
AC_ARG_ENABLE(nerd,
AC_HELP_STRING([--enable-nerd],
[enables Nagios Event Radio Dispatch (NERD)]),
NERD=yes
)
if test "x$NERD" = "xyes"; then
AC_DEFINE_UNQUOTED(ENABLE_NERD,,[defined if user enabled NERD (radio dispatcher)])
NERD_O="nerd.o"
fi
AC_SUBST(NERD_O)
dnl 'corewindow' is now disabled. Allow it to be enabled if someone wants it
COREWINDOW=no
@ -393,7 +474,7 @@ AC_ARG_ENABLE(corewindow,
AC_SUBST(COREWINDOW)
dnl statusmap CGI enabled by default, unless users chooses not to use it
TRYSTATUSMAP=yep
TRYSTATUSMAP=yes
AC_ARG_ENABLE(statusmap,
AC_HELP_STRING([--disable-statusmap],
[disables compilation of statusmap CGI]),
@ -402,14 +483,14 @@ AC_ARG_ENABLE(statusmap,
dnl statuswrl CGI enabled by default, unless users chooses not to use it
TRYSTATUSWRL=yep
TRYSTATUSWRL=yes
AC_ARG_ENABLE(statuswrl,
AC_HELP_STRING([--disable-statuswrl],
[disables compilation of statuswrl (VRML) CGI]),
TRYSTATUSWRL=nope
)
if test x$TRYSTATUSWRL = xyep; then
if test "x$TRYSTATUSWRL" = "xyes"; then
AC_DEFINE_UNQUOTED(USE_STATUSWRL,,[statuswrl CGI enabled by default, unless users chooses not to use it])
CGIEXTRAS="$CGIEXTRAS statuswrl.cgi"
fi
@ -464,7 +545,7 @@ char $2();
dnl Should we try and detect the GD libs?
if test x$TRYGD = xyep; then
if test "x$TRYGD" = "xyes"; then
dnl libiconv is required on some systems - tack it on if found
AC_CHECK_LIB(iconv,main,ICONV=-liconv,)
@ -473,36 +554,36 @@ if test x$TRYGD = xyep; then
dnl GD > 1.8.3 requires the TrueType library to be present as well, so test for that first...
JMD_CHECK_LIB_ORDER(gd,gdImagePng,1,[
GDLIBFOUND=yep
GDLIBFOUND=yes
GDLIBS="-lgd -lttf -lpng -ljpeg -lz -lm"
],:,[-lttf -lpng -ljpeg -lz -lm])
dnl GD > 1.8.1 requires the jpeg library to be present as well, so test for that...
if test x$GDLIBFOUND = x; then
if test "x$GDLIBFOUND" = "x"; then
JMD_CHECK_LIB_ORDER(gd,gdImagePng,2,[
GDLIBFOUND=yep
GDLIBFOUND=yes
GDLIBS="-lgd $ICONV -lpng -ljpeg -lz -lm"
],:,[$ICONV -lpng -ljpeg -lz -lm])
fi
dnl If we failed the first test, try without jpeg library
if test x$GDLIBFOUND = x; then
if test "x$GDLIBFOUND" = "x"; then
JMD_CHECK_LIB_ORDER(gd,gdImagePng,3,[
GDLIBFOUND=yep
GDLIBFOUND=yes
GDLIBS="-lgd $ICONV -lz -lm -lpng"
],:,[$ICONV -lz -lm -lpng])
fi
dnl We failed again, so try a different library ordering (without jpeg libs)
if test x$GDLIBFOUND = x; then
if test "x$GDLIBFOUND" = "x"; then
JMD_CHECK_LIB_ORDER(gd,gdImagePng,4,[
GDLIBFOUND=yep
GDLIBFOUND=yes
GDLIBS="-lgd $ICONV -lpng -lz -lm"
],:,[$ICONV -lpng -lz -lm])
fi
dnl Did we find the necessary GD libraries?
if test x$GDLIBFOUND = x; then
if test "x$GDLIBFOUND" = "x"; then
echo ""
echo ""
echo "*** GD, PNG, and/or JPEG libraries could not be located... *********"
@ -538,8 +619,9 @@ if test x$TRYGD = xyep; then
dnl We found the GD lib!
else
echo "GD library was found!"
if test x$TRYSTATUSMAP = xyep; then
AC_MSG_CHECKING([for GD library])
AC_MSG_RESULT([yes])
if test "x$TRYSTATUSMAP" = "xyes"; then
AC_DEFINE_UNQUOTED(USE_STATUSMAP,,[defined if the user chose to include status map])
CGIEXTRAS="$CGIEXTRAS statusmap.cgi"
AC_CHECK_LIB(gd,gdImageCreateTrueColor,
@ -579,7 +661,7 @@ AC_ARG_ENABLE(nanosleep,
USE_NANOSLEEP=$enableval,
USE_NANOSLEEP=yes
)
if test x$USE_NANOSLEEP = xyes; then
if test "x$USE_NANOSLEEP" = "xyes"; then
AC_DEFINE_UNQUOTED(USE_NANOSLEEP,,[enables use of nanosleep (instead of sleep)])
fi
@ -592,24 +674,24 @@ AC_ARG_ENABLE(event-broker,
)
BROKER_LDFLAGS=""
BROKERLIBS="";
some_dl_found="no";
if test x$USE_EVENTBROKER = xyes; then
BROKERLIBS=""
some_dl_found=no
if test "x$USE_EVENTBROKER" = "xyes"; then
dnl Which loader library should we use? libtdl or dl?
dnl Hopefully this will be portable and not give us headaches...
AC_CHECK_HEADER(ltdl.h,[
AC_CHECK_LIB(ltdl,lt_dlinit,[
AC_DEFINE(HAVE_LTDL_H,,[Which loader library should we use? libtdl or dl?])
some_dl_found="yes"
some_dl_found=yes
BROKERLIBS="$BROKERLIBS -lltdl"
])
])
if test "x$some_dl_found" != xyes; then
if test "x$some_dl_found" != "xyes"; then
AC_CHECK_HEADER(dlfcn.h,[
AC_CHECK_LIB(dl,dlopen,[
AC_DEFINE(HAVE_DLFCN_H,,[Which loader library should we use? libtdl or dl?])
some_dl_found="yes"
some_dl_found=yes
BROKERLIBS="$BROKERLIBS -ldl"
])
])
@ -646,7 +728,7 @@ if test x$USE_EVENTBROKER = xyes; then
esac
AC_SUBST(BROKER_LDFLAGS)
AC_SUBST(BROKERLIBS)
test "x$BROKER_LDFLAGS" != x && AC_MSG_RESULT([$BROKER_LDFLAGS])
test "x$BROKER_LDFLAGS" != "x" && AC_MSG_RESULT([$BROKER_LDFLAGS])
dnl - Modified version from www.erlang.org
@ -712,7 +794,7 @@ AC_ARG_ENABLE(cygwin,
[enables building under the CYGWIN environment]),
[cygwin=$enableval]
)
if test x$cygwin = xyes; then
if test "x$cygwin" = "xyes"; then
CFLAGS="${CFLAGS} -DCYGWIN"
nagios_name=nagios.exe;
nagiostats_name=nagiostats.exe;
@ -732,7 +814,21 @@ dnl Find traceroute
AC_PATH_PROG(PATH_TO_TRACEROUTE,traceroute)
AC_DEFINE_UNQUOTED(TRACEROUTE_COMMAND,"$PATH_TO_TRACEROUTE",[traceroute command to use])
dnl Enable debugging?
ENABLE_DEBUGGING=no
AC_ARG_ENABLE(debugging,AC_HELP_STRING([--enable-debugging],[DEBUGGING ONLY - Enable some debugging for Nagios Core]),
[ENABLE_DEBUGGING=$enableval])
if test "x$ENABLE_DEBUGGING" = "xyes" -o "x$ENABLE_TESTING" = "xyes"; then
CFLAGS="${CFLAGS} -O0 -ggdb3 -g3"
fi
dnl Enable coverage?
ENABLE_COVERAGE=no
AC_ARG_ENABLE(coverage,AC_HELP_STRING([--enable-coverage],[DEBUGGING ONLY - Enable coverage reports (use with debugging)]),
[ENABLE_COVERAGE=$enableval])
if test "x$ENABLE_COVERAGE" = "xyes" -o "x$ENABLE_TESTING" = "xyes"; then
CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
fi
dnl Package directory for Solaris pkgmk (and other OSs, eventually)
dnl VERSION=`grep 1.0 include/common.h | cut -d ' ' -f 3 | sed 's/"//g'`
@ -768,7 +864,7 @@ AC_ARG_ENABLE(libtap,
# Disabled for moment
# If not local, check if we can use the system one
#if test "$enable_libtap" != "yes" ; then
#if test "$enable_libtap" != "yes"; then
# dnl Check for libtap, to run perl-like tests
# AC_CHECK_LIB(tap, plan_tests,
# enable_libtap="yes"
@ -776,7 +872,7 @@ AC_ARG_ENABLE(libtap,
#fi
# Finally, define tests if we use libtap
if test "$enable_libtap" = "yes" ; then
if test "x$enable_libtap" = "xyes" -o "x$ENABLE_TESTING" = "xyes"; then
AC_CONFIG_SUBDIRS([tap])
USE_LIBTAP=yes
else
@ -788,7 +884,6 @@ AC_SUBST(USE_LIBTAP)
AC_SUBST(CGIEXTRAS)
AC_SUBST(GDLIBS)
AC_SUBST(BASEEXTRALIBS)
AC_SUBST(INITDIR)
AC_SUBST(USE_EVENTBROKER)
AC_PATH_PROG(PERL,perl)
@ -801,11 +896,34 @@ if test -z "$UNZIP"; then
AC_MSG_ERROR([Cannot continue without unzip!])
fi
AC_OUTPUT(Makefile lib/Makefile subst pkginfo base/Makefile common/Makefile contrib/Makefile cgi/Makefile html/Makefile module/Makefile worker/Makefile worker/ping/Makefile xdata/Makefile daemon-init openrc-init t/Makefile t-tap/Makefile)
dnl Need this here because of removing it from autoconf-macros
eval sbindir=$sbindir
AC_OUTPUT([
Makefile
lib/Makefile
base/Makefile
common/Makefile
contrib/Makefile
cgi/Makefile
html/Makefile
module/Makefile
worker/Makefile
worker/ping/Makefile
xdata/Makefile
subst
pkginfo
startup/openrc-init
startup/default-init
startup/default-service
startup/upstart-init
t/Makefile
t-tap/Makefile
])
perl subst include/locations.h
perl subst html/config.inc.php
dnl perl subst daemon-service
echo ""
@ -828,6 +946,16 @@ perl subst sample-config/template-object/printer.cfg
perl subst sample-config/template-object/switch.cfg
incdir=`eval echo $includedir`
if test "x$incdir" = "x$prefix/include"; then
includedir=$prefix/include/nagios
fi
if test "x$USE_EVENTBROKER" != "xyes"; then
USE_EVENTBROKER=no
fi
dnl Review options
echo ""
echo ""
@ -840,20 +968,12 @@ echo " -------------------------"
AC_MSG_RESULT([ Nagios executable: $nagios_name])
AC_MSG_RESULT([ Nagios user/group: $nagios_user,$nagios_grp])
AC_MSG_RESULT([ Command user/group: $command_user,$command_grp])
if test x$USE_EVENTBROKER = xyes; then
AC_MSG_RESULT([ Event Broker: yes])
else
AC_MSG_RESULT([ Event Broker: no])
fi
AC_MSG_RESULT([ Event Broker: $USE_EVENTBROKER])
AC_MSG_RESULT([ Install \${prefix}: $prefix])
incdir=`eval echo $includedir`
if test x$incdir = x$prefix/include; then
includedir=$prefix/include/nagios
fi
AC_MSG_RESULT([ Install \${includedir}: $includedir])
AC_MSG_RESULT([ Lock file: $lockfile])
AC_MSG_RESULT([ Lock file: $subsyslockfile])
AC_MSG_RESULT([ Check result directory: $CHECKRESULTDIR])
AC_MSG_RESULT([ Init directory: $init_dir])
AC_MSG_RESULT([ Init directory: $initdir])
AC_MSG_RESULT([ Apache conf.d directory: $HTTPD_CONF])
AC_MSG_RESULT([ Mail program: $MAIL_PROG])
AC_MSG_RESULT([ Host OS: $host_os])

View File

@ -22,7 +22,7 @@ INSTALL_OPTS=@INSTALL_OPTS@
prefix=@prefix@
exec_prefix=@exec_prefix@
CGIDIR=@sbindir@
CGIDIR=@cgibindir@
BINDIR=@bindir@
CGIS=traceroute.cgi daemonchk.cgi
@ -88,14 +88,18 @@ $(CGI_O): $(CGI_C)
##############################################################################
# rpm making automation for CentOS/RHEL.
ARCH ?= $(shell arch)
ARCH ?= $(shell uname -m)
ifeq ($(ARCH),x86_64)
RPM_ARCH := x86_64
else
ifeq ($(ARCH),i686)
RPM_ARCH := i386
else
ifeq ($(ARCH),aarch64)
RPM_ARCH := aarch64
else
$(error Unknown arch "$(ARCH)".)
endif
endif
endif

View File

@ -1,6 +1,6 @@
/************************************************************************
*
* CONVERTCFG.C - Config File Convertor
* CONVERTCFG.C - Config File Converter
*
* Copyright (c) 2001-2005 Ethan Galstad (egalstad@nagios.org)
* Last Modified: 08-12-2005
@ -310,7 +310,7 @@ int main(int argc, char **argv) {
printf("\tretain_status_information\t1\t; Retain status information across program restarts\n");
printf("\tretain_nonstatus_information\t1\t; Retain non-status information across program restarts\n");
printf("\n");
printf("\tregister\t\t\t0\t; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!\n");
printf("\tregister\t\t\t0\t; DON'T REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!\n");
printf("\t}\n\n");
have_template = 1;
@ -430,7 +430,7 @@ int main(int argc, char **argv) {
printf("\tretain_status_information\t1\t; Retain status information across program restarts\n");
printf("\tretain_nonstatus_information\t1\t; Retain non-status information across program restarts\n");
printf("\n");
printf("\tregister\t\t\t0\t; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!\n");
printf("\tregister\t\t\t0\t; DON'T REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!\n");
printf("\t}\n\n");
have_template = 1;
@ -667,7 +667,7 @@ int main(int argc, char **argv) {
temp_ptr = my_strsep(&temp_ptr2, "[");
temp_ptr = my_strsep(&temp_ptr2, ";");
printf("# serviceextinfo definition\n", temp_ptr);
printf("# '%s' serviceextinfo definition\n", temp_ptr);
printf("define serviceextinfo{\n");
printf("\thost_name\t\t%s\t\t; The name of the service this data is associated with\n", temp_ptr);

View File

@ -21,6 +21,7 @@ div.status { font-size: 10pt; text-align: center; }
.statusUNKNOWN { font-size: 8pt; background-color: #ffbb55; border: 1px solid #777777; padding: 0 5 0 5; }
.statusWARNING { font-size: 8pt; background-color: #ffff00; border: 1px solid #777777; padding: 0 5 0 5; }
.statusCRITICAL { font-size: 8pt; background-color: #f88888; border: 1px solid #777777; padding: 0 5 0 5; }
.statusCRITICALACK { font-size: 8pt; background-color: #f88888; border: 1px solid #777777; padding: 0 5 0 5; }
.statusHOSTPENDING { font-size: 8pt; background-color: #acacac; line-height: 150%; padding: 0 4 0 4; }
.statusHOSTUP { font-size: 8pt; background-color: #cce8cc; line-height: 150%; padding: 0 4 0 4; }

View File

@ -202,23 +202,6 @@ want to reserve that for special cases.
The following are completely optional (for now):
@li command - The command we executed
@li timeout - The timeout Nagios requested for this job
@li ru_nsignals - The ru_nsignals field from the rusage struct
@li ru_nswap - The ru_nswap field from the rusage struct
@li ru_minflt - The ru_minflt field from the rusage struct
@li ru_majflt - The ru_majflt field from the rusage struct
@li ru_stime - The ru_stime field from the rusage struct
@li ru_utime - The ru_utime field from the rusage struct
@li ru_inblock - The ru_inblock field from the rusage struct
@li ru_oublock - The ru_oublock field from the rusage struct
The meaning of the fields of the rusage struct can be viewed in the
section 2 man-page for the getrusage() system call. Normally, you
would access it by executing the following command:
@verbatim
man 2 getrusage
@endverbatim
Note that most systems do not support all the fields of the rusage
struct and may leave them empty if so.
@section logging Logging
Worker processes can send events to the main Nagios process that

View File

@ -1,5 +1,5 @@
PROJECT_NAME = Nagios
PROJECT_NUMBER = 4.3.4
PROJECT_NUMBER = 4.4.3
PROJECT_BRIEF = "Dev docs for Nagios core and neb-module hackers"
INPUT = lib/ docs/

View File

@ -7,8 +7,8 @@ exec_prefix=@exec_prefix@
LOGDIR=@localstatedir@
CFGDIR=@sysconfdir@
BINDIR=@bindir@
CGIDIR=@sbindir@
HTMLDIR=@datadir@
CGIDIR=@cgibindir@
HTMLDIR=@webdir@
datarootdir=@datarootdir@
INSTALL=@INSTALL@
INSTALL_OPTS=@INSTALL_OPTS@
@ -18,10 +18,10 @@ CP=@CP@
all html:
(cd angularjs && unzip -u angular-1.3.9.zip)
(cd angularjs && unzip -u ui-utils-0.2.1.zip)
if [ ! -d bootstrap-3.3.0 ] ; then mkdir -p bootstrap-3.3.0 && ( cd bootstrap-3.3.0 && unzip -u ../bootstrap-3.3.0-dist.zip && mv dist/* . && rmdir dist ) ; fi
(cd angularjs && unzip -u ui-utils-0.2.3.zip)
if [ ! -d bootstrap-3.3.7 ] ; then mkdir -p bootstrap-3.3.7 && ( cd bootstrap-3.3.7 && unzip -u ../bootstrap-3.3.7-dist.zip && mv dist/* . && rmdir dist ) ; fi
mkdir -p d3
(cd d3 && unzip -u ../d3-3.5.3.zip)
(cd d3 && unzip -u ../d3-3.5.17.zip)
clean:
rm -f *.cfg *.sub core
@ -34,8 +34,8 @@ clean:
rm -f stylesheets/*~
rm -f js/*~
rm -rf angularjs/angular-1.3.9
rm -rf angularjs/ui-utils-0.2.1
rm -rf bootstrap-3.3.0
rm -rf angularjs/ui-utils-0.2.3
rm -rf bootstrap-3.3.7
rm -rf d3
distclean: clean
@ -58,9 +58,9 @@ install:
# Directories for new CGI pages
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/angularjs
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/angularjs/angular-1.3.9
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/angularjs/ui-utils-0.2.1
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.0
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.0/css
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/angularjs/ui-utils-0.2.3
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.7
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.7/css
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/d3
$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/spin
# End of directories for new CGI pages
@ -122,10 +122,10 @@ install:
# Support files for new graphical CGIs
$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/angular-1.3.9/angular.min.js $(DESTDIR)$(HTMLDIR)/angularjs/angular-1.3.9
$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/angular-1.3.9/angular.min.js.map $(DESTDIR)$(HTMLDIR)/angularjs/angular-1.3.9
$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/ui-bootstrap-tpls-0.12.0.min.js $(DESTDIR)$(HTMLDIR)/angularjs
$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/ui-utils-0.2.1/ui-utils.js $(DESTDIR)$(HTMLDIR)/angularjs/ui-utils-0.2.1
$(INSTALL) -m 664 $(INSTALL_OPTS) bootstrap-3.3.0/css/bootstrap.min.css $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.0/css
$(INSTALL) -m 664 $(INSTALL_OPTS) bootstrap-3.3.0/css/bootstrap-theme.min.css $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.0/css
$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/ui-bootstrap-tpls-0.14.3.min.js $(DESTDIR)$(HTMLDIR)/angularjs
$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/ui-utils-0.2.3/ui-utils.js $(DESTDIR)$(HTMLDIR)/angularjs/ui-utils-0.2.3
$(INSTALL) -m 664 $(INSTALL_OPTS) bootstrap-3.3.7/css/bootstrap.min.css $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.7/css
$(INSTALL) -m 664 $(INSTALL_OPTS) bootstrap-3.3.7/css/bootstrap-theme.min.css $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.7/css
$(INSTALL) -m 664 $(INSTALL_OPTS) d3/d3.min.js $(DESTDIR)$(HTMLDIR)/d3
$(INSTALL) -m 664 $(INSTALL_OPTS) spin/spin.min.js $(DESTDIR)$(HTMLDIR)/spin
# End of support files for new graphical CGIs

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
html/d3-3.5.17.zip Normal file

Binary file not shown.

Binary file not shown.

View File

@ -114,7 +114,7 @@
</div>
<div class="checkbox">
<label>
<input type="checkbox"
<input type="checkbox"
ng-model="params.ignorerepeatedstates">
Ignore Repeated States
</label>

View File

@ -43,5 +43,5 @@
</td>
</tr>
</tbody>
</table>
</table>

View File

@ -5,9 +5,9 @@
<title>Nagios Histogram</title>
<link type="image/ico" rel="shortcut icon" href="images/favicon.ico"/>
<link type="text/css" rel="stylesheet"
href="bootstrap-3.3.0/css/bootstrap.min.css">
href="bootstrap-3.3.7/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet"
href="bootstrap-3.3.0/css/bootstrap-theme.min.css">
href="bootstrap-3.3.7/css/bootstrap-theme.min.css">
<link type='text/css' rel='stylesheet' href='stylesheets/common.css'>
<link type='text/css' rel='stylesheet'
href='stylesheets/histogram.css'>
@ -16,9 +16,9 @@
<script type="text/javascript"
src="angularjs/angular-1.3.9/angular.min.js"></script>
<script type="text/javascript"
src="angularjs/ui-bootstrap-tpls-0.12.0.min.js"></script>
src="angularjs/ui-bootstrap-tpls-0.14.3.min.js"></script>
<script type="text/javascript"
src="angularjs/ui-utils-0.2.1/ui-utils.js"></script>
src="angularjs/ui-utils-0.2.3/ui-utils.js"></script>
<script type="text/javascript" src="d3/d3.min.js"></script>
<script type="text/javascript" src="spin/spin.min.js"></script>
<script type="text/javascript" src="js/histogram.js"></script>
@ -63,7 +63,7 @@
reload="{{reload}}"
build="canBuildHistogram()">
</div>
<div id="menubutton">
<button type="button" class="btn" ng-click="displayForm()">
<img src="images/menu.png"/>

View File

@ -3,6 +3,14 @@
require_once(dirname(__FILE__).'/../config.inc.php');
// get enable_page_tour no matter what
function get_enable_page_tour(){
global $cfg;
$cfg["enable_page_tour"] = true;
read_cgi_config_file();
}
get_enable_page_tour();
function get_update_information(){
global $cfg;
@ -125,53 +133,59 @@ function get_update_information(){
function read_main_config_file($thefile=""){
global $cfg;
$contents=array();
static $already_called = false;
static $contents=array();
// file name can be overridden from default
if(isset($thefile) && $thefile!="")
$fname=$thefile;
else
$fname=$cfg['main_config_file'];
// open main config file for reading...
if(($fh=@fopen($fname,'r'))!=FALSE){
// read all lines in the config file
while(!feof($fh)){
$s=fgets($fh);
if (!$already_called) {
// skip comments
if($s[0]=='#')
continue;
// file name can be overridden from default
if(isset($thefile) && $thefile!="")
$fname=$thefile;
else
$fname=$cfg['main_config_file'];
// open main config file for reading...
if(($fh=@fopen($fname,'r'))!=FALSE){
// read all lines in the config file
while(!feof($fh)){
$s=fgets($fh);
// skip blank lines
// TODO - is this necessary?
// split comments out from config
$s2=explode(";",$s);
// get var/val pairs
$v=explode("=",$s2[0]);
if(isset($v[0]) && isset($v[1])){
// trim var/val pairs
$v[0]=trim($v[0]);
$v[1]=trim($v[1]);
// allow for multiple values for some variables...
$arr=false;
if(!strcmp($v[0],"cfg_file"))
$arr=true;
else if(!strcmp($v[0],"cfg_dir"))
$arr=true;
// skip comments
if($s[0]=='#')
continue;
if($arr==true)
$contents[$v[0]][] = $v[1];
else
$contents[$v[0]] = $v[1];
// skip blank lines
// TODO - is this necessary?
// split comments out from config
$s2=explode(";",$s);
// get var/val pairs
$v=explode("=",$s2[0]);
if(isset($v[0]) && isset($v[1])){
// trim var/val pairs
$v[0]=trim($v[0]);
$v[1]=trim($v[1]);
// allow for multiple values for some variables...
$arr=false;
if(!strcmp($v[0],"cfg_file"))
$arr=true;
else if(!strcmp($v[0],"cfg_dir"))
$arr=true;
if($arr==true)
$contents[$v[0]][] = $v[1];
else
$contents[$v[0]] = $v[1];
}
}
fclose($fh);
}
fclose($fh);
$already_called = true;
}
return $contents;
@ -181,46 +195,52 @@ function read_main_config_file($thefile=""){
// reads variables from cgi config file
function read_cgi_config_file($thefile=""){
global $cfg;
$contents=array();
// file name can be overridden from default
if(isset($thefile) && $thefile!="")
$fname=$thefile;
else
$fname=$cfg['cgi_config_file'];
static $already_called = false;
static $contents=array();
if (!$already_called) {
// open cgi config file for reading...
if(($fh=@fopen($fname,'r'))!=FALSE){
// read all lines in the config file
while(!feof($fh)){
$s=fgets($fh);
// file name can be overridden from default
if(isset($thefile) && $thefile!="")
$fname=$thefile;
else
$fname=$cfg['cgi_config_file'];
// skip comments
if($s[0]=='#')
continue;
// open cgi config file for reading...
if(($fh=@fopen($fname,'r'))!=FALSE){
// read all lines in the config file
while(!feof($fh)){
$s=fgets($fh);
// skip blank lines
// TODO - is this necessary?
// split comments out from config
$s2=explode(";",$s);
// skip comments
if($s[0]=='#')
continue;
// skip blank lines
// TODO - is this necessary?
// get var/val pairs
$v=explode("=",$s2[0]);
if(isset($v[0]) && isset($v[1])){
// split comments out from config
$s2=explode(";",$s);
// get var/val pairs
$v=explode("=",$s2[0]);
if(isset($v[0]) && isset($v[1])){
// trim var/val pairs
$v[0]=ltrim(rtrim($v[0]));
$v[1]=ltrim(rtrim($v[1]));
// trim var/val pairs
$v[0]=ltrim(rtrim($v[0]));
$v[1]=ltrim(rtrim($v[1]));
// do not allow for multiple values
$contents[$v[0]] = $v[1];
$cfg[$v[0]] = $v[1];
// do not allow for multiple values
$contents[$v[0]] = $v[1];
$cfg[$v[0]] = $v[1];
}
}
fclose($fh);
}
fclose($fh);
$already_called = true;
}
return $contents;

View File

@ -26,22 +26,23 @@ if ("@COREWINDOW@" == "yes" && isset($_GET['corewindow'])) {
$url = "main.php";
}
$this_year = '2017';
$this_year = '2019';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<script LANGUAGE="javascript">
var n = Math.round(Math.random() * 10000000000);
document.write("<title>Nagios Core on " + window.location.hostname + "</title>");
document.cookie = "NagFormId=" + n.toString(16);
</script>
<title>Nagios: <?php echo $_SERVER['SERVER_NAME']; ?></title>
<link rel="shortcut icon" href="images/favicon.ico" type="image/ico">
<script LANGUAGE="javascript">
var n = Math.round(Math.random() * 10000000000);
document.cookie = "NagFormId=" + n.toString(16);
</script>
</head>
<frameset cols="180,*" style="border: 0px;">
<frameset cols="180,*" style="border: 0px; framespacing: 0px">
<frame src="side.php" name="side" frameborder="0" style="">
<frame src="<?php echo $url; ?>" name="main" frameborder="0" style="">

5
html/js/jquery-1.12.4.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -136,6 +136,16 @@ angular.module("mapApp")
// Force layout information
var forceLayout = new Object;
// Watch for noresize update
$scope.$watch("noresize", function() {
$scope.allowResize = $scope.noresize == "false";
if ($scope.allowResize) {
d3.select("#resize-handle").style("visibility", "visible");
} else {
d3.select("#resize-handle").style("visibility", "hidden");
}
})
// Watch for changes on the reload value
$scope.$watch("reload", function(newValue) {
@ -928,6 +938,11 @@ angular.module("mapApp")
// First record the parent node of the current node
var parent = currentNode.parent;
// Fix root nodes with no parent nodes
if (parent === undefined) {
return true;
}
// Next remove the current node as a child of
// the parent node
parent.children = parent.children.filter(function(e, i, a) {
@ -1084,24 +1099,20 @@ angular.module("mapApp")
});
}
// If the node has no children and the host list
// does, create the property and initialize it
if (!node.hasOwnProperty("children") ||
node.children == null) {
if (!node.hasOwnProperty("children") || node.children == null) {
node.children = new Array;
}
// Next add any hosts in the list as children
// of the node, if they're not already
hosts.forEach(function(e) {
var childIndex = findElement(node.children, e,
function(list, index) {
return list[index].hostInfo.name;
});
var childIndex = node.children.findIndex(function(s) {
return s.hostInfo.name === e;
});
if ($scope.hostList[e]) {
if (childIndex == null) {
if (childIndex === -1) {
// Create the node object
var hostNode = new Object;
@ -1275,7 +1286,8 @@ angular.module("mapApp")
// Reparent the tree to specified root host
if ($scope.hostList.hasOwnProperty($scope.root) &&
($scope.rootNode != $scope.hostTree)) {
($scope.rootNode != $scope.hostTree) &&
$scope.hostList[$scope.root].hasOwnProperty("hostNodes")) {
reparentTree($scope.hostList[$scope.root].hostNodes[0]);
}
@ -1671,7 +1683,7 @@ angular.module("mapApp")
$scope.hostList[host].serviceStatusJSON[service] =
json.data.servicelist[host][service];
}
if (serviceStatUpdated) {
if ($scope.hostList[host].hasOwnProperty("g") && serviceStatUpdated) {
$scope.hostList[host].g.forEach(function(e, i, a) {
updateNode(e);
});
@ -1844,6 +1856,14 @@ angular.module("mapApp")
// Update the map
var updateMap = function(source, reparent) {
// Update config variables before updating the map
$scope.showText = $scope.notext == "false";
$scope.showLinks = $scope.nolinks == "false";
$scope.showPopups = $scope.nopopups == "false";
$scope.allowResize = $scope.noresize == "false";
$scope.showIcons = $scope.noicons == "false";
reparent = reparent || false;
switch($scope.layout) {
case layouts.UserSupplied.index:

View File

@ -22,18 +22,25 @@ angular.module("nagiosDecorations", [])
updateIntervalValue: "@updateInterval",
lastUpdate: "=lastUpdate",
initialState: "@initialState",
collapsable: "@collapsable",
includePartial: "@includePartial"
collapsible: "@collapsible",
includePartial: "@includePartial",
root: "@root"
},
controller: function($scope, $element, $attrs, $http) {
$scope.updateInterval = parseInt($scope.updateIntervalValue);
$scope.isPermanentlyCollapsed = $scope.isCollapsed =
$scope.initialState == "collapsed";
$scope.isCollapsable = $scope.collapsable == "true";
$scope.isCollapsable = $scope.collapsible == "true";
$scope.haveProgramStatus = false;
// Create cgiurl and root node name
$scope.params = { cgiurl: $scope.cgiurl, root: $scope.root };
$scope.$watch("root", function() {
$scope.params.root = $scope.root;
});
$scope.$watch("cgiurl", function() {
getStatus();
});

View File

@ -286,7 +286,7 @@ angular.module("trendsApp")
d3.select("g#groupXAxis").select("path").remove();
};
// Handle a succesful availability response
// Handle a successful availability response
var onAvailabilitySuccess = function(json) {
// Local layout variables

View File

@ -4,7 +4,7 @@
<head>
<title>JSON Query Generator</title>
<link rel="stylesheet" type="text/css" href="stylesheets/jsonquery.css"/>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="js/jsonquery.js"></script>
</head>
<body>
@ -40,8 +40,8 @@
</tr>
</table>
<button type="submit">Send Query</button>
<form>
<div>
</form>
</div>
</div>
</body>
</body>
</html>

View File

@ -1,8 +1,8 @@
<?php
include_once(dirname(__FILE__).'/includes/utils.inc.php');
$this_version = '4.3.4';
$this_year = '2017';
$this_version = '4.4.3';
$this_year = '2019';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
@ -14,20 +14,25 @@ $this_year = '2017';
<title>Nagios Core</title>
<link rel="stylesheet" type="text/css" href="stylesheets/common.css?<?php echo $this_version; ?>" />
<link rel="stylesheet" type="text/css" href="stylesheets/nag_funcs.css?<?php echo $this_version; ?>" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="js/nag_funcs.js"></script>
<script type='text/javascript'>
var vbox, cookie;
var vBoxId = "main";
var vboxText = "<a href=https://www.nagios.com/tours target=_blank> " +
"Click here to watch the entire Nagios Core 4 Tour!</a>";
var cookie;
<?php if ($cfg["enable_page_tour"]) { ?>
var vbox;
var vBoxId = "main";
var vboxText = "<a href=https://www.nagios.com/tours target=_blank> " +
"Click here to watch the entire Nagios Core 4 Tour!</a>";
<?php } ?>
$(document).ready(function() {
var user = "<?php echo $_SERVER['REMOTE_USER']; ?>";
vBoxId += ";" + user;
vbox = new vidbox({pos:'lr',vidurl:'https://www.youtube.com/embed/2hVBAet-XpY',
text:vboxText,vidid:vBoxId});
<?php if ($cfg["enable_page_tour"]) { ?>
vBoxId += ";" + user;
vbox = new vidbox({pos:'lr',vidurl:'https://www.youtube.com/embed/2hVBAet-XpY',
text:vboxText,vidid:vBoxId});
<?php } ?>
loadRemoteFeed( // Our top banner splash.
'#splashbox0-contents', 'corebanner', 1,
'', processBannerItem, ''
@ -140,7 +145,7 @@ $this_year = '2017';
<div id="currentversioninfo">
<div class="product">Nagios<sup><span style="font-size: small;">&reg;</span></sup> Core<sup><span style="font-size: small;">&trade;</span></sup></div>
<div class="version">Version <?php echo $this_version; ?></div>
<div class="releasedate">August 24, 2017</div>
<div class="releasedate">January 15, 2019</div>
<div class="checkforupdates"><a href="https://www.nagios.org/checkforupdates/?version=<?php echo $this_version; ?>&amp;product=nagioscore" target="_blank">Check for updates</a></div>
</div>
@ -209,7 +214,7 @@ $this_year = '2017';
</div>
</div><!-- end splashrow1 -->
<div id="splashrow2">
<div id="splashbox4" class="splashbox splashbox-clear"><!-- latest news feed -->
@ -240,7 +245,7 @@ $this_year = '2017';
<a href="https://www.nagios.org/" target="_blank"><img src="images/weblogo1.png" width="102" height="47" border="0" style="padding: 0 40px 0 40px;" title="Nagios.org" /></a>
<a href="http://sourceforge.net/projects/nagios" target="_blank"><img src="images/sflogo.png" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a>
</div>
</div>
</div>
</body>

View File

@ -68,7 +68,7 @@
<div class="form-group">
<label>Root Node</label>
<select class="form-control" ng-model="params.root"
ng-options="node for node in nodelist">
ng-options="node for node in nodelist track by node">
</select>
</div>
<div class="form-group">

View File

@ -3,16 +3,16 @@
<tr>
<td class="linkBox">
<span ng-show="params.root != 'Nagios Process'">
<a ng-href="{{params.cgiurl}}cgi-bin/status.cgi?host={{params.host | uriComponentEncode}}" target="_self">
<a ng-href="{{params.cgiurl}}status.cgi?host={{params.root | uriComponentEncode}}" target="_self">
View Status Detail For This Host
</a>
<br/>
</span>
<a ng-href="{{params.cgiurl}}cgi-bin/status.cgi?host=all" target="_self">
<a ng-href="{{params.cgiurl}}status.cgi?host=all" target="_self">
View Status Detail For All Hosts
</a>
<br/>
<a ng-href="{{params.cgiurl}}cgi-bin/status.cgi?hostgroup=all" target="_self">
<a ng-href="{{params.cgiurl}}status.cgi?hostgroup=all" target="_self">
View Status Overview For All Hosts
</a>
</td>

View File

@ -4,7 +4,7 @@
<?php
include_once(dirname(__FILE__).'/includes/utils.inc.php');
get_update_information();
?>
?>
<head>
<meta charset="utf-8"/>
@ -38,19 +38,19 @@
) {
$layout = $_GET['layout'];
}
if ($layout == 4)
$layout = 6;
?>
?>
<script type="text/javascript">
map_layout=<?php echo $layout; ?>;
</script>
<title>Nagios Map</title>
<link type="image/ico" rel="shortcut icon" href="images/favicon.ico"/>
<link type="text/css" rel="stylesheet"
href="bootstrap-3.3.0/css/bootstrap.min.css">
href="bootstrap-3.3.7/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet"
href="bootstrap-3.3.0/css/bootstrap-theme.min.css">
href="bootstrap-3.3.7/css/bootstrap-theme.min.css">
<link type='text/css' rel='stylesheet' href='stylesheets/common.css'/>
<link type='text/css' rel='stylesheet' href='stylesheets/map.css'/>
<link type='text/css' rel='stylesheet' href='stylesheets/map-directive.css'/>
@ -59,31 +59,33 @@
<script type="text/javascript"
src="angularjs/angular-1.3.9/angular.min.js"></script>
<script type="text/javascript"
src="angularjs/ui-bootstrap-tpls-0.12.0.min.js"></script>
src="angularjs/ui-bootstrap-tpls-0.14.3.min.js"></script>
<script type="text/javascript"
src="angularjs/ui-utils-0.2.1/ui-utils.js"></script>
src="angularjs/ui-utils-0.2.3/ui-utils.js"></script>
<script type="text/javascript" src="spin/spin.min.js"></script>
<script type="text/javascript" src="js/map.js"></script>
<script type="text/javascript" src="js/map-directive.js"></script>
<script type="text/javascript" src="js/map-form.js"></script>
<script type="text/javascript" src="js/nagios-decorations.js"></script>
<script type="text/javascript" src="js/nagios-time.js"></script>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="js/nag_funcs.js"></script>
<script type='text/javascript'>
var vbox;
var vBoxId = "map";
var vboxText = "<a href=https://www.nagios.com/tours target=_blank>" +
"Click here to watch the entire Nagios Core 4 Tour!</a>";
$(document).ready(function() {
var user = "<?php echo $_SERVER['REMOTE_USER']; ?>";
<?php if ($cfg["enable_page_tour"]) { ?>
<script type='text/javascript'>
var vbox;
var vBoxId = "map";
var vboxText = "<a href=https://www.nagios.com/tours target=_blank>" +
"Click here to watch the entire Nagios Core 4 Tour!</a>";
$(document).ready(function() {
var user = "<?php echo $_SERVER['REMOTE_USER']; ?>";
vBoxId += ";" + user;
vbox = new vidbox({pos:'lr',vidurl:'https://www.youtube.com/embed/leaRdb3BElI',
text:vboxText,vidid:vBoxId});
});
</script>
vBoxId += ";" + user;
vbox = new vidbox({pos:'lr',vidurl:'https://www.youtube.com/embed/leaRdb3BElI',
text:vboxText,vidid:vBoxId});
});
</script>
<?php } ?>
</head>
<body ng-controller="mapCtrl" <?php echo $img; ?>>
@ -94,8 +96,9 @@
update-interval="10"
last-update="lastUpdate"
initial-state="collapsed"
collapsable="true"
include-partial="map-links.html">
collapsible="true"
include-partial="map-links.html"
root="{{params.root}}">
</div>
</div>
<div id="map-container" ng-hide="formDisplayed"

View File

@ -1,7 +1,7 @@
<?php
include_once(dirname(__FILE__).'/includes/utils.inc.php');
$this_version = '4.3.4';
$this_version = '4.4.3';
$link_target = 'main';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

View File

@ -38,7 +38,7 @@ div.status { font-size: 10pt; text-align: center; }
.statusHOSTPENDING,.statusPENDING { background-color: #ACACAC; }
.statusHOSTUP,.statusOK { background-color: #33FF00; }
.statusHOSTDOWN,.statusCRITICAL { background-color: #F83838; }
.statusHOSTDOWNACK { background-color: #F83838; }
.statusHOSTDOWNACK,.statusCRITICALACK { background-color: #F83838; }
.statusHOSTDOWNSCHED { background-color: #F83838; }
.statusHOSTUNREACHABLE { background-color: #F83838; }
.statusHOSTUNREACHABLEACK { background-color: #F83838; }

View File

@ -5,9 +5,9 @@
<title>Nagios Trends</title>
<link type="image/ico" rel="shortcut icon" href="images/favicon.ico"/>
<link type="text/css" rel="stylesheet"
href="bootstrap-3.3.0/css/bootstrap.min.css">
href="bootstrap-3.3.7/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet"
href="bootstrap-3.3.0/css/bootstrap-theme.min.css">
href="bootstrap-3.3.7/css/bootstrap-theme.min.css">
<link type='text/css' rel='stylesheet' href='stylesheets/common.css'>
<link type='text/css' rel='stylesheet' href='stylesheets/trends.css'>
<link type='text/css' rel='stylesheet'
@ -16,9 +16,9 @@
<script type="text/javascript"
src="angularjs/angular-1.3.9/angular.min.js"></script>
<script type="text/javascript"
src="angularjs/ui-bootstrap-tpls-0.12.0.min.js"></script>
src="angularjs/ui-bootstrap-tpls-0.14.3.min.js"></script>
<script type="text/javascript"
src="angularjs/ui-utils-0.2.1/ui-utils.js"></script>
src="angularjs/ui-utils-0.2.3/ui-utils.js"></script>
<script type="text/javascript" src="spin/spin.min.js"></script>
<script type="text/javascript" src="js/trends.js"></script>
<script type="text/javascript" src="js/trends-form.js"></script>

View File

@ -93,7 +93,7 @@ NAGIOS_BEGIN_DECL
#define NAGFUNCS_CSS "nag_funcs.css"
/********************************* JAVASCRIPT INCLUDES **********************/
#define JQUERY_JS "jquery-1.7.1.min.js"
#define JQUERY_JS "jquery-1.12.4.min.js"
#define NAGFUNCS_JS "nag_funcs.js"
/********************************* ICONS ************************************/
@ -439,8 +439,17 @@ typedef struct lifo_struct {
struct lifo_struct *next;
} lifo;
struct nagios_extcmd {
const char *name;
int id;
int cmt_opt; /* 0 = not allowed, 1 = optional, 2 = required */
char *default_comment;
};
/******************************** FUNCTIONS *******************************/
typedef void (*read_config_callback)(const char*, const char*);
void reset_cgi_vars(void);
void cgi_init(void (*doc_header)(int), void (*doc_footer)(void), int object_options, int status_options);
void free_memory(void);
@ -448,7 +457,7 @@ void free_memory(void);
const char *get_cgi_config_location(void); /* gets location of the CGI config file to read */
const char *get_cmd_file_location(void); /* gets location of external command file to write to */
int read_cgi_config_file(const char *);
int read_cgi_config_file(const char *, read_config_callback);
int read_main_config_file(const char *);
int read_all_object_configuration_data(const char *, int);
int read_all_status_data(const char *, int);
@ -494,5 +503,9 @@ void free_lifo_memory(void);
int push_lifo(char *);
char *pop_lifo(void);
struct nagios_extcmd* extcmd_get_command_id(int);
struct nagios_extcmd* extcmd_get_command_name(const char *);
const char *extcmd_get_name(int);
NAGIOS_END_DECL
#endif

View File

@ -113,6 +113,6 @@ int add_comment_to_hashlist(struct nagios_comment *);
void free_comment_data(void); /* frees memory allocated to the comment list */
NAGIOS_BEGIN_DECL
NAGIOS_END_DECL
#endif

View File

@ -24,8 +24,8 @@
#include "shared.h"
#define PROGRAM_VERSION "4.3.4"
#define PROGRAM_MODIFICATION_DATE "2017-08-24"
#define PROGRAM_VERSION "4.4.3"
#define PROGRAM_MODIFICATION_DATE "2019-01-15"
NAGIOS_BEGIN_DECL

View File

@ -29,6 +29,12 @@
/* Event broker integration */
#undef USE_EVENT_BROKER
/* NERD / radio dispatch usage */
#undef ENABLE_NERD
/* check for RLIMIT_PROC */
#undef DETECT_RLIMIT_PROBLEM
/* commands used by CGIs */
#undef TRACEROUTE_COMMAND
#undef PING_COMMAND

Some files were not shown because too many files have changed in this diff Show More