Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I'm trying to get history #3

Open
SCH48 opened this issue May 29, 2020 · 4 comments
Open

Hi! I'm trying to get history #3

SCH48 opened this issue May 29, 2020 · 4 comments
Labels

Comments

@SCH48
Copy link

SCH48 commented May 29, 2020

Hi! I'm trying to get history

Auth-Zabbix -URL 'http://10.248.10.148/zabbix'

image

$Printer = Get-ZabbixHost -Host 'NPI9233D9'
$Printer | ft hostid, Host, Name

image

$Item = Get-ZabbixItem -id 30441
$Item | ft ItemID, Name, key_

image

Get-ZabbixHistory -history 0 -Hosts $Printer -Items $Item -limit 100

= Empty output :-( But simple code work!

$params.body = @{
        "jsonrpc"= "2.0"
        "method" = "history.get"
        "params"= @{
            "output" = "extend"
            "itemids" = "30441"
            "history" = "0"
            "sortfield" = "clock"
            "sortorder" ="DESC"
            "limit" = 10
         }
        auth = ($result.Content | ConvertFrom-Json).result
        id = 1
        
} | ConvertTo-Json

$result = Invoke-WebRequest @params
$result = Invoke-WebRequest @params
$result.Content #| ConvertFrom-Json

image

Originally posted by @SCH48 in #2 (comment)

@rrg92
Copy link
Owner

rrg92 commented May 29, 2020

Hey @SCH48, thanks your time!

I will analyze this case soon.

@rrg92 rrg92 added the bug label May 29, 2020
@SCH48
Copy link
Author

SCH48 commented Jun 3, 2020

Problem in param "history" = "0" and Zabbix Printer Template collecting data into the database as a "numeric float".
image

History object types to return.
Possible values:
0 - numeric float;
1 - character;
2 - log;
3 - numeric unsigned;
4 - text.
Default: 3.

I change in Template "float" to "unsigned"
image

Testing 2 printers with different templates but same OID "page count" ....

$PrintersInGroups = Get-ZabbixHost -Groups 'Network Printers' -HostStatus 0
$PrintersInGroups| ft hostid, host

image

$OID = "1.3.6.1.2.1.43.10.2.1.4.1.1"
$ItemsOID = Get-ZabbixItem -Hosts $PrintersInGroups | ?{$_.snmp_oid -contains $OID}
$ItemsOID | ft hostid, itemid, snmp_oid, name, lastclock, lastvalue

image

First, testing the correct "itemid=30461"

Get-ZabbixHistory -limit 5 -Items "30461" | ft

image

Default "history" is 3 - "numeric unsigned", All right.

Now check the problem data - "itemid=30441"

Get-ZabbixHistory -limit 5 -Items "30441" | ft

image

Oh, great! But One record?
Check "numeric float" data add "-hystory 0":

Get-ZabbixHistory -limit 5 -Items "30441" -history 0 | ft

image

Nothing changed :-(

Test Simple code:

  1. Without "history"
$params.body = @{
        "jsonrpc"= "2.0"
        "method" = "history.get"
        "params"= @{
            "output" = "extend"
            "itemids" = "30441"
            "sortfield" = "clock"
            "sortorder" ="DESC"
            "limit" = 10
         }
        auth = ($result.Content | ConvertFrom-Json).result
        id = 1
} | ConvertTo-Json
$result = (Invoke-WebRequest @params).Content | ConvertFrom-Json
$result.result | ft

image

Also one record. It's the record I translated in "numeric unsigned". But the rest of the entries remained in the "numeric float". Check

  1. Add "history" = 0
$params.body = @{
        "jsonrpc"= "2.0"
        "method" = "history.get"
        "params"= @{
            "output" = "extend"
            "history" = "0"
            "itemids" = "30441"
            "sortfield" = "clock"
            "sortorder" ="DESC"
            "limit" = 10
         }
        auth = ($result.Content | ConvertFrom-Json).result
        id = 1
} | ConvertTo-Json

image

Yes they exist!!!

I understand that I need to convert all the data to one format.
But Why does not it work Get-ZabbixHistory -history 0 ?

And is it possible to convert data in the "Get-Zabbix History" command without use the "history" parameter? Ore least a number format lead one to another?

Sorry for my English, I'm Russian. Regards, @SCH48

@rrg92
Copy link
Owner

rrg92 commented Sep 14, 2022

Hi @SCH48 , sorry the delay. I will review this soon.

@rrg92
Copy link
Owner

rrg92 commented Sep 25, 2024

Thank you very much for your analysis efforts. Once again, apologies for the years-long delay. I will investigate what you have put together and see if it still makes sense for corrections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants