[Spacewalk-list] list of systems by uptime?
Andy Ingham
andy.ingham at duke.edu
Wed Feb 4 13:38:57 UTC 2015
Matthew --
I've been using the following python script to output last reboots across my plant, ordered either by running kernel version OR by last boot time (toggled by commenting/uncommenting near the end of the script). Note that it pulls login credentials from a separate file named "creds.py"
Is this helpful?
Andy
#!/usr/bin/python
from __future__ import print_function
import xmlrpclib
import re
import datetime
from datetime import date
from datetime import timedelta
import os
import smtplib
from email.mime.text import MIMEText
from creds import SATELLITE_LOGIN, SATELLITE_PASSWORD
SATELLITE_URL = "https://[YOUR_FQDN_HERE]/rpc/api"
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
today = date.today()
yesterday = today - timedelta(days=1)
list = client.system.list_systems(key)
for system in list:
lastboot = client.system.get_details(key,system.get('id'))
currKern = client.system.get_running_kernel(key,system.get('id'))
matchObj = re.search(".*\'last_boot\'\: \<DateTime \'(.*?)\'\ at.*", str(lastboot))
# The following line prints easily sortable by last boot timestamp. AWI 2/26/14
## print(matchObj.group(1),system.get('name'),currKern)
# The following line prints easily sortable by current running kernel. AWI 2/26/14
print(currKern,system.get('name'),matchObj.group(1))
client.auth.logout(key)
From: Matthew Rinella <MRinella at apptio.com<mailto:MRinella at apptio.com>>
Reply-To: "spacewalk-list at redhat.com<mailto:spacewalk-list at redhat.com>" <spacewalk-list at redhat.com<mailto:spacewalk-list at redhat.com>>
Date: Tuesday, February 3, 2015 at 4:46 PM
To: "spacewalk-list at redhat.com<mailto:spacewalk-list at redhat.com>" <spacewalk-list at redhat.com<mailto:spacewalk-list at redhat.com>>
Subject: [Spacewalk-list] list of systems by uptime?
Is there a way to get the uptime or last reboot time of a system, or all systems through the API?
I saw via google this was discussed before on the list but I couldn't not find a definitive answer if it was ever implemented.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/spacewalk-list/attachments/20150204/c69d1cfd/attachment.htm>
More information about the Spacewalk-list
mailing list