= gt; $ o_privpass, privpass: s = gt; $ o_privpass,
L: s = gt; $ v3protocols, protocols: s = gt; $ v3protocols,
t: i = gt; $ o_timeout, timeout: i = gt; $ o_timeout,
V = gt; $ o_version, version = gt; $ o_version,
I = gt; $ o_cisco, cisco = gt; $ o_cisco,
N = gt; $ o_netsnmp, netsnmp = gt; $ o_netsnmp,
E = gt; $ o_hp, hp = gt; $ o_hp,
2 = gt; $ o_version2, v2c = gt; $ o_version2,
c: s = gt; $ o_crit, critical: s = gt; $ o_crit,
w: s = gt; $ o_warn, warn: s = gt; $ o_warn,
m = gt; $ o_cache, memcache = gt; $ o_cache,
f = gt; $ o_perf, perfdata = gt; $ o_perf
); (defined ($ o_help)) {help (); exit $ ERRORS { UNKNOWN }}; (defined ($ o_version)) {p_version (); exit $ ERRORS { UNKNOWN }}; (! defined ($ o_host)) # check host and filter
{print No host defined! n raquo ;; 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 }}
} (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;}
# Check Warning and crit are present (! defined ($ o_warn) ||! defined ($ o_crit))
{print Put warning and critical values! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }}
# Get rid of% sign
$ o_warn=~ s/%//g;
$ o_crit=~ s/%//g;
# if -N or -E switch, undef $ o_netsnmp (defined ($ o_cisco) || defined ($ o_hp)) {
$ o_netsnmp=undef; (isnnum ($ o_warn) || isnnum ($ o_crit))
{print Numeric value for warning or critical! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} (($ o_crit!=0) amp; amp; ($ o_warn gt; $ o_crit))
{print warning lt;=critical! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }}
} (defined ($ o_netsnmp)) {@ o_warnL=split (/, /, $ o_warn); @ o_critL=split (/, /, $ o_crit); (($ # o_warnL!= 1) || ($ # o_critL!=1))
{print 2 warnings and critical! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} (my $ i=0; $ i lt; 2; $ i ++) {(isnnum ($ o_warnL [$ i]) || isnnum ($ o_critL [$ i]))
{print Numeric value for warning or critical! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} (($ o_critL [$ i]!=0) amp; amp; ($ o_warnL [$ i] gt; $ o_critL [$ i]))
{print warning lt;=critical! n raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }} ($ o_critL [$ i] gt; 100)
{print critical percent must be lt; 100! N raquo ;; print_usage (); exit $ ERRORS { UNKNOWN }}
}
$ o_warnR=$ o_warnL [0]; $ o_warnS=$ o_warnL [1];
$ o_critR=$ o_critL [0]; $ o_critS=$ o_critL [1];
}
}
########## MAIN #######
_ options ();
# Check gobal timeout if snmp screws up (defined ($ TIMEOUT)) {( Alarmat $ TIMEOUT ); ($ TIMEOUT);
} else {( no timeout defined: $ o_timeout + 10 ); ($ o_timeout + 10);
}
# Connect to host ($ session...