zensix / Openshift-project

Zabbix Template and script use to supervise deployment and pods for OCP project
0 stars 0 forks source link

Problem with discovery rule/template #1

Open pizzulicchio opened 3 years ago

pizzulicchio commented 3 years ago

Hi, i'm testing your script and template, but i have some difficult to make it works.

before all, there is an error into your example json config file ( openshift.json_model ) At line 8 and 9 : "token": "" "port": "443" at the end of both lines, are missing a " ; ".

In addiction, here is the error wit the discovery into zabbix interface: immagine

and

immagine

and

immagine

The last one seems to be a problem with json standard output because the output is starting with a " [ " instead of a "{ "

What am i doing of wrong ?

zensix commented 3 years ago

hi, thk for your return and sorry for the delay of my answer, Note: I see somes errors in the help text , I must correct this when I have time Before all can you run manually the script to check if configuration is ok on your zbx server or proxy ?

/usr/lib/zabbix/externalscripts/request_oc_project.py namespaces -e "your env" and check if json return is correct Do the same check for other function /usr/lib/zabbix/externalscripts/request_oc_project.py dc_discover -e "your env" -n "namepace" /usr/lib/zabbix/externalscripts/request_oc_project.py pod_discover -e "your env" -n "namepace"

zensix commented 3 years ago

Hi Samuele, I discover, I have forget to write very importante informations about project supervsion confguration in zabbix Do not hesitate to contact me for more precision

pizzulicchio commented 3 years ago

Hi, I didn't tell you that i have already tested your script before implementing in zabbix. I have no problem with : /usr/lib/zabbix/externalscripts/request_oc_project.py namespaces -e "your env"

This is a sample output : immagine

But i have problem with the pod discover because the output of your script end with a " ] " , and i think that is's the real problme because it's not a standard json output and zabbix is not be able to intepretet correctly:

immagine

Let me know if I'm pointing the attenction in a wrong place or if the problem is not there. ( I'm not a developer I'm an IT Technician, be patient.. )

zensix commented 3 years ago

I Samuele

I don't have this problem because "normaly" zabbix accept two discover format { "data": [ { first data .. }, { second data .. } ..... ] } or just : [ { first data .. }, { second data .. } .... ]

I use the first format for namespaces and second for the others ( with no real reason ;-) I don't understand why your zabbix don't accept the second form (or the problem is not here ). but in doubt, today or tomorrow I change code to use the first discover format for all discovers ( pods and deployment config) Thank for you Ps: I don't imagine other person use my code ;-) no problems to help you has I can

zensix commented 3 years ago

I commit new version , tell me if the problems are solved

pizzulicchio commented 3 years ago

Great! I'm testing and we/YOU have solved 2 of our 3 problems. immagine Only this discovery rule is not working. ( Pod Discover {$NAMESPACE} - Prom Restart Rate )

pizzulicchio commented 3 years ago

May be useful this for you ?

immagine

zensix commented 3 years ago

Thank for test, yes it's very useful ! I think i see what is it , I try to correct this tomorow. I keep you posted

zensix commented 3 years ago

I samuele,

for the moment, I don't understand why the object is not correctly processed (no problem with me) I added a dump function to the show full object ( json ) before processing in order to compare the structure Could you run : request_oc_project.py dump_object -e oscllab -s /api/v1/namespaces/openshift-logging/pods/kibana..... And send me result ( has text ) ? Other questions your OCP version you pyhton version thank you Zen

pizzulicchio commented 3 years ago

Hi, the only function that seems to not work it's "prom_rate_restart_pod": immagine

We are using OCP version 4.6.12 my python version is 2.7.16

and this is the debug using your new feature "dump_object"

START

