Skip to content

Conversation

@mikee2
Copy link

@mikee2 mikee2 commented Jan 16, 2022

Added formatted output for influxdb.
Improve output format consistency.

Added formatted output for influx.
Improve output format consistency.
@ElCoyote27
Copy link
Contributor

I really like your patch @mikee2 , I think it is a great addition.
I ran into a small problem using it on RHEL8.6 with a PERC H730P:

# ./megaclisas-status --influxdb
Traceback (most recent call last):
  File "./megaclisas-status", line 698, in <module>
    print (hbafmt % ( hba[1], hba[5], hba[2], hba[3], hba[4], hba[0][1:], time.time_ns()))
AttributeError: module 'time' has no attribute 'time_ns'

This is python 3.6.8

@ElCoyote27
Copy link
Contributor

I replaced all occurrences of time.time_ns() with time.time() and it seemed to work.. Dunno if influxdb can handle the time in seconds with digits:

#  ./megaclisas-status --influxdb
megaraid_controller,host=ravenvale,model="PERC H730P Adapter",firmware="25.5.9.0001" memory=2048MB,temp=61C,bbu=Good,controller=0i 1669343017.1509335
megaraid_array,host=ravenvale,status=Optimal array_id="c0u0",raid_type="RAID-0",size="1818G",stripsz="512KB",flags="ADRA+WB",cache="Enabled",task="None" 1669343017.1812508
megaraid_array,host=ravenvale,status=Optimal array_id="c0u1",raid_type="RAID-0",size="6985G",stripsz="512KB",flags="RA+WB",cache="Default",task="None" 1669343017.1814437
megaraid_array,host=ravenvale,status=Optimal array_id="c0u2",raid_type="RAID-0",size="6985G",stripsz="512KB",flags="ADRA+WB",cache="Default",task="None" 1669343017.1816642
megaraid_array,host=ravenvale,status=Optimal array_id="c0u3",raid_type="RAID-0",size="6985G",stripsz="512KB",flags="ADRA+WB",cache="Default",task="None" 1669343017.1818352
megaraid_array,host=ravenvale,status=Optimal array_id="c0u4",raid_type="RAID-0",size="6985G",stripsz="512KB",flags="ADRA+WB",cache="Default",task="None" 1669343017.182005
megaraid_disk,host=ravenvale,status=Online+SpunUp,serial=S620NG0R303366N,disk_id=c0u0p0 model="SSD 870 EVO 2TB SVT02B6Q",disk_type="SSD",size="1.818TB",speed="6.0Gb/s",temp=30i 1669343017.2012992
megaraid_disk,host=ravenvale,status=Online+SpunUp,serial=HGST,disk_id=c0u1p0 model="",disk_type="SSD",size="6.985TB",speed="12.0Gb/s",temp=49i 1669343017.2013218
megaraid_disk,host=ravenvale,status=Online+SpunUp,serial=HGST,disk_id=c0u2p0 model="",disk_type="SSD",size="6.985TB",speed="12.0Gb/s",temp=37i 1669343017.201328
megaraid_disk,host=ravenvale,status=Online+SpunUp,serial=HGST,disk_id=c0u3p0 model="",disk_type="SSD",size="6.985TB",speed="12.0Gb/s",temp=41i 1669343017.2013319
megaraid_disk,host=ravenvale,status=Online+SpunUp,serial=HGST,disk_id=c0u4p0 model="",disk_type="SSD",size="6.985TB",speed="12.0Gb/s",temp=41i 1669343017.2013361
megaraid_global,host=ravenvale,raid_global=OK raid_ok=5i,raid_bad=0i,disks_ok=5i,disks_bad=0i 1669343017.2076218

@mikee2
Copy link
Author

mikee2 commented Nov 25, 2022

time_ns is new in python 3.7 so it is normal that it failed with your version. You should be able to update.

The issue here is with precision of the samples. If you read python documentation, time.time gives the result in seconds with a millisecond/microsecond precision depending on the system but, by default, influxdb expects samples in the nanosecond range so either you adjust the returned value to match nanoseconds or you will be getting skewed results.

@ElCoyote27
Copy link
Contributor

This makes a lot of sense. I am going to trying backporting your patch into 1.82 (I've been maintaining this on the side as elverde appears to very busy).
https://github.com/ElCoyote27/hwraid/blob/master/wrapper-scripts/megaclisas-status

@ElCoyote27
Copy link
Contributor

How about this?

def pytimeoverride():
    if sys.version_info < (3, 7):
        return time.time()
    else:
        return time.time_ns()

this way, for people still < 3.7, the script would not fail albeit at the drawback that the time data would be inaccurate.

@ElCoyote27
Copy link
Contributor

ElCoyote27 commented Nov 25, 2022

@eLvErDe I updated a PR with the changes from @mikee2 and @netham45, please pull. thank you.
#137

@mikee2 mikee2 closed this Jan 11, 2024
@mikee2 mikee2 reopened this Jan 11, 2024
@mikee2
Copy link
Author

mikee2 commented Jan 11, 2024

How to pull? I am told that there are pending merges...

@mikee2 mikee2 closed this Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants