[Spacewalk-list] list of systems by uptime?

Andy Ingham andy.ingham at duke.edu
Wed Feb 4 14:10:51 UTC 2015


I shouldn't say the output is "ordered".  The difference is simply in which set of values is at the beginning of each output line (which makes it easy to re-order within your favorite text editor).

Andy

From: Andy Ingham <andy.ingham at duke.edu<mailto:andy.ingham at duke.edu>>
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: Wednesday, February 4, 2015 at 8:38 AM
To: "spacewalk-list at redhat.com<mailto:spacewalk-list at redhat.com>" <spacewalk-list at redhat.com<mailto:spacewalk-list at redhat.com>>
Subject: Re: [Spacewalk-list] list of systems by uptime?

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/70e0461a/attachment.htm>


More information about the Spacewalk-list mailing list