Page MenuHomePhabricator
Paste P8744

checking puppetdb compiled catalogs for nrpe::monitor_service with non-boolean values for $critical
ActivePublic

Authored by CDanis on Jul 14 2019, 7:18 PM.
Tags
Referenced Files
F29782064: raw.txt
Jul 16 2019, 1:42 PM
F29767788: raw.txt
Jul 14 2019, 7:18 PM
F29767781: raw.txt
Jul 14 2019, 7:18 PM
Subscribers
# run from puppetdb1001
# get list of all nodes
curl http://localhost:8080/pdb/query/v4/nodes | jq -r '.[] | .certname' > all-nodes.txt
mkdir resources
# get some/all catalogs
head -n50 all-nodes.txt | xargs -P20 -I@ /bin/sh -c 'curl -s http://localhost:8080/pdb/query/v4/catalogs/@/resources > resources/@'
cat all-nodes.txt | xargs -P20 -I@ /bin/sh -c 'curl -s http://localhost:8080/pdb/query/v4/catalogs/@/resources > resources/@'
# jq search
jq '.[] | select(.type == "Nrpe::Monitor_service") | select(.parameters.critical != false and .parameters.critical != true) ' resources/*
# empty output!
# clean up afterwards
nohup shred --remove=unlink resources/* &
disown

Event Timeline

CDanis edited the content of this paste. (Show Details)

First used to validate the change made in https://gerrit.wikimedia.org/r/c/operations/puppet/+/522992 but useful generically.

@Volans also points out that one can query the v4/resources/ endpoint with a a query to get only resources with parameters matching your criteria: https://puppet.com/docs/puppetdb/4.4/api/query/v4/resources.html
which might take more or less time than the above, depending on how hard it is to write the query.