Git Product home page Git Product logo

zabbix-cli-monitor's People

Watchers

 avatar  avatar  avatar

zabbix-cli-monitor's Issues

Batch mode, severity and macro expansion

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 :

  1. Batch mode - no colors and condensed output
  2. Severity - triggers now have severity displayed in front of them.
  3. Macro expansion - Zabbix expands macro itself, getting rid of the regexp substitute at the end.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.