Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module to check the memory used/target ratio. #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions plugins-scripts/Classes/MSSQL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,36 @@ sub init {
label => 'batch_requests_per_sec',
value => $self->{batch_requests_per_sec},
);
} elsif ($self->mode =~ /^server::memoryusedtargetratio/) {
if ($self->version_is_minimum("9.x")) {
if (! defined ($self->{memory_used_target_ratio} = $self->fetchrow_array(q{
SELECT ROUND(100.0 * (
SELECT CAST([cntr_value] AS FLOAT)
FROM sys.dm_os_performance_counters
WHERE
[object_name] LIKE '%Memory Manager%'
AND [counter_name] = 'Total Server Memory (KB)'
) / (
SELECT CAST([cntr_value] AS FLOAT)
FROM sys.dm_os_performance_counters
WHERE
[object_name] LIKE '%Memory Manager%'
AND [counter_name] = 'Target Server Memory (KB)')
, 2)AS [Ratio]
}))) {
$self->add_unknown("got no memory_used_target_ratio from dm_os_sys_info");
}
}
if (! $self->check_messages()) {
$self->set_thresholds(warning => '90:', critical => '80:');
$self->add_message($self->check_thresholds($self->{memory_used_target_ratio}),
sprintf "Used Memory/Target Ratio %.2f%%", $self->{memory_used_target_ratio});
$self->add_perfdata(
label => 'memory_used_target_ratio',
value => $self->{memory_used_target_ratio},
uom => '%',
);
};
} elsif ($self->mode =~ /^server::totalmemory/) {
$self->get_perf_counters([
['total_server_memory', 'SQLServer:Memory Manager', 'Total Server Memory (KB)'],
Expand Down
6 changes: 6 additions & 0 deletions plugins-scripts/check_mssql_health.pl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@
alias => undef,
help => 'Initial compilations per second',
);
$plugin->add_mode(
internal => 'server::memoryusedtargetratio',
spec => 'memory-used-target-ratio',
alias => undef,
help => 'The amount of memory used / memory target',
);
$plugin->add_mode(
internal => 'server::totalmemory',
spec => 'total-server-memory',
Expand Down