changed date format
This commit is contained in:
21
ixiostat.py
21
ixiostat.py
@@ -5,24 +5,8 @@ import os
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
def convert_to_machine_readable(date_string):
|
|
||||||
# Define the format string considering the time zone information (EDT)
|
|
||||||
format_string = "%a %b %d %H:%M:%S %p %Z %Y"
|
|
||||||
try:
|
|
||||||
# Parse the date string using the format string
|
|
||||||
datetime_obj = datetime.strptime(date_string, format_string)
|
|
||||||
return datetime_obj
|
|
||||||
except ValueError:
|
|
||||||
print(f"given: {date_string}")
|
|
||||||
print(
|
|
||||||
f"Error: Invalid date format. Please provide a string in the format '{format_string}'."
|
|
||||||
)
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
# Define your shell command
|
# Define your shell command
|
||||||
command = ["zpool", "iostat", "-Td", "-l", "-p", "-v", "-y", "1", "1"]
|
command = ["zpool", "iostat", "-Tu", "-l", "-p", "-v", "-y", "1", "1"]
|
||||||
|
|
||||||
headerRow = [
|
headerRow = [
|
||||||
"time",
|
"time",
|
||||||
@@ -63,9 +47,6 @@ def runZpoolIostat():
|
|||||||
# get timestamp
|
# get timestamp
|
||||||
timestamp = pool.splitlines()[0].strip()
|
timestamp = pool.splitlines()[0].strip()
|
||||||
|
|
||||||
if timestamp:
|
|
||||||
timestamp = str(convert_to_machine_readable(timestamp))
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# remove ------ lines
|
# remove ------ lines
|
||||||
pool = re.sub("^---.*", "", pool).strip()
|
pool = re.sub("^---.*", "", pool).strip()
|
||||||
|
|||||||
Reference in New Issue
Block a user