Skip to content

Commit

Permalink
Merge pull request #28 from mdvickst/master
Browse files Browse the repository at this point in the history
Added 4 date commands to help determine when a server was built.
  • Loading branch information
cnsnyder authored Sep 19, 2016
2 parents 732f57a + ffadb61 commit f38d071
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/rho/clicommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ def _do_command(self):
'redhat-packages.num_installed_packages',
'redhat-packages.last_installed',
'redhat-packages.last_built',
'date.anaconda_log', 'date.machine_id',
'date.filesystem_create', 'date.yum_history',
'virt-what.type', 'virt.virt',
'virt.num_guests', 'virt.num_running_guests',
'cpu.count', 'cpu.socket_count', 'ip', 'port',
Expand Down
21 changes: 17 additions & 4 deletions src/rho/rho_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,27 @@ def parse_data(self):

class DateRhoCmd(RhoCmd):
name = "date"
cmd_strings = ['date']

fields = {'date.date': _('date')}
cmd_strings = ['date',
"ls --full-time /root/anaconda-ks.cfg | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}'",
"ls --full-time /etc/machine-id | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}'",
"fs_date=$(tune2fs -l $(mount | egrep '/ type' | grep -o '/dev.* on' "
"| sed -e 's/\on//g') | grep 'Filesystem created' | sed 's/Filesystem created:\s*//g'); "
"if [[ $fs_date ]]; then date +'%F' -d \"$fs_date\"; else echo "" ; fi",
"yum history | tail -n 4 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}'"]

fields = {'date.date': _('date'),
'date.anaconda_log': _("/root/anaconda-ks.cfg modified time"),
'date.machine_id': _("/etc/machine-id modified time'"),
'date.filesystem_create': _("uses tune2fs -l on the / filesystem dev found using mount"),
'date.yum_history': _("dates from yum history")}

def parse_data(self):

self.data['date.date'] = self.cmd_results[0][0].strip()

self.data['date.anaconda_log'] = self.cmd_results[1][0].strip()
self.data['date.machine_id'] = self.cmd_results[2][0].strip()
self.data['date.filesystem_create'] = self.cmd_results[3][0].strip()
self.data['date.yum_history'] = self.cmd_results[4][0].strip()

class UnameRhoCmd(RhoCmd):
name = "uname"
Expand Down

0 comments on commit f38d071

Please sign in to comment.