Commit Graph

64 Commits

Author SHA1 Message Date
Tony Murray d1b7004fef
Severity Enum (#14620)
* Severity Enum
Replace old Alert constants

* Fix whitespace

* Additional uses

* style fixes

* Fix test too

* More missed locations

* More
2023-08-05 12:12:36 -05:00
Jellyfrog 71d740770b
Remove Log::event (#14526)
* Remove Log::event

Use the Eventlog class directly instead

* wip

* wip

* wip

* Apply fixes from StyleCI

* Update Eventlog.php
2022-11-09 09:47:19 +01:00
Jellyfrog b90fbcb9bf
Undefined array key fixes (#14532)
* Undefined array key fixes

* Update check-services.php
2022-10-27 21:02:27 +02:00
Tony Murray 61c89794e4
Remove debug globals (#12811)
* Remove $debug global
and $vdebug global
makes these variables more accessible and protects from collisions.

* the on boot set sends application as the first parameter, just handle that

* Relocate other debug related functions

* Log debug to stdout

* Wrong output

* remove stupid constants

* Fix lint and style issues
2021-04-29 22:42:18 -05:00
Tony Murray 1c379dcd05
Remove legacy function calls (#12651)
* massive inlines

* fix style and wtf

* remove rrdtool.inc.php include

* fix CommonFunctions namespace issues

* looking for missing class space, fix undefined class issues

* style fixes
2021-03-29 00:25:30 +02:00
Jellyfrog 29f45ca352
Apply fixes from StyleCI (#12124) 2020-09-21 15:59:34 +02:00
Jellyfrog 77c531527c
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI

* Disable style check
2020-09-21 14:54:51 +02:00
Tony Murray df16de9d2f
Refactor Datastores to allow future improvements. OpenTSDB Tags. (#11283)
* Datastores to object oriented code, using the Laravel IoC container

Change instantiation
better DI
move OpenTSDB

Small re-orgs

remove unused stuff

Fix graphs and other scripts

Use DI for all except rrd

fix up connection error handling

Add tests, fix up a "few" things
Add Config::forget()

Style fixes

Don't reference legacy code

remove accidental code paste

Add datastores phpunit groups

some tests

* rebase fixes

* some test fixes

* shorter tests

* shorter tests

* Don't except when rrdtool can't be started.

* restore tests

* fix rrd tests

* fix iterable change upstream

* fix isValidDataset

* fix invalid data bug

* fix mysql incorrect ds

* fix issue with data that is too long

* use regular data_update()

* Use log facade

* OpenTSDB mis-ordered arguments fix

* Making a singleton with different options makes different singletons.  Just use the global config settings to disable datastores.

* only filter tags for datastores that won't it don't modify the tags permanently

* Update copyrights to include original authors.

* Stats for all datastores

* Fix mysql sends different rrd / other ds names

* fix snmp last stats not initialized
remove unused function

* remove unused function and move single use function closer to its use

* InfluxDB does not need to update null or U values.
Skip write if all fields are empty

* Fix smart value checks

* fix style issues

* Make sure port data is stored the same way as before for Graphite and OpenTSDB
Add ifIndex tag to all to be compatible

* Missed rrdtool_tune() call

* Test update WIP

* OpenTSDB now includes tags

* fix style
2020-03-16 09:17:58 -05:00
Tony Murray 7fe895bd08
Revert "Refactor datastores to classes (#9179)" (#11273)
This reverts commit e5dad7a64e.
2020-03-11 07:52:52 -05:00
Tony Murray e5dad7a64e
Refactor datastores to classes (#9179)
* Datastores to object oriented code, using the Laravel IoC container

Change instantiation
better DI
move OpenTSDB

Small re-orgs

remove unused stuff

Fix graphs and other scripts

Use DI for all except rrd

fix up connection error handling

Add tests, fix up a "few" things
Add Config::forget()

Style fixes

Don't reference legacy code

remove accidental code paste

Add datastores phpunit groups

some tests

* rebase fixes

* some test fixes

* shorter tests

* shorter tests

* Don't except when rrdtool can't be started.

* restore tests

* fix rrd tests

* fix iterable change upstream

* fix isValidDataset

* fix invalid data bug

* fix mysql incorrect ds

* fix issue with data that is too long

* use regular data_update()

* Use log facade

* OpenTSDB mis-ordered arguments fix

* Making a singleton with different options makes different singletons.  Just use the global config settings to disable datastores.

* only filter tags for datastores that won't it don't modify the tags permanently

* Update copyrights to include original authors.

* Stats for all datastores

* Fix mysql sends different rrd / other ds names

* fix snmp last stats not initialized
remove unused function

* remove unused function and move single use function closer to its use

* InfluxDB does not need to update null or U values.
Skip write if all fields are empty

* Fix smart value checks

* fix style issues
2020-03-10 19:08:00 -05:00
Heath Barnhart 5a2f2497bb Allow setting Service Ignore and Disable in UI (#10334)
* Added disable and ignore checkboxes to services modal

* Updated add_services function to set disabled field

* Modified check-services.php respect service_disable value

* Minor code change for consistency in new_service.inc.php

* Removed unneeded includes
2019-07-06 17:58:06 +02:00
Tony Murray f3ba8947f7
Use Config helper (#10339)
remove usage of global variable
2019-06-23 00:29:12 -05:00
Tony Murray 8480fdf7de
remove strict comparisons for check-services.php (#8992)
Required by #8935

That PR returns ints if appropriate
"0" => 0
2018-08-06 20:29:06 -05:00
PipoCanaja 2c91348c5c Log an event for each Service Status change (#8968)
Hello

Here is a proposal for a pièce of code to log (using log_events) each service status change onto the device itself. 

Let me know if we should create the "getStatusText()" function to convert the int to "OK", "Critical" etc etc . I searched for such a function but did not find it. 

I also add to use a hack for the SQL cause it would prevent the device_id valueto be available in the resulting $service when device_attribs is empty for the device. If you have a better way to suggest, I'll be happy to use it. 

PipoCanaja

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [X] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
2018-08-04 21:35:23 +01:00
dsgagi 24d84aec9d Poll service check only if the associated device is available (#8757)
* Update check-services.php

Poll service check only if the associated device is available.

* Update check-services.php

Updating line 68 based on laf suggestion.

* Update check-services.php

Also check the following before polling the service:
* "Disable ICMP Test" is enabled
* Service hostname/IP is different from associated device.

* Update check-services.php

Remove whitespaces.

* Update check-services.php

* Make check-services.php perform more similarly to services.wrapper.py - loop service checks per device and execute RunRules() function after polling all services for one device (like in poller.php).
* Add more debugging information, similar to poller.php

* Update check-services.php

Implement logging to eventlog when service is skipped due to icmp down event. Event is logged only once during device down event, which is achieved by checking value in service_disabled column in services table.

* Update check-services.php

Fix Travis errors.

* Update check-services.php

Revert back to one query and one foreach loop code.
Added inet6_ntop() for reading $service['ip'] value.
Removed RunRules() function.

* Update check-services.php

Formatting fixes.

* Update check-services.php

More formatting fixes. :)

* Update check-services.php

Removed 'alerts' from init_module.

* Update Services.md

Update Services documentation with info about changes to service checks polling logic.

* Update check-services.php

Fix spelling check on `previosly`.

* Update check-services.php

Replace phrase "Nagios Service" with "Service check".

* Update Services.md

Reword first two sentences of `Service checks polling logic` section.
2018-07-25 08:38:52 +01:00
Tony Murray eeb3d58f5b Improved Logging and Debugging (#8870)
Use Log facility when Laravel is booted.
Update init.php so we can easily boot Laravel for CLI scripts. (and just Eloquent, but that may go away)
Move all debug setup into set_debug() function and use that across all scripts.
Log Laravel database queries.
Send debug output to librenms log file when enabling debug in the webui.
Allow for colorized Log CLI output. (currently will leave % tags in log file output)

** Needs testing and perhaps tweaking still.

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
2018-07-13 23:08:00 +01:00
cchance27 09d6b2fd54 feature: Added Prometheus PushGateway metric support (#8437)
* Added Prometheus PushGateway support

* fixed formatting

* fix set_curl_proxy to correct variable

* add documentation

* Update Metric-Storage.md

* Update mkdocs.yml
2018-04-13 15:46:19 +01:00
Neil Lathwood c5a3d82040 feature: Add services-wrapper.py to enable support for distributed setups with service checks #4658 2017-01-12 08:29:29 +00:00
Tony Murray 9a33464c52 refactor: Centralize includes and initialization (#4991) 2016-11-21 20:12:59 +00:00
Tony Murray d2193f76ca feature: allow scripts to be run from any working directory (#4437)
* feature: allow validate.php to be run from any working directory

* remove redundant realpath() call

* re-add realpath() to remove symbolic links

* realpath() isn't needed...

* chdir() in all php scripts in ./ and ./scripts/

* update-sql.php clearly is not used, as it was broken.

* Change some scripts to executable
Remove extra chdir() call in snmp-scan.php

* Missed console-ui.php
Kind of fixed console-ui.php help output

* Re-add newline
2016-09-14 16:53:04 +01:00
Tony Murray abc6a5b799 PSR-2 Final cleanup (#4247)
refactor: Final PSR2 cleanup
2016-08-28 23:32:55 +01:00
Tony Murray 200e670315 Fix defunct process issues: create Proc class (#4210)
* Proc class
Encapsulate processes in a class, when they go out of scope, we can use the __destruct() process to make sure the process terminates.

* Fix rrdtool_last checks failing

* Don't close rrdtool in rrd_graph
Try to start rrdtool process if they haven't been started yet
Remove some extra debug output

* phpdocs added
several cleanups
should still be functioning the same
Only open one  rrdtool process for graph.php
2016-08-26 07:50:29 +01:00
Tony Murray e80a385b7f RRDtool dual process (remote creation/check) (#4104)
* Prepare for dual rrdtool processes
Disabled at this time
Split out rrdtool version checks into rrdtool_create_command()
Tests for rrdtool_create_command()
Fixes a few small issues.

* Enable dual process and remote rrd check/creation

* remove full path for remote commands

* Doc updates
minor fix to rrdtool_tune()

* Set up bootstrap for phpunit
Fix issues with FileExistsException

* Attempt to fix phpunit

* Fix classloader and bootstrap to use full paths only (not depending on $config)

* Fix phpunit tests, config.php does not exist.
2016-08-22 16:32:05 +01:00
Aaron Daniels 5028039b48 - Added influxdb options to check-services.php
- Confirmed to coding standards
2016-08-11 17:08:44 +10:00
Aaron Daniels 854812a457 - added rrd_pipes to check script
- renamed service_* to *_service
2016-03-22 16:40:51 +10:00
Aaron Daniels 870d3aee56 - Moved poller module back to check-services.php
- added debug option -d
2016-03-21 16:48:26 +10:00
Aaron Daniels 0d6cfec589 Nagios Services
- Moved check-services.php to a poller module
    - Added performance data collection to the poller
    - Centralised DB functions to includes/services.inc.php
    - Created add/edit/delete functions off the device, services page
    - Removed legacy edit/delete interfaces.
    - Moved and modified check.inc scripts
    - Documentation Updates
    - Modified services table
2016-03-15 22:23:14 +10:00
Daniel Preussker 4a79348759 Update services SQL 2016-03-09 18:30:59 +01:00
Tony Murray 9f22b18dc8 Split is removed in PHP7, replace with explode as none were using it as a regex.
Also fix two array keys without quotes in include/syslog.php
Fixes #2205
2016-02-25 14:34:06 -06:00
laf 5516ac89ce Dynamic use of nagios-service checks 2015-10-26 21:53:15 +00:00
laf 987634e463 Updated rrdtool_update() to use new array format 2015-08-18 16:26:55 +00:00
laf 17dac9e755 Removed old alerting system code 2015-08-01 15:54:15 +00:00
Job Snijders ebd0f6fc35 Apply "Squiz" code style on old (pre-2014) files 2015-07-11 16:12:35 +02:00
Tyler Christiansen 63d428c0e1 Revert "update copyright notice" after discussion with Paul
This reverts commit 774233327e.
2013-10-28 12:01:36 -07:00
Tyler Christiansen 774233327e update copyright notice 2013-10-28 01:46:59 -07:00
Adam Amstrong dbf212f652 phpDocumentator headers. retire static-config. IF YOU ARE READING THIS, REMOVE IT FROM THE BOTTOM YOUR CONFIG.PHP. YES. YOU.
git-svn-id: http://www.observium.org/svn/observer/trunk@3150 61d68cd4-352d-0410-923a-c4978735b2b8
2012-05-09 10:01:42 +00:00
Tom Laermans 7e96d87022 improvements to services
git-svn-id: http://www.observium.org/svn/observer/trunk@3144 61d68cd4-352d-0410-923a-c4978735b2b8
2012-05-06 23:02:18 +00:00
Adam Amstrong 77d055f9d6 fix services stuff
git-svn-id: http://www.observium.org/svn/observer/trunk@3090 61d68cd4-352d-0410-923a-c4978735b2b8
2012-04-26 13:05:52 +00:00
Adam Amstrong 4045c970af improved emailing and additional configuration options to use phpmailer. (#38 from Mike Stupalov)
git-svn-id: http://www.observium.org/svn/observer/trunk@3089 61d68cd4-352d-0410-923a-c4978735b2b8
2012-04-26 12:11:03 +00:00
Tom Laermans 6b210ea056 change directory to observium root, now also for other commandline tools
git-svn-id: http://www.observium.org/svn/observer/trunk@2990 61d68cd4-352d-0410-923a-c4978735b2b8
2012-04-08 10:44:41 +00:00
Tom Laermans e68cc3246e syntaxer run
git-svn-id: http://www.observium.org/svn/observer/trunk@2974 61d68cd4-352d-0410-923a-c4978735b2b8
2012-04-06 15:19:43 +00:00
Tom Laermans d864ce234f kill a whole bunch of trailing spaces
git-svn-id: http://www.observium.org/svn/observer/trunk@2516 61d68cd4-352d-0410-923a-c4978735b2b8
2011-09-20 09:55:11 +00:00
Adam Amstrong bc0cdd2415 move poller.php (inc os/system) to db* (and others, but poller is biggest change)
git-svn-id: http://www.observium.org/svn/observer/trunk@2298 61d68cd4-352d-0410-923a-c4978735b2b8
2011-05-13 11:42:26 +00:00
Tom Laermans f55a30f744 some formatting cleanups, introduce some more FIXMEs to look at, plus replace mysql_fetch_array by mysql_fetch_assoc, for great justice
git-svn-id: http://www.observium.org/svn/observer/trunk@2029 61d68cd4-352d-0410-923a-c4978735b2b8
2011-04-06 13:54:50 +00:00
Tom Laermans de7ff537cc revert r1957 patch
git-svn-id: http://www.observium.org/svn/observer/trunk@1960 61d68cd4-352d-0410-923a-c4978735b2b8
2011-03-23 09:54:56 +00:00
Geert Hauwaerts 6501cd29b5 - Code cleanup by Bastian Widmer.
git-svn-id: http://www.observium.org/svn/observer/trunk@1957 61d68cd4-352d-0410-923a-c4978735b2b8
2011-03-22 20:27:39 +00:00
Tom Laermans c6428480bc remove dead map.php code, rename some .inc to .inc.php files, general trailing space cleanup part 1, some reindent. No expected functionality change whatsoever ;)
git-svn-id: http://www.observium.org/svn/observer/trunk@1824 61d68cd4-352d-0410-923a-c4978735b2b8
2011-03-12 08:50:47 +00:00
Adam Amstrong cd76567edb ginger patch
git-svn-id: http://www.observium.org/svn/observer/trunk@1699 61d68cd4-352d-0410-923a-c4978735b2b8
2010-09-03 18:26:59 +00:00
Adam Amstrong 79db0b9823 add leading slash to path postpend
git-svn-id: http://www.observium.org/svn/observer/trunk@1684 61d68cd4-352d-0410-923a-c4978735b2b8
2010-08-14 13:32:36 +00:00
Adam Amstrong 1790641e4d fix services bugs (thanks to neitsabes71)
git-svn-id: http://www.observium.org/svn/observer/trunk@1682 61d68cd4-352d-0410-923a-c4978735b2b8
2010-08-13 18:48:10 +00:00