Giter Site home page Giter Site logo

Comments (6)

aimbot31 avatar aimbot31 commented on April 28, 2024 11

Kubernetes RAM, CPU, Events :
Requires : kubectl with a valid configuration

runcharts:
  - title: K8S Node Ram Usage
    position: [[0, 20], [40, 20]]
    rate-ms: 5000
    legend:
        enabled: true
        details: false
    scale: 0
    items:
      - label: node1
        color: 178
        sample: kubectl top nodes | awk 'NR==2 {printf "%d", $5}'
      - label: node2
        sample: kubectl top nodes | awk 'NR==3 {printf "%d", $5}'
      - label: node4
        sample: kubectl top nodes | awk 'NR==4 {printf "%d", $5}'
    triggers:
      - title: RAM usage exceeded
        condition: echo "$cur > 80" |bc -l
        actions:
          terminal-bell: true
          sound: true
          visual: true
          script: 'say alert: ${label} : RAM exceeded ${cur}% of usage'
  - title: K8S Node CPU Usage
    position: [[40, 20], [40, 20]]
    rate-ms: 5000
    legend:
        enabled: true
        details: false
    scale: 0
    items:
      - label: node1
        color: 178
        sample: kubectl top nodes | awk 'NR==2 {printf "%d", $3}'
      - label: node2
        sample: kubectl top nodes | awk 'NR==3 {printf "%d", $3}'
      - label: node4
        sample: kubectl top nodes | awk 'NR==4 {printf "%d", $3}'
    triggers:
      - title: CPU usage exceeded
        condition: echo "$cur > 80" |bc -l
        actions:
          terminal-bell: true
          sound: true
          visual: true
          script: 'say alert: ${label} : CPU exceeded ${cur}% of usage'
textboxes:
  - title: Kubernetes events
    position: [[0, 0], [80, 20]]
    rate-ms: 3000
    color: 211
    sample: kubectl get events -A | grep -e "Failed" -e "NAMESPACE"

from sampler.

Asherslab avatar Asherslab commented on April 28, 2024 5

So, after a days work. i improved upon my thing above.
Now, it's python, and faster, and better. does sometimes error though.

Python3 script: https://gist.github.com/Asherslab/1f37627854e913b86f088aa8ca30e8d0

i use a cache file to keep just one session accessing the api, so this is needed for all the elements below it:

This would definitely be improved by: #38
(instead of having cache.json)

Note: i have the rate-ms at 30 minutes because my repo was large and didn't wanna update too often. just be careful that you don't exceed github's rate limiting

textboxes:
  - title: ""
    position: [[0, 0], [0, 0]]
    rate-ms: 1800000
    sample: github/main.py output -k <GITHUB OAUTH KEY> -r ldtteam/minecolonies -f cache.json -l > /dev/null
    border: false

Sparklines for open and closed issues

sparklines:
  - title: Open Issues
    position: [[0, 6], [40, 9]]
    rate-ms: 2000
    sample: cat cache.json | github/main.py input -si -v issues.open
  - title: Closed Issues
    position: [[40, 6], [40, 9]]
    rate-ms: 2000
    sample: cat cache.json | github/main.py input -si -v issues.closed

Runcharts for issue labels

runcharts:
  - title: Issues
    position: [[0, 20], [80, 20]]
    rate-ms: 2000
    legend:
        enabled: true
        details: false
    scale: 2
    items:
      - label: Bug
        sample: cat cache.json | github/main.py input -si -v issues.labels.bug.open
      - label: Invalid
        sample: cat cache.json | github/main.py input -si -v issues.labels.invalid.open
      - label: Question
        sample: cat cache.json | github/main.py input -si -v issues.labels.question.open
      - label: In Progress
        sample: cat cache.json | github/main.py input -si -v issues.labels.in_progress.open

Text box for some data:

textboxes:
  - title: Pull Requests
    position: [[0, 15], [20, 5]]
    rate-ms: 2000
    sample: cat cache.json | github/main.py input -si --verbose -v pull_requests.open pull_requests.closed pull_requests.total pull_requests.labels.hotfix.open

ASCII box that uses the repo's name:

asciiboxes:
  - title: name
    position: [[0, 0], [26, 6]]
    rate-ms: 2000
    sample: cat cache.json | github/main.py input -si -v name

from sampler.

Asherslab avatar Asherslab commented on April 28, 2024 3

On another note. lemme throw in my small (and stupidly complicated) Bash script, and config, for github issues/pr count viewing.

BTW, only my second time writing a bash script. don't stab me =P

https://gist.github.com/Asherslab/2553dc63a95702563007e193e93878ae

a few example sections using the script:

Requirements: All these scripts require the jq bash command, plus the script above (yeah it's death)

View your projects open PRs vs Closed (in a gauge)

gauges:
  - title: "[ChatChain] Open Prs"
    rate-ms: 300000
    percent-only: false
    color: 178
    cur:
      sample: ./github.sh -n -r ldtteam/chatchain -s open -t pr
    max:
      sample: ./github.sh -n -r ldtteam/chatchain -s total -t pr
    min:
      sample: echo 0

View your project's open Issues vs Closed (in a gauge)

gauges:
  - title: "[ChatChain] Open Issues"
    rate-ms: 300000
    percent-only: false
    cur:
      sample: ./github.sh -n -r ldtteam/chatchain -s open -t issue
    max:
      sample: ./github.sh -n -r ldtteam/chatchain -s total -t issue
    min:
      sample: echo 0

View all stats in a simple text box

textboxes:
  - title: "[ChatChain] Status"
    position: [[1, 6], [23, 35]]
    rate-ms: 300000
    sample: ./github.sh -r ldtteam/chatchain

Note: there are rate limits on github's API. (you can increase them by using an API Key with the -u and -p parameters)

Note2: Large repositories take a decent while to load/whatever. The script could very much be improved. i'm probably gonna redo it in python or something similar at a later point. maybe

from sampler.

sqshq avatar sqshq commented on April 28, 2024 1

Hey @WaffleMongeringShit, thank you for sharing and starting the thread! I've pinned it.

btw I recommend to use init script to establish the database connection, otherwise it will be done each time the sample script is executed, which might cause unnecessary CPU utilization at higher update rates

from sampler.

Asherslab avatar Asherslab commented on April 28, 2024 1

[Request]
Could someone make something for some nice Docker Swarm metrics?
Node metrics (maybe cpu and such) and stack metrics?

EDIT:
Also @sqshq you could make this a wiki page instead, and have additions to this issue added to it if wanted?

from sampler.

umbynos avatar umbynos commented on April 28, 2024

Here's my contribution: CPU temperature runchart:

  - title: CPU Temp
    rate-ms: 1000        # sampling rate, default = 1000
    scale: 0            # number of digits after sample decimal point, default = 1
    legend:
      enabled: true     # enables item labels, default = true
      details: true    # enables item statistics: cur/min/max/dlt values, default = true
    items:
      - label: CPU Temp
        sample: cat /sys/class/thermal/thermal_zone2/temp | awk '{ print ($1 / 1000)}'
        color: 178      # 8-bit color number, default one is chosen from a pre-defined palette

PS: thermal_zone2 may not correspond with your CPU. I suggest to search it with cat /sys/class/thermal/thermal_zone*/type and find x86_pkg_temp, which in my case correspond to thermal_zone2

from sampler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.