PowerShell and Zabbix API

Getting a data element from the ZPI Zabbix. One of the output parameters is “lastclock”.

If I understand correctly, this parameter is responsible for the time of the last check. If not, please explain what this parameter is for?

And the second question is: How do I convert the value of this parameter to a time format?

And where i can get describe about all parameters below?

Code and Output below:

$GetValue = @{
    "jsonrpc"= "2.0";
    "method"= "item.get";
    "params"= @{
        "output"= "extend";
        "selectMappings" = "extend";
        "hostids" = "11130"
        "search" = @{
            "name" = "Interface Vlan25(): Operational status"
        }
    }
    "id"= 2;
    "auth" = $token
}
$HostValue = Invoke-RestMethod -Method 'Post' -Uri "http://$ZabbixIP/zabbix/api_jsonrpc.php" -Body ($GetValue | ConvertTo-Json) -ContentType "application/json"

Output:

itemid           : 161511
type             : 20
snmp_oid         : 1.3.6.1.2.1.2.2.1.8.11025
hostid           : 11130
name             : Interface Vlan25(): Operational status
key_             : net.if.status[ifOperStatus.11025]
delay            : 30
history          : 7d
trends           : 365d
status           : 0
value_type       : 3
trapper_hosts    : 
units            : 
formula          : 
logtimefmt       : 
templateid       : 0
valuemapid       : 1035
params           : 
ipmi_sensor      : 
authtype         : 0
username         : 
password         : 
publickey        : 
privatekey       : 
flags            : 4
interfaceid      : 583
description      : 
inventory_link   : 0
lifetime         : 30d
evaltype         : 0
jmx_endpoint     : 
master_itemid    : 0
timeout          : 3s
url              : 
query_fields     : {}
posts            : 
status_codes     : 200
follow_redirects : 1
post_type        : 0
http_proxy       : 
headers          : {}
retrieve_mode    : 0
request_method   : 0
output_format    : 0
ssl_cert_file    : 
ssl_key_file     : 
ssl_key_password : 
verify_peer      : 0
verify_host      : 0
allow_traps      : 0
uuid             : 
state            : 0
error            : 
parameters       : {}
lastclock        : 1724923393
lastns           : 412969585
lastvalue        : 1
prevvalue        : 1

If I understand correctly, this parameter is responsible for the time of the last check.

Yes; the docs state re lastclock, which is of type timestamp (see below):

Time when the item value was last updated.

By default, only values that fall within the last 24 hours are displayed. You can extend this time period by changing the value of Max history display period parameter in the Administration → General menu section.

Complementarily, lastns (whose type is integer) provides additional accuracy:

Nanoseconds when the item value was last updated.

Data type timestamp in the context of the ZABBIX API means that a point in time is expressed in Unix time, i.e. “by the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1st January 1970, the Unix epoch” – that is, the granularity of this time stamp is whole seconds.

You can translate such a value into a .NET [datetimeoffset] / [datetime] instance as follows:

$dto = 
  [datetimeoffset]::FromUnixTimeSecond($HostValue.lastclock)

# Use $dto.LocalDateTime / $dto.UtcDateTime to get a local / UTC
# timestamp of type [datetime].

If you need the added accuracy provided by the lastns value:

$dto = 
  [datetimeoffset]::FromUnixTimeSecond($HostValue.lastclock) + 
  $HostValue.lastns / 100

Note: [datetimeoffset] and [datetime] instances have a granularity of so-called ticks, which are 100-nanosecond units; thus, the nanonsecond value stored in .lastns is divided by 100 above, which means there’s a slight loss of accuracy.

To get a local / UTC [datetime] instance from the above, use $dto.LocalTime / $dto.UtcDateTime.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật