Package installations and upgrades on a *nix server
System patches, software upgrades, and software installations are risky processes in a production environment. They can lead to an outage or incident if the software installation introduces compatibility issues with critical processes and applications running on the host. You want a search that will show you recent software changes on a host, so you can more easily identify what changed and when while investigating an incident.
Procedure
Run the following search. You can optimize it by specifying an index and adjusting the time range.
((tag=update) OR (yum ("Updated:" OR "Installed:")) OR (sourcetype=dnf ("Installed:" OR "Upgraded:"))) (NOT Downloading:) host=* |rex "(?s)(Upgraded|Updated):(?<pkgs_updated>.*?(?=Installed:|\Z))" |rex "(?s)Installed:(?<pkgs_installed>.*)" |rex mode=sed field=pkgs_updated "s/\s+/ /g" |rex mode=sed field=pkgs_installed "s/\s+/ /g" |eval pkgs_updated=split(pkgs_updated, " "), pkgs_installed=split(pkgs_installed, " ") |table _time host pkgs* _raw
Search explanation
The table provides an explanation of what each part of this search achieves. You can adjust this query based on the specifics of your environment.
Splunk Search | Explanation |
---|---|
|
Return all software installations and upgrades in your environment. |
|
Search on all hosts. |
|
Capture everything between |
|
Capture everything after Installed:. |
|
Replace any white space with a single space in the string pointed to by |
|
Replace any white space with a single space in the string pointed to by |
|
Split the listed field by the single space added in the rex commands. |
|
Display the results in a table with columns in the order shown. |
Next steps
Sample results for this search are shown in the table below. It shows the time of the update or upgrade, the affected host, and the name of the package that has either installed or been updated.
_time |
host |
pkgs_installed |
pkgs_updated |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Finally, you might be interested in other processes associated with the Maintaining *nix systems use case.