ready for release
This commit is contained in:
parent
c296cbe82b
commit
263961e302
2
MANIFEST
2
MANIFEST
|
@ -7,3 +7,5 @@ t/00-load.t
|
|||
t/manifest.t
|
||||
t/pod-coverage.t
|
||||
t/pod.t
|
||||
bin/boop_snoot
|
||||
README.md
|
4
README
4
README
|
@ -1,6 +1,8 @@
|
|||
Monitoring-Sneck-Boop_Snoot
|
||||
|
||||
|
||||
This his basically a wrapper for smpget and nicely formatting
|
||||
the returned output. Also saves one the headache of having to
|
||||
remember the OID or have it handy.
|
||||
|
||||
INSTALLATION
|
||||
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
# Monitoring-Sneck-Boop_Snoot
|
||||
|
||||
This his basically a wrapper for smpget and nicely formatting
|
||||
the returned output. Also saves one the headache of having to
|
||||
remember the OID or have it handy.
|
||||
|
||||
## FLAGS
|
||||
|
||||
```
|
||||
boop_snoot <args> <host>
|
||||
|
||||
-p Do not pretty print.
|
||||
|
||||
-s Do not Sort the keys.
|
||||
|
||||
-d Print all of it and not just .data
|
||||
|
||||
-v <version > Version to use. 1, 2c, or 3
|
||||
Default: 2c
|
||||
|
||||
SNMP Version 1 or 2c specific
|
||||
-c <community> SNMP community stream.
|
||||
Default: public
|
||||
|
||||
SNMP Version 3
|
||||
-a <value> Set authentication protocol (MD5|SHA|SHA-224|SHA-256|SHA-384|SHA-512)
|
||||
-A <value> Set authentication protocol pass phrase
|
||||
-e <value> Set security engine ID (e.g. 800000020109840301)
|
||||
-E <value> Set context engine ID (e.g. 800000020109840301)
|
||||
-l <value> Set security level (noAuthNoPriv|authNoPriv|authPriv)
|
||||
-n <value> Set context name (e.g. bridge1)
|
||||
-u <value> Set security name (e.g. bert)
|
||||
-x <value> Set privacy protocol (DES|AES)
|
||||
-X <value> Set privacy protocol pass phrase
|
||||
-Z <value> Set destination engine boots/time
|
||||
|
||||
-h Print help info.
|
||||
--help Print help info.
|
||||
--version Print version info.
|
||||
```
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
```
|
||||
> boop_snoot nibbles1
|
||||
{
|
||||
"alert" : 0,
|
||||
"alertString" : "",
|
||||
"checks" : {
|
||||
"geom_nibbles1" : {
|
||||
"check" : "/usr/local/libexec/nagios/check_geom mirror nibbles1",
|
||||
"exit" : 0,
|
||||
"output" : "OK mirror/nibbles1 COMPLETE { da0 (ACTIVE) , da1 (ACTIVE) }|geom_mirror=2;;;0;",
|
||||
"ran" : "/usr/local/libexec/nagios/check_geom mirror nibbles1"
|
||||
},
|
||||
"zfs_src" : {
|
||||
"check" : "/usr/local/libexec/nagios/check_zpools -p src",
|
||||
"exit" : 0,
|
||||
"output" : "ALL ZFS POOLS OK (src)|src=15%",
|
||||
"ran" : "/usr/local/libexec/nagios/check_zpools -p src"
|
||||
},
|
||||
"zfs_storage" : {
|
||||
"check" : "/usr/local/libexec/nagios/check_zpools -p storage",
|
||||
"exit" : 0,
|
||||
"output" : "ALL ZFS POOLS OK (storage)|storage=18%",
|
||||
"ran" : "/usr/local/libexec/nagios/check_zpools -p storage"
|
||||
}
|
||||
},
|
||||
"critical" : 0,
|
||||
"errored" : 0,
|
||||
"hostname" : "nibbles1",
|
||||
"ok" : 3,
|
||||
"time" : 1651728300,
|
||||
"unknown" : 0,
|
||||
"vars" : {
|
||||
"PATH" : "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
|
||||
},
|
||||
"warning" : 0
|
||||
}
|
||||
```
|
108
bin/boop_snoot
108
bin/boop_snoot
|
@ -1,5 +1,91 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
=head1 NAME
|
||||
|
||||
boop_snoot - fetches the results of sneck extend via SNMP.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
boop_snoot [B<-v> 1] [B<-c> <community>] [B<-p>] [B<-s>] [B<-d>]] <host>
|
||||
|
||||
boop_snoot [B<-v> 2c] [B<-c> <community>] [B<-p>] [B<-s>] [B<-d>]] <host>
|
||||
|
||||
boop_snoot [B<-v> 3] [B<-a> <value>] [B<-A> <value>] [B<-e> <value>] [B<-E> <value>] [B<-l> <value>] [B<-n> <value>] [B<-u> <value>] [B<-x> <value>] [B<-X> <value>] [B<-Z> <value>] [B<-p>] [B<-s>] [B<-d>]] <host>
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This his basically a wrapper for smpget and nicely formatting
|
||||
the returned output.
|
||||
|
||||
=head1 GENERAL FLAGS
|
||||
|
||||
=head2 -p
|
||||
|
||||
Do not pretty print the return. Just prints the raw return,
|
||||
provided -s and -d is given.
|
||||
|
||||
=head2 -s
|
||||
|
||||
Do not sort the JSON keys.
|
||||
|
||||
=head2 -d
|
||||
|
||||
Only print the data hash in the JSON.
|
||||
|
||||
=head1 SNMP 1/2c FLAGS
|
||||
|
||||
=head2 -v <version>
|
||||
|
||||
SNMP version to use, 1, 2c, or 3. Defaults to 2c.
|
||||
|
||||
=head2 -c <community>
|
||||
|
||||
SNMP community to use for 2c or 3.
|
||||
|
||||
=head1 SNMP 3 FLAGS
|
||||
|
||||
=head2 -a <value>
|
||||
|
||||
Set authentication protocol (MD5|SHA|SHA-224|SHA-256|SHA-384|SHA-512)
|
||||
|
||||
=head2 -A <value>
|
||||
|
||||
Set authentication protocol pass phrase
|
||||
|
||||
=head2 -e <value>
|
||||
|
||||
Set security engine ID (e.g. 800000020109840301)
|
||||
|
||||
=head2 -E <value>
|
||||
|
||||
Set context engine ID (e.g. 800000020109840301)
|
||||
|
||||
=head2 -l <value>
|
||||
|
||||
Set security level (noAuthNoPriv|authNoPriv|authPriv)
|
||||
|
||||
=head2 -n <value>
|
||||
|
||||
Set context name (e.g. bridge1)
|
||||
|
||||
=head2 -u <value>
|
||||
|
||||
Set security name (e.g. bert)
|
||||
|
||||
=head2 -x <value>
|
||||
|
||||
Set privacy protocol (DES|AES)
|
||||
|
||||
=head2 -X <value>
|
||||
|
||||
Set privacy protocol pass phrase
|
||||
|
||||
=head2 -Z <value>
|
||||
|
||||
Set destination engine boots/time
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
|
@ -11,7 +97,7 @@ sub prog_version {
|
|||
}
|
||||
|
||||
sub help {
|
||||
&proc_version;
|
||||
&prog_version;
|
||||
|
||||
print '
|
||||
|
||||
|
@ -85,8 +171,8 @@ GetOptions(
|
|||
'X=s' => \$X,
|
||||
'Z=s' => \$Z,
|
||||
's' => \$sort,
|
||||
'p' => \$pretty,
|
||||
'd'=>\$data,
|
||||
'p' => \$pretty,
|
||||
'd' => \$data,
|
||||
);
|
||||
|
||||
# print version or help if requested
|
||||
|
@ -126,8 +212,8 @@ my $sneck_snoot_booper = Monitoring::Sneck::Boop_Snoot->new(
|
|||
my $raw_json = $sneck_snoot_booper->boop_the_snoot( $ARGV[0] );
|
||||
|
||||
# was told to raw print it, so just print and exit
|
||||
if ($sort && $pretty) {
|
||||
print $raw_json."\n";
|
||||
if ( $sort && $pretty ) {
|
||||
print $raw_json. "\n";
|
||||
}
|
||||
|
||||
my $json;
|
||||
|
@ -136,20 +222,20 @@ if ($@) {
|
|||
die( 'Failed to decode the returned JSON.... ' . $raw_json . ' ... ' . $@ );
|
||||
}
|
||||
|
||||
my $new_json=JSON->new->utf8;
|
||||
my $new_json = JSON->new->utf8;
|
||||
|
||||
if (!$data) {
|
||||
if (!defined($json->{data})) {
|
||||
if ( !$data ) {
|
||||
if ( !defined( $json->{data} ) ) {
|
||||
die( 'The returned JSON lacks a $json->{data} section.... ' . $raw_json );
|
||||
}
|
||||
$json=$json->{data};
|
||||
$json = $json->{data};
|
||||
}
|
||||
|
||||
if (!$pretty) {
|
||||
if ( !$pretty ) {
|
||||
$new_json->pretty(1);
|
||||
}
|
||||
|
||||
if (!$sort) {
|
||||
if ( !$sort ) {
|
||||
$new_json->canonical(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ our $VERSION = '0.0.1';
|
|||
});
|
||||
|
||||
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 new
|
||||
|
@ -86,7 +85,13 @@ sub new {
|
|||
|
||||
=head2 boop_the_snoot
|
||||
|
||||
Fetches the data for the host and returns it.
|
||||
|
||||
One option is taken and that is the hostname to poll.
|
||||
|
||||
This will die on snmpget failure.
|
||||
|
||||
my $raw_json=$$sneck_snoot_booper->boop_the_snoot($host);
|
||||
|
||||
=cut
|
||||
|
||||
|
|
Loading…
Reference in New Issue