I am trying to build a set of tests in a nagios install I have on ubuntu 16.04, that are based on the results of queries run against a MSSQL server else where on the network, at this time I struggling plugin that still has support.
Any suggestions of ways to do this would be appreciated
https://exchange.nagios.org/directory/Plugins/Databases/SQLServer/check_mssql/details
This plugin will do exactly what you want.
Download it and place the script in your plugin directory (usually /usr/local/nagios/libexec)
Make sure you have the proper dependencies installed. Ubuntu 16.04 should be:
sudo apt-get install php5-sybase freetds-common libsybdb5
And then set up your command definition:
define command{
command_name check_mssql_query
command_line $USER1$/check_mssql -H $HOSTADDRESS$ $ARG1$
}
Then add it as a service to whatever Host monitors the MSSQL server:
define service{
host_name mssql-server
service_description MSSQL Query 1
use local-service
check_command check_mssql_query!--username USERNAME --password PASSWORD --port PORT --instance INSTANCE --database DATABASE --query QUERY
register 1
}
I suggest reading through the help of the plugin itself with the command:
./check_mssql -h
It has a lot more helpful information. Good luck!
Related
I have a self hosted gitlab on ubuntu machine. I configure a linux container for it to run runner. Now, I am trying to write a configuration for my dotnet project to run unit test on this setup.
I get configuration to run dotnet application without database, and only part I got stuck is that I cannot get Database to load or connect through my test environment.
I get SQL Server linux container to run as service (I am guessing it is running). But I am not sure how I can load my database to it. I know I can do that using Docker Run. But I cannot figure it out how to run it here.
When I try to run "mssql-tools" as service I cannot get it's command to run as it is not install by default in dotnet image.
Here is my file.
image: microsoft/dotnet:latest
variables:
ACCEPT_EULA: Y
SA_PASSWORD: my_secure_password
MSSQL_PID: Developer
stages:
- test
before_script:
- "cd Source"
- "dotnet restore"
test:
stage: test
services:
- mcr.microsoft.com/mssql/server:2017-latest
- mcr.microsoft.com/mssql-tools
script:
- "cd ../Database"
- "docker run -it mcr.microsoft.com/mssql-tools"
- "sqlcmd -S . -U SA -P my_secure_password -i testdata_structure.sql"
- "exit"
- "cd ../Source"
- "dotnet build"
- "dotnet test"
"sqlcmd -S . -U SA -P my_secure_password -i testdata_structure.sql this command won't work in this setup as sqlcmd is not installed, but is one of service. I don't want to make a new image that has all pre-install. But use available stuff to work.
Not, sure if I am able to explain my issue and knowledge here. I am new, but I am reading and changing configuration from 2 days. I can get Linux based SQL Server to run with my app from local docker commands and stuff, but on Gitlab to run Unit Test I cannot get database to restore/get running and connect to application.
GitLab Services does not install commands or apps inside your container job, instead a Service is another container that is usually run in parallel to offer infrastructure services such as databases, cache, queues, etc.
if you want to have sqlcmd inside your container you must install it:
This is an extract from my pipeline, in this case my container is based on Alpine but you can find more ways here: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15
before_script:
- apk add curl
- apk add --no-cache gnupg
- curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.7.2.1-1_amd64.sig
- curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_17.7.1.1-1_amd64.sig
- curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.7.2.1-1_amd64.apk
- curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_17.7.1.1-1_amd64.apk
- curl https://packages.microsoft.com/keys/microsoft.asc | gpg --import -
- gpg --verify msodbcsql17_17.7.2.1-1_amd64.sig msodbcsql17_17.7.2.1-1_amd64.apk
- gpg --verify mssql-tools_17.7.1.1-1_amd64.sig mssql-tools_17.7.1.1-1_amd64.apk
- apk add --allow-untrusted msodbcsql17_17.7.2.1-1_amd64.apk
- apk add --allow-untrusted mssql-tools_17.7.1.1-1_amd64.apk
script:
- /opt/mssql-tools/bin/sqlcmd -S $DBC_SERVER -U $DBC_USER -P $DBC_PASSWORD -q "USE myTestDb; CREATE TABLE testGitlab (id int); SELECT * FROM testGitLab"
I end up using my custom Docker Image that has dotnetcore and Sqlcmd installed in it, I can use MsSQL Server as Service in gitlab configuration. (have to define SQL Server' hostname, as IP in same range as my server).
Not an idle answer, but workaround for me.
Firstly, sorry for my english.
I try to configure a probe in nagios for monitor log files and notify me when Nagios find string like "Exception" or "Error".
I use Nagios with Centreon.
So, when I execute my command :
$USER1$/check_log -F path/for/log.files -q /Exception/
Nagios return : "Log check error: Log file path/for/log.files does not exist!"
When i check in my server the path, the files exists, all (root, group and other) can read the file. So the problem doesn't seem to come of rights management.
The client for supervisor is a CentOS. I have already install nrpe client, and configure allowed host etc ...
I looked everywhere for someone who had the same error but find nothing.
If someone can help me, it would be so nice !
If you need further informations for help me, please, don't hesitate, i'm not sur that i'm explain in good way my problem.
Regards.
On Nagios server side, you must define something like this:
define service {
service_description service_name
host_name your_remote_hostname
use your_template
check_command ext_check!check_log!-f path/for/log.files -g /Exception/
}
In commands.cfg or in similar file on Nagios server:
define command{
command_name ext_check
command_line $USER1$/check_nrpe -t 30 -H $HOSTADDRESS$ -p 5666 -c $ARG1$ -a $ARG2$
}
On client/monitored host you must edit nrpe.cfg file:
command[check_log]=/opt/nagios/plugins/check_log $ARG1$
after that, you must restart nrpe service and reload Nagios configuration.
I installed Sqlserver on my Mac in a docker container, following the instructions from this article.
I run the container with Kitematic and managed to connect to the server using Navicat Essentials for SQl Server.
The server has four databases and I can create new ones, but, ideally, I would like to import an existing database as .bacpac.
The instructions from this answer have been of use to me in the past. Can I run something similar within the container? Or, more generally, is there a way to import a database in the container?
Hi all! We finally have a preview ready for sqlpackage that is built on dotnet core and is cross-platform! Below are the links to download from. They are evergreen links, i.e. each day a new build is uploaded. This way any checked in bug fix is available the next day. Included in the .zip file is the preview EULA.
linux
https://go.microsoft.com/fwlink/?linkid=873926
osx
https://go.microsoft.com/fwlink/?linkid=873927
windows
https://go.microsoft.com/fwlink/?linkid=873928
Release notes:
The /p:CommandTimeout parameter is hardcoded to 120
Build and deployment contributors are not supported
a. Need to move to .NET Core 2.1 where System.ComponentModel.Composition.dll is supported
b. Need to handle case-sensitive paths
SQL CLR UDT types are not supported.
a. This includes SQL Server Types SqlGeography, SqlGeometry, & SqlHierarchyId
Older .dacpac and .bacpac files that use Json serialization are not supported
Referenced .dacpacs (e.g. master.dacpac) may not resolve due to issues with case-sensitive file systems
For lack of a better method, please provide any feedback you have here on this GitHub issue.
Thanks for giving it a try and letting us know how it goes!
https://github.com/Microsoft/mssql-docker/issues/135#issuecomment-389245587
EDIT: I've made you a Docker image for this
https://hub.docker.com/r/samuelmarks/mssql-server-fts-sqlpackage-linux/
Example of setting up a container, creating a database, copying a .bacpac file over, and importing it into aforementioned database:
docker run -d -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 --name sqlfts0 samuelmarks/mssql-server-fts-sqlpackage-linux
docker exec -it sqlfts0 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourStrong!Passw0rd>' -Q 'CREATE DATABASE MyDb0'
docker cp ~/Downloads/foo.bacpac sqlfts0:/opt/downloads/foo.bacpac
docker exec -it sqlfts0 dotnet /opt/sqlpackage/sqlpackage.dll /tsn:localhost /tu:SA /tp:'<YourStrong!Passw0rd>' /A:Import /tdn:MyDb0 /sf:foo.bacpac
It looks like Microsoft has implemented support of this on sqlpackage, with documentation!
You will have to add sqlpackage to your container.
You can download it here. (optionally, direct link to linux package here, hopefully doesn't change)
The following are instructions for running this from a windows machine -- obviously it's the bare minimum to get it working. Please change passwords, and probably put this in a docker-compose.yml for re-use.
I unzip the above package into a folder 'c:\sqlpackage' (my windows docker run doesn't allow relative paths), and then mount that into the container with the bacpac, like such:
docker run -d -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Asdf1234" -v c:\sqlpackage:/opt/sqlpackage -v c:\yourdb.bacpac:/tmp/yourdb.bacpac -p 1433:1433 --name mssql-server-example microsoft/mssql-server-linux:2017-latest
here is what a *nix user could run alternatively:
docker run -d -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Asdf1234' -v ./sqlpackage:/opt/sqlpackage -v ./yourdb.bacpac:/tmp/yourdb.bacpac -p 1433:1433 --name mssql-server-example microsoft/mssql-server-linux:2017-latest
and finally, attach to your container and run:
/opt/sqlpackage/sqlpackage /a:Import /tsn:. /tdn:targetdbname /tu:sa /tp:Asdf1234 /sf:/tmp/yourdb.bacpac
After this, you should be able to connect with SSMS to localhost, username and password as you provide them above, and see 'targetdbname'! These are mostly notes I wrote for myself but I'm sure others could use them too.
You can use free Azure Data Studio from Microsoft. Once you have it installed, install the extension "Admin Pack for SQL Server" from Microsoft. Then you can import bacpac files with ease.
This is not a supported feature with a LINUX implementation it seems.
See this link.
I am looking for a little help in configuring NAGIOS for NRPE. I am quite new at Linux and seem to be having some trouble getting this working.
I am running Ubuntu 11.10 with the Nagios 3.3.1 core and Nagios plugins 1.4.15 running nrpe2.13
Currently I am trying to get the Nagios Exchange plugin check_be.exe to work with Nagios. I followed the check_be.txt for the setup on my nagios server and windows backup exec server.
Currently if I run
root#PERSES:/usr/local/nagios/libexec# ./check_nrpe -H 192.168.1.10 -t200 -c check_be
I will get
Job: Daily Backup, Success, Date:17/4/2012
From Nagios all I get is no output returned from plugin.
Windows.cfg has the following entry
# Service for Backup Exec agent
define service {
use template-backupexec
service_description BackupExec - Daily DAT backup ; specific display name, if you need
host_name cmbssrv.cmbs.local
}
Templates.cfg has this entry – I have tried to modify it to avoid the socket timeout
define service{
name template-backupexec
use generic-service
service_description BackupExec Job Check ; default display name in Nagios
check_command check_nrpe! -t 240 -c check_be ; same name as in the nsclient++ nsc.ini command defini$
normal_check_interval 60 ; your check intervals here
retry_check_interval 60
register 0 ; this is a template
}
Commands.cfg:
# 'check_nrpe' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDESS$ -p 5666 -v $ARG1$
}
Any ideas would be greatly appreciated
This looks wrong
check_command check_nrpe! -t 240 -c check_be
I think those extra arguments need to be in the define command block.
Also change the name of the check_command. You may confuse the check_nrpe executable command (runs in terminal) with your check_command of the same name (which is unknown to the terminal shell).
Here's a working example much like what you are doing.
On the main nagios machine:
define command {
command_name check_nrpe_cart
command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -p 6565 -c $ARG1$
}
define service{
use clientcritical
host_name cartbox
service_description email
normal_check_interval 15
check_command check_nrpe_cart!check_postfix
}
On cartbox in /etc/nagios/nrpe_local.cfg
command[check_postfix]=/usr/lib/nagios/plugins/check_procs -w 1:1 -c 1:1 -C master
You should read pdf from the following link you will get maximum posible answer
for NRPE NAGIOS comunication problem.
http://assets.nagios.com/downloads/nagiosxi/docs/NRPE_Troubleshooting_and_Common_Solutions.pdf
i can only find psql command, but can't find any other postgres commands or tools, can
anyone tell me how to create database and connect to it using the default postgres
shipped with mac lion?
only if it doesn't work ,i dont' want to install another postgres instance.
PostgreSQL will be started by Launchd, if configured so.
Look for /System/Library/LaunchDaemons/org.postgresql.postgres.plist, this is an XML file and you will need to modify some settings there, like listen_address.
Default location for the PGDATA files is /var/pgsql, also found in the plist file above.
Cluster is owned by the _postgres user, so to access the “tools”, you should execute them via the sudo -u _postgres … prefix, like: sudo -u _postgres pg_ctl -D /var/pgsql -w start
I highly recommend creating another role with superuser permissions, as _postgres is sharing password with the Administrator account of your Lion.
You can also use the Server Admin tools for Lion to control PostgreSQL and other services:
sudo serveradmin list
# look for postgres in the output
sudo serveradmin fullstatus postgres
sudo serveradmin stop postgres
sudo serveradmin start postgres
Check the version of your PostgreSQL cluster, using: sudo -u _postgres psql -tc "select version()" and refer to the official manuals on how to create the database and setup initial access. Manual for the latest PostgreSQL version can be found here.
If you do not have the software installed, I strongly recommend the Enterprise DB package. It makes installing pretty darn easy.