hiredis getting err 1 REDIS_ERR_IO No such file or directory - c

redisAsyncConnectUnix() returns a redisAsyncContext(not NULL) that has err=1 i.e REDIS_ERR_IO with errstr "No such file or directory" , what file/directory are they looking for ?
Redis is up and running, was able to SET from redis-cli

redisAsyncConnectUnix is used to connect to the server using a Unix Domain Socket, which is materialized by a pseudo-file. The path of this file has to be provided as a parameter:
redisAsyncContext *redisAsyncConnectUnix(const char *path);
For instance, you could use:
path = /tmp/redis.socket
However, you need to check that the server (which has to run on the same machine than the client), is listening to the same path. Check the definition of the following parameters in the Redis configuration file:
unixsocket /tmp/redis.socket
unixsocketperm 755
Make sure the path is valid, and access rights are correct. You can check that the configuration is ok on server-side by running:
redis-cli -s /tmp/redis.socket

Related

Access user keyring from systemd hook or crontab

I'm trying to implement a systemd hook (systemd-sleep) to connect and disconnect from protonvpn. However, these scripts are executed as root and do not have access to the keyring. The backend is kwallet, since I am on fedora-kde plasma. When I execute protonvpn-cli c --sc, I get the following error:
[...] keyring_data_user = ExecutionEnvironment().keyring[ File "/usr/lib/python3.10/site-packages/protonvpn_nm_lib/core/keyring/linuxkeyring.py", line 32, in __getitem__ raise exceptions.KeyringError(e) protonvpn_nm_lib.exceptions.KeyringError: Environment variable DBUS_SESSION_BUS_ADDRESS is unset
I tried several things, none of them worked:
run sudo -E -u myuser protonvpn-cli c --sc, or replacing -E by -i, or none.
importing the DBUS session of myuser (who is currently logged ir and has kwallet opened). In this case, I get the error [...] bus = secretstorage.dbus_init() File "/usr/lib/python3.10/site-packages/secretstorage/__init__.py", line 80, in dbus_init raise SecretServiceNotAvailableException(str(ex)) from ex secretstorage.exceptions.SecretServiceNotAvailableException: [Errno 32] Broken pipe
I tried systemd --user services, but I've found no way to link this service to the suspend.target, or hibernate.target, since they are system targets and are executed on separate process.
Is there a way give access the an already opened kwallet to this hook script?

Execute a shell command in C but not through web page

I have a program in C/java/html 5
The service file of the program runs as root user and it is on an Archlinux distribution.
I want to have the result IP address that SMB will find and show it in an html page i have.
The part of the code i am interested is this:
sds ns_server_list(sds buffer, sds method, int request_id)
{
FILE *fp = popen("/usr/bin/nmblookup -S \'*\' | grep \"<00>\" | awk \'{print $1}\'", "r");
// returns three lines per server found - 1st line ip address 2nd line name 3rd line workgroup
if (fp == NULL)
{
LOG_ERROR("Failed to get server list");
buffer = jsonrpc_respond_message(buffer, method, request_id, "Failed to get server list", true);
}
If i run the program through shell (./test) and after compile, it returns the results in HTML just fine.
If i run it through the web interface of program and through a service file, it returns these SMB errors in journalctl -xe:
WARNING: no network interfaces found
name_query failed to find name *
ERROR Executing syscmd "/usr/bin/nmblookup -S '*'" failed
SMB.conf
[global]
server string = SMB Server
security = user
guest account = root
map to guest = bad user
log level = 0
load printers = No
syslog = 0
directory mask = 0775
create mask = 0775
browseable = yes
#veto files = /._*/.DS_Store/
interfaces = eth0 192.168.2.0/24
Summarized...
If i run the program through service file and without IP address in SMB.conf i have the errors in journalctl. If i put the IP everything is ok but i do not want to work it like this way (dynamic ip and eth0 do not work, same errors).
If i run the program through shell with the executable compiled file (./test) everything play fine without ip address in smb.conf
Why is that?
Thank you.

How to change log directory location in postgresql 9.4?

my current log_directory path is
**/opt/demo/PostgreSQL/9.4/data/pg_log**
I'm trying to change the log directory path to
**/logs/demo/**
The server won't start when i uncomment the log path and it starts only when its default.
The postgresql.conf file looks like
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------
# - Where to Log -
log_destination = 'stderr' # Valid values are combinations of
# stderr, csvlog, syslog, and eventlog,
# This is used when logging to stderr:
logging_collector = on
# These are only used if logging_collector is on:
#log_directory = '/logs/etbos/demo/' #directorywherelogfiles are written
#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'
# This is only relevant when logging to eventlog (win32):
#event_source = 'PostgreSQL'
So this is what I supposed :) You need to grant permissions to the new log directory to postgres user.
You can do this using f.e.:
sudo chown postgres:postgres /your/new/log/dir/path
Answering your other question:
To allow TCP/IP connections from remote hosts you need to edit pg_hba.conf file.
You can allow ALL TCP/IP connections by adding a line like this:
host all all 0.0.0.0/32 md5
There are five parameters above, you can read about them in the pg_hba.conf file in the comments at the top of the file, but in short they mean:
[connection_type] [database_name] [user_name] [remote_ip/mask] [auth_type]

How to change the HTTP port number of JBoss 7 dynamically

I have grouped my Jboss 7 server, Postgres database and test.bat into a demo.exe file using Advanced Installer. When file i.e demo.exe file double clicked on the client side then test.bat file runs and it deploys JBoss and postgres at the predefined location and the service starts and my application runs at the port number 8080 .All the script has been written to test.bat file .This demo.exe file has to used by different users . It may be possible that 8080 might be used or engaged by different application on client side.
So how can i change port number of jboss dynamically on the client side as per port usage?
Do i have to use any Jboss installer or write scipt on batch file i.e test.bat ?
Not able to click things or right approach :(
Any help will be highly appreciated and will be thankful .
You can do this using CLI. This example changes the port from 8081 to 8080:
Start CLI (in .../bin/):
$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
Connect
[disconnected /] connect
Change into the target area
[standalone#localhost:9999 /] cd /socket-binding-group=standard-sockets/socket-binding=http
Show the current state:
[standalone#localhost:9999 socket-binding=http] ls -l
ATTRIBUTE VALUE TYPE
bound true BOOLEAN
bound-address 127.0.0.1 STRING
bound-port 8081 INT
client-mappings undefined LIST
fixed-port false BOOLEAN
interface undefined STRING
multicast-address undefined STRING
multicast-port undefined INT
name http STRING
port 8081 INT
Change the port attribute:
[standalone#localhost:9999 socket-binding=http] :write-attribute(name="port", value="8080")
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
Note that the process-state is "reload-required"
Look again:
[standalone#localhost:9999 socket-binding=http] ls -l
ATTRIBUTE VALUE TYPE
bound true BOOLEAN
bound-address 127.0.0.1 STRING
bound-port 8081 INT
client-mappings undefined LIST
fixed-port false BOOLEAN
interface undefined STRING
multicast-address undefined STRING
multicast-port undefined INT
name http STRING
port 8080 INT
Note that here as well the bound-port is still at the old value.
So go back to the root directory
[standalone#localhost:9999 subsystem=web] cd /
Reload
[standalone#localhost:9999 /] :reload
{
"outcome" => "success",
"response-headers" => {"process-state" => "reload-required"}
}
That means that the reload is still in progress, again
[standalone#localhost:9999 /] :reload
{"outcome" => "success"}
Now the HTTP connector should listen on the new port.
Update
The question asks for changing the port dynamically (JBoss is up and running).
The other option is to write the port into the configuration file (standalone.xml). This is statically, but it will probably work as well as for installation purposes.

How do I test a manual check in check_mk / Nagios

My organization is using Nagios with the check_mk plugin to monitor our nodes. My question is: is it possible run a manual check from the command line? It is important, process-wise, to be able to test a configuration change before deploying it.
For example, I've prepared a configuration change which uses the ps.perf check type to check the number of httpd processes on our web servers. The check looks like this:
checks = [
( ["web"], ALL_HOSTS, "ps.perf", "Number of httpd processes", ( "/usr/sbin/httpd", 1, 2, 80, 100 ) )
]
I would like to test this configuration change before committing and deploying it.
Is it possible to run this check via the command line, without first adding it to main.mk? I'm envisioning something like:
useful_program -H my.web.node -c ps.perf -A /usr/sbin/httpd,1,2,80,100
I don't see any way to do something like this in the check_mk documentation, but am hoping there is a way to achieve something like this.
Thanks!
that is easy to check.
Just make your config changes and then run:
cmk -nv HOSTNAME.
That (-n) will try run everything and return (-v) the output.
So can see the same results like later in the GUI.
List the check
$check_mk -L | grep ps.perf
if it listing ps.perf then run following command,
$check_mk --checks=ps.perf -I Hostname

Resources