willixix / naglio-plugins Goto Github PK
View Code? Open in Web Editor NEWMonitoring Plugins by William Leibzon
Home Page: http://william.leibzon.org/nagios/
Monitoring Plugins by William Leibzon
Home Page: http://william.leibzon.org/nagios/
I'm monitoring a redis server with 5 different db's. They've each got different ranges for the number of keys that would be considered normal for that db.
I'd like to be able to monitor the number of keys in each db separately. It looks like redis returns this data via INFO, and it's captured in the plugin while calculating the total_keys amount.
Any chance the plugin could be altered to support checking the number of keys used in a single database?
Running check_files.pl with the -a (age) option and specifying ~ as warning value, the check always returns WARNING if there's no file exceeding the CRITICAL age:
$ ./check_files.pl -D /mnt/myfolder/ -F "*.mxf" -a ~,300 -c 20 -f -T files
WARNING - testfile.mxf is 6 (more than ) seconds old | '*.mxf'=1;;20 age_oldest=6s;;300 age_newest=6s
I'd like to be able to monitor per-slab settings using 'stats slabs' and 'stats items', both across all slabs and with stricter thresholds for particular slabs that I care about. For instance, alert if any slab has outofmemory != 0 in stats items, and alert if slab 5 has an evicted_time below 86,400.
Unfortunately, this doesn't work out-of-the-box, since the variable names from memcached cause a perl syntax error.
check_memcached.pl -s misc,slabs
Can't use string ("STAT 1:chunk_size 96
STAT 1:chu") as a HASH ref while "strict refs" in use at check_memcached.pl line 797.
If I do something like:
check_files.pl -D /home/user/directory -F *.txt -l -c 1 -v
...and there are no files matching *.txt
in /home/user/directory
, I get the following error:
Translated filespec '*.txt' to regex '.*\.txt'
Only critical value check is specified - setting warning to ~
check_files.pl plugin version 0.417
Alarm at 30
Changed to directory '/home/user/directory/'
Command: LANG=C ls -l
Executing LANG=C ls -l *.txt 2>&1
got line: ls: cannot access *.txt: No such file or directory
parsed: type=unset
UNKNOWN ERROR - execution of LANG=C ls -l *.txt resulted in an error 512 -
I'm using -l
because I have a lot of files in the directory, and the Nagios check is timing out if I leave it off. I could increase the timeout, but adding the -l
seems to be the better solution.
I'll have a go at patching it, but can't make any promises it'll be a good patch. :-)
If the file count of the checked directory is zero the following error under nagios embedded perl appears:
**ePN /usr/lib/nagios/plugins/check_files.pl: "Use of uninitialized value $oldest_filetime in concatenation (.) or string at (eval 4) line 755,".
Using normal perl interpreter it works without problems.
nagios core (3.x) - 3.5.0-79.1.x86_64 (2013-06-28)
define service{
use local-service
hostgroup_name elma-server
servicegroups elma-services
service_description Syslog Queue
check_command check_local_files!'Syslog Queue /var/spool/rsyslog'!/var/spool/rsyslog!'dbq.*'!10!100
}
define command{
command_name check_local_files
command_line
}
Hello! :)
ii libredis-perl 2:1.9510-2 all persistent key-value database with network interface (Perl client library)
ii redis-server 2:2.6.15-1 amd64 Persistent key-value database with network interface
./check_redis.pl -H localhost -m88,90 -M2048M -v
Processing memory utilization thresholds: 88,90
check_redis.pl plugin version 0.73
Alarm at 15
connecting to localhost:6379
[SEND] PING $VAR1 = [];
[SEND RAW] *1
$4
PING
[RECV RAW] '+PONG' at /usr/share/perl5/Redis.pm line 522, chunk 1.
[RECV] PING $VAR1 = 'PONG';
$VAR2 = undef;
[SEND] INFO $VAR1 = [];
[SEND RAW] *1
$4
INFO
[RECV RAW] '$1660' at /usr/share/perl5/Redis.pm line 522, chunk 2.
[RECV RAW] '# Server
redis_version:2.6.15
redis_git_sha1:00000000
redis_git_dirty:0
redis_mode:standalone
os:Linux 3.2.0-4-amd64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.7.2
process_id:31623
run_id:8a72e1fb0f2337acaac81cf21eb560931e9f72c3
tcp_port:6379
uptime_in_seconds:1346
uptime_in_days:0
hz:10
lru_clock:1405428
connected_clients:2
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
used_memory:1625944
used_memory_human:1.55M
used_memory_rss:3092480
used_memory_peak:1703840
used_memory_peak_human:1.62M
used_memory_lua:31744
mem_fragmentation_ratio:1.90
mem_allocator:jemalloc-3.0.0
loading:0
rdb_changes_since_last_save:1141
rdb_bgsave_in_progress:0
rdb_last_save_time:1377201742
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
total_connections_received:63
total_commands_processed:2018
instantaneous_ops_per_sec:0
rejected_connections:0
expired_keys:0
evicted_keys:0
keyspace_hits:493
keyspace_misses:166
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
role:slave
master_host:192.168.1.62
master_port:6379
master_link_status:up
master_last_io_seconds_ago:8
master_sync_in_progress:0
slave_priority:100
slave_read_only:1
connected_slaves:0
used_cpu_sys:0.60
used_cpu_user:0.08
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
db0:keys=329,expires=329,avg_ttl=0
' at /usr/share/perl5/Redis.pm line 545, chunk 2.
[RECV] INFO $VAR1 = '# Server
redis_version:2.6.15
redis_git_sha1:00000000
redis_git_dirty:0
redis_mode:standalone
os:Linux 3.2.0-4-amd64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.7.2
process_id:31623
run_id:8a72e1fb0f2337acaac81cf21eb560931e9f72c3
tcp_port:6379
uptime_in_seconds:1346
uptime_in_days:0
hz:10
lru_clock:1405428
connected_clients:2
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
used_memory:1625944
used_memory_human:1.55M
used_memory_rss:3092480
used_memory_peak:1703840
used_memory_peak_human:1.62M
used_memory_lua:31744
mem_fragmentation_ratio:1.90
mem_allocator:jemalloc-3.0.0
loading:0
rdb_changes_since_last_save:1141
rdb_bgsave_in_progress:0
rdb_last_save_time:1377201742
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
total_connections_received:63
total_commands_processed:2018
instantaneous_ops_per_sec:0
rejected_connections:0
expired_keys:0
evicted_keys:0
keyspace_hits:493
keyspace_misses:166
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
role:slave
master_host:192.168.1.62
master_port:6379
master_link_status:up
master_last_io_seconds_ago:8
master_sync_in_progress:0
slave_priority:100
slave_read_only:1
connected_slaves:0
used_cpu_sys:0.60
used_cpu_user:0.08
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
db0:keys=329,expires=329,avg_ttl=0
';
$VAR2 = undef;
[SEND] QUIT $VAR1 = [];
[SEND RAW] *1
$4
QUIT
Stats Line: slave_priority = 100
Stats Line: 63 = total_commands_processed
Stats Line: Linux 3.2.0-4-amd64 x86_64 = arch_bits
Stats Line: 1346 = uptime_in_days
Stats Line: 1.90 = mem_allocator
Stats Line: 1703840 = used_memory_peak_human
Stats Line: 166 = pubsub_channels
Stats Line: 8a72e1fb0f2337acaac81cf21eb560931e9f72c3 = tcp_port
Stats Line: master_link_status = up
Stats Line: 1.55M = used_memory_rss
Stats Line: loading = 0
Stats Line: 1625944 = used_memory_human
Stats Line: # Stats = total_connections_received
Stats Line: rdb_last_bgsave_time_sec = -1
Stats Line: connected_clients = 2
Stats Line: 0.60 = used_cpu_user
Stats Line: 31744 = mem_fragmentation_ratio
Stats Line: 1405428 = # Clients
Stats Line: rdb_last_bgsave_status = ok
Stats Line: master_host = 192.168.1.62
Stats Line: 1.62M = used_memory_lua
Stats Line: client_biggest_input_buf = 0
Stats Line: aof_rewrite_scheduled = 0
Stats Line: master_last_io_seconds_ago = 8
Stats Line: rdb_last_save_time = 1377201742
Stats Line: standalone = os
Stats Line: 10 = lru_clock
Stats Line: role = slave
Stats Line: rdb_changes_since_last_save = 1141
Stats Line: db0 = keys=329,expires=329,avg_ttl=0
elsif ($uptime_output =~ /up\s+(d+)s+days?,s+(d+)s+min/) {
should be
elsif ($uptime_output =~ /up\s+(\d+)\s+days?,\s+(\d+)\s+min/) {
to match : 11:39:53 up 204 days, 21 min, 1 user, load average: 0.15, 0.15, 0.10
Without --nagios_with_savedata:
eth0:UP (1 UP): OK | 'eth0_in_octet'=3332824843c 'eth0_out_octet'=285853005c 'eth0_in_error'=0 'eth0_out_error'=0 'eth0_in_discard'=0 'eth0_out_discard'=0 cache_descr_ids=2 cache_descr_names=eth0 cache_descr_time=1383821720 ptime=1383822815
With --nagios_with_savedata:
eth0:UP (1 UP): OK | 'eth0_in_error'=0 'eth0_out_error'=0 'eth0_in_discard'=0 'eth0_out_discard'=0 || cache_descr_ids=2 cache_descr_names=eth0 cache_descr_time=1383821720 'eth0_in_octet'=3329426741 'eth0_out_octet'=285420176 ptime=1383822312
Checking if an if is up results in the warning "Use of uninitialized value within @oid_perf_inoct" on a Cisco 3750.
As requested on the check_netint.pl plugin page at exchange.nagios.org in a comment, here's the output from the latest version from the dev branch with the -v option:
$ ./check_netint-2.4b5.pl -H 10.1.1.1 -C public --name=GigabitEthernet1/0/10 -v
Alarm at 15 + 5
Filter : GigabitEthernet1/0/10
SNMP v1 login
Doing snmp get_table request on Interfaces Description Table OID: 1.3.6.1.2.1.2.2.1.2
OID: 1.3.6.1.2.1.2.2.1.2.26 Clean Desc: 'Vlan26' Raw Desc: Vlan26
OID: 1.3.6.1.2.1.2.2.1.2.10123 Clean Desc: 'GigabitEthernet1/0/23' Raw Desc: GigabitEthernet1/0/23
OID: 1.3.6.1.2.1.2.2.1.2.10108 Clean Desc: 'GigabitEthernet1/0/8' Raw Desc: GigabitEthernet1/0/8
OID: 1.3.6.1.2.1.2.2.1.2.28 Clean Desc: 'Vlan28' Raw Desc: Vlan28
OID: 1.3.6.1.2.1.2.2.1.2.10126 Clean Desc: 'GigabitEthernet1/0/26' Raw Desc: GigabitEthernet1/0/26
OID: 1.3.6.1.2.1.2.2.1.2.5003 Clean Desc: 'Port-channel3' Raw Desc: Port-channel3
OID: 1.3.6.1.2.1.2.2.1.2.5179 Clean Desc: 'StackPort1' Raw Desc: StackPort1
OID: 1.3.6.1.2.1.2.2.1.2.5004 Clean Desc: 'Port-channel4' Raw Desc: Port-channel4
OID: 1.3.6.1.2.1.2.2.1.2.5001 Clean Desc: 'Port-channel1' Raw Desc: Port-channel1
OID: 1.3.6.1.2.1.2.2.1.2.10117 Clean Desc: 'GigabitEthernet1/0/17' Raw Desc: GigabitEthernet1/0/17
OID: 1.3.6.1.2.1.2.2.1.2.22 Clean Desc: 'Vlan22' Raw Desc: Vlan22
OID: 1.3.6.1.2.1.2.2.1.2.10127 Clean Desc: 'GigabitEthernet1/0/27' Raw Desc: GigabitEthernet1/0/27
OID: 1.3.6.1.2.1.2.2.1.2.23 Clean Desc: 'Vlan23' Raw Desc: Vlan23
OID: 1.3.6.1.2.1.2.2.1.2.10107 Clean Desc: 'GigabitEthernet1/0/7' Raw Desc: GigabitEthernet1/0/7
OID: 1.3.6.1.2.1.2.2.1.2.10104 Clean Desc: 'GigabitEthernet1/0/4' Raw Desc: GigabitEthernet1/0/4
OID: 1.3.6.1.2.1.2.2.1.2.10119 Clean Desc: 'GigabitEthernet1/0/19' Raw Desc: GigabitEthernet1/0/19
OID: 1.3.6.1.2.1.2.2.1.2.10113 Clean Desc: 'GigabitEthernet1/0/13' Raw Desc: GigabitEthernet1/0/13
OID: 1.3.6.1.2.1.2.2.1.2.30 Clean Desc: 'Vlan30' Raw Desc: Vlan30
OID: 1.3.6.1.2.1.2.2.1.2.10106 Clean Desc: 'GigabitEthernet1/0/6' Raw Desc: GigabitEthernet1/0/6
OID: 1.3.6.1.2.1.2.2.1.2.254 Clean Desc: 'Vlan254' Raw Desc: Vlan254
OID: 1.3.6.1.2.1.2.2.1.2.10120 Clean Desc: 'GigabitEthernet1/0/20' Raw Desc: GigabitEthernet1/0/20
OID: 1.3.6.1.2.1.2.2.1.2.10121 Clean Desc: 'GigabitEthernet1/0/21' Raw Desc: GigabitEthernet1/0/21
OID: 1.3.6.1.2.1.2.2.1.2.10115 Clean Desc: 'GigabitEthernet1/0/15' Raw Desc: GigabitEthernet1/0/15
OID: 1.3.6.1.2.1.2.2.1.2.10111 Clean Desc: 'GigabitEthernet1/0/11' Raw Desc: GigabitEthernet1/0/11
OID: 1.3.6.1.2.1.2.2.1.2.1 Clean Desc: 'Vlan1' Raw Desc: Vlan1
OID: 1.3.6.1.2.1.2.2.1.2.10103 Clean Desc: 'GigabitEthernet1/0/3' Raw Desc: GigabitEthernet1/0/3
OID: 1.3.6.1.2.1.2.2.1.2.5181 Clean Desc: 'StackSub-St1-2' Raw Desc: StackSub-St1-2
OID: 1.3.6.1.2.1.2.2.1.2.14501 Clean Desc: 'Null0' Raw Desc: Null0
OID: 1.3.6.1.2.1.2.2.1.2.20 Clean Desc: 'Vlan20' Raw Desc: Vlan20
OID: 1.3.6.1.2.1.2.2.1.2.5002 Clean Desc: 'Port-channel2' Raw Desc: Port-channel2
OID: 1.3.6.1.2.1.2.2.1.2.10101 Clean Desc: 'GigabitEthernet1/0/1' Raw Desc: GigabitEthernet1/0/1
OID: 1.3.6.1.2.1.2.2.1.2.5005 Clean Desc: 'Port-channel5' Raw Desc: Port-channel5
OID: 1.3.6.1.2.1.2.2.1.2.29 Clean Desc: 'Vlan29' Raw Desc: Vlan29
OID: 1.3.6.1.2.1.2.2.1.2.10128 Clean Desc: 'GigabitEthernet1/0/28' Raw Desc: GigabitEthernet1/0/28
OID: 1.3.6.1.2.1.2.2.1.2.10118 Clean Desc: 'GigabitEthernet1/0/18' Raw Desc: GigabitEthernet1/0/18
OID: 1.3.6.1.2.1.2.2.1.2.223 Clean Desc: 'Vlan223' Raw Desc: Vlan223
OID: 1.3.6.1.2.1.2.2.1.2.25 Clean Desc: 'Vlan25' Raw Desc: Vlan25
OID: 1.3.6.1.2.1.2.2.1.2.10116 Clean Desc: 'GigabitEthernet1/0/16' Raw Desc: GigabitEthernet1/0/16
OID: 1.3.6.1.2.1.2.2.1.2.10109 Clean Desc: 'GigabitEthernet1/0/9' Raw Desc: GigabitEthernet1/0/9
OID: 1.3.6.1.2.1.2.2.1.2.10124 Clean Desc: 'GigabitEthernet1/0/24' Raw Desc: GigabitEthernet1/0/24
OID: 1.3.6.1.2.1.2.2.1.2.10112 Clean Desc: 'GigabitEthernet1/0/12' Raw Desc: GigabitEthernet1/0/12
OID: 1.3.6.1.2.1.2.2.1.2.10102 Clean Desc: 'GigabitEthernet1/0/2' Raw Desc: GigabitEthernet1/0/2
OID: 1.3.6.1.2.1.2.2.1.2.10122 Clean Desc: 'GigabitEthernet1/0/22' Raw Desc: GigabitEthernet1/0/22
OID: 1.3.6.1.2.1.2.2.1.2.27 Clean Desc: 'Vlan27' Raw Desc: Vlan27
OID: 1.3.6.1.2.1.2.2.1.2.21 Clean Desc: 'Vlan21' Raw Desc: Vlan21
OID: 1.3.6.1.2.1.2.2.1.2.24 Clean Desc: 'Vlan24' Raw Desc: Vlan24
OID: 1.3.6.1.2.1.2.2.1.2.5180 Clean Desc: 'StackSub-St1-1' Raw Desc: StackSub-St1-1
OID: 1.3.6.1.2.1.2.2.1.2.10110 Clean Desc: 'GigabitEthernet1/0/10' Raw Desc: GigabitEthernet1/0/10
OID: 1.3.6.1.2.1.2.2.1.2.10125 Clean Desc: 'GigabitEthernet1/0/25' Raw Desc: GigabitEthernet1/0/25
OID: 1.3.6.1.2.1.2.2.1.2.10105 Clean Desc: 'GigabitEthernet1/0/5' Raw Desc: GigabitEthernet1/0/5
OID: 1.3.6.1.2.1.2.2.1.2.10114 Clean Desc: 'GigabitEthernet1/0/14' Raw Desc: GigabitEthernet1/0/14
Name : GigabitEthernet1/0/10, Index : 10110
Doing snmp request on status table OIDs: 1.3.6.1.2.1.2.2.1.8.10110
Finished SNMP request. Result contains 1 entries:
1.3.6.1.2.1.2.2.1.8.10110 = 1
Use of uninitialized value within @oid_perf_inoct in hash element at ./check_netint-2.4b5.pl line 2232.
GigabitEthernet1/0/10:UP (1 UP): OK
$
My pnp4nagios version is pnp4nagiosâ0.6.18
The Redis and Memcached plugins work beautifully and show the graphs in Nagios. The MySQL plugin shows the following error.
Please check the documentation for information about the following error.
XML file "/usr/local/pnp4nagios/var/perfdata/localhost/MYSQLD.xml" not found. Read FAQ online
file [line]:
application/models/data.php [312]:
I see the following files in perfdata:
root@v-enterprise15:/usr/local/pnp4nagios# ls -f var/perfdata/localhost/*
var/perfdata/localhost/Current_Load.rrd var/perfdata/localhost/MYSQLD_open_tables.rrd var/perfdata/localhost/Root_Partition.rrd
var/perfdata/localhost/Current_Load.xml var/perfdata/localhost/MYSQLD_questions.rrd var/perfdata/localhost/Root_Partition.xml
var/perfdata/localhost/Current_Users.rrd var/perfdata/localhost/MYSQLD_slow_queries.rrd var/perfdata/localhost/SOLR.rrd
var/perfdata/localhost/Current_Users.xml var/perfdata/localhost/MYSQLD_threads_connected.rrd var/perfdata/localhost/SOLR.xml
var/perfdata/localhost/Memcached.rrd var/perfdata/localhost/MYSQLD_uptime.rrd var/perfdata/localhost/Swap_Usage.rrd
var/perfdata/localhost/Memcached.xml var/perfdata/localhost/Redis.rrd var/perfdata/localhost/Swap_Usage.xml
var/perfdata/localhost/MYSQLD_connection_time.rrd var/perfdata/localhost/Redis.xml
What might be the problem. Any help would be appreciated.
Please add an option to ignore interfaces that are administrative DOWN when checking for operational UP interfaces.
This happens all the time: a server has many interfaces but a number of them might not be configured and thus be down.
I made this change for the original plugin, so if you want I can send you the diff.
Hi,
I Just upgraded my Redis Env's to 2.6 (from 2.2).
somehow i encounter issues regarding monitoring Redis Hitrate, getting the following Error:
CRITICAL: hitrate data is missing - REDIS
Any Idea what might be the cause?
It doesn't handle multiple controllers well, the support is not there at all, especially when using an enclosure.
I have managed to test the sasraid only (i own a bunch of megaraid cards).
but return value is total hit rate
so, I test manually
./check_redis.pl -H host_addr -R -f -P "keyspace_hits=89737856c keyspace_misses=35252550c"
but also return value is total hit rate
how get real hit rate?
thank you
Per the plugin use notes:
If you're using -P option to pass performance data back to plugin then
# you may (depending on version of nagios) also need to modify nagios.cfg
# and remove ' from illegal_macro_output_chars=`~$&|'"<> line, i.e. change to
# illegal_macro_output_chars=`~$&|"<>
Despite that, there is provision in the code (in sub prev_perf
) to handle the case that nagios did strip the single quote char.
Since I'm using this plugin with Icinga2 (where there's no illegal_macro_output_chars
or similar variable/constant), the above provision in the plugin code would help deal with the single quote char problem. But it doesn't work.
The reason is an error in the pattern match inside the sub prev_perf
(line 1081 in check_netint.pl):
if ($name =~ /^'(.*)`$/) {
It should be replaced with:
if ($name =~ /^'(.*)'$/) {
that is, replace the back-quote char with the single quote char
It would be great to generate a bytes read / written per second similar to the way memcache-top does. I tried hacking around a bit but got stuck trying to figure out how to get the last time the check was run in order to do the calculations.
On oraclelinux with kernel 2.6.18 it works as inteded.
On oraclelinux with kernel 2.6.39 there is always a critical alarming shown but in real the cpu usage is always below 10%. It seems that there isn't checked against cpu used anymore but against cpu free.
CRITICAL - 2 CPU cores - CPU(all) 95.0% used > 90%, CPU0 97.0% used > 90%, CPU1 93.0% used > 90%
-> but CPU usage is very low
So something changed in the kernel version between 2.6.18 and 2.6.39 in relation to /proc/stat
I had a small look at the changelog of those kernels and found a possible reason for this issue in kenel uupdate 2.6.37 at "Memory management":
/proc/stat: Make reading /proc/stat scalable (commit), fix scalability of irq sum of all cpu (commit)
Please have a look at:
http://kernelnewbies.org/Linux_2_6_37
Feel free to contact me for testing!
Example:
$ uptime
11:55:38 up 189 days, 20 min, 3 users, load average: 0.06, 0.08, 0.04
$ ./check_uptime.pl
OK: Linux mysystem.domain.com 2.6.32-358.18.1.el6.x86_64 - up 11:55:38 up 189 days, 20 min, 3 users, load average: 0.06, 0.08, 0.04 | type=1
So no uptime_mins= in perf data
Below you can find a unified diff for some small code corrections against the latest check_netint.pl.
Fixes:
Franky
--- check_netint.pl.20120927 2012-09-27 13:55:31.000000000 +0200
+++ check_netint.pl 2012-09-28 13:06:21.000000000 +0200
@@ -2318,15 +2318,14 @@
}
# Get rid of special characters for performance in description
# $descr[$i] =~ s/'\/\(\)/_/g;
- if ((($int_status == $ok_val) || (defined($o_dormant) && $int_status == 5)) && $int_status_opt==0) {
+ if ((($int_status == $ok_val) || (defined($o_dormant) && $int_status == $status{'DORMANT'})) && $int_status_opt==0) {
$num_ok++;
- } elsif (defined($o_admindown_ok) && $ok_val==1 && !$o_admin && $int_status == 2 && $admin_int_status == 2) {
+ } elsif (defined($o_admindown_ok) && $ok_val==1 && !$o_admin && $int_status == $status{'DOWN'} && $admin_int_status == $status{'DOWN'}) {
# we want to check for operational UP interfaces, so don't check those that are supposed to be down (administratively down)
$num_admindown++;
}
- # WL: [TODO] I think 'int_status==1' check below and above (when doing actual bandwidth checks)
- # should be removed and performance values processed no matter what status interface has. [DONE: removed]
- if (defined($interfaces[$i]{'descr'}) && (defined($o_perf) || defined($o_perfs) || defined($o_perfr) || defined($o_perfp) || defined($o_checkperf))) {
+ # Don't return performance data for interfaces that are down and are supposed to be down
+ if (!(defined($o_admindown_ok) && $ok_val==1 && $int_status == $status{'DOWN'} && $admin_int_status == $status{'DOWN'}) && defined($interfaces[$i]{'descr'}) && (defined($o_perf) || defined($o_perfs) || defined($o_perfr) || defined($o_perfp) || defined($o_checkperf))) {
if (defined ($o_perfp)) { # output in % of speed
if ($usable_data==0) {
$perf_out .= " ".perf_name($descr,"in_prct")."=";
@@ -2396,8 +2395,8 @@
if (defined ($o_perfe) && defined($o_ext_checkperf)) {
$perf_out .= " ".perf_name($descr,"in_error")."=". $interfaces[$i]{'in_errors'};
$perf_out .= " ".perf_name($descr,"out_error")."=". $interfaces[$i]{'out_errors'};
- $perf_out .= " ".perf_name($descr,"in_discard")."=". $interfaces[$i]{'in_dropped'};
- $perf_out .= " ".perf_name($descr,"out_discard")."=". $interfaces[$i]{'out_dropped'};
+ $perf_out .= " ".perf_name($descr,"in_discard")."=". $interfaces[$i]{'in_dropped'} if defined ($interfaces[$i]{'in_dropped'});
+ $perf_out .= " ".perf_name($descr,"out_discard")."=". $interfaces[$i]{'out_dropped'} if defined ($interfaces[$i]{'out_dropped'});
# $perf_out .= " ".perf_name($descr,"in_error")."=". $$resultf{$oid_perf_inerr[$i]} ."c" if defined $$resultf{$oid_perf_inerr[$i]};
# $perf_out .= " ".perf_name($descr,"in_discard")."=". $$resultf{$oid_perf_indisc[$i]} ."c" if defined $$resultf{$oid_perf_indisc[$i]};
# $perf_out .= " ".perf_name($descr,"out_error")."=". $$resultf{$oid_perf_outerr[$i]} ."c" if defined $$resultf{$oid_perf_outerr[$i]};
Current checked-in version won't run at all for me:
$ ./check_snmp_raid.pl --help
Global symbol "$do_bulk_snmp" requires explicit package name at ./check_snmp_raid.pl line 1196.
Global symbol "$do_bulk_snmp" requires explicit package name at ./check_snmp_raid.pl line 1196.
Execution of ./check_snmp_raid.pl aborted due to compilation errors.
Temporarily commenting out use strict
leads to a lot of pretty warnings:
$ ./check_snmp_raid.pl -H foo.bar.local -C quux --check_battery -P
Use of uninitialized value $opt_cardtype in string eq at ./check_snmp_raid.pl line 1017.
Use of uninitialized value $o_bulksnmp in string eq at ./check_snmp_raid.pl line 1249.
Use of uninitialized value $o_bulksnmp in string eq at ./check_snmp_raid.pl line 1249.
Use of uninitialized value $o_bulksnmp in string eq at ./check_snmp_raid.pl line 1249.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1652.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1657.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1664.
Use of uninitialized value $nerr in concatenation (.) or string at ./check_snmp_raid.pl line 1674.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1679.
Use of uninitialized value $nerr in numeric ne (!=) at ./check_snmp_raid.pl line 1686.
Use of uninitialized value in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_3"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_18"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_9"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_0"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_19"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_21"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_6"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_6"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_15"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_10"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_22"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_14"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_17"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_2"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_20"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_13"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_11"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_5"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_8"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_18"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_11"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_4"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_2"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_21"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_19"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_13"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_16"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_17"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_20"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_0"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_1"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_16"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_22"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_7"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_9"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_3"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_10"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_12"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_4"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_8"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_12"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_1"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_5"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_23"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"oerr_23"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_14"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
Use of uninitialized value $curr_perf{"merr_7"} in concatenation (.) or string at ./check_snmp_raid.pl line 903.
RAID OK - 2 logical disks, 24 physical drives, 1 batteries found | oerr_15= oerr_3= merr_18= merr_9= oerr_0= merr_19= merr_21= merr_6= oerr_6= merr_15= merr_10= oerr_22= oerr_14= merr_17= oerr_2= merr_20= merr_13= oerr_11= merr_5= merr_8= oerr_18= merr_11= oerr_4= merr_2= oerr_21= oerr_19= oerr_13= oerr_16= oerr_17= oerr_20= merr_0= oerr_1= merr_16= merr_22= oerr_7= oerr_9= merr_3= oerr_10= oerr_12= merr_4= oerr_8= merr_12= merr_1= oerr_5= merr_23= oerr_23= merr_14= merr_7=
The following OID can be used to obtain this information.
.1.3.6.1.4.1.3582.4.1.4.1.6.2.1.27
batteryReplacement OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS optional
DESCRIPTION "This property denotes whether the
Battery needs to be replaced or not.1 =battery needs to be replaced ,0
=battery needs not to be replaced"
::= { bbuEntry 27 }
I needed to add this for the performance output to work, even after setting the octetlength to 65535:
--- check_netint.pl.20131104 2013-11-04 17:24:06.000000000 +0100
+++ check_netint.pl 2013-11-04 17:24:14.000000000 +0100
@@ -1792,15 +1792,21 @@
# Get the perf value if -f (performance) option defined or -k (check bandwidth)
if (defined($o_perf) || defined($o_checkperf) || $expected_speed!=0) {
if (!defined($o_minsnmp)) {
- verb("Retrieving OIDs: ".join(' ',@oid_perf));
- $resultf = $session->get_request(
- Varbindlist => \@oid_perf
- );
- if (!defined($resultf)) {
- printf("ERROR: Statistics table : %s.\n", $session->error);
- $session->close;
- exit $ERRORS{"UNKNOWN"};
- }
+ while (@oid_perf) {
+ my @sublist = splice @oid_perf, 0, 10;
+ verb("Retrieving OIDs: ".join(' ',@sublist));
+ my $oid_resultf = $session->get_request(
+ Varbindlist => \@sublist
+ );
+ if (!defined($oid_resultf)) {
+ printf("ERROR: Statistics table : %s.\n", $session->error);
+ $session->close;
+ exit $ERRORS{"UNKNOWN"};
+ }
+ while (my ($key,$value) = each %{$oid_resultf}) {
+ $resultf->{$key}=$value;
+ }
+ }
}
else {
$resultf = $result;
also, in a number of cases the snmp call get_table failed on me, so I needed to add
-maxrepetitions => 1,
to every get_table call.
Hi!
A few days ago I decided to migrate my own servers to Debian GNU/Linux Jessie. Having migrated my firewall, I started getting an error in the Nagios Manubulon plugin check_snmp_netint.pl
since it does not find the interface eth1.
# ./check_snmp_netint.pl -H 10.1.0.10 -l Us3r -x passw0rd0 -X passwOrd1 -L md5,des \
> -w 1500,295 -c 2500,400 -k -B --label -n eth1
ERROR : Unknown interface eth1
This was running smoothly prior to migration, although it now seems to have changed the description:
# ./check_snmp_netint.pl -H 10.1.0.10 -l Us3r -x passw0rd0 -X passwOrd1 -L md5,des -n -v
Alarm at 10 + 5
SNMPv3 AuthPriv login : Us3r, md5, des
Filter :
OID : 1.3.6.1.2.1.2.2.1.2.2, Desc : Realtek Semiconductor Co., Ltd. RTL-8100/8101L/8139 PCI Fast Ethernet Adapter
OID : 1.3.6.1.2.1.2.2.1.2.1, Desc : lo
OID : 1.3.6.1.2.1.2.2.1.2.3, Desc : VIA Technologies, Inc. VT6102 [Rhine-II]
OID : 1.3.6.1.2.1.2.2.1.2.4, Desc : tun0
Name : Realtek Semiconductor Co., Ltd. RTL-8100/8101L/8139 PCI Fast Ethernet Adapter, Index : 2
Realtek Semiconductor Co., Ltd. RTL-8100/8101L/8139 PCI Fast Ethernet Adapter:UP:(1 UP): OK |
So I checked the equivalence between ifDescr and ifName:
# snmpwalk -v 3 -u Us3r -l authPriv -a MD5 -A passw0rd0 -x DES -X passwOrd1 10.1.0.10 ifDescr
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: Realtek Semiconductor Co., Ltd.
RTL-8100/8101L/8139 PCI Fast Ethernet Adapter
IF-MIB::ifDescr.3 = STRING: VIA Technologies, Inc. VT6102 [Rhine-II]
IF-MIB::ifDescr.4 = STRING: tun0
# snmpwalk -v 3 -u Us3r -l authPriv -a MD5 -A passw0rd0 -x DES -X passwOrd1 10.1.0.10 ifName
IF-MIB::ifName.1 = STRING: lo
IF-MIB::ifName.2 = STRING: eth1
IF-MIB::ifName.3 = STRING: eth0
IF-MIB::ifName.4 = STRING: tun0
I could use something like this, but the output is extremely long:
# ./check_snmp_netint.pl -H 10.1.0.10 -l Us3r -x passw0rd0 -X passwOrd1 -L md5,des \
> -w 1500,295 -c 2500,400 -k -B --label -n "Realtek.*"
Realtek Semiconductor Co., Ltd. RTL-8100/8101L/8139 PCI Fast Ethernet Adapter:UP (in=93.0Kbps/out=13.1Kbps):(1 UP): OK |
It's a pity If it can not solve because quite a while I was using the check_snmp_netint.pl
plugin and was very happy with their results. But now in Debian Jessie I'm having this problem. It seems that something has changed in the SNMP service included in the new version of Debian since before (on Debian Wheezy) the description matched the ifName:
# ./check_snmp_netint.pl -H srv01.freesoftware -C public -w 1500,295 -c 2500,400 -n -v
Alarm at 10 + 5
SNMP v1 login
Filter :
OID : 1.3.6.1.2.1.2.2.1.2.2, Desc : eth0
OID : 1.3.6.1.2.1.2.2.1.2.1, Desc : lo
Name : eth0, Index : 2
eth0:UP:(1 UP): OK |
I think it is easier to identify interfaces such as eth0, eth1, etc, rather than by its manufacturer/model.
Is it possible to change the behavior of the plugin so that "-n" allows to specify ifName instead of ifDescr and the plugin output is based on ifName because of this change in Debian?
Thanks in advance.
Best regards,
Daniel
Hi William,
Today I started working with the perf data options in your check_redis plugin and ran into a problem. I initially tried to use the -A option to return everything but Nagios was not recording a .xml or .rrd file. I did a bunch of checking on my Nagios and pnp4nagios configs trying to figure out what was wrong. After not finding anything wrong in my configs I ended up trying the -f option to output the perf data for only the specific items I was testing. With the -f option I immediately started getting a .rrd file. Not sure if I am doing something incorrect or if the -A option is outputting something Nagios isn't liking.
Thanks,
Matt
"--debug" without an argument doesn't work at all
"--debug=filename" write some information to the file and some other information to the console
Status Information: Translated filespec 'dbq.' to regex 'dbq..'
check_files.pl plugin version 0.41
Alarm at 25
Changed to directory '/var/spool/rsyslog'
**ePN /usr/lib/nagios/plugins/check_files.pl: "Use of uninitialized value $shell_command in concatenation (.) or string at (eval 1) line 619,".
Service Information
Last Updated: Sat May 4 09:09:48 CEST 2013
Updated every 90 seconds
Nagios® Core™ 3.5.0 - www.nagios.org
Logged in as admin
define command{
command_name check_local_files
command_line
}
define service{
use local-service
hostgroup_name elma-server
servicegroups elma-services
service_description Syslog Queue
check_command check_local_files!Syslog Queue!/var/spool/rsyslog!'dbq.*'!10!100
}
It looks like the parsing of stats key/values goes off-by-1 at some point. Not sure if this is due to Redis 2.6, but I see the following error when running the script:
Use of uninitialized value in concatenation (.) or string at ./check_redis.pl line 1661.
When the parser gets off-by-1, the line run_id:db543ce9fac79f455eee32d605e1b78dc5e0f93b is interpreted so that the hash string (which starts with db) is interpreted as a key, which matches the '$vnam =~ /^db/' check, and I eventually get an error when it tries to parse/use the expected db status lines.
I was using the latest check_redis.pl from git at the time of this bug report.
$ ./check_redis.pl -v -H **** -p **** check_redis.pl plugin version 0.61 Alarm at 15 connecting to ****:**** [SEND] PING $VAR1 = []; [SEND RAW] *1 $4 PING [RECV RAW] '+PONG' at /usr/lib/perl5/site_perl/5.8.8/Redis.pm line 522, chunk 1. [RECV] PING $VAR1 = 'PONG'; $VAR2 = undef; [SEND] INFO $VAR1 = []; [SEND RAW] *1 $4 INFO [RECV RAW] '$1471' at /usr/lib/perl5/site_perl/5.8.8/Redis.pm line 522, chunk 2. [RECV RAW] '# Server redis_version:2.5.9 redis_git_sha1:5ab7eaf8 redis_git_dirty:1 os:Linux 2.6.32-220.7.1.el6.x86_64 x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:4.4.6 process_id:2416 run_id:db543ce9fac79f455eee32d605e1b78dc5e0f93b tcp_port:**** uptime_in_seconds:860179 uptime_in_days:9 lru_clock:237328 # Clients connected_clients:1 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 # Memory used_memory:410064 used_memory_human:400.45K used_memory_rss:7557120 used_memory_peak:410288 used_memory_peak_human:400.67K used_memory_lua:30720 mem_fragmentation_ratio:18.43 mem_allocator:jemalloc-2.2.5 # Persistence loading:0 aof_enabled:1 changes_since_last_save:0 bgsave_in_progress:0 last_save_time:1343690790 last_bgsave_status:ok bgrewriteaof_in_progress:0 bgrewriteaof_scheduled:0 aof_current_size:0 aof_base_size:0 aof_pending_rewrite:0 aof_buffer_length:0 aof_pending_bio_fsync:0 aof_delayed_fsync:0 # Stats total_connections_received:1473 total_commands_processed:1484 instantaneous_ops_per_sec:0 rejected_connections:0 expired_keys:0 evicted_keys:0 keyspace_hits:0 keyspace_misses:0 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:1676 # Replication role:master connected_slaves:2 slave0:10.56.124.27,33599,online slave1:10.144.34.31,47142,online # CPU used_cpu_sys:0.89 used_cpu_user:0.92 used_cpu_sys_children:0.01 used_cpu_user_children:0.00 # Keyspace ' at /usr/lib/perl5/site_perl/5.8.8/Redis.pm line 545, chunk 2. [RECV] INFO $VAR1 = '# Server redis_version:2.5.9 redis_git_sha1:5ab7eaf8 redis_git_dirty:1 os:Linux 2.6.32-220.7.1.el6.x86_64 x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:4.4.6 process_id:2416 run_id:db543ce9fac79f455eee32d605e1b78dc5e0f93b tcp_port:**** uptime_in_seconds:860179 uptime_in_days:9 lru_clock:237328 # Clients connected_clients:1 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 # Memory used_memory:410064 used_memory_human:400.45K used_memory_rss:7557120 used_memory_peak:410288 used_memory_peak_human:400.67K used_memory_lua:30720 mem_fragmentation_ratio:18.43 mem_allocator:jemalloc-2.2.5 # Persistence loading:0 aof_enabled:1 changes_since_last_save:0 bgsave_in_progress:0 last_save_time:1343690790 last_bgsave_status:ok bgrewriteaof_in_progress:0 bgrewriteaof_scheduled:0 aof_current_size:0 aof_base_size:0 aof_pending_rewrite:0 aof_buffer_length:0 aof_pending_bio_fsync:0 aof_delayed_fsync:0 # Stats total_connections_received:1473 total_commands_processed:1484 instantaneous_ops_per_sec:0 rejected_connections:0 expired_keys:0 evicted_keys:0 keyspace_hits:0 keyspace_misses:0 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:1676 # Replication role:master connected_slaves:2 slave0:10.56.124.27,33599,online slave1:10.144.34.31,47142,online # CPU used_cpu_sys:0.89 used_cpu_user:0.92 used_cpu_sys_children:0.01 used_cpu_user_children:0.00 # Keyspace '; $VAR2 = undef; [SEND] QUIT $VAR1 = []; [SEND RAW] *1 $4 QUIT Stats Line: last_save_time = 1343690790 Stats Line: bgsave_in_progress = 0 Stats Line: 1676 = # Replication Stats Line: 2.5.9 = redis_git_sha1 Stats Line: 860179 = uptime_in_days Stats Line: db543ce9fac79f455eee32d605e1b78dc5e0f93b = tcp_port Use of uninitialized value in concatenation (.) or string at ./check_redis.pl line 1661. - stats data added: db543ce9fac79f455eee32d605e1b78dc5e0f93b_tcp_port = Stats Line: 1 = os Stats Line: 4.4.6 = process_id Stats Line: loading = 0 Stats Line: **** = uptime_in_seconds Stats Line: aof_pending_bio_fsync = 0 Stats Line: 0.92 = used_cpu_sys_children Stats Line: # Stats = total_connections_received Stats Line: connected_clients = 1 Stats Line: 2416 = run_id Stats Line: client_biggest_input_buf = 0 Stats Line: changes_since_last_save = 0 Stats Line: Linux 2.6.32-220.7.1.el6.x86_64 x86_64 = arch_bits Stats Line: 410288 = used_memory_peak_human Stats Line: role = master Stats Line: aof_pending_rewrite = 0 Stats Line: bgrewriteaof_scheduled = 0 Stats Line: 237328 = # Clients Stats Line: 7557120 = used_memory_peak Stats Line: jemalloc-2.2.5 = # Persistence Stats Line: aof_buffer_length = 0 Stats Line: # Memory = used_memory Stats Line: aof_delayed_fsync = 0 Stats Line: slave0 = 10.56.124.27,33599,online Stats Line: 5ab7eaf8 = redis_git_dirty Stats Line: aof_base_size = 0 Stats Line: 18.43 = mem_allocator Stats Line: 0.01 = used_cpu_user_children Stats Line: 0 = latest_fork_usec Stats Line: # Server = redis_version Stats Line: 0.89 = used_cpu_user Stats Line: aof_current_size = 0 Stats Line: 30720 = mem_fragmentation_ratio Stats Line: epoll = gcc_version Stats Line: client_longest_output_list = 0 Stats Line: 64 = multiplexing_api Stats Line: blocked_clients = 0 Stats Line: 400.67K = used_memory_lua Stats Line: aof_enabled = 1 Stats Line: 9 = lru_clock Stats Line: # CPU = used_cpu_sys Stats Line: 1473 = total_commands_processed Stats Line: 400.45K = used_memory_rss Stats Line: bgrewriteaof_in_progress = 0 Stats Line: slave1 = 10.144.34.31,47142,online Stats Line: 1484 = instantaneous_ops_per_sec Stats Line: 0.00 = # Keyspace Stats Line: connected_slaves = 2 Stats Line: last_bgsave_status = ok Stats Line: 410064 = used_memory_human Calculated Data: total_keys=0 Calculated Data: total_expires=0 OK: REDIS on ****:**** has 1 databases (db543ce9fac79f455eee32d605e1b78dc5e0f93b)
Hi,
I'm using your plugin check_linux_procstat and saw that it doesn't work well with pnp4nagios 0.6.x when using multiple rrd's to store the results (RRD_STORAGE_TYPE = MULTIPLE in the file process_perfdata.cfg).
Below you can find the adapted version (which should work for all cases).
<?php
#
# Copyright (c) 2011 William Leibzon (http://william.leibzon.org/nagios/)
#
# This is PNP4Nagios template for check_linux_procstat.pl nagios plugin
# The plugin reads /proc/stat and gives out its content as performance data:
#
# CPU data is cpu_???? for all cpu together and cpu?_???? for specific core
# csum_???? is sum from all cpu?_ cores which replaces cpu_?? if its different
#
# Some additional data are memory and swap operations (not in for later 2.6 kernel),
# interrupts and context switches, processes forking and blocked processes stats
$CORE = array();
foreach ($this->DS as $KEY=>$VAL) {
$cpunum=-1;
if (preg_match('/cpu_(.*)/', $VAL['LABEL'], $matches)) {
$cpunum=0;
$cpuparam=$matches[1];
}
else if (preg_match('/cpu(\d*)_(.*)/', $VAL['LABEL'], $matches)) {
$cpunum=$matches[1]+1;
$cpuparam=$matches[2];
}
if ($cpunum != -1) {
if (!isset($CORE[$cpunum])) $CORE[$cpunum]=array();
$CORE[$cpunum][$cpuparam]= $VAL;
}
if ($VAL['LABEL'] == 'num_intr') {
$num_intr = $VAL;
}
if ($VAL['LABEL'] == 'ctxt') {
$ctxt = $VAL;
}
if ($VAL['LABEL'] == 'processes') {
$processes = $VAL;
}
if ($VAL['LABEL'] == 'procs_blocked') {
$procs_blocked = $VAL;
}
if ($VAL['LABEL'] == 'procs_running') {
$procs_running = $VAL;
}
if ($VAL['LABEL'] == 'swap_paged_in') {
$swap_paged_in = $VAL;
}
if ($VAL['LABEL'] == 'swap_paged_out') {
$swap_paged_out = $VAL;
}
if ($VAL['LABEL'] == 'data_paged_in') {
$data_paged_in = $VAL;
}
if ($VAL['LABEL'] == 'data_paged_out') {
$data_paged_out = $VAL;
}
}
# Go through all CPUs and prepare graphs
for ($i=0; $i<count($CORE); $i++) {
$gkey = $i;
$pre = '';
$unm = '';
if ($i==0) {
$opt[$gkey] = '--vertical-label Percent --title "Total for all CPUs on ' . $this->MACRO['DISP_HOSTNAME']. '" --upper=101 --lower=0';
$ds_name[$gkey] = "Total for All CPUs";
$pre = 'percent_';
$unm = '%2.1lf%% ';
}
else {
$opt[$gkey] = '--vertical-label "jiffs/sec" --title "CPU Core '. ($i-1) . ' on '. $this->MACRO['DISP_HOSTNAME'].'" --lower=0';
$ds_name[$gkey] = 'CPU Core '.($i-1);
$unm = '%6.2lf ';
}
$def[$gkey] = '';
foreach ($CORE[$i] as $K=>$V) {
$def[$gkey] .= rrd::def($K, $V['RRDFILE'], $V['DS'], "AVERAGE");
}
$def[$gkey] .= rrd::cdef("total", "idle,nice,+,user,+,system,+,iowait,+,irq,+,softirq,+");
$def[$gkey] .= rrd::cdef("percent_used", "total,idle,-,total,/,100,*");
$def[$gkey] .= rrd::cdef("percent_idle", "idle,total,/,100,*");
$def[$gkey] .= rrd::cdef("percent_nice", "nice,total,/,100,*");
$def[$gkey] .= rrd::cdef("percent_user", "user,total,/,100,*");
$def[$gkey] .= rrd::cdef("percent_system", "system,total,/,100,*");
$def[$gkey] .= rrd::cdef("percent_iowait", "iowait,total,/,100,*");
$def[$gkey] .= rrd::cdef("percent_irq", "irq,total,/,100,*");
$def[$gkey] .= rrd::cdef("percent_softirq", "softirq,total,/,100,*");
$def[$gkey] .= rrd::cdef("user_area", $pre."used");
$def[$gkey] .= rrd::cdef("nice_area_temp", "user_area,".$pre."user,-");
$def[$gkey] .= rrd::cdef("nice_area","nice_area_temp,0,LT,0,nice_area_temp,IF");
$def[$gkey] .= rrd::cdef("system_area_temp", "nice_area,".$pre."nice,-");
$def[$gkey] .= rrd::cdef("system_area","system_area_temp,0,LT,0,system_area_temp,IF");
$def[$gkey] .= rrd::cdef("irq_area_temp", "system_area,".$pre."system,-");
$def[$gkey] .= rrd::cdef("irq_area","irq_area_temp,0,LT,0,irq_area_temp,IF");
$def[$gkey] .= rrd::cdef("softirq_area_temp", "irq_area,".$pre."irq,-");
$def[$gkey] .= rrd::cdef("softirq_area","softirq_area_temp,0,LT,0,softirq_area_temp,IF");
$def[$gkey] .= rrd::cdef("iowait_area", $pre."iowait");
$def[$gkey] .= rrd::comment("* Total Idle\\t");
$def[$gkey] .= rrd::gprint($pre."idle", array("LAST", "MAX", "AVERAGE"), $unm);
$def[$gkey] .= rrd::comment("* Total Used\\t");
$def[$gkey] .= rrd::gprint($pre."used", array("LAST", "MAX", "AVERAGE"), $unm);
$def[$gkey] .= rrd::comment("\\r");
$def[$gkey] .= rrd::area("user_area", "#40E0D0", "user\\t");
$def[$gkey] .= rrd::gprint($pre."user", array("LAST", "AVERAGE", "MAX"), $unm);
$def[$gkey] .= rrd::area("nice_area", "#87CEEB", "nice\\t");
$def[$gkey] .= rrd::gprint($pre."nice", array("LAST", "AVERAGE", "MAX"), $unm);
$def[$gkey] .= rrd::area("system_area", "#8B4513", "system\\t");
$def[$gkey] .= rrd::gprint($pre."system", array("LAST", "AVERAGE", "MAX"), $unm);
$def[$gkey] .= rrd::area("irq_area", "#FF0000", "irq \\t");
$def[$gkey] .= rrd::gprint($pre."irq", array("LAST", "AVERAGE", "MAX"), $unm);
$def[$gkey] .= rrd::area("softirq_area", "#FFFF00", "softirq\\t");
$def[$gkey] .= rrd::gprint($pre."softirq", array("LAST", "AVERAGE", "MAX"), $unm);
$def[$gkey] .= rrd::area("iowait_area", "#FFA500", "iowait\\t");
$def[$gkey] .= rrd::gprint($pre."iowait", array("LAST", "AVERAGE", "MAX"), $unm);
}
if (isset($swap_paged_in) && isset($swap_paged_out) && isset($data_paged_in) && isset($data_paged_out)) {
$gkey++;
$opt[$gkey] = '--vertical-label # --title "Memory and Swap Operations on ' . $this->MACRO['DISP_HOSTNAME']. '"';
$ds_name[$gkey] = "Memory and Swap Operations";
$def[$gkey] = rrd::def("data_paged_in", $data_paged_in['RRDFILE'], $data_paged_in['DS'], "AVERAGE");
$def[$gkey] .= rrd::def("data_paged_out", $data_paged_out['RRDFILE'], $data_paged_out['DS'], "AVERAGE");
$def[$gkey] .= rrd::def("swap_paged_in", $swap_paged_in['RRDFILE'], $swap_paged_in['DS'], "AVERAGE");
$def[$gkey] .= rrd::def("swap_paged_out", $swap_paged_out['RRDFILE'], $swap_paged_out['DS'], "AVERAGEo");
$def[$gkey] .= "AREA:data_paged_in#00CF00:\"Data Paged In \: \t\g\" ";
$def[$gkey] .= rrd::gprint("data_paged_in", array("LAST", "AVERAGE", "MAX"), '%6.2lf ');
$def[$gkey] .= "AREA:data_paged_out#FF8C0:\"Data Paged Out\: \t\g\":STACK ";
$def[$gkey] .= rrd::gprint("data_paged_out", array("LAST", "AVERAGE", "MAX"), '%6.2lf ');
$def[$gkey] .= "LINE2:swap_paged_in#FF0000:\"Swap Paged In \: \t\g\" ";
$def[$gkey] .= rrd::gprint("swap_paged_in", array("LAST", "AVERAGE", "MAX"), '%6.2lf ');
$def[$gkey] .= rrd::cdef("swap_paged_out_line", "swap_paged_out,data_paged_in,+");
$def[$gkey] .= "LINE2:swap_paged_out_line#0000FF:\"Swap Paged Out\: \t\g\" ";
$def[$gkey] .= rrd::gprint("swap_paged_out", array("LAST", "AVERAGE", "MAX"), '%6.2lf ');
}
if (isset($num_intr) && isset($ctxt)) {
$gkey++;
$opt[$gkey] = '--vertical-label "events per sec" --title "Interrupts and Context Switches on ' . $this->MACRO['DISP_HOSTNAME']. '"';
$ds_name[$gkey] = "Interrupts and Context Switches";
$def[$gkey] = rrd::def("ctxt", $ctxt['RRDFILE'], $ctxt['DS'], "AVERAGE");
$def[$gkey] .= rrd::def("num_intr", $num_intr['RRDFILE'], $num_intr['DS'], "AVERAGE");
$def[$gkey] .= "AREA:ctxt#00CF00:\"Context Switches (per second)\: \t\g\" ";
$def[$gkey] .= rrd::gprint("ctxt", array("LAST", "AVERAGE", "MAX"), '%6.2lf ');
$def[$gkey] .= "LINE1:num_intr#FF0000:\"Interrupts (per second) \: \t\g\" ";
$def[$gkey] .= rrd::gprint("num_intr", array("LAST", "AVERAGE", "MAX"), '%6.2lf ');
}
if (isset($processes) && isset($procs_running) && isset($procs_blocked)) {
$gkey++;
$opt[$gkey] = '--vertical-label "processes" --title "Process Scheduling on ' . $this->MACRO['DISP_HOSTNAME']. '"';
$ds_name[$gkey] = "Process Scheduling";
$def[$gkey] = rrd::def("processes", $processes['RRDFILE'], $processes['DS'], "AVERAGE");
$def[$gkey] .= rrd::def("procs_running", $procs_running['RRDFILE'], $procs_running['DS'], "AVERAGE");
$def[$gkey] .= rrd::def("procs_blocked", $procs_blocked['RRDFILE'], $procs_blocked['DS'], "AVERAGE");
$def[$gkey] .= "AREA:processes#00CF00:\"Processes Forked Per Second\: \t\g\" ";
$def[$gkey] .= rrd::gprint("processes", array("LAST", "AVERAGE", "MAX"), '%6.2lf ');
$def[$gkey] .= "LINE1:procs_running#0000FF:\"Processes In Running State \: \t\g\" ";
$def[$gkey] .= rrd::gprint("procs_running", array("LAST", "AVERAGE", "MAX"), '%6.2lf ');
$def[$gkey] .= "LINE1:procs_blocked#FF0000:\"Processes Currently Blocked\: \t\g\" ";
$def[$gkey] .= rrd::gprint("procs_blocked", array("LAST", "AVERAGE", "MAX"), '%6.2lf ');
}
?>
I've mounted a cifs share, and sometimes the times do not show up in the output of "ls -l" or "ls -la", etc. I've found the times always show up with the following usage:
ls -l --time-style=+"%M %D:%H:%M"
ls --full-time
There are other methods that show the time, as well. The main problem is that I can't find a way for the script to measure "file ages" properly due to the issue in the mounted directory.
Argument "v6.0.1" isn't numeric in numeric lt (<) at /usr/lib64/nagios/plugins/check_snmp_attributes.pl line 1177.
I fixed this by changing the '<' to 'lt' but I am unsure if this breaks the comparison in older versions if gives a numeric value.
I did some changes to get better time values (not only seconds):
#!/usr/bin/perl
#
# ============================== SUMMARY =====================================
#
# Program : check_files.pl
# Version : 0.422
# Date : Okt 20, 2017
# Author : William Leibzon - [email protected]
# Summary : This is a nagios plugin that counts files in a directory and
# checks their age an size. Various thresholds on this can be set.
# Licence : GPL - summary below, full text at http://www.fsf.org/licenses/gpl.txt
#
# =========================== PROGRAM LICENSE ================================
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GnU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# ===================== INFORMATION ABOUT THIS PLUGIN ========================
#
# This is a nagios plugin that checks number of files of specified type
# in a directory and can give an error if there are too few or too few.
# It can also check files age, file size and set thresholds based on these
# parameters such as report an error if files are too old.
#
# This program is written and maintained by:
# William Leibzon - william(at)leibzon.org
#
# =============================== SETUP NOTES ================================
#
# List of files to check are specified with -F option. These should be
# specified in a way you'd specify files for ls, so for example to check
# all perl files you use "*.pl" which is specified as:
# $ ./check_files.pl -L Files -F '*.pl' -w 4 -c 7
# (above will give a warning if there are > 4 *.pl files and critical alert if > 7)
#
# You can specify more than one file type to check, for example:
# $ ./check_files.pl -L Files -F '*.pl,*.sh' -w 4,3 -c 7,5
# (above will give a warning if there are more than 4 .pl or more than 3 *.sh files
# and CRITICAL alert if there are more than 7 .pl or more than 5 *.sh files)
#
# And these are examples provided by Patrick Bailat for options he added:
# Compute the sum size of files:
# $ ./check_files.pl -D /opt/oradata -F "t" -f -S -H "10.0.0.1"
# OK - Sum of file sizes is 3897 octet, 2 t files found | 't'=2 size_sum=3897o
# Search largest file:
# $ ./check_files.pl -D /opt/oradata -F "t" -f -s -H "10.0.0.1"
# OK - Largest size file is 3896 octet, 2 t files found | 't'=2 size_largest=3896o size_smallest=1o
#
# About Threhold Format:
#
# Warning and critical levels are specified with '-w' and '-c' and each one
# must have exactly same number of values (separated by ',') as number of
# file type checks specified with '-F'. Any values you dont want
# to compare you specify as ~. There are also number of other one-letter
# modifiers that can be used before actual data value to direct how data is
# to be checked. These are as follows:
# > : issue alert if data is above this value (default)
# < : issue alert if data is below this value
# = : issue alert if data is equal to this value
# ! : issue alert if data is NOT equal to this value
#
# Supported are also two specifications of range formats:
# number1:number2 issue alert if data is OUTSIDE of range [number1..number2]
# i.e. alert if data<$number1 or data>$number2
# @number1:number2 issue alert if data is WITHIN range [number1..number2]
# i.e. alert if data>=$number and $data<=$number2
#
# A special modifier '^' can also be used to disable checking that warn values
# are less than (or greater than) critical values (it is rarely needed).
#
# Additional Options:
#
# You can check file age with '--age' option which allows to set threshold
# if any file (in any of the file specs given with -F) is older than specified
# number of seconds. The option either takes one number separated by ',' for
# WARNING and CRITICAL alerts. If you want only CRITICAL specify WARNING as ~.
# For example -a '~,60' would give CRITICAL alert if any file is older than minute
#
# Just '-a' will show how old found files are which was the behavior prior to 0.36
# version even if -a was not given as an option.
#
# You can also check file size with '--size' option which allows to set threshold
# if any file (in any of the file specs given with -F) is larger than specified
# number of octets (bytes). The option either takes one number separated by ','
# for WARNING and CRITICAL alerts. If you want only CRITICAL specify WARNING as ~.
# For example -s '~,60' would give CRITICAL alert if any file is larger than 60
# octets (bytes)
#
# If you want performance output then use '-f' option. The plugin will then
# output number of files of each type and age of oldest and newest files.
#
# Execution Options:
#
# This plugin checks list of files by executing 'ls' on a local system where
# it is run. It can also execute ls on a remote system or process the output
# from ls command executed through some other plugin. Options -C, -H and -I
# are used to specify how and where to execute 'ls' and process results.
#
# With -I the plugin will expect output from "ls -l" in standard input.
#
# With -C you specify actual shell command and it is executed by the plugin.
#
# With option -H plugin executes ls on a specified host using ssh, it is expected
# that you'd have proper keys for this option to work. This is simple option is
# basically a special case of -C and if you want something more complex use -C
#
# Note: I first wrote -C but found that -I is easier to use and cleaner as
# far as nagios command specification. Patrick Bailat added -H option.
#
# ========================== VERSION CHANGES AND TODO =========================
#
# [0.2] Apr 19, 2012 - First version written based on check_netstat.pl 0.351
# [0.3] Apr 21, 2012 - Added -l -r and -T options and fixed bugs
# [0.32] Apr 21, 2012 - Added -I as an alternative to -C
# [0.33] Apr 27, 2012 - Fixed bug with determining file ages
# [0.34] Jun 22, 2012 - Added better reporting of file age than just seconds
# [0.35] Aug 21, 2012 - Option '-T' was broken. Bug reported by Jeremy Mauro
# [0.36] Sep 20, 2012 - Made reporting of age optional only when -a option is given.
# This is a suggestion by Bernhard Eisenschmid
# [0.37] Jan 21, 2013 - Added -s option for check file size (Patrick Bailat)
# [0.38] Jan 22, 2013 - Added -S option for check sum of file size (Patrick Bailat)
# [0.39] Jan 23, 2013 - Added -H option for execute ls -l by ssh (Patrick Bailat)
# [0.40] Feb 10, 2013 - Documentation cleanup. New release.
# [0.41] Mar 23, 2013 - Fixed bug in parse_threshold function
# [0.416] May 3, 2013 - Fixed bugs reported by Joerg Heinemann that caused
# failures under embedded perl. Bugs were in
# open_shell_stream() and parse_lsline() functions
# [0.417] Jun 17, 2013 - More bug fixes that showed up with embedded perl
# [0.42] July 30, 2013 - Several bugs fixed. Main was git issue #36 by
# bradcavanagh when -l is used and no files in directory.
# [0.421] Aug 20, 2013 - More bug fixes for embedded perl, see issue #32
# [0.422] Okt 20, 2017 - More readable time output (Grischa Zengel)
#
# TODO: This plugin is using early threshold check code that became the base
# of Naglio library and should be updated to use the library later
#
# ========================== LIST OF CONTRIBUTORS =============================
#
# The following individuals have contributed code, patches, bug fixes and ideas to
# this plugin (listed in last-name alphabetical order):
#
# Patrick Bailat
# Vincent Besançon
# Bernhard Eisenschmid
# William Leibzon
# Jeremy Mauro
#
# Open source community is grateful for all your contributions.
#
# ========================== START OF PROGRAM CODE ============================
use strict;
use Getopt::Long;
use Date::Parse;
# Nagios specific
use lib "/usr/lib/nagios/plugins";
our $TIMEOUT;
our %ERRORS;
eval 'use utils qw(%ERRORS $TIMEOUT)';
if ($@) {
$TIMEOUT = 20;
%ERRORS = ('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
}
my $Version='0.421';
my $o_help= undef; # help option
my $o_timeout= 10; # Default 10s Timeout
my $o_verb= undef; # verbose mode
my $o_version= undef; # version info option
my $o_perf= undef; # Performance data option
my $o_files= undef; # What files(s) to check
my @o_filesLv= (); # array for above list
my @o_filesL= (); # array of regex based on above
my $o_warn= undef; # warning level option
my @o_warnLv= (); # array from warn options, before further processing
my @o_warnL= (); # array of warn options, each array element is an array of threshold spec
my $o_crit= undef; # Critical level option
my @o_critLv= (); # array of critical options before processing
my @o_critL= (); # array of critical options, each element is an array of threshold spec
my $o_dir= undef; # directory in which to check files
my $o_age= undef; # option to specify threshold of file age in seconds
my $o_age_warn= undef; # processed warning and critical thresholds for file age
my $o_age_crit= undef; # critical threshold for age
my $o_size= undef; # option to specify threshold of file size in octet
my $o_size_warn= undef; # processed warning and critical thresholds for file size
my $o_size_crit= undef; # critical threshold for size
my $o_sumsize= undef; # option to specify threshold of sum of file size in octet
my $o_sumsize_warn= undef; # processed warning and critical thresholds for sum of file size
my $o_sumsize_crit= undef; # critical threshold for sum of file size
my $o_recurse= undef; # recurse into subdirectories
my $o_filetype= undef; # option to look into only files or only directories
my $o_lsfiles= undef; # will cause ls to actually look for specified files
my $o_label= undef; # optional label
my $o_cmd= undef; # specify shell command here that does equivalent to 'ls -l'
my $o_stdin= undef; # instead of executing 'ls -l', expect this data from std input
my $o_host= undef; # optional hostadress execute ls -l by ssh
my $ls_pid= undef;
# For verbose output
sub verb { my $t=shift; print $t,"\n" if defined($o_verb) ; }
sub print_version { print "$0: $Version\n" };
sub print_usage {
print "Usage: $0 [-v] [-t <timeout>] -D <directory> -F <files to check> -w <warn level(s)> -c <crit level(s)> [-a [<warn age>,<crit age>]] [-s [<warn size>,<crit size>]] [-S [<warn size>,<crit size>]] [-f] [-r] [-l] [-T files|dir] [-L label] [-V] [-H <hostaddress> | -I | -C <cmd that does 'ls -l>']\n";
}
# Return true if arg is a number - in this case negative and real numbers are not allowed
sub isnum {
my $num = shift;
if ( $num =~ /^[+]?(\d*)$/ ) { return 1 ;}
return 0;
}
sub perf_name {
my $iname = shift;
$iname =~ s/'\/\(\)/_/g; #' get rid of special characters in performance description name
return "'".$iname."'";
}
sub todebugstr {
my $in = shift;
return 'undef' if !defined($in);
return $in;
}
# help function used when checking data against critical and warn values
sub check_threshold {
my ($attrib, $data, $th_array,$date) = @_;
my $mod = $th_array->[0];
my $lv1 = $th_array->[1];
my $lv2 = $th_array->[2];
my $xlv1 = $date ? readable_time($lv1) : $lv1;
my $xlv2 = $date ? readable_time($lv2) : $lv2;
my $xdata = $date ? readable_time($data) : $data;
# verb("debug check_threshold: $mod : ".(defined($lv1)?$lv1:'')." : ".(defined($lv2)?$lv2:''));
return "" if !defined($lv1) || ($mod eq '' && $lv1 eq '');
return " " . $attrib . " is " . $xdata . " (equal to $xlv1)" if $mod eq '=' && $data eq $lv1;
return " " . $attrib . " is " . $xdata . " (not equal to $xlv1)" if $mod eq '!' && $data ne $lv1;
return " " . $attrib . " is " . $xdata . " (more than $xlv1)" if $mod eq '>' && $data>$lv1;
return " " . $attrib . " is " . $xdata . " (more than $xlv2)" if $mod eq ':' && $data>$lv2;
return " " . $attrib . " is " . $xdata . " (more than or equal $xlv1)" if $mod eq '>=' && $data>=$lv1;
return " " . $attrib . " is " . $xdata . " (less than $xlv1)" if ($mod eq '<' || $mod eq ':') && $data<$lv1;
return " " . $attrib . " is " . $xdata . " (less than or equal $xlv1)" if $mod eq '<=' && $data<=$lv1;
return " " . $attrib . " is " . $xdata . " (in range $xlv1..$xlv2)" if $mod eq '@' && $data>=$lv1 && $data<=$lv2;
return "";
}
# this is a help function called when parsing threshold options data
sub parse_threshold {
my $thin = shift;
# link to an array that holds processed threshold data
# array: 1st is type of check, 2nd is value2, 3rd is value2, 4th is option, 5th is nagios spec string representation for perf out
my $th_array = [ '', undef, undef, '', '' ];
my $th = $thin;
my $at = '';
$at = $1 if $th =~ s/^(\^?[@|>|<|=|!]?~?)//; # check mostly for my own threshold format
$th_array->[3]='^' if $at =~ s/\^//; # deal with ^ option
$at =~ s/~//; # ignore ~ if it was entered
if ($th =~ /^\:([-|+]?\d+\.?\d*)/) { # :number format per nagios spec
$th_array->[1]=$1;
$th_array->[0]=($at !~ /@/)?'>':'<=';
$th_array->[5]=($at !~ /@/)?('~:'.$th_array->[1]):($th_array->[1].':');
}
elsif ($th =~ /([-|+]?\d+\.?\d*)\:$/) { # number: format per nagios spec
$th_array->[1]=$1;
$th_array->[0]=($at !~ /@/)?'<':'>=';
$th_array->[5]=($at !~ /@/)?'':'@';
$th_array->[5].=$th_array->[1].':';
}
elsif ($th =~ /([-|+]?\d+\.?\d*)\:([-|+]?\d+\.?\d*)/) { # nagios range format
$th_array->[1]=$1;
$th_array->[2]=$2;
if ($th_array->[1] > $th_array->[2]) {
print "Incorrect format in '$thin' - in range specification first number must be smaller then 2nd\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
$th_array->[0]=($at !~ /@/)?':':'@';
$th_array->[5]=($at !~ /@/)?'':'@';
$th_array->[5].=$th_array->[1].':'.$th_array->[2];
}
if (!defined($th_array->[1])) {
$th_array->[0] = ($at eq '@')?'<=':$at;
$th_array->[1] = $th;
$th_array->[5] = '~:'.$th_array->[1] if ($th_array->[0] eq '>' || $th_array->[0] eq '>=');
$th_array->[5] = $th_array->[1].':' if ($th_array->[0] eq '<' || $th_array->[0] eq '<=');
$th_array->[5] = '@'.$th_array->[1].':'.$th_array->[1] if $th_array->[0] eq '=';
$th_array->[5] = $th_array->[1].':'.$th_array->[1] if $th_array->[0] eq '!';
}
if ($th_array->[0] =~ /[>|<]/ && !isnum($th_array->[1])) {
print "Numeric value required when '>' or '<' are used !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# verb("debug parse_threshold: $th_array->[0] and $th_array->[1]");
$th_array->[0] = '=' if !$th_array->[0] && !isnum($th_array->[1]) && $th_array->[1] ne '';
if (!$th_array->[0] && isnum($th_array->[1])) { # this is just the number by itself, becomes 0:number check per nagios guidelines
$th_array->[2]=$th_array->[1];
$th_array->[1]=0;
$th_array->[0]=':';
$th_array->[5]=$th_array->[2];
}
return $th_array;
}
# this function checks that for numeric data warn threshold is within range of critical threshold
# where within range depends on actual threshold spec and normally just means less
sub threshold_specok {
my ($warn_thar,$crit_thar) = @_;
return 0 if (defined($warn_thar->[1]) && !isnum($warn_thar->[1])) || (defined($crit_thar->[1]) && !isnum($crit_thar->[1]));
return 1 if defined($warn_thar) && defined($warn_thar->[1]) &&
defined($crit_thar) && defined($crit_thar->[1]) &&
isnum($warn_thar->[1]) && isnum($crit_thar->[1]) &&
$warn_thar->[0] eq $crit_thar->[0] &&
(!defined($warn_thar->[3]) || $warn_thar->[3] !~ /\^/) &&
(!defined($crit_thar->[3]) || $crit_thar->[3] !~ /\^/) &&
(($warn_thar->[1]>$crit_thar->[1] && ($warn_thar->[0] =~ />/ || $warn_thar->[0] eq '@')) ||
($warn_thar->[1]<$crit_thar->[1] && ($warn_thar->[0] =~ /</ || $warn_thar->[0] eq ':')) ||
($warn_thar->[0] eq ':' && $warn_thar->[2]>=$crit_thar->[2]) ||
($warn_thar->[0] eq '@' && $warn_thar->[2]<=$crit_thar->[2]));
return 0; # return with 0 means specs check out and are ok
}
sub help {
print "\nFile(s) Age and Count Monitor Plugin for Nagios version ",$Version,"\n";
print " by William Leibzon - william(at)leibzon.org\n\n";
print_usage();
print <<EOD;
-h, --help
print this help message
-V, --version
prints version number
-t, --timeout=INTEGER
timeout for command to finish (Default : 5)
-L, --label
output label (what prints first on status line)
-v, --verbose
print extra debugging information
File and Directory Selection options:
-F, --files=STR[,STR[,STR[..]]]
Which files to check. What is here is similar to what you use for listing
file with ls i.e. *.temp would look for all temp files. This is converted
to a regex and NOT an actual ls command input, so some errors are possible.
-D, --dir=<STR>
Directory name in which to check files. If this is specifies all file names
given in -F will be relative to this directory.
-T, --filetype='files'|'dir'
Allows to specify if we should count only files or only directories.
Default is to count both and ignore file type.
-r, --recurse
When present ls will do 'ls -r' and recursive check in subdirectories
-l, --lsfiles
When present this adds specified file spec to ls. Now ls will list
only files you specified with -F where as by default 'ls -l' will
list all files in directory and choose some with regex. This option
should be used if there are a lot of files in a directory.
WARNING: using this option will cause -r not to work on most systems
Execution Options:
-C, --cmd=STR
By default the plugin will chdir to specified directory, do 'ls -l'
and parse results. Here you can specify alternative cmd to execute
that provides the data. This is used, for example, when files are
to be checked on a remote system, in which case here you could be
using 'ssh'.
-I, --stdin
Instead of executing "ls -l" directory or command specified with -C
plugin expects to get results in standard input. This is basically an
alternative to -C which may not work in all cases
-H, --hostaddress=<STR>
This option followed by the IP address or the server name execute "ls"
on the remote server with ssh. Beware the script must be run with an account
that has its public key to the remote server.
This option does not work with the -C option
Threshold Checks and Performance Data options:
-f, --perfparse
Give number of files and file oldest file age in perfout
-w, --warn=STR[,STR[,STR[..]]]
Warning level(s) for number of files - must be a number
Warning values can have the following prefix modifiers:
> : warn if data is above this value (default)
< : warn if data is below this value
= : warn if data is equal to this value
! : warn if data is not equal to this value
~ : do not check this data (must be by itself)
^ : this disables checks that warning is less than critical
Threshold values can also be specified as range in two forms:
num1:num2 - warn if data is outside range i.e. if data<num1 or data>num2
\@num1:num2 - warn if data is in range i.e. data>=num1 && data<=num2
-c, --crit=STR[,STR[,STR[..]]]
Critical level(s) (if more than one file spec, must have multiple values)
Critical values can have the same prefix modifiers as warning, except '^'
-a, --age[=WARN[,CRIT]]
Show file age if no WARN/CRIT threshold parameter specified.
Check to make sure files are not older than the specified threshold(s).
This number is in seconds. Also supports same extended spec as -w and -c
-s, --size[=WARN[,CRIT]]
Show file size if no WARN/CRIT threshold parameter specified.
Check to make sure files are not larger than the specified threshold(s).
This number is in octet/byte. Also supports same extended spec as -w and -c
-S, --sumsize[=WARN[,CRIT]]
Show sum of file sizes if no WARN/CRIT threshold parameter specified.
Check to make sure sum of file sizes are not larger than the specified threshold(s).
This number is in octet/byte. Also supports same extended spec as -w and -c
EOD
}
sub check_options {
my $i;
Getopt::Long::Configure ("bundling");
GetOptions(
'v' => \$o_verb, 'verbose' => \$o_verb,
'h' => \$o_help, 'help' => \$o_help,
't:i' => \$o_timeout, 'timeout:i' => \$o_timeout,
'V' => \$o_version, 'version' => \$o_version,
'L:s' => \$o_label, 'label:s' => \$o_label,
'c:s' => \$o_crit, 'crit:s' => \$o_crit,
'w:s' => \$o_warn, 'warn:s' => \$o_warn,
'f' => \$o_perf, 'perfparse' => \$o_perf,
'F:s' => \$o_files, 'files:s' => \$o_files,
'a:s' => \$o_age, 'age:s' => \$o_age,
's:s' => \$o_size, 'size:s' => \$o_size,
'S:s' => \$o_sumsize, 'sumsize:s' => \$o_sumsize,
'D:s' => \$o_dir, 'dir:s' => \$o_dir,
'C:s' => \$o_cmd, 'cmd:s' => \$o_cmd,
'r' => \$o_recurse, 'recurse' => \$o_recurse,
'l' => \$o_lsfiles, 'lsfiles' => \$o_lsfiles,
'T:s' => \$o_filetype, 'filetype:s' => \$o_filetype,
'I' => \$o_stdin, 'stdin' => \$o_stdin,
'H:s' => \$o_host, 'hostaddress:s' => \$o_host,
);
if (defined($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}; }
if (defined($o_version)) { print_version(); exit $ERRORS{"UNKNOWN"}; }
@o_filesLv=split(/,/,$o_files) if defined($o_files);
if (!defined($o_files) || scalar(@o_filesLv)==0) {
print "You must specify files to check on with '-F'\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
@o_filesLv=split(/,/, $o_files);
for (my $i=0; $i<scalar(@o_filesLv); $i++) {
$o_filesL[$i] = parse_filespec($o_filesLv[$i]);
verb("Translated filespec '".$o_filesLv[$i]."' to regex '".$o_filesL[$i]."'");
}
if (defined($o_warn) || defined($o_crit)) {
@o_filesLv=split(/,/, $o_files);
@o_warnLv=split(/,/ ,$o_warn) if defined($o_warn);
@o_critLv=split(/,/ ,$o_crit) if defined($o_crit);
if (scalar(@o_warnLv)!=scalar(@o_filesLv) || scalar(@o_critLv)!=scalar(@o_filesLv)) {
if (scalar(@o_warnLv)==0 && scalar(@o_critLv)==scalar(@o_filesLv)) {
verb('Only critical value check is specified - setting warning to ~');
for($i=0;$i<scalar(@o_filesLv);$i++) { $o_warnLv[$i]='~'; }
}
elsif (scalar(@o_critLv)==0 && scalar(@o_warnLv)==scalar(@o_filesLv)) {
verb('Only warning value check is specified - setting critical to ~');
for($i=0;$i<scalar(@o_filesLv);$i++) { $o_critLv[$i]='~'; }
}
else {
printf "Number of specified warning levels (%d) and critical levels (%d) must be equal to the number checks specified at '-F' (%d). If you need not set threshold specify it as '~'\n", scalar(@o_warnLv), scalar(@o_critLv), scalar(@o_filesL);
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
for (my $i=0; $i<scalar(@o_filesLv); $i++) {
$o_warnL[$i] = parse_threshold($o_warnLv[$i]);
$o_critL[$i] = parse_threshold($o_critLv[$i]);
if (threshold_specok($o_warnL[$i],$o_critL[$i])) {
print "Problem with warn threshold '".$o_warnL[$i][5]."' and/or critical threshold '".$o_critL[$i][5]."'\n";
print "All warning and critical values must be numeric or ~. Warning must be less then critical\n";
print "or greater then when '<' is used or within or outside of range for : and @ specification\n";
print "Note: to override less than check prefix warning value with ^\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
}
if (defined($o_age)) {
my @agetemp = split(',',$o_age);
$o_age_warn = parse_threshold($agetemp[0]) if defined($agetemp[0]) && $agetemp[0] ne '';
$o_age_crit = parse_threshold($agetemp[1]) if defined($agetemp[1]) && $agetemp[1] ne '';
}
if (defined($o_size)) {
my @sizetemp = split(',',$o_size);
$o_size_warn = parse_threshold($sizetemp[0]) if defined($sizetemp[0]) && $sizetemp[0] ne '';
$o_size_crit = parse_threshold($sizetemp[1]) if defined($sizetemp[1]) && $sizetemp[1] ne '';
}
if (defined($o_sumsize)) {
my @sumsizetemp = split(',',$o_sumsize);
$o_sumsize_warn = parse_threshold($sumsizetemp[0]) if defined($sumsizetemp[0]) && $sumsizetemp[0] ne '';
$o_sumsize_crit = parse_threshold($sumsizetemp[1]) if defined($sumsizetemp[1]) && $sumsizetemp[1] ne '';
}
if (defined($o_filetype)) {
$o_filetype = lc $o_filetype;
$o_filetype = 'file' if $o_filetype eq 'files';
$o_filetype = 'dir' if $o_filetype eq 'dirs';
if ($o_filetype ne 'file' && $o_filetype ne 'dir') {
print "Filetype must be one word - either 'file' or 'dir'\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
if ((defined($o_stdin) && defined($o_cmd)) ||
(defined($o_stdin) && defined($o_host)) ||
(defined($o_host) && defined($o_cmd))) {
print "Can use only one of -C or -I or -H\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
sub parse_filespec {
my $spec = shift;
$spec =~ s/\./\\\./g;
$spec =~ s/\?/\.\?/g;
$spec =~ s/\*/\.\*/g;
return $spec;
}
# ls -l line example:
# -rwxr-xr-x 1 WLeibzon users 21747 Apr 20 23:04 check_files.pl
sub parse_lsline {
my $line = shift;
my @parsed = split (/\s+/, $line);
my %ret = ('type' => 'unset');
# parse file mode into std number
if (defined($parsed[0]) && $parsed[0] =~ /([-d])(.{3})(.{3})(.{3})/) {
my ($file_type,$mod_user, $mod_group, $mod_all) = ($1,$2,$3,$4);
if ($file_type eq 'd') {
$ret{'type'}='dir';
}
else {
$ret{'type'}='file';
}
$ret{'mode'} = 0;
$ret{'mode'} += 400 if $mod_user =~ /r/;
$ret{'mode'} += 200 if $mod_user =~ /w/;
$ret{'mode'} += 100 if $mod_user =~ /x/;
$ret{'mode'} += 40 if $mod_group =~ /r/;
$ret{'mode'} += 20 if $mod_group =~ /w/;
$ret{'mode'} += 10 if $mod_group =~ /x/;
$ret{'mode'} += 4 if $mod_all =~ /r/;
$ret{'mode'} += 2 if $mod_all =~ /w/;
$ret{'mode'} += 1 if $mod_all =~ /x/;
$ret{'nfiles'} = $parsed[1] if defined($parsed[1]); # number of files, dir start with 2
$ret{'user'} = $parsed[2] if defined($parsed[2]);
$ret{'group'} = $parsed[3] if defined($parsed[3]);
$ret{'size'} = $parsed[4] if defined($parsed[4]);
$ret{'time_line'} = $parsed[5].' '.$parsed[6].' '.$parsed[7] if defined($parsed[5]) && defined($parsed[6]) && defined($parsed[7]);
$ret{'filename'} = $parsed[8] if defined($parsed[8]);
$ret{'time'} = str2time($ret{'time_line'}) if defined($ret{'time_line'});
}
elsif ($line =~ /No such file or directory/) {
$ret{'nofilesfound'}=1;
}
return \%ret;
}
sub div_mod { return int( $_[0]/$_[1]) , ($_[0] % $_[1]); }
sub readable_time {
my $total_sec = shift;
my ($sec,$mins,$hrs,$days);
($mins,$sec) = div_mod($total_sec,60);
($hrs,$mins) = div_mod($mins,60);
($days,$hrs) = div_mod($hrs,24);
my $txtout="";
$txtout .= "$days days " if $days>0;
$txtout .= "$hrs hours " if $hrs>0;
$txtout .= "$mins minutes " if $mins>0 && ($days==0 || $hrs==0);
$txtout .= "$sec seconds" if ($sec>0 || $mins==0) && ($hrs==0 && $days==0);
return $txtout;
}
sub open_shell_stream {
my $shell_command_ref = shift;
my $cd_dir=undef;
my $shell_command=undef;
if (defined($o_stdin)) {
$shell_command = "<stdin>";
$$shell_command_ref = $shell_command if defined($shell_command_ref);
return \*STDIN;
}
else {
if ($o_dir) {
if (not defined($o_host)) {
if (!chdir($o_dir)) {
print "UNKNOWN ERROR - could not chdir to $o_dir - $!";
exit $ERRORS{'UNKNOWN'};
} else {
verb("Changed to directory '".$o_dir."'");
}
} else {
$cd_dir="\"cd ".$o_dir." && ";
}
}
if (defined($o_cmd)) {
verb("Command Specified: ".$o_cmd);
$shell_command=$o_cmd;
} else {
if(defined($o_host)) {
$shell_command = "ssh -o BatchMode=yes -o ConnectTimeout=30 ".$o_host." ";
}
else {
$shell_command = "";
}
$shell_command .= $cd_dir if defined($cd_dir);
$shell_command .= "LANG=C ls -l";
verb("Command: ".$shell_command);
}
$shell_command .= " -R" if defined($o_recurse);
$shell_command .= " ".join(" ",@o_filesLv) if defined($o_lsfiles);
$shell_command .= "\"" if defined($cd_dir);
# I would have preferred open3 [# if (!open3($cin, $cout, $cerr, $shell_command))]
# but there are problems when using it within nagios embedded perl
verb("Executing ".$shell_command." 2>&1");
$ls_pid=open(SHELL_DATA, "$shell_command 2>&1 |");
if (!$ls_pid) {
print "UNKNOWN ERROR - could not execute $shell_command - $!";
exit $ERRORS{'UNKNOWN'};
}
$$shell_command_ref = $shell_command if defined($shell_command_ref);
return \*SHELL_DATA;
}
return undef; # it should never get here
}
# Get the alarm signal (just in case timeout screws up)
$SIG{'ALRM'} = sub {
print ("ERROR: Alarm signal (Nagios time-out)\n");
kill 9, $ls_pid if defined($ls_pid);
exit $ERRORS{"UNKNOWN"};
};
########## MAIN ##############
check_options();
verb("check_files.pl plugin version ".$Version);
# Check global timeout if something goes wrong
if (defined($TIMEOUT)) {
verb("Alarm at ".($TIMEOUT+10));
alarm($TIMEOUT+10);
} else {
verb("no timeout defined : $o_timeout + 10");
alarm ($o_timeout+10);
}
# next part of the code builds list of attributes to be retrieved
my $statuscode = "OK";
my $statusinfo = "";
my $statusdata = "";
my $perfdata = "";
my $chk = "";
my $i;
my $shell_command = "";
my $nlines=0;
my @ls=();
my $oldest_filetime=undef;
my $oldest_filename=undef;
my $newest_filetime=undef;
my $newest_filename=undef;
my $smallest_filesize=undef;
my $smallest_filesizename=undef;
my $largest_filesize=undef;
my $largest_filesizename=undef;
my @nmatches=();
my $READTHIS=undef;
my $matched=0;
my $temp;
my $sum_filesize=0;
$READTHIS = open_shell_stream(\$shell_command);
# go through each line
while (<$READTHIS>) {
chomp($_);
$ls[$nlines]=parse_lsline($_);
# $ls[$nlines]{'ls_text'}=$_;
verb('got line: '.$_);
$temp=""; # these 3 lines are all for debug output
$temp .= ' '.$_.'='. $ls[$nlines]{$_} foreach (keys %{$ls[$nlines]});
verb (" processed:".$temp);
if (defined($ls[$nlines]{'filename'}) && (!defined($o_filetype) ||
(defined($o_filetype) && $ls[$nlines]{'type'} eq $o_filetype))) {
$matched=0;
for (my $i=0; $i<scalar(@o_filesL); $i++) {
if ($ls[$nlines]{'filename'} =~ /$o_filesL[$i]/) {
$nmatches[$i] = 0 if !defined($nmatches[$i]);
$nmatches[$i]++;
verb(" file matches regex '".$o_filesL[$i]."' for file spec '".$o_filesLv[$i]."'");
$matched=1;
}
}
if ($matched==1 && defined($ls[$nlines]{'time'})) {
if (!defined($newest_filetime) || $ls[$nlines]{'time'}>$newest_filetime) {
$newest_filetime=$ls[$nlines]{'time'};
$newest_filename=$ls[$nlines]{'filename'};
}
if (!defined($oldest_filetime) || $ls[$nlines]{'time'}<$oldest_filetime) {
$oldest_filetime=$ls[$nlines]{'time'};
$oldest_filename=$ls[$nlines]{'filename'};
}
}
if ($matched==1 && defined($ls[$nlines]{'size'})) {
$sum_filesize += $ls[$nlines]{'size'};
if (!defined($largest_filesize) || $ls[$nlines]{'size'}>$largest_filesize) {
$largest_filesize=$ls[$nlines]{'size'};
$largest_filesizename=$ls[$nlines]{'filename'};
}
if (!defined($smallest_filesize) || $ls[$nlines]{'size'}<$smallest_filesize) {
$smallest_filesize=$ls[$nlines]{'size'};
$smallest_filesizename=$ls[$nlines]{'filename'};
}
}
}
$nlines++;
}
if (defined($ls[0]{'nofilesfound'}) && $ls[0]{'nofilesfound'}) {
close($READTHIS) if defined($o_stdin);
$nlines=1;
}
else {
if (!defined($o_stdin) && defined($READTHIS) && !close($READTHIS)) {
print "UNKNOWN ERROR - execution of $shell_command resulted in an error $? - $!";
exit $ERRORS{'UNKNOWN'};
}
if ($nlines eq 0) {
print "UNKNOWN ERROR - did not receive any results";
exit $ERRORS{'UNKNOWN'};
}
}
# Check time
my $tnow = time();
verb("Date ".$tnow." Oldest_filetime: ".todebugstr($oldest_filetime)." Newest_filetime: ".todebugstr($newest_filetime));
my $oldest_secold=$tnow-$oldest_filetime if defined($oldest_filetime);
my $newest_secold=$tnow-$newest_filetime if defined($newest_filetime);
verb("Oldest file has age of ".$oldest_secold." seconds and newest ".$newest_secold." seconds") if defined($oldest_secold) && defined($newest_secold);
if (defined($o_age) && defined($oldest_secold)) {
if (defined($o_age_crit) && ($chk = check_threshold($oldest_filename." ",$oldest_secold,$o_age_crit,1)) ) {
$statuscode = "CRITICAL";
$statusinfo .= "," if $statusinfo;
$statusinfo .= $chk." old";
}
if (defined($o_age_warn) && ($chk = check_threshold($oldest_filename." ",$oldest_secold,$o_age_warn,1)) && $statuscode eq 'OK' ) {
$statuscode = "WARNING" if $statuscode eq "OK";
$statusinfo .= "," if $statusinfo;
$statusinfo .= $chk." old";
}
if ($statuscode eq 'OK') {
$statusdata .= "," if ($statusdata);
$statusdata .= " Oldest timestamp is ".readable_time($oldest_secold)." old";
}
}
# Check size
verb("Largest file has size of ".$largest_filesize." octet and smallest ".$smallest_filesize." octet");
if (defined($o_size) && defined($largest_filesize)) {
my $flag_data=0;
if (defined($o_size_crit) && ($chk = check_threshold($largest_filesizename." ",$largest_filesize,$o_size_crit)) ) {
$flag_data=1;
$statuscode = "CRITICAL";
$statusinfo .= "," if $statusinfo;
$statusinfo .= $chk." bytes";
}
if (defined($o_size_warn) && ($chk = check_threshold($largest_filesizename." ",$largest_filesize,$o_size_warn)) && ($statuscode eq 'OK' || $statuscode eq 'WARNING') ) {
$flag_data=1;
$statuscode = "WARNING" if $statuscode eq "OK";
$statusinfo .= "," if $statusinfo;
$statusinfo .= $chk." bytes";
}
if ($flag_data==0) {
$statusdata .= "," if ($statusdata);
$statusdata .= " Largest size file is ".$largest_filesize." bytes";
}
}
# Check sum of file sizes
if (defined($o_sumsize) && $sum_filesize > 0) {
my $flag_data=0;
verb("Sum of file sizes is ".$sum_filesize." octet");
if (defined($o_sumsize_crit) && ($chk = check_threshold("Sum of file sizes ",$sum_filesize,$o_sumsize_crit)) ) {
$flag_data=1;
$statuscode = "CRITICAL";
$statusinfo .= "," if $statusinfo;
$statusinfo .= $chk." octet";
}
if (defined($o_sumsize_warn) && ($chk = check_threshold("Sum of file sizes ",$sum_filesize,$o_sumsize_warn)) && ($statuscode eq 'OK' || $statuscode eq 'WARNING') ) {
$flag_data=1;
$statuscode="WARNING" if $statuscode eq "OK";
$statusinfo .= "," if $statusinfo;
$statusinfo .= $chk." bytes ";
}
if ($flag_data==0) {
$statusdata .= "," if ($statusdata);
$statusdata .= " Sum of file sizes is ".$sum_filesize." bytes";
}
}
# loop to check if warning & critical attributes are ok
for ($i=0;$i<scalar(@o_filesL);$i++) {
$nmatches[$i]=0 if !defined($nmatches[$i]);
if ($chk = check_threshold($o_filesLv[$i],$nmatches[$i],$o_critL[$i])) {
$statuscode = "CRITICAL";
$statusinfo .= "," if $statusinfo;
$statusinfo .= $chk;
} elsif ($chk = check_threshold($o_filesLv[$i],$nmatches[$i],$o_warnL[$i])) {
$statuscode="WARNING" if $statuscode eq "OK";
$statusinfo .= "," if $statusinfo;
$statusinfo .= $chk;
} else {
$statusdata .= "," if ($statusdata);
$statusdata .= " ".$nmatches[$i]." ". $o_filesLv[$i] ." files found";
}
$perfdata .= " ". perf_name($o_filesLv[$i]) ."=". $nmatches[$i] if defined($o_perf);
if (defined($o_perf) && defined($o_warnL[$i][5]) && defined($o_critL[$i][5])) {
$perfdata .= ';' if $o_warnL[$i][5] ne '' || $o_critL[$i][5] ne '';
$perfdata .= $o_warnL[$i][5] if $o_warnL[$i][5] ne '';
$perfdata .= ';'.$o_critL[$i][5] if $o_critL[$i][5] ne '';
}
}
# perffata for age
if (defined($o_perf) && defined($o_age)) {
$oldest_secold=0 if !defined($oldest_secold);
$newest_secold=0 if !defined($newest_secold);
$perfdata .= " age_oldest=".$oldest_secold."s";
$perfdata .= ';' if (defined($o_age_warn) && $$o_age_warn[5] ne '') || (defined($o_age_crit) && $$o_age_crit[5] ne '');
$perfdata .= $$o_age_warn[5] if defined($$o_age_warn[5]) && $$o_age_warn[5] ne '';
$perfdata .= ';'.$$o_age_crit[5] if defined($$o_age_crit[5]) && $$o_age_crit[5] ne '';
$perfdata .= " age_newest=".$newest_secold."s";
}
# perffata for size
if (defined($o_perf) && defined($o_size)) {
$largest_filesize=0 if !defined($largest_filesize);
$smallest_filesize=0 if !defined($smallest_filesize);
$perfdata .= " size_largest=".$largest_filesize."b";
$perfdata .= ';' if (defined($o_size_warn) && $$o_size_warn[5] ne '') || (defined($o_size_crit) && $$o_size_crit[5] ne '');
$perfdata .= $$o_size_warn[5] if defined($$o_size_warn[5]) && $$o_size_warn[5] ne '';
$perfdata .= ';'.$$o_size_crit[5] if defined($$o_size_crit[5]) && $$o_size_crit[5] ne '';
$perfdata .= " size_smallest=".$smallest_filesize."b";
}
# perffata for sum of file sizes
if (defined($o_perf) && defined($o_sumsize)) {
$perfdata .= " size_sum=".$sum_filesize."b";
$perfdata .= ';' if (defined($o_sumsize_warn) && $$o_sumsize_warn[5] ne '') || (defined($o_sumsize_crit) && $$o_sumsize_crit[5] ne '');
$perfdata .= $$o_sumsize_warn[5] if defined($$o_sumsize_warn[5]) && $$o_sumsize_warn[5] ne '';
$perfdata .= ';'.$$o_sumsize_crit[5] if defined($$o_sumsize_crit[5]) && $$o_sumsize_crit[5] ne '';
}
$o_label .= " " if $o_label ne '';
print $o_label . $statuscode;
print " -".$statusinfo if $statusinfo;
print " -".$statusdata if $statusdata;
print " |".$perfdata if $perfdata;
print "\n";
exit $ERRORS{$statuscode};
First off thanks for this great plugin. Almost wrote my own and this saved me a bunch of time. The issue I think I found has to do with maxmemory when using the mem_utilization option. I tested using K and M values for the -M maxmemory option and when I run the script it throws this error:
Argument "4000M" isn't numeric in multiplication (*) at ./check_redis.pl line 2550.
I looked at the code and it appears the section that converts K,M,G values to bytes is doing the math operation with the K,M or G still part of the number.
My quick hack to fix it was to change:
elsif ($o_totalmemory =~ /^(\d+K)/) {
$o_totalmemory = $1*1024;
}
To this:
elsif ($o_totalmemory =~ /^(\d+K)/) {
$o_totalmemory = $1;
$o_totalmemory =~ s/K//;
$o_totalmemory = $o_totalmemory*1024;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.