Linux系统管理员应该知道监控工具
- - CSDN博客推荐文章如果想监控Linux服务器的性能,请试一下内置的shell命令和一些附加的工具. 很多Linux发行版都有“成吨”的监控工具. 这些工具提供了可度量信息,用于观察系统的活动,找到导致系统性能的可疑之处. 我们下面讨论的工具是一些最基本的. 命令,可以用来系统的分析和服务的调试:. 3、找出CPU、内存瓶颈.
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready master 9d v1.18.0
$ kubectl get ns
NAME STATUS AGE
charts Active 8d
default Active 9d
kube-node-lease Active 9d
kube-public Active 9d
kube-system Active 9d
$ kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-66bff467f8-mjptx 1/1 Running 2 9d
coredns-66bff467f8-t2xcz 1/1 Running 2 9d
etcd-minikube 1/1 Running 1 9d
kube-apiserver-minikube 1/1 Running 1 9d
kube-controller-manager-minikube 1/1 Running 2 9d
kube-proxy-rpc9d 1/1 Running 1 9d
kube-scheduler-minikube 1/1 Running 2 9d
storage-provisioner 1/1 Running 1 9d
$ kubectl create ns hello-there
namespace/hello-there created
$ kubectl create cronjob my-cron --image=busybox --schedule="*/5 * * * *" -- echo hello
cronjob.batch/my-namespaced-cron created
$ kubectl create cj my-existing-cron --image=busybox --schedule="*/15 * * * *" -- echo hello
cronjob.batch/my-existing-cron created
$ kubectl edit cronjob/my-existing-cron
# Please edit the object below. Lines beginning with a '#' will be ignored,}
and an empty file will abort the edit. If an error occurs while saving this file will be
reopened with the relevant failures.
#
apiVersion: batch/v1beta1
kind: CronJob
metadata:
creationTimestamp: "2020-04-19T16:06:06Z"
managedFields:
- apiVersion: batch/v1beta1
fieldsType: FieldsV1
fieldsV1:
f:spec:
f:concurrencyPolicy: {}
f:failedJobsHistoryLimit: {}
f:jobTemplate:
f:metadata:
f:name: {}
f:spec:
f:template:
f:spec:
f:containers:
k:{"name":"my-new-cron"}:
.: {}
f:command: {}
f:image: {}
f:imagePullPolicy: {
$ kubectl edit cronjob/my-existing-cron
cronjob.batch/my-existing-cron edited
$ KUBE_EDITOR="nano" kubectl edit cronjob/my-existing-cron
$ kubectl delete cronjob my-existing-cron
cronjob.batch "my-existing-cron" deleted
$ kubectl apply -f commands.yaml
serviceaccount/tiller created
clusterrolebinding.rbac.authorization.k8s.io/tiller created
$ kubectl describe cronjob my-cron
Name: my-cron
Namespace: default
Labels:
Annotations:
Schedule: */5 * * * *
Concurrency Policy: Allow
Suspend: False
Successful Job History Limit: 3
Failed Job History Limit: 1
Starting Deadline Seconds:
Selector:
Parallelism:
Completions:
Pod Template:
Labels:
Containers:
my-cron:
Image: busybox
Port:
Host Port:
$ kubectl logs cherry-chart-88d49478c-dmcfv -n charts
172.17.0.1 - - [19/Apr/2020:16:01:15 0000] "GET / HTTP/1.1" 200 612 "-" "kube-probe/1.18" "-"
172.17.0.1 - - [19/Apr/2020:16:01:20 0000] "GET / HTTP/1.1" 200 612 "-" "kube-probe/1.18" "-"
172.17.0.1 - - [19/Apr/2020:16:01:25 0000] "GET / HTTP/1.1" 200 612 "-" "kube-probe/1.18" "-"
172.17.0.1 - - [19/Apr/2020:16:01:30 0000] "GET / HTTP/1.1" 200 612 "-" "kube-probe/1.18" "-"
172.17.0.1 - - [19/Apr/2020:16:01:35 0000] "GET / HTTP/1.1" 200 612 "-" "kube-probe/1.18" "-"
172.17.0.1 - - [19/Apr/2020:16:01:40 0000] "GET / HTTP/1.1" 200 612 "-" "kube-probe/1.18" "-"
172.17.0.1 - - [19/Apr/2020:16:01:45 0000] "GET / HTTP/1.1" 200 612 "-" "kube-probe/1.18" "-"
172.17.0.1 - - [19/Apr/2020:16:01:50 0000] "GET / HTTP/1.1" 200 612 "-" "kube-probe/1.18" "-"
172.17.0.1 - - [19/Apr/2020:16:01:55 0000] "GET / HTTP/1.1" 200 612 "-" "kube-probe/1.18" "-"
$ kubectl logs cherry-chart-88d49478c-dmcfv -n charts | grep -vie kube-probe
127.0.0.1 - - [10/Apr /2020:23:01:55 0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0" “-”
$ kubectl exec -it cherry-chart-88d49478c-dmcfv -n charts -- /bin/bash
root@cherry-chart-88d49478c-dmcfv:/#
kubectl cp <filename\> <namespace/podname:/path/tofile>
。 $ kubectl cp commands_copy.txt charts/cherry-chart-88d49478c-dmcfv:commands.txt
$ kubectl exec -it cherry-chart-88d49478c-dmcfv -n charts -- /bin/bash
root@cherry-chart-88d49478c-dmcfv:/# ls
bin boot commands.txt dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
kubectl cp <namespace/podname:/path/tofile>
$ kubectl cp charts/cherry-chart-88d49478c-dmcfv:commands.txt commands_copy.txt
$ ls
commands_copy.txt