Commit Graph

83 Commits

Author SHA1 Message Date
Tony Murray
0ba76e6d62 New python service for poller, discovery + more (#8455)
Currently has a file handle leak (and will eventually run out of handles) related to the self update process.

Either need to fix that or rip out self-update and leave that up to cron or something.


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-06-30 12:19:49 +01:00
Tony Murray
e736f5efec Updated YAML schema validation (#8808)
Changed some values to be explicitly boolean


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-06-15 09:45:20 +01:00
Tony Murray
411a5db269 fix: Fixed Poller taking too long -> device took too long alert rule (#8622)
* Fix poller taking too long rule

* Update alert_rules.json
2018-05-13 20:02:57 +01:00
Tony Murray
1ad7f3138b
Add Laravel to LibreNMS (#8318)
* Add Laravel to LibreNMS.

* Try to set permissions during initial install and first composer update to Laravel.

* Fix composer.lock
Fix missing db config keys

* Start building v1 layout
Port ajax_setresolution, inject csrf into jquery ajax calls
Layout works, building menu
Partially done.

* Fix device group list
remove stupid count relationships

* Print messages for common boot errors.
Don't log to laravel.log file.
Log to error_log until booted, then librenms.log

* Fix up some issues with Config loading
Start of custom directives

* Custom blade directives: config, notconfig, admin

* Preflight checks
Only load config files once.

* Update the composer.lock for php 5.6

* Menu through routing

* Start of alert menu

* Better alert scopes

* reduce cruft in models

* Alerting menu more or less working :D

* Fix style

* Improved preflight

* Fix chicken-eggs!

* Remove examples

* Better alert_rule status queries
Debugbar

* fix app.env check

* User Menu

* Settings bar (dropped refresh)
Search JS

* Toastr messages

* Rename preflight

* Use hasAccess(User) on most models.
Add port counts

* Missed a Preflight -> Checks rename

* Fix some formatting

* Boot Eloquent outside of Laravel
Use Eloquent for Config and Plugins so we don't have to connect with dbFacile inside Laravel.
Move locate_binary() into Config class

* Config WIP

* Try to fix a lot of config loading issues.

* Improve menu for non-admins removing unneeded menus
url() for all in menu

* Only use eloquent if it exists

* Include APP_URL in initial .env settings

* Implement Legacy User Provider

* Helper class for using Eloquent outside of Laravel.
Allows access to DB style queries too and checking the connection status.

* Fix up tests

* Fix device groups query

* Checking Travis

* copy config.test.php earlier

* dbFacile check config before connecting
Don't use exception to check if eloquent is connected, it gets grabbed by the exception handler.
Ignore missing config.php error.

* Fix config load with database is not migrated yet.

* Remove Config::load() from early boot.

* Use laravel config settings to init db (this prefers .env settings)
Fix bgp vars not set in menu
add _ide_helper.php to .gitignore

* Restrict dependencies to versions that support php 5.6

* Update ConfigTest

* Fix a couple of installation issues

* Add unique NODE_ID to .env

* Correct handling of title image

* Fix database config not loading. Thanks @laf

* Don't prepend /

* add class_exists checks for development service providers

* Fix config value casting

* Don't use functions that may not exist

* Update dbFacile.php

* d_echo may not be defined when Config used called.

* Add SELinux configuration steps
More detailed permissions check.
Check all and give complete corrective commands in one step.

* Ignore node_modules directory

* Re-add accidetal removal
2018-05-09 08:05:17 -05:00
Tony Murray
6c04f92877 fix: Fixed port_usage_perc macro (#8625)
We cannot check if the port is enabled inside the macro because it casts the usage percentage to a boolean (1 / 0)

Remove redundant macros.port in rule collection (was check 3 times before this)

Broken by #8511
2018-04-27 14:27:05 +01:00
Tony Murray
81d8060632 Update schema def too... 2018-04-26 11:29:51 -05:00
Neil Lathwood
1eee6e8195 alert: Added ability to make notes for acking alerts + record who did so (#8433)
* alert: Added ability to make notes for acking alerts + record who did so

* Updated schema

* moved sql file

* Updated from comments in PR

* warning changed to blue

* reset notes + keep notes on ack
2018-04-26 00:00:56 -05:00
Neil Lathwood
39aea3da71
fix: Updated ports macros to use %macros.port (#8511)
* fix: Updated ports macros to use %macros.port

* small updates
2018-04-05 22:39:01 +01:00
Søren Rosiak
26bcf89b76 fix: Change rootPort DB data type (#8404)
* fix: Change rootPort DB data type

* Updated schema
2018-03-20 14:01:08 +00:00
Tony Murray
8c94ccf4d6 refactor: Use custom phpcs ruleset for LibreNMS (#8418)
* Use custom phpcs ruleset for LibreNMS
PSR2 with exclusions

* Don't check line length

* Restore build_excludes()
Drop influxdb lib exclusion

* Fix whitespace
2018-03-20 11:32:52 +00:00
Neil Lathwood
03076c4025
feature: Added new alert rule builder UI and rule mapping UI (#8293)
* feature: Added new alert rule builder UI

* Updated to export sql queries

* More updates

* more changes

* removed debug

* fix scrut

* Updated to include import options + various other fixes

* fix rule

* Populate name from collection rules.

* Fix default rule import
Allow new and old style rules in the collection.
Don't add new yet as I'm not sure GenSQL() is working.

* Fix GenSQL call

* Extract filter building to class so it is nicely contained in one place

* moved schema

* some fixes and tweaks

* travis fixes

* Some more features / updates

* Fix up my mistakes when adding default rules

* Use a modal for new alert (Incomplete)
Larger dialog!!
Remove page loading stuff.

Working:
Loading rules, resetting dialog, importing from collection.

Not working yet:
select width
device limited rule access? don't know what this is...

Lots of unused stuff to delete...

* reload "table" after save

* fixed editing rule

* Auto select2 width

* Reload window on save

* Restore per-device alert. Remove debug.

* Small cleanups. Rule Name first.

* Restore button to button type. Rename schema.

* Fixes: wrong command to reload window, remove extra attributes, rule is never passed

* Fixed old rule editing

* some small updates for old imports

* travis update to use trusty

* maybe travis fix

* Ability to set alert rule mappings on the rule edit screen

* pip installs one line, no quiet for deploy

* update schema def

* Fix style and some copyright headers

* fix docs missing file

* Allow new versions of snmpsim and libraries

* Parser WIP

* Fix default rules insert

* reorganize

* Legacy import first draft done

* Implement saving
Skip translation to sql for now

* Working on glues

* small rule collection fix

* Working on glues

* Working on glues

* Docs updates + small UI changes

* Parser WIP

* reorganize

* Legacy import first draft done

* Implement saving
Skip translation to sql for now

* Working on glues

* Working on glues

* Working on glues

* Add table mapping, should move to it's own class

* WIP

* Glue working!!

* Extract Schema class

* Some final touches.
revert alerts_rules.json for now.

* Finish up initial implementation
Needs more tests

* Fix a few places

* small doc updates

* Fix finding tables in grouped rules.

* remove unused code

* code format fixes

* Some quick tests for Schema
Simplified output for findRelationshipPath. Always includes start and target in the result.
This simplifies a lot of code in QueryBuilderParser.php
This also always loads the target table data now (which we want)

* Make bill_id the PRIMARY index for the bills table

* Load macros from a json file in misc instead of the database.

* Fix whitespace and wrong key for collection.

* Handle IN properly when generating SQL

* Fix glue (devices.device_id = ports.port_id) is incorrect :D
Show ALL tables we can resolve relationships for in the query builder filter.

* Remove all macros from the database
Remove insert statements, leave updates to update user's existing rules.
2018-03-14 20:25:19 +00:00
Jason Ellison
84b0b32bd8 Change the column type from varchar(255) to TEXT for nagios-plugins perfdata (#8322) 2018-03-03 22:47:49 +00:00
sorano
1d45d4b73d fix: MySQL query in alert_rules.json (#8300)
Fix the:
MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= (DATE_SUB(NOW(),INTERVAL 5 MINUTE))  &&  syslog.msg REGEXP ".*authentication f' at line 1 (SELECT * FROM syslog WHERE (syslog.device_id = '149') && (syslog.timestamp > = (DATE_SUB(NOW(),INTERVAL 5 MINUTE))  &&  syslog.msg REGEXP ".*authentication failure.*"  ))
2018-02-27 09:22:59 +00:00
Tony Murray
e9c42e3b06 Re-add index to ports_fdb table (#8267) 2018-02-21 09:23:00 +00:00
Tony Murray
1c5b9d3524
Fix bgp peers discovery cleanup (#8263)
Take context into account, update index for that
2018-02-19 09:08:27 -06:00
Tony Murray
1188b53192 security: Use more secure password hashes (#8213)
* More secure password hashes
Use PHP 5.5 password_hash(), currently uses bcrypt
increase password field length as per php documentation

* Use password_hash()/password_verify() for cookies too

* forgot to update db_schema.yaml
2018-02-08 23:08:21 +00:00
dragans
547451974d Update librenms.logrotate (#8220)
* Update librenms.logrotate

- Change path /opt/librenms/logs/*log so that logrotate catches http logs (access_log and error_log).
- Added SU parameter to rotate files with librenms user, as it was throwing insecure permissions error without it.
- Added CREATE parameter to create new log files as librenms user.

* Update librenms.logrotate
2018-02-07 13:44:17 -06:00
Tony Murray
947e53d8cc fix: Fix arp-tables updates (#8180)
* Fix arp-tables updates
Little more complete fix this time.
Don't allow context_name to be nullable...

* update schema file
2018-02-01 09:50:32 +00:00
FTBZ
2755763758 device: Added suspended state to PAN OS (#8125)
* device: add suspended state to PAN OS

* remove bad rules, solution in other PR
2018-01-25 21:08:22 +00:00
Chip Gwyn
f2088a505a fix: Palo Alto HA Alert Rule references non-existent column in sensors table (#8138)
column in the sensors table.  However there is no "type" column.  This should be "sensor_type".  This is indicated
by the error in the logs:

`MySQL Error: Unknown column 'sensors.type' in 'where clause' (SELECT * FROM devices,sensors WHERE (( sensors.device_id = devices.device_id ) && devices.device_id = '102') && (devices.os = "panos" & sensors.type = "panSysHAState"  &&  sensors.sensor_current = "1"  &&  sensors.sensor_prev = "2"  ))
`

Updated the rule to reference the correct column.
2018-01-24 09:18:28 +00:00
Kevin Krumm
88ecbbff24
alert rules: added Dell iDRAC alert rules (#8010)
* alert rules: added Dell idrac alert rules

to the alerts collection.

* Update alert_rules.json

* added iDRAC

fixed iDRAC naming.

* added iDRAC Global System Status Alert
2018-01-05 16:06:49 -06:00
Tony Murray
c91ec3842a Fix bugs in bgp-peers poller (#7976)
* Test Data

* fix bugs in bgp-peers poller
peer data in wrong format
array_diff doesn't work right, change to array_diff_assoc
astext is too short for some
2017-12-29 11:52:49 +00:00
Aldemir Akpinar
56561aa4dc feature: Added support for Host dependencies (#7332)
* First draft of the modals and the config interfaces

* GUI part done

* Backend code and db schema addition

* Documentation added, fixed alerting bug

* Fix typos

* Do not try to push an older db_schame.yaml

* Small db fix

* More db fixes

* Travis CI fixes

* missed a line in the travis error

* Fixed dependency clearing bug, Manage Host dependencies button now shows current selections

* Removed unnecessary index

* Correct faulty query

* Fixed sql query as requested, and renamed sql file

* Added requested changes

* Removed debug code

* Renamed sql file

* More fixes as requested

* Trying to fix db_schema.yaml

* adding laf's diff

* Corrected a small bug

* Try to resolve scrutinizer issue

* Main page bootgrid ajax modifications

* Also corrected travis ci errors

* Added select2 for pull downs, removed a redundant debug output. Changed parent_id to text

* Add missing class in the device settings page

* Fix bug where a link wasn't added after save

* Better parent down detection

* Add missing comma

* Behold the multi-parent code

* Added lookup table

* Ready for testing

* Trying to fix documentation conflicts

* Fix copy paste errors, and possible sql injection

* indentation problems

* Modified db_schema.yaml as well

* Typos, typos

* This should correct alerts

* Try to fix travis ci error

* Fix the typo in index.php

* Changed to Tony's query

* function explanation text changed

* Updated db_schema.yaml

* Trying to make automated tests happy

* Changes as requested

* Added acknowledgment for select2

* Added laf's patch

* dbBulkInsert when adding parents
2017-12-20 14:17:52 +00:00
Tony Murray
e1b74a0b1e fix: Agent tries to insert processes data that is too long (#7891) 2017-12-13 22:35:05 +00:00
bergroth
84fdfdf542 Junos dwdm interface sensor support (#7714)
* Junos dwdm interface sensor support  …
  four new sensors
    Chromatic Dispersion ps/nm
    Delay s (seconds)
    Q_factor (dB)
    preFEC_BER (ratio)

  reuse of
    SNR, dbm, temperature, current

* new dwdm sensors more generic, ber and quality_factor

* new sensors updated

* renamed html graphs new sensors

*  fixed ber polling

* Change to base SI Hz and s.

* update sensor divisors to bigint

* rename sql-schema/216.sql to 218.sql

* YAML junos dwmd sensor definitions, except BER

* bigint divisor fixed

* deafult 1 divisior

* small fixes including schema change for another PR

* schema fix
2017-12-12 20:27:10 -06:00
Tony Murray
b620692426 refactor: Update all applications to store metrics (#7853)
* Update all applications to store metrics

* fix db schema

* Add glue test
2017-12-06 22:13:10 +00:00
Kevin Krumm
f7aed1e203
rules: deafult alert rules, updated the name for (#7861)
Sensor Over/Under to better help users understand where this alert is coming from. :)
2017-12-06 08:04:31 -06:00
Tony Murray
5405498ed6 alerts: Adde generic alerts for state sensors (#7812)
* feature: Generic alerts for state sensors
A bit of a hack, but gets the job done. Perhaps someone can refactor the ResolveGlues() function sometime to make it better.

* Fix mistakes

* Add docs and collection rules, critical enabled by default

* moved schema file to 221.sql
2017-12-02 23:03:36 +00:00
Tony Murray
a21a3fb2b6 feature: Added support Entity State polling (#7625)
* Entity state sensors??

* feature: Entity State polling
Display entity state on the Inventory page.
Allows for alerting based on states.

* fix empty last changed, timezones, alarm parsing, and db updates

* do not display unavailable alarms (80)
add tooltip with state value

* remove debug

* Entity state sensors??

* feature: Entity State polling
Display entity state on the Inventory page.
Allows for alerting based on states.

* fix empty last changed, timezones, alarm parsing, and db updates

* do not display unavailable alarms (80)
add tooltip with state value

* remove debug

* Use a discovery module and only fetch the rest of the data if entStateLastChanged is updated.

* A little more efficient sql use in the case nothing has changed.

* disabled by default, add to docs.

* moved schema file to 220.sql
2017-12-02 20:23:56 +00:00
Tony Murray
4a03e7838e feature: Save application metrics to db for alerting (#7828)
* feature: save application metrics to db for alerting
However, alerting will not work because ResolveGlues() is broken.
Can add workaround after state_translations alerting is merged

Does not update all applications yet, not sure if that should be done here or in another PR.

Introduces two handy functions dbDeleteOrphans() and array_by_column().  Will replace those in other locations after this is merged or separate them out if this is not merged.

* remove accidental inclusions

* Add db schema
2017-12-01 07:53:26 +00:00
Kevin Krumm
b6abf158a0 alerting: Added more rules to collection (#7797)
Comware Sensors PSU, Fan
Cisco Sensors Fan, PSU
UBNT EdgeSwitch Chassis State
2017-11-26 14:32:32 +00:00
Neil Lathwood
b45302bf70 newdevice: Updated Checkpoint Gaia detection and added storage (#7656)
* newdevice: Updated Checkpoint Gaia detection and added storage

* update db_schema

* added murrants discovery options

* Rename 216.sql to 217.sql
2017-11-22 23:28:33 -06:00
Neil Lathwood
ccbe3ea2e3 fix: Use correct entity columns for sensors (#7775)
* fix: Use correct entity columns for sensors

* updated schema

* Update custom rules too
2017-11-21 22:41:22 -06:00
Kevin Krumm
597af28093 alerts: Added in dell server sensors alert rules to the collection (#7647)
* alert rules: alert rules for dell servers

added in dell alert rules to the collection.

* Update alert_rules.json

fixed the ,

* Update alert_rules.json

fixed the "rule":

* Update alert_rules.json

minor fixes and added in MAC address alert. This could be useful when searching for missing devices or rogue devices on your network.

* Update alert_rules.json

removed mac address rule.
2017-11-07 20:21:37 +00:00
FTBZ
aef1a5f28a newdevice: Added state sensors for Palo Alto Networks firewall (#7482)
* Features: Add state sensors for Palo Alto Networks firewall

* Removed the MIBs files

* fix: Removing echo

* Migrate to YAML

* Migrate to YAML

* Change passive to unknow
2017-11-02 21:41:51 +00:00
Neil Lathwood
cb333071c8
fix: Added primary key to perf_times to improve DELETE performance on replicas using ROW based replication (#7493)
* fix: Added primary key to perf_times to improve DELETE performance on replicas using ROW based replication

* moved sql file

* moved sql file

* Rebased

* fixed schema

* moved sql file
2017-10-31 21:08:16 +00:00
Zmegolaz
f8d7ccfe0d feature: Support for up/down detection of ping only devices.
* Added support for ping only devices.

* Renamed sql-schema/206 to 207.

* Discovery tried to detect the OS when it shouldn't.

* Updated db_schema.yaml

* Added ping icon.

* Don't show unused graphs and tabs when SNMP is disabled.

* Allow the user to specify OS of ping only devices.

* Removing custom OS now changes it to 'ping'.

* Removed unnecessary use of mres().

* UI select box for SNMP enable/disable.

* Hide device_ping_perf if ping is disable on device.

* Fixed SNMP settings update status messages.

* Added functionality to add ping only devices via the web ui.

* Added ping only option to addhost.php

* Added ping only support to snmp-scan.py

* Moved sql 208 to 211

* Fixed scrutinizer issues.

* Fixed broken ossearch.

* Added ping only support to the API.

* Updated API doc.

* Added (optional) to OS and hardware description. Hid Port Settings, Applications, Modules, Storage, Processors, Memory and Components from the edit menu

* Style fix.

* Updated ping icon.

* clean() instead of mres(). More escaping. Better help in snmp-scan.py and addhost.php

* Fixed scrutinizer issue.

* Always try SNMP in snmp-scan.py, new option for it in addhost.php. Slice instead of chunk in ajax_ossuggest.php. Other minor style changes.

* Updated sql modifications to insert the new column in the same place as in db_schema.yaml.
2017-10-27 22:59:25 -05:00
Tony Murray
51ba934e11 feature: Added web validation (#7474)
* refactor: convert validations to modules to prep for gui integration

* accidentally dropped, schema update

* fix accidental output to webui

* mention discovery-wrapper.py and re-arrange.

* refine some fix statements

* rename the Config validation group to Configuration.

* fix some scrutinizer issues
remove as many local functions from validator.php as possible
move extensions from pre-check
remove duplicate timezone check
looks like there is some db schema differences between mariadb 10.1 and 10.2, investigating

* mariadb version diff take2

* Check schema version first for database.
Remove stop to go back to command line for install docs.
Add helpful link when there is no devices added to /addhost

* fix incorrect validation for empty string defaults

* Fix style

* Add additional file permissions checks

* catch exception and fail for invalid timezone
Change visuals a bit.

* add php version warning

* fix space
2017-10-26 07:56:09 +01:00
Neil Lathwood
9774acd055 fix: Fixed clickatell alert transport (#7446)
* fix: Fixed clickatell alert transport

* Set a default value for two config columns to ensure mysql strict

* fixed schema

* fixed schema
2017-10-15 23:49:51 -05:00
FTBZ
2e849e1b02 feature: Added more rules for the alert collection (#7430) 2017-10-04 21:02:17 +01:00
kkrumm1
01a48496c8 features: Added HP iLo and OS-updates rules to the rule collection (#7423)
* features: added even more rules to the collection

Added in,
HPE iLo Server drive degraded/failure
HPE iLo Server Power Supply degraded/failure
HPE iLo Server fan degraded/failure
HPE iLo Server CPU degraded/failure
HPE iLo Server Memory degraded/failure
Applications OS-Updates, New Updates Available

* Update alert_rules.json

* fixed some line issues and spaces

* fixed syntax error

* Update alert_rules.json

fixed a ,

* Update alert_rules.json

fixed mistake with {

* Update alert_rules.json

fixed typo at the end
2017-10-04 08:21:16 +01:00
Tony Murray
c0b267b49c refactor: Discovery protocols re-write (#7380)
* refactor: discovery protocols re-write
extract more code to make it easier to read
use snmpwalk_group
walk lldpRemTable instead of lldpRemoteSystemsData
Optimize discover_device to reduce dns lookups of bad dns names
Make discovery_by_ip behavior consistent between cdp and lldp
move can_skip_discovery to discovery functions

Tested lldp, cdp, and ospf.

* always discover links even if the remote device isn't in system
Fix discover_link always updating

* fix style

* fix update, not fetching id

* increase platform length.  Most devices use sysDescr here, which is max length 255

* remove orphaned links

* update db_schema.yaml
2017-10-04 08:16:23 +01:00
FTBZ
e16900456c feature: Added alert rules for RFC1628 UPS to the rule collection (#7415) 2017-10-03 21:34:12 +01:00
Parth Laxmikant Kolekar
101e7426f8 Extend username to varchar(255) (#7395)
* Extend username to varchar(255)

* Updated DB Schema by running build-schema script

* Updated session.session_username to be varchar(255) too
2017-09-29 20:15:48 +01:00
kkrumm1
777eb1f823 feature: Added more rules to the collection of alert rules (#7363)
* Features: Updated collection of alert rules

Added in the following to the Alerts Collection,

Syslog, received Alert Priority Message
Syslog, received Emergency Priority Message
APC UPS Battery Needs Replacement
APC UPS Switched to Battery Power
APC UPS in Hardware Failure Bypass Mode
APC UPS in Emergency Static Bypass Mode

* Update alert_rules.json

* Update alert_rules.json

fixed changes per request.

* Update alert_rules.json

fixed "white spaces and spaces"

* Update alert_rules.json

Fixed spaces and tabs... rookie mistake.
2017-09-20 22:58:24 +01:00
Neil Lathwood
aef79535f4 newdevice: Added support for A10 ACOS devices (#7327)
* newdevice: Added support for A10 ACOS devices
2017-09-17 21:33:09 +02:00
Neil Lathwood
c16ca70c71 fix: Updated graph_types table so graph_subtype has no default value (#7285)
* fix: Updated graph_types table so graph_subtype has no default value

* added schema update
2017-09-04 23:04:33 -05:00
Neil Lathwood
edae33507a feature: Added script to generate config for new OS (#7161)
* feature: Added script to generate config for new OS

* scrut fixes
2017-09-04 21:38:09 +01:00
Tony Murray
0def643e09 feature: Notify about failed updates, block detectable bad updates (#7188)
* Feature: Notify about failed updates, block detectable bad updates
Ability to post notifications when the update fails.
Detect and roll back updates that will cause broken installs. (Needs testing)
Add severity to notifications, critical (2) notifications will display a toast.

This will be used for removing in-tree dependencies and raising the minimum php version.

* Improve naming a bit add phpdoc to new_notification
In case multiple notifications are created, remove them all.

* Remove notifications when update is disabled.

* update travis to use db testing

* added missing index
2017-08-26 21:35:39 +01:00
Neil Lathwood
932b05c38c fix: Updated dump_db_schema() to use default 0 if available (#7225)
* fix: Updated dump_db_schema() to use default 0 if available

* added removed column for testing
2017-08-26 20:23:30 +01:00