<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>Matthew --</div>
<div><br>
</div>
<div>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"</div>
<div><br>
</div>
<div>Is this helpful?</div>
<div><br>
</div>
<div>Andy</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">#!/usr/bin/python</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">from __future__ import print_function</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">import xmlrpclib</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">import re</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">import datetime</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">from datetime import date</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">from datetime import timedelta</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">import os</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">import smtplib</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">from email.mime.text import MIMEText</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">from creds import SATELLITE_LOGIN, SATELLITE_PASSWORD</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">SATELLITE_URL = "https://[YOUR_FQDN_HERE]/rpc/api"</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">client = xmlrpclib.Server(SATELLITE_URL, verbose=0)</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">today = date.today()</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">yesterday = today - timedelta(days=1)</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">list = client.system.list_systems(key)</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">for system in list:</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">                lastboot = client.system.get_details(key,system.get('id'))</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">                currKern = client.system.get_running_kernel(key,system.get('id'))</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">                matchObj = re.search(".*\'last_boot\'\: \<DateTime \'(.*?)\'\ at.*", str(lastboot))</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"># The following line prints easily sortable by last boot timestamp.  AWI 2/26/14</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">##              print(matchObj.group(1),system.get('name'),currKern)</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"># The following line prints easily sortable by current running kernel.  AWI 2/26/14</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">                print(currKern,system.get('name'),matchObj.group(1))</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">client.auth.logout(key)</p>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Matthew Rinella <<a href="mailto:MRinella@apptio.com">MRinella@apptio.com</a>><br>
<span style="font-weight:bold">Reply-To: </span>"<a href="mailto:spacewalk-list@redhat.com">spacewalk-list@redhat.com</a>" <<a href="mailto:spacewalk-list@redhat.com">spacewalk-list@redhat.com</a>><br>
<span style="font-weight:bold">Date: </span>Tuesday, February 3, 2015 at 4:46 PM<br>
<span style="font-weight:bold">To: </span>"<a href="mailto:spacewalk-list@redhat.com">spacewalk-list@redhat.com</a>" <<a href="mailto:spacewalk-list@redhat.com">spacewalk-list@redhat.com</a>><br>
<span style="font-weight:bold">Subject: </span>[Spacewalk-list] list of systems by uptime?<br>
</div>
<div><br>
</div>
<div xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Is there a way to get the uptime or last reboot time of a system, or all systems through the API?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks.<o:p></o:p></p>
</div>
</div>
</div>
</span>
</body>
</html>