Skip to content

Instantly share code, notes, and snippets.

@morgajel
Created May 11, 2015 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morgajel/170b6e6e0c17666c38a9 to your computer and use it in GitHub Desktop.
Save morgajel/170b6e6e0c17666c38a9 to your computer and use it in GitHub Desktop.
password not showing up in debug log (correct behavior, I think?)
object CheckCommand "check_mssql_health" {
import "plugin-check-command"
#command = "$USER1$/check_mssql_health --server $host.name$ --username Monitoring --password $mssqlCredential$ --offlineok --mode $ARG1$"
command =[ PluginMorgNagPlugDir + "/check_mssql_health"]
arguments = {
"--server" = "$address$"
"--password" = "$mssql_password$"
"--username" = "$mssql_username$"
"--mode" = "$mssql_mode$"
"--name" = "$mssql_name$"
"--warning" = "$mssql_warn$"
"--critical" = "$mssql_crit$"
"--offlineok" = {
set_if = "$mssql_offlineok$"
}
}
vars.mssql_username = "Monitoring"
}
const mssqlCredentials = "somethinggood"
[2015-05-11 12:55:19 -0400] information/ExternalCommandListener: Executing external command: [1431363319] SCHEDULE_FORCED_SVC_CHECK;sqlserver;sqlserver Page locks-timeouts;1431363319
[2015-05-11 12:55:19 -0400] notice/ExternalCommandProcessor: Rescheduling next check for service 'sqlserver Page locks-timeouts'
[2015-05-11 12:55:19 -0400] debug/IdoMysqlConnection: Query: INSERT INTO icinga_externalcommands (command_args, command_name, command_type, entry_time, instance_id) VALUES ('sqlserver;sqlserver Page locks-timeouts;1431363319', 'SCHEDULE_FORCED_SVC_CHECK', '54', FROM_UNIXTIME(1431363319), 1)
[2015-05-11 12:55:19 -0400] debug/CheckerComponent: Executing check for 'sqlserver!sqlserver Page locks-timeouts'
[2015-05-11 12:55:19 -0400] notice/Process: Running command '/opt/morgnagplug/check_mssql_health' '--critical' '30' '--mode' 'locks-timeouts' '--name' 'Page' '--server' '192.168.2.59' '--username' 'Monitoring' '--warning' '20': PID 31284
[2015-05-11 12:55:19 -0400] debug/CheckerComponent: Check finished for object 'sqlserver!sqlserver Page locks-timeouts'
[2015-05-11 12:55:19 -0400] notice/Process: PID 31284 ('/opt/morgnagplug/check_mssql_health' '--critical' '30' '--mode' 'locks-timeouts' '--name' 'Page' '--server' '192.168.2.59' '--username' 'Monitoring' '--warning' '20') terminated with exit code 2
[2015-05-11 12:55:19 -0400] debug/DbEvents: add service check history for 'sqlserver!sqlserver Page locks-timeouts'
[2015-05-11 12:55:19 -0400] debug/DbObject: Endpoint node: 'det1c7ut001.entregasystems.com' status update for 'sqlserver!sqlserver Page locks-timeouts'
apply Service "sqlserver _total locks-timeouts" to Host {
import "generic-service"
import "trendable"
check_command = "check_mssql_health"
max_check_attempts = 3
vars.mssql_username="Monitoring"
vars.mssql_password="$mssqlCredentials$"
#vars.ARG1 = "locks-timeouts --name _Total --warning=20 --critical=30"
vars.mssql_name = "_Total"
vars.mssql_mode = "locks-timeouts"
vars.mssql_warn = "20"
vars.mssql_crit = "30"
assign where "sqlserver2012" in host.groups
}
@morgajel
Copy link
Author

Running at the command line without and with a password:

[root@det1c7ut001:/var/log]# /opt/morgnagplug/check_mssql_health --critical=30 --mode=locks-timeouts --name=Page --server=192.168.2.59 --username=Monitoring --warning=20 
CRITICAL - cannot connect to 192.168.2.59. Please specify hostname or server, username and password
[root@det1c7ut001:/var/log]# /opt/morgnagplug/check_mssql_health --critical=30 --mode=locks-timeouts --name=Page --server=192.168.2.59 --username=Monitoring --warning=20  --password='somethinggood'
OK - 4.0734 lock timeouts / sec for Page | Page_lock_timeouts_per_sec=4.0734;20;30

@morgajel
Copy link
Author

Output displayed within icingaweb:

Plugin Output
CRITICAL - cannot connect to 192.168.2.59. Please specify hostname or server, username and password

@morgajel
Copy link
Author

icinga2 object list --name 'check_mssql_health'
Object 'check_mssql_health' of type 'CheckCommand':
% declared in '/etc/icinga2/conf.d/commands.conf', lines 294:1-294:40

  • __name = "check_mssql_health"
  • arguments
    % = modified in '/etc/icinga2/conf.d/commands.conf', lines 299:9-310:9
    • --critical = "$mssql_crit$"
    • --mode = "$mssql_mode$"
    • --name = "$mssql_name$"
    • --offlineok
      • set_if = "$mssql_offlineok$"
    • --password = "$mssql_password$"
    • --server = "$address$"
    • --username = "$mssql_username$"
    • --warning = "$mssql_warn$"
  • command = [ "/opt/morgnagplug/check_mssql_health" ]
    % = modified in '/etc/icinga2/conf.d/commands.conf', lines 297:5-297:60
  • env = null
  • execute
    % = modified in '/usr/share/icinga2/include/command.conf', lines 35:2-35:22
    • type = "Function"
  • name = "check_mssql_health"
  • templates = [ "check_mssql_health", "plugin-check-command" ]
    % = modified in '/etc/icinga2/conf.d/commands.conf', lines 294:1-294:40
    % = modified in '/usr/share/icinga2/include/command.conf', lines 34:1-34:44
  • timeout = 60
  • type = "CheckCommand"
  • vars = null
  • zone = ""

@morgajel
Copy link
Author

Final solution- Global variables don't need quotes or $;

            "--password" = "$mssql_password$"

should be
"--password" = mssqlCredentials

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment