is it possible to set an default contact_group in hostsgroup and modify (redefine) this contact_group later in the service. Or by another way.
Background: We use nagios to monitor near 100 Hosts and near 1000 services. For easy configuration we defined hostgroups with default checks and default contactgroups. But there are more and more services on special server that must have other contactgroups.
Config-Example that shows what we want, but it doesn't work... (Last Part - Redefine)
####################
## HOST GROUP
####################
define hostgroup{
hostgroup_name WINDOWS
alias Windows Server
}
####################
## SERVICE
####################
define service{
use generic-service
name RDP-CHECK-TCP-PORT
hostgroup_name WINDOWS
service_description RDP - Check TCP Port
check_command check_rdp
contact_groups Admin_Alarm
}
define service{
use generic-service
name DF-CHECK
hostgroup_name WINDOWS
service_description HD - Disk free
check_command check_df_win
contact_groups Admin_Alarm
}
####################
## HOST
####################
define host{
use generic-urgent-host
host_name server1
hostgroups WINDOWS
alias Server1
address 1.2.3.1
}
define host{
use generic-urgent-host
host_name server2
hostgroups WINDOWS
alias Server2
address 1.2.3.2
}
define host{
use generic-urgent-host
host_name server3
hostgroups WINDOWS
alias Server3
address 1.2.3.3
}
####################
## Redefine Contactgroups
####################
define service{
host server1
service_description RDP - Check TCP Port
contact_groups No_Alarm
}
define service{
host server2
service_description RDP - Check TCP Port
contact_groups Urgent_Admin_SMS_Alarm, Customer_Admin_Alarm
}
contact_groups can only assigned to hosts, not hostgroups. However you could use templates and put contact_groups into that templates. Later you can override the contact_groups in your host definition.
Have a look at the objectinheritance docs.
Since this hasn't been said:
There are tools that let you express that as rules and have simple overrides to the default settings.
An escalation should rather be used for something like "I want this to immediately be visible and written to our xmpp chatroom as a notification. But if it stays for 30 minutes broken, we also wanna email the manager so he knows we have a noteworthy outage".
As for tools, I'll recommend Check_MK, which is around since 2009. Initially, it was primed for this task. These days it does a lot more.
Disclaimer: I contributed to it, since I think it is a good thing.
Related
From what I have read, I need to make changes to the configuration file postgres.conf and pg_hba.conf and after that we need to create a "replication" user.
How do I make changes to these configuration files and make sure that the changes to these configuration files persist through the restarts?
Since my postgres is running inside a kubernetes pod, I reckon that the user must be created inside the container.
But when I do createuser -replication -P replica, it wont allow me to create one since the current user after I did docker exec -it <container_id> bash is root and not postgres.
This gist has a detailed explanation on how to setup a master-slave replication with Postgres using docker.
Master configuration
Create replication_user
CREATE USER replication_user NOSUPERUSER;
ALTER USER replication_user WITH REPLICATION;
ALTER USER replication_user WITH PASSWORD 'CHANGEME';
postgresql.conf
Edit or add these lines:
listen_addresses = '*' # It can be more specific with the listen IP
wal_level = hot_standby
max_wal_sender = 5 # Specifies the maximum number of concurrent connections from standby servers
ssl = off
archive_mode = on
archive_command = "cp %p /path/to/archive/%f"
pg_hba.conf
Let's suppose that 192.168.0.2/32 is the IP of the slave and replication_user is the replication user.
case no authentication is required
host replication replication_user 192.168.0.2/32 trust
case authentication using password
host replication replication_user 192.168.0.2/32 scram-sha-256 # or MD5
Slave configuration
Let's suppose that the Master IP is: 192.168.0.1 and the port is the default (5432).
listen_addresses = '*'
primary_conninfo = 'user=replication_user password=CHANGEME host=192.168.0.1 port=5432'
hot_standby = on
Making the configuration persistent
You can use docker volumes (or for kubernetes).
Start by creating the configuration files in the local machine that start the containers and then:
docker run --rm --name IMAGE_NAME -v /local/path/to/postgresql.conf:/etc/postgresql/postgresql.conf -v /local/path/to/pg_hba.conf:/var/lib/postgresql/data/pg_hba.conf CONTAINER_NAME
The same for the slaves.
sources:
https://wiki.postgresql.org/wiki/Streaming_Replication
https://gist.github.com/avshabanov/eb8e03a050c79f8e77420b06f9b4abe5
I've failed to set up postgreSQL to work with my Ruby-on-Rails project for the past week. I've tried to uninstall and reinstall, postgreSQL, twice now.But when I try to launch postgreSQL I keep getting the error below:
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and
accepting TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and
accepting TCP/IP connections on port 5432?"
I've looked at many online resources, including stackoverflow and none seem helpful.The key parts of my pg_hba.conf file looks like this:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
And the key part of my postgresql.conf file is as follows:
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directories = '' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
Most of the suggestions, I've seen so far, were based on those two files. (For my case, they were already configured correctly). I also tried disabling the firewall and restarting postgreSQL but it didn't help. Does anyone have any suggestions for me? Thanks!
Got the same issue while settings up PostgreSQL 9.6.16 to work with Python/Django, but this is purely a database issue.
The solution lies in the error: In fact, I found this error mentioned within the official PostgreSQL documentation thus it's a common error.
And here is how I resolved this issue:
Always first start the postgres database server, use postgres or the wrapper program pg_ctl.I used the command, below, on windows 10.Remember, whatever comes after -D should be the path to where you installed PostgreSQL, to the data folder, which holds the pg_hba.conf and postgresql.conf files.
> pg_ctl start -D "C:/Program Files/PostgreSQL/9.6/data"
If that runs well, you are ready to access the database server.Open another cmd shell, and type the command below.Remember the password you entered while installing PostgreSQL?Enter that password when asked Password for user postgres:
> psql -U postgres
Once done, you can now go ahead to CREATE ROLE and CREATE DATABASE accordingly.
I have recently installed MariaDB on Fedora 19 in VirtualBox on Windows 7.
When I run:
MariaDB [(none)]> SELECT user, host, password FROM mysql.user;
I get:
+------+----------------------+-------------------------------------------+
| user | host | password |
+------+----------------------+-------------------------------------------+
| root | localhost | ***************************************** |
| root | my.hostname | ***************************************** |
| root | 127.0.0.1 | ***************************************** |
| nusr | my.hostname | ***************************************** |
+------+----------------------+-------------------------------------------+
my.hostname is the hostname I changed the default hostname to in Fedora.
I created the user 'nusr' with:
CREATE USER 'nusr'#'my.hostname' IDENTIFIED BY 'my_password';
When I try and connect to MariaDB with:
[me#my ~]$ mysql -u nusr -p
Enter password:
I get:
ERROR 1045 (28000): Access denied for user 'nusr'#'localhost' (using password: YES)
I am guessing this is because it is referring to 'nusr'#'localhost' instead of 'nusr'#'my.hostname'.
Why is 'localhost' the default host used when trying to connect to MariaDB?
Do the host's 'localhost' and '127.0.0.1' need to be kept?
As a context to this question, I am not really sure what the terms 'host' and 'hostname' mean, I just wanted to 'customise' my experience of learning MariaDB commands, so perhaps I have gone awry by completing the steps above.
Very old question but..
ERROR 1045 (28000): Access denied for user 'nusr'#'localhost' (using password: YES)
I am guessing this is because it is referring to 'nusr'#'localhost' instead of 'nusr'#'my.hostname'.
YES.
Why is 'localhost' the default host used when trying to connect to MariaDB?
Because the assumption is that you will connect to the database from the same machine the database is in (localhost).
If you define the user as being #my.hostname it means the connection to the database will be made from another machine, called my.hostname.
Do the host's 'localhost' and '127.0.0.1' need to be kept?
Only if you want to be able to access the database from there..
In that setup, if you delete root user #localhost and #127.0.0.1 then you will not be able to log into the database from inside the virtualbox where the database resides. And you will only be able to access if you connect from a machine called my.hostname. But for that to work you must make sure that the database environment knows my.hostname.
The MariaDB server (also MySQL) treats localhost in a special way. Where other software treat it like an alias of the loopback address 127.0.0.1, MariaDB will interpret it as a UNIX domain socket connection to the server. By default this socket file is located in /var/lib/mysql/mysql.sock.
To connect via the network to the local server, use the -h 127.0.01 parameter. This tells the mysql client to connect via the loopback network interface instead of the socket.
Regardless of other grants, MariaDB will always translate localhost to a local socket connection. If you want to prevent this and only allow access via the network, drop the users that have localhost as their host.
You can view all users in the database by executing the following query:
SELECT * FROM mysql.user
You must create properly user on system Fedora 19:
[root#localhost ~]# useradd nusr
[root#localhost ~]# passwd nusr
Changing password for user fedora.
New UNIX password:# set password
Retype new UNIX password:# confirm
passwd: all authentication tokens updated successfully.
[root#localhost ~]# exit # logout
So, a database didn't find user nusr and it will not to handle user nusr because isn't created on system wide.
Hostname is from IP address named as "mydomain.com", but "host" can be IP address or name lookup host "mydomain.com".
Is it possible to connect LOCALHOST DatabaseEgnine without providing the computer name like MyComputerName\LOCALHOST ?
(I use SQL Server 2012 - Standard Edition installed)
MyComputerName\LOCALHOST is named instance called LOCALHOST on your computer. To connect to it you must either specify the instance name (and have the SQL Server Browser service running) or specify the listening port explicitly (and have the instance configured to listen to static port, non-default since default is dynamic ports). So any of the below will work:
.\LOCALHOST
localhost\LOCALHOST
local\LOCALHOST
127.0.0.1\LOCALHOST
machinename\LOCALHOST
.:<port>
localhost:<port>
127.0.0.1:<port>
etc
Is very unlikely you actually wanted to install a named instance called LOCALHOST. You probably didn't read the setup dialogs and misconfigured the instance name. My recommendation would be to install it again, choosing a default instance (ie. unnamed) or a more convenient and less confusing instance name.
you can use . as servername
e.g.
.\mssqlserver
.\sqlexpress
For Default Instance:::
(local) or . (it is a dot)
Named Instance:
(local)\InstanceName (or) .\InstanceName
I've configured everything as i would in another distro (i'm an arch user, and i installed opensuse on a desktop machine).
As :
Django and all it requirements (psycopg)
Postgresql
Created a User for my django server
Created a Database
Granted all power for the database for my new user
Then, when starting syncdb to start working i get this message (I've changed users etc.. in this thread for user:question, password:password, database:question as it is in reality with other words):
FATAL: Ident authentication failed for user "question"
After lurking i got the idea to change my pg_hba.conf file (located at : /var/lib/pgsql/data/pg_hba.conf)
This is what I have:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
My django conf file contains :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'question',
'USER': 'question',
'PASSWORD': 'password',
'HOST': '127.0.0.1',
'PORT': '',
}
}
I don't understand what i missed here, any ideas ?
Edit the /var/lib/pgsql/data/pg_hba.conf file and change the method from trust to md5. This way Postgres will ask for a password.
Also remember to reload the configuration file.
Have you tried changing:
host all all 127.0.0.1/32 ident
to:
host all all 127.0.0.1/32 md5
It appears that you are connecting via TCP (so the first line in pg_hba.confg with "trust" doesn't apply) and authenticate via ident, which requires entries in pg_ident.conf. You probably want "md5" or one of the other password-based authentication options.