$ o_warn,
f = gt; $ o_perf, perfparse = gt; $ o_perf,
T: s = gt; $ o_check_type, type: s = gt; $ o_check_type
);
# check the -T option $ T_option_valid=0; (@ valid_types) {if ($ _ eq $ o_check_type) {$ T_option_valid=1}}; ($ T_option_valid == 0)
{print Invalid check type (-T)! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }}
# Basic checks (defined ($ o_timeout) amp; amp; (isnnum ($ o_timeout) || ($ o_timeout lt; 2) || ($ o_timeout gt; 60)))
{print Timeout must be gt; 1 and lt; 60! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} (! defined ($ o_timeout)) {$ o_timeout=5;} (defined ($ o_help)) {help (); exit $ ERRORS { UNKNOWN }}; (defined ($ o_version)) {p_version (); exit $ ERRORS { UNKNOWN }}; (! defined ($ o_host)) # check host and filter
{print_usage (); exit $ ERRORS { UNKNOWN }}
# check snmp information (! defined ($ o_community) amp; amp; (! defined ($ o_login) ||! defined ($ o_passwd)))
{print Put snmp login info! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} ((defined ($ o_login) || defined ($ o_passwd)) amp; amp; (defined ($ o_community) || defined ($ o_version2)))
{print Can not mix snmp v1,2c, 3 protocols! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} (defined ($ v3protocols)) {(! defined ($ o_login)) {print Put snmp V3 login info with protocols! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} @ v3proto=split (/, /, $ v3protocols); ((defined ($ v3proto [0])) amp; amp; ($ v3proto [0] ne ) ) {$ o_authproto=$ v3proto [0]; } # Auth protocol (defined ($ v3proto [1])) {$ o_privproto=$ v3proto [1]; } # Priv protocol ((defined ($ v3proto [1])) amp; amp; (! Defined ($ o_privpass))) { Put snmp V3 priv login info with priv protocols! N raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }}
}
# Check warnings and critical (! defined ($ o_warn) ||! defined ($ o_crit))
{print put warning and critical info! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }}
# Get rid of% sign
$ o_warn=~ s/%//g;
$ o_crit=~ s/%//g;
# Check for multiple warning and crit in case of -L (($ o_check_type eq netsl ) || ($ o_check_type eq cisco ) || ($ o_check_type eq cata raquo ;) ||
($ o_check_type eq nsc ) || ($ o_check_type eq hpux )) {
@ o_warnL=split (/, /, $ o_warn);
@ o_critL=split (/, /, $ o_crit); (($ # o_warnL!=2) || ($ # o_critL!=2))
{print 3 warnings and critical! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} (my $ i=0; $ i lt; 3; $ i ++) {(isnnum ($ o_warnL [$ i]) || isnnum ($ o_critL [$ i]))
{print Numeric value for warning or critical! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} ($ o_warnL [$ i] gt; $ o_critL [$ i])
{print warning lt;=critical! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }}
}
} else {(($ o_warn=~ /, /) || ($ o_crit=~ /, /)) {
{print Multiple warning/critical levels not available for this check n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }}
} (isnnum ($ o_warn) || isnnum ($ o_crit))
{print Numeric value for warning or critical! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} ($ o_warn gt; $ o_crit)
{print warning lt;=critical! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }}
}
}
########## MAIN #######
_ options ();
# Check gobal timeout if snmp screws up (defined ($ TIMEOUT)) {( Alarm at $ TIMEOUT + 5 ); ($ TIMEOUT + 5);
} else {( no global timeout defined: $ o_timeout + 10 ); ($ o_timeout + 10);
}
$ SIG { ALRM }=sub { No answer from host n raquo ;; $ ERRORS { UNKNOWN };
};
# Connect to host ($ session, $ error); (defined ($ o_login) amp; amp; defined ($ o_passwd)) {
# SNMPv3 login ( SNMPv3 login ); (! defined ($ o_privpass)) {( SNMPv3 AuthNoPriv login: $ o_login, $ o_authproto );
($ session, $ error)=Net :: SNMP- gt; session (
hostname= gt; $ o_host,
v...