Mojo::Zabbix is a simple perl wrapper of Zabbix API. we build only authentication and request methods and few helper methods to simplify calling methods such as create/get/update/delete/exists. Mojo::Zabix - 是对zabbix api函数的简å•æ‰“包,以便更易于用perl脚本进行 访问æ“作zabbix。目å‰ä»…支æŒè®¤è¯å’Œè¯·æ±‚方法,å¯ä»¥ç”¨å…¶è¿›è¡Œcreate/get /update/delete/exists方法调用,è§ä¾‹å。本模å—基于Mojo::useragent,结果 å¯ä»¥ç”¨Mojo:DOM进行处ç†å’Œå†…容æå–。 The more details ,please visting the Zabbix API documentation pages . - [Zabbix API Wiki](http://www.zabbix.org/) - [Zabbix 1.8 API](http://www.zabbix.com/documentation/1.8/api) - [Zabbix 2.0 API](http://www.zabbix.com/documentation/2.0/) - [Zabbix 2.2 API](https://www.zabbix.com/documentation/2.2/) - [Zabbix 3.0 API](https://www.zabbix.com/documentation/3.0/) - [Zabbix 3.2 API](https://www.zabbix.com/documentation/3.2/) - [Zabbix 3.4 API](https://www.zabbix.com/documentation/3.4/) ### Test The module is compatible and tested with Zabbix less version 3.0 本模å—ç›®å‰ä»…在3.0以å‰çš„模å—下测试,3.0以上版本ç†è®ºä¸Šåº”该å¯ä»¥ä½¿ç”¨ï¼Œä½†æ˜¯æœªä¸¥æ ¼æµ‹è¯• ### Example use Mojo::Zabbix; my $z = Net::Zabbix->new( url => "https://server/zabbix/", username => 'user', password => 'pass', verify_ssl => 0, debug => 1, trace => 0, ); my $r = $z->get("host", { filter => undef, search => { host => "test", }, } ); #### A example for print the zabbix api version 打å°zabbixæœåŠ¡å™¨ç‰ˆæœ¬. print $z->get("apiinfo.version",)->{result},"\n"; #### A example for get the new warn message of triggerid 打å°æ–°è¦å‘Šè§¦å‘器. print getTriggers($z); sub getTriggers { my $z=shift; my $ysterday=localtime(time()-24*3600); my $r = $z->get("trigger", { filter => {value => 1, lastChangeSince => "$ysterday", 'withUnacknowledgedEvents'=>1, }, output => ["","triggerid","description","priority"], sortfield =>"priority", sortorder => "DESC", expandData=>"host", }, ); my $result; my $host=$r->{'result'}; for (@$host){ $result.="$_->{'host'}:".$_->{'description'}."\n" ; } return $result; } The result all 结果示æ„: xxx.xxx.xx.55: {HOST.CONN}æœåŠ¡å™¨çš„84端å£down xxx.xxx.xx.55: {HOST.CONN}æœåŠ¡å™¨çš„81端å£down xxx.xxx.xx.55: {HOST.CONN}æœåŠ¡å™¨çš„82端å£down xxx.xxx.xx.55.9: {HOST.CONN}æœåŠ¡å™¨çš„80端å£down xxx.xxx.xx.12: {HOST.NAME} æœåŠ¡å™¨è´Ÿè½½è¾ƒé«˜ï¼Œè¯·åŠæ—¶æŸ¥çœ‹ xxx.xxx.xx.124: ç£ç›˜sdb利用率超过95%,当å‰å€¼ä¸º{ITEM.LASTVALUE} xxx.xxx.xx.44: ç£ç›˜sdb利用率超过95%,当å‰å€¼ä¸º{ITEM.LASTVALUE} xxx.xxx.xx.45: ç£ç›˜sdb利用率超过95%,当å‰å€¼ä¸º{ITEM.LASTVALUE} xxx.xxx.xx.33: ç£ç›˜sdb利用率超过95%,当å‰å€¼ä¸º{ITEM.LASTVALUE} xxx.xxx.xx.56: ç£ç›˜sda利用率超过95%,当å‰å€¼ä¸º{ITEM.LASTVALUE} xxx.xxx.xx.57: ç£ç›˜sda利用率超过95%,当å‰å€¼ä¸º{ITEM.LASTVALUE} wo can add the program to crontab and gain the result for mail or some Im tool. 我们å¯ä»¥é€šè¿‡cron定时调用程åºèŽ·å¾—结果,也å¯ä»¥é€šè¿‡IM工具(qq,微信, ç›®å‰æœ‰ä¸ªwebqq(https://github.com/sjdy521/Mojo-Webqq)的æ’件,交互 性获å–监控数æ®ã€‚ 本模å—有个高级函数打包模å—Mojo::Zabbix:APP å¯ä»¥æ›´æ–¹ä¾¿ä½¿ç”¨ï¼Œå»ºè®®å¯ å‚考使用。 ### Git repo [github](https://github.com/bollwarm/Mojo-Zabbix) ### AUTHOR [orange] (linzhe@ijz.me),[blog](http://ijz.me) ### License This software is copyright (c) 2016 by oragnge. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself..