, $ error); (defined ($ o_login) amp; amp; defined ($ o_passwd)) {
# SNMPv3 login (! defined ($ o_privpass)) {( SNMPv3 AuthNoPriv login: $ o_login, $ o_authproto );
($ session, $ error)=Net :: SNMP- gt; session (
hostname= gt; $ o_host,
version= gt; 3 ,
username= gt; $ o_login,
authpassword= gt; $ o_passwd,
authprotocol= gt; $ o_authproto,
timeout= gt; $ o_timeout
);
} else {( SNMPv3 AuthPriv login: $ o_login, $ o_authproto, $ o_privproto );
($ session, $ error)=Net :: SNMP- gt; session (
hostname= gt; $ o_host,
version= gt; 3 ,
username= gt; $ o_login,
authpassword= gt; $ o_passwd,
authprotocol= gt; $ o_authproto,
privpassword= gt; $ o_privpass,
privprotocol= gt; $ o_privproto,
timeout= gt; $ o_timeout
);
}
} else {(defined ($ o_version2)) {
# SNMPv2 Login ( SNMP v2c login );
($ session, $ error)=Net :: SNMP- gt; session (
hostname= gt; $ o_host,
version= gt; 2,
community= gt; $ o_community,
port= gt; $ o_port,
timeout= gt; $ o_timeout
);
} else {
# SNMPV1 login ( SNMP v1 login );
($ session, $ error)=Net :: SNMP- gt; session (
hostname= gt; $ o_host,
community= gt; $ o_community,
port= gt; $ o_port,
timeout= gt; $ o_timeout
);
}
} (! defined ($ session)) {( ERROR opening session:% s. n raquo ;, $ error); $ ERRORS { UNKNOWN };
}
# Global variable $ resultat=undef;
########### Cisco memory check ############ (defined ($ o_cisco)) {
# Get Cisco memory table
$ resultat=(Net :: SNMP- gt; VERSION lt; 4)?
$ session- gt; get_table ($ cisco_mem_pool)
: $ session- gt; get_table (Baseoid= gt; $ cisco_mem_pool);
(! defined ($ resultat)) {( ERROR: Description table:% s. n raquo ;, $ session- gt; error);
$ session- gt; close; $ ERRORS { UNKNOWN };
} (@ oid, @ index)=(undef, undef); $ nindex=0; my $ key (keys% $ resultat) {( OID: $ key, Desc: $$ resultat {$ key} ); ($ key=~/$ cisco_index /) {
@ oid=split (/./,$ key);
$ index [$ nindex ++]=pop (oid);
}
}
# Check if at least 1 memory pool exists ($ nindex == 0) {( ERROR: No memory pools found );
$ session- gt; close; $ ERRORS { UNKNOWN };
}
# Test every memory pool ($ c_output, $ prct_free)=(undef, undef); ($ warn_s, $ crit_s)=(0,0); ($ used, $ free)=( 0,0); (@ index) {
$ c_output.=, if defined ($ c_output); ($$ resultat {$ cisco_valid. . . $ _} == 1) {
$ used +=$$ resultat {$ cisco_used. . . $ _};
$ free +=$$ resultat {$ cisco_free. . . $ _};
$ prct_free=round ($$ resultat {$ cisco_used. . . $ _} * 100/($$ resultat {$ cisco_free. . . $ _} + $$ resultat {$ cisco_used. . . $ _}), 0);
$ c_output.=$$ resultat {$ cisco_index. . . $ _}. : . $ prct_free. % raquo ;; (($ o_crit!=0) amp; amp; ($ o_crit lt;=$ prct_free)) {
$ crit_s=1;
} elsif (($ o_warn!=0) amp; amp; ($ o_warn lt;=$ prct_free)) {
$ warn_s=1;
}
} else {
$ c_output.=$$ resultat {$ cisco_index. . . $ _}. laquo ;: INVALID raquo ;;
$ crit_s=1;
}
} $ total=$ used + $ free;
$ prct_free=round ($ used * 100/($ total), 0); ( Total used: $ used, free: $ free, output: $ c_output ); $ c_status= OK raquo ;;
$ c_output.=: Raquo;. $ prct_free. %: raquo ;; ($ crit_s ...