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

new mode connected-sessions, modified connected-users #53

Open
wants to merge 1 commit 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
22 changes: 21 additions & 1 deletion plugins-scripts/Classes/ASE.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sub init {
$self->set_variable("maxpagesize", $self->fetchrow_array(
q{ SELECT @@MAXPAGESIZE }
));
if ($self->mode =~ /^server::connectedusers/) {
if ($self->mode =~ /^server::connectedsessions/) {
my $connectedusers = $self->fetchrow_array(q{
SELECT
COUNT(*)
Expand All @@ -26,6 +26,26 @@ sub init {
WHERE
hostprocess IS NOT NULL AND program_name != 'JS Agent'
});
if (! defined $connectedsessions) {
$self->add_unknown("unable to count connected sessions");
} else {
$self->set_thresholds(warning => 50, critical => 80);
$self->add_message($self->check_thresholds($connectedsessions),
sprintf "%d connected users", $connectedsessions);
$self->add_perfdata(
label => "connected_sessions",
value => $connectedsessions
);
}
} elsif ($self->mode =~ /^server::connectedusers/) {
my $connectedusers = $self->fetchrow_array(q{
SELECT
COUNT(DISTINCT loginame)
FROM
master..sysprocesses
WHERE
hostprocess IS NOT NULL AND program_name != 'JS Agent'
});
if (! defined $connectedusers) {
$self->add_unknown("unable to count connected users");
} else {
Expand Down
43 changes: 33 additions & 10 deletions plugins-scripts/Classes/MSSQL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ sub init {
$self->set_variable("ishadrenabled", $self->fetchrow_array(
q{ SELECT CAST(COALESCE(SERVERPROPERTY('IsHadrEnabled'), 0) as int) }
));
if ($self->mode =~ /^server::connectedusers/) {
my $connectedusers;
if ($self->mode =~ /^server::connectedsessions/) {
my $connectedsessions;
if ($self->get_variable("product") eq "ASE") {
$connectedusers = $self->fetchrow_array(q{
$connectedsessions = $self->fetchrow_array(q{
SELECT
COUNT(*)
FROM
Expand All @@ -41,7 +41,7 @@ sub init {
} else {
# http://www.sqlservercentral.com/articles/System+Tables/66335/
# user processes start at 51
$connectedusers = $self->fetchrow_array(q{
$connectedsessions = $self->fetchrow_array(q{
SELECT
COUNT(*)
FROM
Expand All @@ -50,17 +50,40 @@ sub init {
spid >= 51
});
}
if (! defined $connectedusers) {
$self->add_unknown("unable to count connected users");
if (! defined $connectedsessions) {
$self->add_unknown("unable to count connected sessions");
} else {
$self->set_thresholds(warning => 50, critical => 80);
$self->add_message($self->check_thresholds($connectedusers),
sprintf "%d connected users", $connectedusers);
$self->add_message($self->check_thresholds($connectedsessions),
sprintf "%d connected sessions", $connectedsessions);
$self->add_perfdata(
label => "connected_users",
value => $connectedusers
label => "connected_sessions",
value => $connectedsessions
);
}
} elsif ($self->mode =~ /^server::connectedusers/) {
my $connectedusers;
if ($self->get_variable("product") eq "ASE") {
$connectedusers = $self->fetchrow_array(q{
SELECT
COUNT(DISTINCT loginame)
FROM
master..sysprocesses
WHERE
hostprocess IS NOT NULL AND program_name != 'JS Agent'
});
} else {
# http://www.sqlservercentral.com/articles/System+Tables/66335/
# user processes start at 51
$connectedusers = $self->fetchrow_array(q{
SELECT
COUNT(DISTINCT loginame)
FROM
master..sysprocesses
WHERE
spid >= 51
});
}
} elsif ($self->mode =~ /^server::cpubusy/) {
if ($self->version_is_minimum("9.x")) {
if (! defined ($self->{secs_busy} = $self->fetchrow_array(q{
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 @@ -45,6 +45,12 @@
alias => undef,
help => 'Full table scans per second',
);
$plugin->add_mode(
internal => 'server::connectedsessions',
spec => 'connected-sessions',
alias => undef,
help => 'Number of currently open sessions',
);
$plugin->add_mode(
internal => 'server::connectedusers',
spec => 'connected-users',
Expand Down