srvlnxzabbix01:/usr/lib/zabbix/externalscripts# ./request_oc_project.py.ORIG dump_object -e oscllab -n openshift-logging -s /api/v1/namespaces/openshift-logging/pods/fluentd-nbbq5 <type 'dict'> { "status": { "initContainerStatuses": [ { "restartCount": 1, "name": "fluentd-init", "image": "registry.redhat.io/openshift4/ose-logging-fluentd@sha256:9f912161c7e220517211c046093debc18b47586e6b87a655400761db0197a6bc", "imageID": "registry.redhat.io/openshift4/ose-logging-fluentd@sha256:9f912161c7e220517211c046093debc18b47586e6b87a655400761db0197a6bc", "state": { "terminated": { "startedAt": "2021-05-22T15:04:10Z", "reason": "Completed", "finishedAt": "2021-05-22T15:04:11Z", "containerID": "cri-o://364ea072315acca167e5d910fcaf35a9b0c4b2ed3cbf3b3ba057cc7f42e19161", "exitCode": 0 } }, "ready": true, "lastState": {}, "containerID": "cri-o://364ea072315acca167e5d910fcaf35a9b0c4b2ed3cbf3b3ba057cc7f42e19161" } ], "hostIP": "10.17.37.7", "qosClass": "Burstable", "containerStatuses": [ { "restartCount": 1, "name": "fluentd", "started": true, "image": "registry.redhat.io/openshift4/ose-logging-fluentd@sha256:9f912161c7e220517211c046093debc18b47586e6b87a655400761db0197a6bc", "imageID": "registry.redhat.io/openshift4/ose-logging-fluentd@sha256:9f912161c7e220517211c046093debc18b47586e6b87a655400761db0197a6bc", "state": { "running": { "startedAt": "2021-05-22T15:04:12Z" } }, "ready": true, "lastState": { "terminated": { "startedAt": "2021-05-12T13:36:59Z", "reason": "OOMKilled", "finishedAt": "2021-05-22T15:04:06Z", "containerID": "cri-o://9cb1e2e0e09a6affc7de5a3361e1bd83206a1ca3d4c172512daf424aab55cbda", "exitCode": 137 } }, "containerID": "cri-o://ee9094352f14fb47da971946113710d2090727fee349ddddcdd6a2ca35ce7511" } ], "podIP": "10.128.0.101", "startTime": "2021-05-12T13:36:54Z", "podIPs": [ { "ip": "10.128.0.101" } ], "phase": "Running", "conditions": [ { "status": "True", "lastProbeTime": null, "type": "Initialized", "lastTransitionTime": "2021-05-22T15:04:12Z" }, { "status": "True", "lastProbeTime": null, "type": "Ready", "lastTransitionTime": "2021-05-22T15:04:13Z" }, { "status": "True", "lastProbeTime": null, "type": "ContainersReady", "lastTransitionTime": "2021-05-22T15:04:13Z" }, { "status": "True", "lastProbeTime": null, "type": "PodScheduled", "lastTransitionTime": "2021-05-12T13:36:54Z" } ] }, "kind": "Pod", "spec": { "priorityClassName": "cluster-logging", "dnsPolicy": "ClusterFirst", "securityContext": {}, "serviceAccountName": "logcollector", "schedulerName": "default-scheduler", "enableServiceLinks": true, "serviceAccount": "logcollector", "nodeSelector": { "kubernetes.io/os": "linux" }, "priority": 1000000, "terminationGracePeriodSeconds": 10, "restartPolicy": "Always", "affinity": { "nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": { "nodeSelectorTerms": [ { "matchFields": [ { "operator": "In", "values": [ "oscllab-ptcrx-master-1" ], "key": "metadata.name" } ] } ] } } }, "volumes": [ { "hostPath": { "path": "/var/log", "type": "" }, "name": "varlog" }, { "hostPath": { "path": "/var/lib/docker", "type": "" }, "name": "varlibdockercontainers" }, { "configMap": { "name": "fluentd", "defaultMode": 420 }, "name": "config" }, { "configMap": { "optional": true, "name": "secure-forward", "defaultMode": 420 }, "name": "secureforwardconfig" }, { "secret": { "optional": true, "defaultMode": 420, "secretName": "secure-forward" }, "name": "secureforwardcerts" }, { "configMap": { "optional": true, "name": "syslog", "defaultMode": 420 }, "name": "syslogconfig" }, { "secret": { "optional": true, "defaultMode": 420, "secretName": "syslog" }, "name": "syslogcerts" }, { "configMap": { "name": "fluentd", "defaultMode": 420 }, "name": "entrypoint" }, { "secret": { "optional": true, "defaultMode": 420, "secretName": "fluentd" }, "name": "certs" }, { "hostPath": { "path": "/etc/localtime", "type": "" }, "name": "localtime" }, { "hostPath": { "path": "/etc/sysconfig/docker", "type": "" }, "name": "dockercfg" }, { "hostPath": { "path": "/etc/docker", "type": "" }, "name": "dockerdaemoncfg" }, { "hostPath": { "path": "/var/lib/fluentd", "type": "" }, "name": "filebufferstorage" }, { "secret": { "defaultMode": 420, "secretName": "fluentd-metrics" }, "name": "collector-metrics" }, { "secret": { "defaultMode": 420, "secretName": "fluentd" }, "name": "fluentd" }, { "configMap": { "items": [ { "path": "tls-ca-bundle.pem", "key": "ca-bundle.crt" } ], "name": "fluentd-trusted-ca-bundle", "defaultMode": 420 }, "name": "fluentd-trusted-ca-bundle" }, { "secret": { "defaultMode": 420, "secretName": "logcollector-token-vh69j" }, "name": "logcollector-token-vh69j" } ], "tolerations": [ { "operator": "Exists", "effect": "NoSchedule", "key": "node-role.kubernetes.io/master" }, { "operator": "Exists", "effect": "NoSchedule", "key": "node.kubernetes.io/disk-pressure" }, { "operator": "Exists", "effect": "NoExecute", "key": "node.kubernetes.io/not-ready" }, { "operator": "Exists", "effect": "NoExecute", "key": "node.kubernetes.io/unreachable" }, { "operator": "Exists", "effect": "NoSchedule", "key": "node.kubernetes.io/memory-pressure" }, { "operator": "Exists", "effect": "NoSchedule", "key": "node.kubernetes.io/pid-pressure" }, { "operator": "Exists", "effect": "NoSchedule", "key": "node.kubernetes.io/unschedulable" } ], "preemptionPolicy": "PreemptLowerPriority", "initContainers": [ { "terminationMessagePath": "/dev/termination-log", "name": "fluentd-init", "image": "registry.redhat.io/openshift4/ose-logging-fluentd@sha256:9f912161c7e220517211c046093debc18b47586e6b87a655400761db0197a6bc", "volumeMounts": [ { "readOnly": true, "mountPath": "/etc/fluent/keys", "name": "certs" }, { "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount", "name": "logcollector-token-vh69j" } ], "terminationMessagePolicy": "File", "command": [ "./wait_for_es_version.sh", "6", "https://elasticsearch.openshift-logging.svc:9200" ], "imagePullPolicy": "IfNotPresent", "resources": { "requests": { "cpu": "100m", "memory": "736Mi" }, "limits": { "memory": "736Mi" } } } ], "imagePullSecrets": [ { "name": "logcollector-dockercfg-w9l75" } ], "containers": [ { "terminationMessagePath": "/dev/termination-log", "name": "fluentd", "image": "registry.redhat.io/openshift4/ose-logging-fluentd@sha256:9f912161c7e220517211c046093debc18b47586e6b87a655400761db0197a6bc", "volumeMounts": [ { "mountPath": "/var/log", "name": "varlog" }, { "readOnly": true, "mountPath": "/var/lib/docker", "name": "varlibdockercontainers" }, { "readOnly": true, "mountPath": "/etc/fluent/configs.d/user", "name": "config" }, { "readOnly": true, "mountPath": "/etc/fluent/configs.d/secure-forward", "name": "secureforwardconfig" }, { "readOnly": true, "mountPath": "/etc/ocp-forward", "name": "secureforwardcerts" }, { "readOnly": true, "mountPath": "/etc/fluent/configs.d/syslog", "name": "syslogconfig" }, { "readOnly": true, "mountPath": "/etc/ocp-syslog", "name": "syslogcerts" }, { "readOnly": true, "mountPath": "/opt/app-root/src/run.sh", "subPath": "run.sh", "name": "entrypoint" }, { "readOnly": true, "mountPath": "/etc/fluent/keys", "name": "certs" }, { "readOnly": true, "mountPath": "/etc/localtime", "name": "localtime" }, { "readOnly": true, "mountPath": "/etc/sysconfig/docker", "name": "dockercfg" }, { "readOnly": true, "mountPath": "/etc/docker", "name": "dockerdaemoncfg" }, { "mountPath": "/var/lib/fluentd", "name": "filebufferstorage" }, { "mountPath": "/etc/fluent/metrics", "name": "collector-metrics" }, { "mountPath": "/var/run/ocp-collector/secrets/fluentd", "name": "fluentd" }, { "readOnly": true, "mountPath": "/etc/pki/ca-trust/extracted/pem/", "name": "fluentd-trusted-ca-bundle" }, { "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount", "name": "logcollector-token-vh69j" } ], "terminationMessagePolicy": "File", "env": [ { "valueFrom": { "fieldRef": { "fieldPath": "spec.nodeName", "apiVersion": "v1" } }, "name": "NODE_NAME" }, { "name": "METRICS_CERT", "value": "/etc/fluent/metrics/tls.crt" }, { "name": "METRICS_KEY", "value": "/etc/fluent/metrics/tls.key" }, { "valueFrom": { "fieldRef": { "fieldPath": "status.hostIP", "apiVersion": "v1" } }, "name": "NODE_IPV4" }, { "valueFrom": { "fieldRef": { "fieldPath": "status.podIP", "apiVersion": "v1" } }, "name": "POD_IP" }, { "name": "FLUENT_CONF_HASH", "value": "0a320cf850370affa22a1ee75c854d45" } ], "imagePullPolicy": "IfNotPresent", "securityContext": { "privileged": true }, "ports": [ { "protocol": "TCP", "name": "metrics", "containerPort": 24231 } ], "resources": { "requests": { "cpu": "100m", "memory": "736Mi" }, "limits": { "memory": "736Mi" } } } ], "nodeName": "oscllab-ptcrx-master-1" }, "apiVersion": "v1", "metadata": { "name": "fluentd-nbbq5", "labels": { "pod-template-generation": "4", "logging-infra": "fluentd", "component": "fluentd", "provider": "openshift", "controller-revision-hash": "7b9fbd6c68" }, "namespace": "openshift-logging", "managedFields": [ { "fieldsV1": { "f:metadata": { "f:generateName": {}, "f:annotations": { "f:logging.openshift.io/hash": {}, "f:scheduler.alpha.kubernetes.io/critical-pod": {}, ".": {} }, "f:labels": { "f:pod-template-generation": {}, "f:component": {}, "f:provider": {}, ".": {}, "f:logging-infra": {}, "f:controller-revision-hash": {} }, "f:ownerReferences": { "k:{\"uid\":\"8631f9f1-c571-4386-bde5-66a379d4be9b\"}": { "f:apiVersion": {}, "f:blockOwnerDeletion": {}, "f:uid": {}, "f:name": {}, "f:kind": {}, ".": {}, "f:controller": {} }, ".": {} } }, "f:spec": { "f:volumes": { "k:{\"name\":\"dockercfg\"}": { "f:hostPath": { "f:path": {}, "f:type": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"fluentd-trusted-ca-bundle\"}": { "f:configMap": { "f:defaultMode": {}, "f:name": {}, "f:items": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"config\"}": { "f:configMap": { "f:defaultMode": {}, "f:name": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"varlibdockercontainers\"}": { "f:hostPath": { "f:path": {}, "f:type": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"syslogcerts\"}": { "f:name": {}, "f:secret": { "f:secretName": {}, "f:defaultMode": {}, "f:optional": {}, ".": {} }, ".": {} }, "k:{\"name\":\"dockerdaemoncfg\"}": { "f:hostPath": { "f:path": {}, "f:type": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"certs\"}": { "f:name": {}, "f:secret": { "f:secretName": {}, "f:defaultMode": {}, "f:optional": {}, ".": {} }, ".": {} }, ".": {}, "k:{\"name\":\"varlog\"}": { "f:hostPath": { "f:path": {}, "f:type": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"localtime\"}": { "f:hostPath": { "f:path": {}, "f:type": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"entrypoint\"}": { "f:configMap": { "f:defaultMode": {}, "f:name": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"filebufferstorage\"}": { "f:hostPath": { "f:path": {}, "f:type": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"syslogconfig\"}": { "f:configMap": { "f:defaultMode": {}, "f:name": {}, "f:optional": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"collector-metrics\"}": { "f:name": {}, "f:secret": { "f:secretName": {}, "f:defaultMode": {}, ".": {} }, ".": {} }, "k:{\"name\":\"secureforwardconfig\"}": { "f:configMap": { "f:defaultMode": {}, "f:name": {}, "f:optional": {}, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"fluentd\"}": { "f:name": {}, "f:secret": { "f:secretName": {}, "f:defaultMode": {}, ".": {} }, ".": {} }, "k:{\"name\":\"secureforwardcerts\"}": { "f:name": {}, "f:secret": { "f:secretName": {}, "f:defaultMode": {}, "f:optional": {}, ".": {} }, ".": {} } }, "f:securityContext": {}, "f:terminationGracePeriodSeconds": {}, "f:enableServiceLinks": {}, "f:priorityClassName": {}, "f:schedulerName": {}, "f:affinity": { "f:nodeAffinity": { "f:requiredDuringSchedulingIgnoredDuringExecution": { "f:nodeSelectorTerms": {}, ".": {} }, ".": {} }, ".": {} }, "f:containers": { "k:{\"name\":\"fluentd\"}": { "f:image": {}, "f:imagePullPolicy": {}, "f:securityContext": { "f:privileged": {}, ".": {} }, "f:volumeMounts": { "k:{\"mountPath\":\"/etc/fluent/metrics\"}": { "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/opt/app-root/src/run.sh\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:subPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/etc/sysconfig/docker\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/etc/fluent/configs.d/secure-forward\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/var/log\"}": { "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/etc/localtime\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/etc/docker\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, ".": {}, "k:{\"mountPath\":\"/var/lib/fluentd\"}": { "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/etc/fluent/configs.d/user\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/var/run/ocp-collector/secrets/fluentd\"}": { "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/etc/pki/ca-trust/extracted/pem/\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/etc/ocp-forward\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/var/lib/docker\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/etc/ocp-syslog\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/etc/fluent/keys\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, "k:{\"mountPath\":\"/etc/fluent/configs.d/syslog\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} } }, "f:ports": { "k:{\"containerPort\":24231,\"protocol\":\"TCP\"}": { "f:containerPort": {}, "f:name": {}, "f:protocol": {}, ".": {} }, ".": {} }, "f:terminationMessagePath": {}, "f:name": {}, "f:resources": { "f:limits": { "f:memory": {}, ".": {} }, "f:requests": { "f:memory": {}, "f:cpu": {}, ".": {} }, ".": {} }, "f:terminationMessagePolicy": {}, "f:env": { "k:{\"name\":\"FLUENT_CONF_HASH\"}": { "f:name": {}, "f:value": {}, ".": {} }, "k:{\"name\":\"METRICS_KEY\"}": { "f:name": {}, "f:value": {}, ".": {} }, "k:{\"name\":\"NODE_NAME\"}": { "f:valueFrom": { "f:fieldRef": { "f:apiVersion": {}, "f:fieldPath": {}, ".": {} }, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"POD_IP\"}": { "f:valueFrom": { "f:fieldRef": { "f:apiVersion": {}, "f:fieldPath": {}, ".": {} }, ".": {} }, "f:name": {}, ".": {} }, "k:{\"name\":\"METRICS_CERT\"}": { "f:name": {}, "f:value": {}, ".": {} }, "k:{\"name\":\"NODE_IPV4\"}": { "f:valueFrom": { "f:fieldRef": { "f:apiVersion": {}, "f:fieldPath": {}, ".": {} }, ".": {} }, "f:name": {}, ".": {} }, ".": {} }, ".": {} } }, "f:restartPolicy": {}, "f:tolerations": {}, "f:dnsPolicy": {}, "f:initContainers": { "k:{\"name\":\"fluentd-init\"}": { "f:image": {}, "f:imagePullPolicy": {}, "f:command": {}, "f:volumeMounts": { "k:{\"mountPath\":\"/etc/fluent/keys\"}": { "f:readOnly": {}, "f:mountPath": {}, "f:name": {}, ".": {} }, ".": {} }, "f:terminationMessagePath": {}, "f:name": {}, "f:resources": { "f:limits": { "f:memory": {}, ".": {} }, "f:requests": { "f:memory": {}, "f:cpu": {}, ".": {} }, ".": {} }, "f:terminationMessagePolicy": {}, ".": {} }, ".": {} }, "f:serviceAccountName": {}, "f:serviceAccount": {}, "f:nodeSelector": { "f:kubernetes.io/os": {}, ".": {} } } }, "apiVersion": "v1", "manager": "kube-controller-manager", "time": "2021-05-12T13:36:54Z", "operation": "Update", "fieldsType": "FieldsV1" }, { "fieldsV1": { "f:metadata": { "f:annotations": { "f:k8s.v1.cni.cncf.io/network-status": {}, "f:k8s.v1.cni.cncf.io/networks-status": {} } } }, "apiVersion": "v1", "manager": "multus", "time": "2021-05-22T15:04:09Z", "operation": "Update", "fieldsType": "FieldsV1" }, { "fieldsV1": { "f:status": { "f:hostIP": {}, "f:phase": {}, "f:containerStatuses": {}, "f:podIP": {}, "f:initContainerStatuses": {}, "f:podIPs": { "k:{\"ip\":\"10.128.0.101\"}": { "f:ip": {}, ".": {} }, ".": {} }, "f:conditions": { "k:{\"type\":\"ContainersReady\"}": { "f:type": {}, "f:lastTransitionTime": {}, "f:status": {}, "f:lastProbeTime": {}, ".": {} }, "k:{\"type\":\"Ready\"}": { "f:type": {}, "f:lastTransitionTime": {}, "f:status": {}, "f:lastProbeTime": {}, ".": {} }, "k:{\"type\":\"Initialized\"}": { "f:type": {}, "f:lastTransitionTime": {}, "f:status": {}, "f:lastProbeTime": {}, ".": {} } }, "f:startTime": {} } }, "apiVersion": "v1", "manager": "kubelet", "time": "2021-05-22T15:04:13Z", "operation": "Update", "fieldsType": "FieldsV1" } ], "ownerReferences": [ { "kind": "DaemonSet", "name": "fluentd", "apiVersion": "apps/v1", "controller": true, "blockOwnerDeletion": true, "uid": "8631f9f1-c571-4386-bde5-66a379d4be9b" } ], "resourceVersion": "104301834", "generateName": "fluentd-", "creationTimestamp": "2021-05-12T13:36:54Z", "annotations": { "k8s.v1.cni.cncf.io/networks-status": "[{\n \"name\": \"\",\n \"interface\": \"eth0\",\n \"ips\": [\n \"10.128.0.101\"\n ],\n \"default\": true,\n \"dns\": {}\n}]", "logging.openshift.io/hash": "c65777c5a76db7a209a3ba5e6c5590cb", "k8s.v1.cni.cncf.io/network-status": "[{\n \"name\": \"\",\n \"interface\": \"eth0\",\n \"ips\": [\n \"10.128.0.101\"\n ],\n \"default\": true,\n \"dns\": {}\n}]", "scheduler.alpha.kubernetes.io/critical-pod": "", "openshift.io/scc": "privileged" }, "selfLink": "/api/v1/namespaces/openshift-logging/pods/fluentd-nbbq5", "uid": "6431c761-113e-457a-9e2c-646d7effe18f" } } srvlnxzabbix01:/usr/lib/zabbix/externalscripts#

