@Eyal_Roth @Hawkeye_Parker I want to revive this thread as I am running into the exact same issue.
I am writing a script to parse a date time string into epoch time.
The script:
#! META
name: cas-show-ssl
description: Show list of certificates on the management (VPN, SIC etc) in MDS
type: monitoring
monitoring_interval: 59 minutes
requires:
vendor: "symantec"
os.name: “cas”
#! COMMENTS
certificate-expiration:
skip-documentation: true
#! REMOTE::SSH
show ssl | display json | exclude contents | nomore
#! PARSER::JSON
Example input shown below. The timezone is always on UTC.
“valid-until”: “2037-12-01T11:59:59-00:00”
_metrics:
-
_groups:
$.data.ssl:ssl.ca-certificates[0:]:
_tags:
"live-config":
_constant: "true"
"display-name":
_constant: "Certificate Expiration"
"im.identity-tags":
_constant: "name"
"[im.name](http://im.name/)":
_constant: "certificate-expiration"
"im.dstype.displaytype":
_constant: "date"
"name":
_value: "id"
_temp:
"expiration":
_value: "valid-until"
_transform:
_value.double: |
{
datestring = temp("expiration")
gsub(/-|T|:/, " ", datestring)
split(datestring, dateArray, / /)
month = dateArray[2]
day = dateArray[3]
year = dateArray[1]
hour = dateArray[4]
minute = dateArray[5]
second = dateArray[6]
secondsSinceEpoch = datetime(year, month, day, hour, minute, second)
print secondsSinceEpoch
}
partial input:
{
"id": "VRSN_Class_4_Pub_G3",
"subject": "\n/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 1999 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 4 Public Primary Certification Authority - G3\n ",
"issuer": "\n/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 1999 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 4 Public Primary Certification Authority - G3\n ",
"valid-from": "1999-10-01T12:00:00-00:00",
“valid-until”: “2036-07-16T11:59:59-00:00”,
"fingerprint": "\nC8:EC:8C:87:92:69:CB:4B:AB:39:E9:8D:7E:57:67:F3:14:95:73:9D\n ",
"contents": "content"
},
partial output:
{
"type": "ts",
"tags": {
"name": "VRSN_Class_4_Pub_G3",
"im.identity-tags": "name",
"im.dstype.displaytype": "date",
"im.name": "certificate-expiration",
"live-config": "true",
"display-name": "Certificate Expiration"
},
“value”: 2099858399,
"timestamp": 1541299584595
},
My computer is on Honolulu timezone which is UTC-10
test.json:
{
“nameToCase”: {
"multiple-entries-utc-timezone": {
"timezoneId": "Pacific/Honolulu",
"inputPath": "multiple-entries-utc-timezone/input.json",
"outputPath": "multiple-entries-utc-timezone/output.json"
}
}
}
The Question:
The documentation for datetime function says it should return the date as epoch, https://indeni.atlassian.net/wiki/spaces/IKP/pages/54198317/AWK+Helper+Functions#AWKHelperFunctions-Datemanipulationfunctions.
If the datetime function is translating the date string with the timezone of the computer it’s running on, then the output makes sense but then the script becomes timezone sensitive to where the script is running. If this is the case, it would be really bad if Indeni server is on non UTC time zone, because all date time related metric would be incorrect. The question is “is this expected behavior?” and “If so, can Indeni server be on non UTC timezone?”
Thanks