Grafana 기초1

Prometheus 2021. 11. 10. 13:41

테스트 환경 : VirturalBox 6.x   ,  Ubuntu20.04

 

ubuntu 설치시에 Prometheus를 기본으로 추가 하여 설치 하였다.

prometheus.yml 설정파일이 보이고  9090포트가 LISTEN이 된걸 확인 할수 있다.

root@server:/# find ./ -name prometheus.yml
./var/snap/prometheus/53/prometheus.yml
root@server:/#

root@server:/# netstat -an | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:40778         127.0.0.1:9090          ESTABLISHED
tcp        0     64 192.168.0.50:22         192.168.0.28:9862       ESTABLISHED
tcp6       0      0 :::9090                 :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 127.0.0.1:9090          127.0.0.1:40778         ESTABLISHED
udp        0      0 127.0.0.53:53           0.0.0.0:*
udp        0      0 192.168.0.50:68         0.0.0.0:*
raw6       0      0 :::58                   :::*                    

 

 

모니터정보를 수집할 Agent를 설치한 모습

 

'Prometheus' 카테고리의 다른 글

fluent-bit , influxDB  (2) 2024.07.19
신규 설치 error  (0) 2024.04.18
블로그 이미지

iesay

,

DISCORD bot 제작

nodejs 2021. 10. 22. 23:48

DISCORD bot 제작

출처 :  https://mmsesang.tistory.com/19

 

nodejs 버전 14.10 설정

apt-get install build-essential libssl-dev
 


curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
 


source ~/.bashrc

 

nvm install 14.10.0

nvm use v14.10.0

nvm alias default v14.10.0
node --version

 

package.json

{
  "name": "bot",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "discord.js": "^12.3.0"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

기본으로 npm install discord.js 설치한 13버전은 동작하지 않았슴

dependencies    discord버전을 12.3으로 명시해서

npm init

npm install을 하는게 좋음

 

 

index.js

const Discord = require("discord.js");
const config = require("./config.json");
const prefix = "!";


const client = new Discord.Client();


client.on("message", function(message) {
    // message 작성자가 봇이면 그냥 return
    if (message.author.bot) return;
    // message 시작이 prefix가 아니면 return
    if (!message.content.startsWith(prefix)) return;


    const commandBody = message.content.slice(prefix.length);
    const args = commandBody.split(' ');
    const command = args.shift().toLowerCase();
   
    if (command === "ping") {
        message.reply(`pong!`);
    } else if (command === "sum") {
        const numArgs = args.map(x => parseFloat(x));
        const sum = numArgs.reduce((counter, x) => counter += x);
        message.reply(`Sum result: ${sum}`);
    }
});


client.login(config.BOT_TOKEN);


config.json

{
    "BOT_TOKEN": "본인토큰값"
}

실행하기

root@server:~/bot# node index.js

 

!ping   명령어를 치면 

봇이 pong! 으로 응답하고

!sum 1 2 3  입력하면

Sum result : 6 반환한다.

다양한 봇을 작성할수가 있다.

 

 

 

 

 

'nodejs' 카테고리의 다른 글

nodejs so파일  (0) 2021.09.10
MongoError: Cannot use a session that has ended  (0) 2021.07.20
nodejs 버전 업데이트 하기  (0) 2021.07.15
nodemon 설정 방법  (0) 2020.12.09
axios 전송  (0) 2020.12.08
블로그 이미지

iesay

,

nodejs so파일

nodejs 2021. 9. 10. 14:55

출처 : https://github.com/node-ffi/node-ffi

디렉토리 생성

 

root@server:~/ffi-napi# node -v
v12.19.0

 

 

mkdir ffi-napi

cd ffi-napi

npm install ffi-napi

 

 

factorial.c

#include <stdio.h>


int factorial(int max) {
  int i = max;
  int result = 1;

  while (i >= 2) {
    result *= i--;
  }

  return result;
}

int main(void)
{
        printf("%d\n", factorial(6));
        return 0;
}

공유라이브러리 컴파일

gcc -shared -fpic factorial.c -o libfactorial.so

 

factorial.js

var ffi = require('ffi-napi');
var libfactorial = ffi.Library('./libfactorial', {
  'factorial': [ 'uint64', [ 'int' ] ]
})

if (process.argv.length < 3) {
  console.log('Arguments: ' + process.argv[0] + ' ' + process.argv[1] + ' <max>')
  process.exit()
}

var output = libfactorial.factorial(parseInt(process.argv[2]))

console.log('Your output: ' + output) 

 

실행 

root@server:~/ffi-napi# node factorial.js 3
Your output: 6
root@server:~/ffi-napi# node factorial.js 7
Your output: 5040

'nodejs' 카테고리의 다른 글

DISCORD bot 제작  (0) 2021.10.22
MongoError: Cannot use a session that has ended  (0) 2021.07.20
nodejs 버전 업데이트 하기  (0) 2021.07.15
nodemon 설정 방법  (0) 2020.12.09
axios 전송  (0) 2020.12.08
블로그 이미지

iesay

,