END

Thankyou very much for your patience.

zensix commented 3 years ago

I have some problem to decode json file ( json error ) possible to do this: ./request_oc_project.py.ORIG dump_object -e oscllab -n openshift-logging -s /api/v1/namespaces/openshift-logging/pods/fluentd-nbbq5 > dump.json and attach result file (dump.jsonà to as link to you post ?

pizzulicchio commented 3 years ago

Sure, dump.json.txt

here for you in attachment. ( it's named dump.json.txt but it's dump.json)

zensix commented 3 years ago

Hi, I discovers curious think , this json generated by python cannot be reload by python ( don't like the managedFields section with entry like " "f:generateName": {}," ... ) Then I change method to generate dc_status output object, has other version it's work for me I hope this will solve your problem, because at the moment I have no other idea and I will have more openshift environment available at the end of the week (I change jobs).

pizzulicchio commented 3 years ago

Bad news... nothing has changed... So it continues to not work. But how is possible that even with this change in your code, i have the exact same output ? Same error and same dump.json if i test it.

maybe some package that i have to install using pip or apt command, to make it works? I'm using Debian 10.

pizzulicchio commented 3 years ago

Hi, i have installed a fresh new RedHat Enterprise 8 , exactly a Red Hat Enterprise Linux release 8.4 (Ootpa). I have noticed these facts: 1) i have had to install python2 and these requirements:

python2-requests python2-backports python2-backports-ssl_match_hostname python2-chardet python2-idna python2-ipaddress python2-pysocks python2-six python2-urllib3

I have deduced it after seeing this error: immagine

This is trivial for a programmer but not for others ;-) I suggest to insert into the docs.

I haven't had any problem into my Debian 10 because i have surely just installed these dependencies for other python's script.

but even in RedHat the "prom_rate_restart_pod" function/discovery isn't working. Same error. immagine

2) Is it possible that your script isn't working with python 3 ( 3.6.8 exactly )?

This is what happen when i test python 3: immagine

I hope to help into debugging. Have a nice day

pizzulicchio commented 3 years ago

Hi guy! have you got any news ?

ZocStorm commented 3 years ago

Hi,

I am also having the same problem with discovery's, 2 of 3 are not working...

Deployment Config Discover... image

and Pod Discover - Prom Restart Rate image

CMD output:

request_oc_project.py prom_rate_restart_pod -e test -n dcs-test Traceback (most recent call last): File "./request_oc_project.py", line 206, in <module> main(cmd,args) File "./request_oc_project.py", line 196, in main prom_rate_restart_pod(cfg['prometheus'],namespace) File "./request_oc_project.py", line 122, in prom_rate_restart_pod r = s.request('GET',url,params=payload,headers={'Authorization': 'Bearer '+cfg['token']},verify=False) File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 542, in request resp = self.send(prep, **send_kwargs) File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 655, in send r = adapter.send(request, **kwargs) File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //prometheus-k8s-openshift-monitoring.apps.ost.egcp.com:443/api/v1/query?query=rate%28kube_pod_container_status_restarts_total%7Bjob%3D%22kube-state-metrics%22%2Cnamespace%3D%22dcs-test%22%7D%5B15m%5D%29 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f73e9a71850>: Failed to establish a new connection: [Errno -2] Name or service not known',))

