I'll just add that you can do either $ hammer --csv host list --search 'name ~ "gce*" and last_report > "2 days ago"'
or $ hammer --csv host list --search 'hostgroup = "gce" and last_report > "2 days ago"' to get the list to iterate over. The --search argument is using same syntax as the search field in hosts UI. Martin On Mon, Nov 13, 2017 at 3:01 PM, Neil Hanlon <[email protected]> wrote: > Greg ++ as always with the save :) > > On Mon, Nov 13, 2017 at 8:59 AM Greg Sutcliffe <[email protected]> > wrote: > >> You could even use hammer with one of the output formatters, and loop >> over it. >> >> Something like "hammer --csv host list --hostgroup GCE" would get you >> the starting list of hosts to loop, then a call to this API (don't think >> hammer has last-report): >> >> '/api/v2/hosts/<host-fqdn>/reports/last' | json_pp | grep "reported_at" >> >> would give you the last report date. You could compare those to $now and >> then call "hammer host delete --name <host-fqdn>" if it's too old. >> >> *OR* consider using the expire_hosts plugin, which if you're just >> concerned about cleanin up old hosts, might be exactly what you want. >> See https://github.com/theforeman/foreman_expire_hosts >> >> Greg >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Foreman users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at https://groups.google.com/group/foreman-users. >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Foreman users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/foreman-users. For more options, visit https://groups.google.com/d/optout.
