This question is usually where I say that people shouldn't be checking if 
packages exist, they should be instead be managing packages with configuration 
management. That way you only need to monitor the results of one config run on 
a server rather than all the individual packages.

More topically, if you have a list of package names you can check them against 
the list from "rpm -qa" and alert. Here's a facter (docs.puppet.com/facter) 
fact which reports package versions for selected packages, you can do something 
similar in a monitoring script and add anything you want like missing package 
notification.

packages = [
  'bash',
]

rpmqa = %x{/bin/rpm -qa --qf '%{NAME};%{V};%{RELEASE}\n'}

output = []

rpmqa.split("\n").each do |line|
  packages.each do |name|
    if /^#{name};/.match(line)
      output << line
    end
  end
end

Facter.add('package_audit') do
  setcode do
    output
  end
end



On Thu, May 25, 2017 at 10:43:59AM -0700, Billy Vitro wrote:
> Does anyone have good suggestions on checking for specific packages (e.g.
> perl-DBD-SQLite) installed on an RHEL host. I know I could just run 'rpm -qa
> perl-DBD-SQLite') for each package, but I was wondering if someone built
> something more thorough.
> 
> Thanks.
> -- 
> Billy Vitro                       |  cisco Systems, Inc.
> [email protected]                  |  (408) 526-4817
> http://www.linkedin.com/in/bvitro |  Illegitimus non carborundum.
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to