Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env ruby
- require 'zabbixapi'
- require 'yaml'
- require 'socket'
- require 'time'
- # ZABBIX CONFIGURATION
- config = YAML.load(File.read('/etc/zabbix/scripts/.zabbix/config.yml'))
- zabbix_url = config['URL']
- zabbix_id = config['USER']
- zabbix_passwd = config['PASSWORD']
- # ZABBIX AUTHENTICATION
- zbx = ZabbixApi.connect(
- url: zabbix_url,
- user: zabbix_id,
- password: zabbix_passwd
- )
- # Create time_from and time_till
- now = Time.now.strftime('%Y/%m/%d %H:%M:%S')
- before = (Time.now - 180).strftime('%Y/%m/%d %H:%M:%S')
- till = Time.parse(now)
- from = Time.parse(before)
- hostname = Socket.gethostname
- zbx.query(
- method: 'item.get',
- params: {
- filter: {
- host: hostname
- },
- itemids: '23663'
- }
- )
- trends = zbx.query(
- method: 'history.get',
- params: {
- itemids: item_id,
- time_from: from,
- time_till: till,
- output: 'extend'
- }
- )
- p trends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement