summaryrefslogtreecommitdiffstats
path: root/log_manager.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Resource leakage on opened file.Troy Lee2019-12-091-2/+2
| | | | | | | | | | The opened file descriptor and inotify won't be released, if the synced file generate in time. This happens occasionally, but the leakage will lead to journal log failure and will not able to use inotify after a long period run. Change-Id: I09cca72c88091ebcf1bb7ddb7df04ee1d2b2d7d6 Signed-off-by: Troy Lee <troy.lee@vertiv.com>
* Allow polling for journal syncMatthew Barth2019-08-281-1/+12
| | | | | | | | | | | | | | | | Each error log commit forces a journal sync and needs to wait for the sync to occur before allowing the commit to continue. The loop managing the journal sync was only performing 2 iterations where the first requests the sync and the second configures the inotify watch. However, the polling necessary to wait for the inotify would never occur. This bumps the managing loop to 3 iterations to allow the polling to occur on the 3rd iteration. Tested: The 5sec polling section of code is run on the 3rd iteration Change-Id: If12c5b33849843b33bb252efd1eb88e0bc954d6d Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
* Implement Logging.Create interfaceMatt Spinler2019-08-051-0/+10
| | | | | | | | | | | | | | | | | | | | This adds the xyz.openbmc_project.Logging.Create interface on the /xyz/openbmc_project/logging path. The interface provides a single method, Create, that allows one to create an event log. This is an alternative to using the report/commit functions provided by the phosphor-logging/elog.hpp header file. Unlike those report/commit interfaces, this does not require that the entries in the AdditionalData event log property be defined ahead of time, as the whole AdditionalData contents are just passed in instead of read out of the journal. This means that the error does not need to have been defined in the error and metadata YAML files for an event log to be successfully created. The discussion on if that is still desired anyway is outside the scope of this commit. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: Icf3f740ab86605deeaeb955ff51aa2ef292f5af4
* Factor out log creation code common code.Matt Spinler2019-08-051-19/+24
| | | | | | | | | In preparation for adding another function to create a log entry, factor out some common code into a new function that will be able to be called in both spots. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I8881f4ec0d36a2b2e2b1897b63d524022a328286
* OpenPower PEL Extension support frameworkMatt Spinler2019-07-161-8/+79
| | | | | | | | | | | | | | | | | | | | | | The goal of extensions is to extend phosphor-logging's `xyz.openbmc_project.Logging.Entry` log support to allow other log formats to be created without incurring extra D-Bus call overhead. The README.md change in this commit provides additional documentation on how extensions work. The summary is that they allow code that resides in this repository to provide functions that can be called at certain points (startup, log creation/deletion) such that the code can then create their own logs based on the contents of an OpenBMC log. A specific extension's code is compiled in using a --enable configure option, so platforms that did not use those log formats would incur no performance/size penalties. This commit provides the support for extensions, plus a basic OpenPower PEL (Platform Event Log) extension as the first extension. PELs are event logs used only on some OpenPower systems. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: Ifbb31325261c157678c29bbebc7f6d32d282582f
* minor cleanup, std namespacingPatrick Venture2018-11-011-2/+5
| | | | | | | Added std namespace to places where there is a cpp version. Change-Id: I60a05a7c9cdcd79cfffc3c4968005fcbe34acf81 Signed-off-by: Patrick Venture <venture@google.com>
* style: local variable entry shadows outer symbolPatrick Venture2018-10-301-7/+7
| | | | | | | | | | | | | | | | | Many functions have a variable entry in a sub namespace to the outer symbol entry from phosphor-logging/log.hpp [phosphor-logging/log.hpp:73] -> [log_manager.hpp:104]: (style) Local variable entry shadows outer symbol [phosphor-logging/log.hpp:73] -> [log_manager.cpp:226]: (style) Local variable entry shadows outer symbol [phosphor-logging/log.hpp:73] -> [log_manager.cpp:243]: (style) Local variable entry shadows outer symbol [phosphor-logging/log.hpp:73] -> [elog_meta.hpp:37]: (style) Local variable entry shadows outer symbol Change-Id: Icf5d585ec05b0a545e515d0afb7d2267645a2f2c Signed-off-by: Patrick Venture <venture@google.com>
* add .clang-formatPatrick Venture2018-10-261-59/+54
| | | | | Change-Id: I2c36b7886a25d0b235693b0776019d29608e1d52 Signed-off-by: Patrick Venture <venture@google.com>
* log_manager: Don't fail on missing synced fileAdriana Kobylak2018-09-051-11/+18
| | | | | | | | | | | | | | | | | | | | | The journald synced file is created during a journal sync, so if it's missing, the log manager should still perform the sync operation so that the synced file gets created. This is the behavior of journalctl which this function is copying, just this logic wasn't transferred in the original commit. Reference: https://github.com/systemd/systemd/blob/60118b21c6b4b29376615921c5edc1b05cde306f/src/journal/journalctl.c#L1999 Disabled the unit test cases that call commit since they now fail. Opened issue openbmc/phosphor-logging#11 for debug. Closes openbmc/phosphor-logging#10 Tested: With the synced file missing, verified that a commit operation created the file and there were no error messages about failing to open the synced file. Change-Id: Ia720741b99552d51d13cdc6b4e08dbbab58bca77 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Add application to configure rsyslogDeepak Kodihalli2018-08-291-4/+0
| | | | | | | | | | | | | | The application implements the xyz.openbmc_project.Network.Client D-Bus interface to set a remote rsyslog server's address and port in the rsyslog config file. This lets us configure rsyslog to be able to stream out logs. TODO: Exception handling and validation will be handled in subsequent commits. Change-Id: I8917daab3f0de1806d2f1aafe99cb3a872f19184 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* Add unit tests for the phosphor-logging serverNagaraju Goruganti2018-08-081-0/+10
| | | | | | | -Add unit tests for error wrapping Change-Id: Ib15620d84de8ab5abdc85b8f88dd7c05f83fd6f3 Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
* Always call close on fd if file has been openedAdriana Kobylak2018-05-231-2/+5
| | | | | | | | | The previous logic only called close if the file had been opened AND there was a valid inotify watch handle. Even if there is not a watch handle, the file should be closed. Change-Id: Id1f6d441129e13c6a48d6156161425082aeba8e8 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Add the BMC code version to error logsMatt Spinler2018-05-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Add the xyz.openbmc_project.Software.Version interface to the elog entries. This allows a user to know what BMC code level was running when the error was created. The level is persisted along with the other elog fields. If this code is flashed on a system that was running older code, and there were existing error logs, the version property will be left empty in the restored log entries. Older code is still able to restore logs created by this code as the version property is at the end of the serialized data and so is just ignored by Cereal. Resolves openbmc/openbmc#3133 Tested: Check that new error logs have the code level, and that restarting phosphor-log-manager preserves that property on the existing logs. Various incantations of running the older code with logs created by this code, and running this code with logs created by older code. Change-Id: I682aa3bf97c8352ce6dda05dfdf55d33173de891 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Add function to read code versionMatt Spinler2018-05-011-0/+25
| | | | | | | | | | | | | | Read the BMC code version once at startup. This will be added to error logs in future commits. The code is getting the version from a file instead of from D-Bus in order to reduce dependencies. Tested: Call the function and check that it returned the correct thing. Change-Id: I9a4729e946a130ec32c375c283fd22a7658121f5 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* log_manager: Create journal sync functionAdriana Kobylak2018-04-171-9/+133
| | | | | | | | | | | | | | | The Synchronize D-Bus method was a systemd patch that calls "journalctl --sync" and will not be upstreamed to systemd. Instead duplicate the function locally in the log_manager so that the patch can be dropped, since the systemd journal service would not start on time if it was idle, leading to missing metadata. Closes openbmc/openbmc#2257 Tested: While printing continously into the journal, verify that a commit request is blocked until the journal is flushed. Change-Id: I8248c4c2e2eaeb041f7876832b395b053409acdd Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Implement ability to override default error levelDeepak Kodihalli2018-04-091-7/+27
| | | | | | | | | | | | | Errors reported by the phosphor-logging app have a default error level, and this level is specified in the error's YAML definition. Enable users of the error's report() API to specify an error level. A user may perceive a different error level for an error scenario, for eg there may be certain host errors (for which we set the level as 'Error') that may just be 'Warnings'. Change-Id: I666a0ddcb099e530c423358a3b1c65f33b0ad01e Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* Roll errors after reaching Cap sizeNagaraju Goruganti2017-12-011-22/+23
| | | | | | | | | | | | | | | | Fixes openbmc/openbmc#2687 -cap on error exists to deal with small flashes, right now the cap is 100 for high severity errors and it is 10 for info(and below) severity) errors. -previous policy was to stop logging new errors once cap is reached for high severity errors. -based on feedback from field engineers, it's better to log new errors, external tools will typically periodically read and store errors, so we won't lose them.so the new policy now is to roll errors. Change-Id: I18b509d81c076fcb80667300cbfda050027bb422 Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
* Perform sanity check while restoring error entriesMarri Devender Rao2017-11-191-5/+22
| | | | | | | | | | Check if the data in the persisted files is valid before restoring the error entries Resolves openbmc/openbmc#2646 Change-Id: Iff0846a3366a27e59484113b7020f540087aa994 Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
* Avoid unnecessary call to id() in ::eraseMarri Devender Rao2017-11-171-2/+6
| | | | | Change-Id: I21e0cd5a03ee06db17b8d3ed7b712b3d350b6a5f Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
* Handle more than 100 error logsNagaraju Goruganti2017-10-241-17/+46
| | | | | | | | | | | Added new Cap for info(and below) severity errors, if cap size reaches, next commited error of severity:info(and below) will replace the first entry of severity:info(and below). Resolves openbmc/openbmc#2381 Change-Id: I2e56c28a934bf3139e57b36d252bd5ad3e1dd90f Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
* Enable Cereal class versioningVishwanatha Subbanna2017-10-111-1/+4
| | | | | | | | | Cereal class versioning helps to handle data de-serialization across different class versions that differ in the way, a particular data is serialized. Change-Id: Ica01c4cb0c213e0dca8824fcfcfaa5cb43c5bc2e Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
* Add implementation for delete all error log entries in one shotNagaraju Goruganti2017-09-131-1/+3
| | | | | | | Resolves openbmc/openbmc#1561. Change-Id: Iac5aaee1bdf9b87ccce9bf8801468ac5a8f9be6c Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
* Add _PID information in elog AdditionalDataJayanth Othayoth2017-09-121-0/+3
| | | | | | | | dreport need PID information to collect process specific journal for InternalFailure type error triggered dump. Change-Id: I313caa4795f7c0d47c1f42dae0653008cdbd5967 Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
* Implement a cap on the number of committed errorsMarri Devender Rao2017-08-161-0/+18
| | | | | | | Resolves openbmc/openbmc#1617 Change-Id: I5850e5addb723e6f5102eb4677bb365285c1a633 Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
* commit: Add call to Synchronize journal dbus methodAdriana Kobylak2017-08-071-0/+9
| | | | | | | | | | | Call the Synchronize method at the beginning of the Commit function to request that all pending messages are written into the journal. Fixes: openbmc/openbmc#1297 Change-Id: Id0ab04ff0cb9b7eeac3b7c2aaeb8730a3b4ed524 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Remove elog-errors-HostEvent.hpp from phosphor-logging repoTom Joseph2017-07-251-10/+1
| | | | | | | Resolves openbmc/phosphor-logging#4 Change-Id: I15ccdef0dd63216991bbd113e47beb057df14df8 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
* Fix host error logged as INFOMarri Devender Rao2017-07-131-1/+1
| | | | | | | | | | | At present org.open_power.Error.Host.Event.Event is handcoded and is not part of the error map used by log manager to identify the type of the error. Resolves openbmc/openbmc#1953 Change-Id: I2f390c29c9b47adcf20efc32bbb02cf026d55758 Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
* Remove persisted error file upon error deletionDeepak Kodihalli2017-06-261-0/+6
| | | | | Change-Id: If2418ad9350d7f3bdbfe28a00728f431f08baf9f Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* Persist error d-bus objectsDeepak Kodihalli2017-06-261-11/+43
| | | | | | | | | | | | Use Cereal to implement serialization and de-serialization of properties of error d-bus objects. Serialize and persist error d-bus objects as they are put on the bus. De-serialize and restore them (if persistent ones exist) when phosphor-log-manager starts up. Change-Id: I1f5df1abbe74bfdb86e3e82a78ff7115e90e2112 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* entry: store parent referenceDeepak Kodihalli2017-04-111-1/+2
| | | | | | | | Have the entry object store a reference to the error manager, passed via the entry ctor. Change-Id: I2c4a8c4c95929ab7005620f44ac17e9654d8e906 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* manager: define erase methodDeepak Kodihalli2017-04-101-0/+9
| | | | | | | The erase method can erase an entry object specified by id. Change-Id: I86bb2a214b8cf9b951af37f69767ff025f2f5fd0 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* Make generated code to be const and externAdriana Kobylak2017-03-151-4/+13
| | | | | | | | | | | | Set generated maps to be const so that they don't get accidentally overwritten. Use .find() to access these generated data sets as the [] operator is not const. Declare the generated maps as extern so that there's no need to include the generated .cpp file. Change-Id: I4efdcace099bec738e1fa9b67decbedd515d3dfa Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Invoke metadata handlerDeepak Kodihalli2017-03-151-0/+29
| | | | | | | | Check if error metadata fields have associated handlers, if yes, invoke them before construction the error d-bus object. Change-Id: I197385c5c43242f633274b82289cd70c85c1d6e7 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* Entry ctor: accept associationsDeepak Kodihalli2017-03-151-1/+3
| | | | | | | | | Pass a list of associations to the Entry ctor. This enables to create associations between the error object and other objects, if such associations exist. Change-Id: I88a517efc0ead0a62b2e6558822d94b8fc1c6070 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* Ensure using correct string length when using transaction id journal dataAdriana Kobylak2017-03-071-4/+16
| | | | | | | | | | | journald does not guarantee that sd_journal_get() returns NULL terminated strings. Specify the actual length of the string (instead of relying on functions that look for NULL terminators to determine the length) to compare the transaction id number, otherwise intermittent errors can occur. Change-Id: I58c34f377866f002a09b07810065b4e064f216b9 Closes: openbmc/openbmc#1217 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Look for an exact match of transaction idAdriana Kobylak2017-03-021-2/+5
| | | | | | | | | | Currently the code would search for a matching string in the whole TRANSACTION_ID=1234 string, but there may cases that this could result in a false match. Change to extract the id number out of the string to do an exact compare. Change-Id: I2cc0e6b42937a36e9afb942c07c91c0b4469a963 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* commit(): Make function more efficientAdriana Kobylak2017-02-281-38/+43
| | | | | | | | | | | Change the logic of the commit function from searching the journal for each metadata variable, to looking for all metadata variables in each journal entry. This change reduces the number of times that we search through the journal from N to 1 time. Change-Id: I47143e746dafb06bdce25dfd0009933494f4d25d Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* commit: Search for all metadata variables in the journalAdriana Kobylak2017-02-221-49/+46
| | | | | | | | Fix the TODO to search for all the metadata variables in the journal. Change-Id: I62e01e5923b3d29317ef94b5b340153bbb8967a7 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* commit: Remove unused codeAdriana Kobylak2017-02-221-30/+0
| | | | | | | | | | | Remove the code that writes data to a tmp file. The error log entry will be saved via dbus property caching openbmc/openbmc#1055 Remove the code that gets the MESSAGE field from the journal, the error log entry doesn't have a use for it as it uses the exception name. Change-Id: Ie400acadc4a34f0d558808af47b41795f0ce8e2c Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Moved log.hpp and elog.hpp to a folder under phosphor-loggingSaqib Khan2017-02-201-2/+2
| | | | | | | | | | Now these files are copied to a folder under phosphor-logging, other repositories will need to be fixed. I'm leaving the files in the base dir as well until I work on fixing all projects that utilizes log.hpp and elog.hpp Change-Id: Ie4640852727c1572325e974548737bc70a6db7c2 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Add HostEvent support to Commit interfaceAdriana Kobylak2017-02-161-0/+22
| | | | | | | | Temporary support for the HostEvent data that is checked in instead of auto-generated. Change-Id: I34e0c8d91dd51b26efaadbe0cd8be951f0e4bc01 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Populate Timestamp when error entry is committedAdriana Kobylak2017-02-151-1/+5
| | | | | | | | | Populate the Entry Timestamp property which is described as the time when the error log entry is committed in milliseconds since 1970. Change-Id: Id47fb974cf8220975eef0cc226581d0603a798a9 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Entry: Populate propertiesAdriana Kobylak2017-02-141-1/+17
| | | | | | | | Create an Entry dbus object when Commit is called and fill in its properties with the journal data. Change-Id: I155cacbdfdccfa8b1f594503d858710fa71f2026 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* log_manager: Cleanup main functionAdriana Kobylak2017-01-301-27/+0
| | | | | | | | The design direction changed after the commit that added the log_manager main function, so updating it to the correct usage. Change-Id: I88459fb65ba6b8272f0f9f85b55f9f837487ffea Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* logging: Commit: Use transaction id and metadata lookupAdriana Kobylak2017-01-301-17/+19
| | | | | | | | | | Add the lookup mako target to the makefile to get it built. Use the lookup map to find the metadata that needs to be added to the error log. Use the transaction id to filter for the desired journal entries. Signed-off-by: Adriana Kobylak <anoo@us.ibm.com> Change-Id: Ia57dc83aab4f7ee35f8de32a799c862be28113f7
* log_manager: Use sdbus++Adriana Kobylak2016-12-081-112/+36
| | | | | Change-Id: Id2ad6a75b6ee3f7226c7cfd274dba24de89f9363 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Add error/event log commit dbus methodAdriana Kobylak2016-11-091-11/+123
| | | | | | | | Create error/event log based on message id (process id) and metadata values. Change-Id: Iaf944130c4075ae2d2c192e5ef840451561791bc Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Create log manager serverAdriana Kobylak2016-11-081-0/+102
Error/event log dbus object with a placeholder method. Change-Id: Icfa3f0dcddb3f47a62d8480a936bd8baa4b49760 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
OpenPOWER on IntegriCloud