oneandoneis2 / zabbix-cli-monitor Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Hi,
I've found your module and used it as a little monitoring helper. However, worked with code to adjust it to my specific situation. As a result I've added :
Here is patch file for the changes , if you interested in incorporating them in :
--- original/Monitor.pm 2014-11-07 16:08:43.741732801 +0000
+++ new/Monitor.pm 2014-11-07 16:31:07.591039751 +0000
@@ -17,13 +17,16 @@ $Data::Dumper::Indent = 1;
has zabbix => ( is => 'rw' );
+my @zbx_prio = ("Unclassified","Info","Warning","Average","High","Disaster");
+
sub BUILD {
my ($self) = @_;
unless (
$self->_config_data->{api_url} &&
$self->_config_data->{user} &&
- $self->_config_data->{password}
+ $self->_config_data->{password} &&
+ $self->_config_data->{env_proxy}
) {
say "No valid config file found. Please ensure config file exists and has required fields defined. Example:";
say <<EOF;
@@ -36,9 +39,9 @@ EOF
exit 1;
}
-
my $zabbix = Zabbix::API->new(
server => $self->_config_data->{api_url},
+ env_proxy => $self->_config_data->{env_proxy},
verbosity => 0
);
@@ -63,9 +66,11 @@ sub get_current_triggers {
output => 'extend', # Helpfully(?) you don't get the description by default
monitored => 1, # Helpfully(?) unmonitored hosts are included by default
selectHosts => 1, # Helpfully(?) the trigger's host is not included by default
- filter => { # Filter to triggers that are still happening
- value => 1
- }
+ only_true => 1, # only active triggers ( duplicate of filter functionality ?)
+ sortfield => 'priority', # Sorting triggers by priority
+ sortorder => 'DESC', # sorting in descending order
+ selectItems => 'extend', # extended info on items
+ expandDescription => 1, # expands macros in triggers names (comment out line to disable)
}
);
# Returns the data as a JSON string in _content,
@@ -87,7 +92,7 @@ sub get_host_list {
}
sub say_current_issues {
- my ($self) = @_;
+ my ($self,$batch) = @_;
my $triggers = $self->get_current_triggers();
@@ -107,18 +112,23 @@ sub say_current_issues {
my $host = $hn->{host};
my $name = $hn->{name};
my $desc = $trigger->{description};
+ my $prio = $trigger->{priority};
- $desc =~ s/\{HOST\.NAME\}/$name/; # Parse Zabbixy stuff
-
- print color 'cyan';
- say "$host";
- print color 'red';
- say "\t$desc\n";
- print color 'reset';
+ if ($batch == 0) {
+ print color 'cyan';
+ say "$zbx_prio[$prio]";
+ print color 'red';
+ say "\t$desc\n";
+ print color 'reset';
+ }
+ else
+ {
+ say "$zbx_prio[$prio]"," - ","$desc";
+ }
}
}
-1;
+;
__END__
=encoding utf-8
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.