request_oc_project.py dc_discover -e test -n dcs-test Traceback (most recent call last): File "./request_oc_project.py", line 206, in <module> main(cmd,args) File "./request_oc_project.py", line 188, in main dc_discover(cfg,namespace) File "./request_oc_project.py", line 55, in dc_discover obj={"{#NAME}":item['metadata']['name'].encode('utf-8'),"{#NAMESPACE}":namespace,"{#SELFLINK}":item['metadata']['selfLink'].encode('utf-8')} KeyError: 'selfLink'

My zabbix version is 5.0 and python 2.7

I also noticed language mix, some trigger names and descriptions in template are in French and some in English.

Hope this helps to fix the issues and make this a successful implementation of zabbix openshift monitoring extension.

Regards

ZocStorm commented 2 years ago

Hi,

New problem emerged, after OpenShift upgrade to v4.8 the one working discovery also stopped working.

Invalid discovery rule value: cannot parse as a valid JSON object: invalid object format, expected opening character '{' or '[' at: 'Traceback (most recent call last): File "/usr/lib/zabbix/externalscripts/request_oc_project.py", line 206, in <module> main(cmd,args) File "/us

Regards

zensix commented 2 years ago

Hi ZocStorm, Thk for your contribution I no longer have access to an openshift environment (other work) so unfortunately I can no longer develop this project. if other people want to take it back it will be with pleasure for me.