<html><body><div style="font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000"><div>Awesome! this works much much faster.<br></div><div><br></div><div data-marker="__SIG_PRE__"><br></div><br><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><b>From: </b>"Matthew Madey" <mattmadey@gmail.com><br><b>To: </b>spacewalk-list@redhat.com<br><b>Sent: </b>Tuesday, January 20, 2015 1:31:46 PM<br><b>Subject: </b>Re: [Spacewalk-list] Query current OSA clients<br></div><br><div data-marker="__QUOTED_TEXT__"><div dir="ltr">Here is a python script I wrote for reporting. It will return the hostname and OSA status for every registered client, and is much faster than using spacecmd. You could wrap it in a shell script to return only the systems you're looking for, or if you're familiar with python just adjust the code to filter the ones that are "online".  You will need to setup a configuration file containing the username and password to use when querying (If you are using Spacewalk 2.2, I'd recommend making this a read-only API user for the sake of security) Hope this helps. <br><div>Create file: /etc/rhn/rhn-api-user.conf<br></div><br><div>File contents:</div><br><div><div>[Spacewalk]</div><div>spw_server = <a href="http://yourserver.example.com" target="_blank">yourserver.example.com</a><br data-mce-bogus="1"></div><div>spw_user   = username</div><div>spw_pass   = password</div></div><br><br><div>Here is the python script:</div><br><div><div>#!/usr/bin/python</div><br><div>import xmlrpclib</div><div>import subprocess</div><div>import os</div><div>import sys</div><div>import ConfigParser</div><br><div>cfg_file="/etc/rhn/rhn-api-user.conf"</div><div>config = ConfigParser.ConfigParser()</div><div>try:</div><div>    config.read (cfg_file)</div><div>except:</div><div>    print "Could not read config file %s." % cfg_file</div><div>    sys.exit(1)</div><div>try:</div><div>    spw_server = config.get ('Spacewalk', 'spw_server')</div><div>    spw_user = config.get ('Spacewalk', 'spw_user')</div><div>    spw_pass = config.get ('Spacewalk', 'spw_pass')</div><div>except:</div><div>    print "The file %s seems not to be a valid config file." % options.cfg_file</div><div>    sys.exit(1)</div><br><br><div>SATELLITE_URL = "http://{0}/rpc/api".format(spw_server)</div><div>SATELLITE_LOGIN = spw_user</div><div>SATELLITE_PASSWORD = spw_pass</div><div>client = xmlrpclib.Server(SATELLITE_URL, verbose=0)</div><div>key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)</div><br><div>print "hostname,status"</div><div>systems = client.system.listSystems(key)</div><div>for system in systems:</div><div>        hostname = system['name']</div><div>        id = system['id']</div><div>        details = client.system.getDetails(key, id)</div><div>        status = details['osa_status']</div><div>        print "%s,%s" % (hostname, status)</div><br><div>client.auth.logout(key)</div></div><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 20, 2015 at 11:02 AM, Justin Edmands <span dir="ltr"><<a href="mailto:j.edmands@sagedining.com" target="_blank">j.edmands@sagedining.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:#000000"><div>Hey Spacewalkers,<br></div><div>I am attempting to query all of the systems that are currently checking in via OSAD. I have been using a fairly inefficient spacecmd command to make this work for now. <br></div><br><div>            [12:00:13][justin@justindev1:~]# spacecmd system_details S0* | grep -e "Name" -e "OSA" >> OSA_status.out ; grep online OSA_status.out | wc -l</div><br><div>the S0 just happens to be the first two characters in the names I want to query. In the end it does a word count to determine how many are "online"<br></div><br><div>Any better way to do this? This takes about 2-5 minutes when run against a list of about 500 clients.</div><br></div></div><br>_______________________________________________<br>
Spacewalk-list mailing list<br>
<a href="mailto:Spacewalk-list@redhat.com" target="_blank">Spacewalk-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/spacewalk-list" target="_blank">https://www.redhat.com/mailman/listinfo/spacewalk-list</a><br></blockquote></div><br></div>
<br>_______________________________________________<br>Spacewalk-list mailing list<br>Spacewalk-list@redhat.com<br>https://www.redhat.com/mailman/listinfo/spacewalk-list<br></div></div></body></html>