Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Firstboot seems to be running based on this:
[root#master ~]# ps ax |grep firstboot
27891 pts/0 R+ 0:00 grep firstboot
I can't seem to kill it
[root#master ~]# killall firstboot
firstboot: no process killed
When I check if it's running, the pid seems to have changed!
[root#master ~]# ps ax |grep firstboot
28233 pts/0 S+ 0:00 grep firstboot
Using chkconfig doesn't work either
[root#master ~]# chkconfig firstboot off
error reading information on service firstboot: No such file or directory
Thoughts on what I can do to kill the process?
You have interpreted this output incorrectly.
[root#master ~]# ps ax |grep firstboot
27891 pts/0 R+ 0:00 grep firstboot
That is not telling you that firstboot is running. Notice the command there grep firstboot. That is telling you that your grep is running.
Try pgrep firstboot or ps ax | grep '[f]irstboot' to avoid that confusion.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I think the main question is complete. I am not familiar with docker and I would love if someone could break down for me the meaning of the following command:
docker build -f 12.Dockerfile -t docker.something.com/blah/postgresql:12 .
docker build -f 12.Dockerfile -t docker.something.com/blah/postgresql:12 .
Breaking it down:
docker build is using the docker cli to invoke the build command
-f 12.Dockerfile specifies the 12.Dockerfile file as the Dockerfile you are trying to build
-t docker.something.com/blah/postgresql:12 is specifying a tag which would be used to identify the build image
. is the docker context that tells docker that files and directories it would have access to, should it need to copy everything.
That said, you'd be better served by reading the documentation and familiarising yourself with these concepts
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
My requirement is to login into pod without selecting the namespace and the pod name, then providing a command to be run inside it. There was no thread or question that answered the query. Below is a solution that I came up with. If there can be improvements in the same, please provide those.
What I was looking for to build automation or a krew plugin for logging into any pod in any namespace and run any command inside it. It is purely automation based, there are plenty of plugins that do the same work like k9s and other krew plugins but my requirement was more of a generic based and lightweight which could be implemented in a Pipeline without any third-party tools.
Create a Shell Script
login.sh
#$1 is namespace $2 is the row number where the pod is located $3 is the command to run inside the pod
#$3 is command can be bash,sh or some command like echo "test"
#Example ./login.sh test-ns 1 bash or ./login.sh test-ns 1 'echo "test"'
pod=$(kubectl get pods -n $1 | grep -v NAME | awk -v i=1 -v j=$2 'FNR == j {print $i}')
kubectl exec -it $pod -n $1 -- $3
How to use it?
login.sh $namespace $pod_number $command
1. Create the above script, make it executable and copy it in /usr/local/bin directory or in the $PATH variable
chmod +x login.sh
#Check if /usr/local/bin exists in PATH variable, if not then run the export command
echo $PATH
export PATH=$PATH:/usr/local/bin
cp -p login.sh /usr/local/bin/login.sh
2. Run kubectl get pods to get the pod number in which you want to the command to run
helloworld-v1-5dfcf5d5cd-v7xtw 1/1 Running 0 8d
httpbin-56db79f4f5-j2cxz 1/1 Running 1 8d
test-cc5b6bfd-2hhmr 1/1 Running 0 39h
And I want to exec into the second pod with the shell being bash
3. Run the command to use the script
login.sh default 2 bash
Demo Output
The output would look something like:
shubham.yadav#my-MAC:~/k8s $ ./login.sh default 2 bash
root#httpbin-56db79f4f5-j2cxz:/#
Another example just to make implementation more clear
shubham.yadav#my-MAC:~/k8s $ login.sh qa-test 2 'echo "From the pod Login Succeeded"'
"From the pod Login Succeeded"
Note: In case you have a large number of pods in the namespace you can use NR utility of awk to get the column numbers of the pods.
kp is an alias for kubectl get pods
kp | grep -v NAME | awk '{print NR, $1}'
1 details-v1-78d78fbddf-zksf7
2 helloworld-v1-5dfcf5d5cd-wl2nx
3 httpbin-56db79f4f5-wj4ql
4 load-generator-5cdbd66865-fxpbm
5 productpage-v1-85b9bf9cd7-qp79l
6 ratings-v1-6c9dbf6b45-xm6ww
7 reviews-v1-564b97f875-cx86c
8 reviews-v2-568c7c9d8f-xxc86
9 reviews-v3-67b4988599-p98ft
10 test-cc5b6bfd-68tqg
11 test-cc5b6bfd-8q694
12 unset-deployment-7896c75bf6-5w27b
13 web-v1-fc4d58bdc-pcv9p
14 web-v2-7bf5dd654d-684t9
15 web-v3-7567d5d6b9-sqrpg
Creating a Binary for Shell Script
In case if you are interested in creating the binary for the above script, you can follow the following link which lets you create a binary for your above shell script.
You can also change the binary name to a more friendly name from login.sh to just execute
shubham.yadav#my-MAC:/usr/local/bin $ mv login.sh execute
shubham.yadav#my-MAC:/usr/local/bin $ execute qa-test 2 'echo "Binary Name Changed"'
"Binary Name Changed"
I know that Zabbix can monitor any service on Linux machine via two options:
scan particular tcp or udp port, on which the service is bound
or count the service processes with proc.num[<processname>]
It is totally counter-intuitive, because I can spawn processes with the same executable name and they will deceive Zabbix. I'd prefer to use standard service <servicename> status or systemctl status name.service tool. But there are no standard way to use it from Zabbix except system.run[cmd]
Could you help me to write templates for monitoring a particular service state. We want to use different OSes like Centos 7 and Ubuntu 14.04 and 16.04 distributions. It is pity but service <servicename> status is completely different in listed operating systems.
You can also add the following UserParameters in zabbix_agentd.conf to monitor service status in systemd systems. For non-systemd the OS doesn't really monitor service status, the various bash script "status" arguments are often unreliable.
UserParameter=systemd.unit.is-active[*],systemctl is-active --quiet '$1' && echo 1 || echo 0
UserParameter=systemd.unit.is-failed[*],systemctl is-failed --quiet '$1' && echo 1 || echo 0
UserParameter=systemd.unit.is-enabled[*],systemctl is-enabled --quiet '$1' && echo 1 || echo 0
And then e.g. for sshd status create an item with a key like:
systemd.unit.is-active[sshd]
If Linux services are managed by systemd (Centos 7+, Ubuntu 16+, ...), then you can use https://github.com/cavaliercoder/zabbix-module-systemd. It uses standard systemd D-Bus communication - that's what systemctl does under the hood.
For centos 6 it can be done:
UserParameter=check_service_status_asterisk,sudo service asterisk status 2> /dev/null | grep -q "is running";echo $?
For centos 7 or similar it can be created with:
UserParameter=check_service_status_grafana,systemctl status grafana-server 2> /dev/null |sed -n 3p |grep -q "running";echo $?
or
UserParameter=check_service_status[*],systemctl status $1 2> /dev/null |sed -n 3p |grep -q "running";echo $?
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I have Ubuntu 14 server dockerized. All are good I guess, but when I'm going to dump a table:
psql -c -h myserver -p5433 mydb -t gr_service_plan_xxx > gr_service_plan_xxx.sql
an error occurs:
psql: warning: extra command-line argument
What does it mean? Am I missing something in the command line?
Judging from the command arguments you included, I think you intended to run pg_dump not psql:
pg_dump -c -h myserver -p 5433 mydb -t gr_service_plan_xxx > gr_service_plan_xxx.sql
Or you need to specify the command for psql, for example:
psql -h myserver -p5433 mydb -c 'SELECT * FROM gr_service_plan_xxx;' > gr_service_plan_xxx.sql
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
How to uninstall .pkg in solaris?
We have command to install pkgadd -d one.pkg,. Similarly can we have command for uninstall?
There is no direct way as the name of the file containing the package can be anything.
You need to retrieve the package name to be able to remove it.
This can be done with that oneliner (ksh or bash):
# pkgrm $(pkginfo -d one.pkg | nawk '{print $2}')
pkgrm <pkg_name>
To know package name run below command
pkginfo -l <word_in_package_name>