<commit_before>#!/usr/bin/perl
#
# check_snmp_alive
# Author: <NAME> <<EMAIL>>
#
# Nagios plugin to check SNMP responding
#

use strict;
use warnings;
use Nagios::Plugin;
use SNMP;
use Data::Dumper;

my $n = Nagios::Plugin->new(
    version => '1.00',
    shortname => "check_snmp_alive",
    blurb => "check_snmp_alive checks SNMP alive on host",
    usage => "Usage: %s -H -T",
);

$n->add_arg(
    spec => "hostname|H=s",
    help => "-H, --hostname=HOSTNAME. Hostname of the RAID array"
);

$n->getopts;

my $hostname = $n->opts->hostname;
$n->nagios_die("no hostname specified") unless $hostname;

my $status = OK;

my $sess = SNMP::Session->new( DestHost => $hostname, Version => '2', Timeout => '500000');
my $val = $sess->get('sysDescr.0');
$n->nagios_die("failed to initiate SNMP session") unless $val;

$n->nagios_exit($status, $val);<commit_msg>Call nagios_die as CRITICAL (was UNKNOWN)<commit_after>#!/usr/bin/perl
#
# check_snmp_alive
# Author: <NAME> <<EMAIL>>
#
# Nagios plugin to check SNMP responding
#

use strict;
use warnings;
use Nagios::Plugin;
use SNMP;
use Data::Dumper;

my $n = Nagios::Plugin->new(
    version => '1.00',
    shortname => "check_snmp_alive",
    blurb => "check_snmp_alive checks SNMP alive on host",
    usage => "Usage: %s -H -T",
);

$n->add_arg(
    spec => "hostname|H=s",
    help => "-H, --hostname=HOSTNAME. Hostname of the RAID array"
);

$n->getopts;

my $hostname = $n->opts->hostname;
$n->nagios_die("no hostname specified") unless $hostname;

my $status = OK;

my $sess = SNMP::Session->new( DestHost => $hostname, Version => '2', Timeout => '500000');
my $val = $sess->get('sysDescr.0');
$n->nagios_die("failed to initiate SNMP session", 2) unless $val;

$n->nagios_exit($status, $val);
{'fraction_non_alphanumeric': 0.18760757314974183, 'fraction_numerical': 0.013195639701663799, 'mean_word_length': 4.3993808049535605, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5653005', 'n_tokens_mistral': 692, 'n_tokens_neox': 683, 'n_words': 173}