일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- MySQL
- rsync
- xcache
- node.js
- 날짜계산
- 중독 게임
- 워드프레스한글팩
- 뒤로 가기
- security.limit_extensions
- openfire
- 리플리케이션 오류
- 태권브이
- ssmtp
- 특정 패키지 업데이트 중지 / 해제
- quota
- 재귀쿼리
- no key alg
- 앞으로 가기
- 쁘띠프랑스
- php-fpm
- 외래키
- 태권v
- strtotime
- set foreign_key
- 이미지주소추출
- mongodb
- simplexml_load_filesimplexml
- 훼인
- node 이미지 저장
- php
- Today
- Total
일상 기록 창고
파이썬으로 ssh 접속하여 cpu,메모리,os,아이피 정보 가져오기 본문
서버의 CPU, 메모리, OS, 아이피 정보 등을 확인할 필요가 있어서 수동으로 처리하기 귀찮아 구글링으로 만든거..
import paramiko olist = {} ips = ['127.0.0.1']; for index, ip in enumerate(ips): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( hostname = ip, username = '', password = '', port = '' ) command01 = "grep \"model name\" /proc/cpuinfo | sort -u | awk '{print $4, $5, $6, $7, $8, $9}'" command02 = "cat /proc/meminfo | grep MemTotal: | awk '{print $2}'" command03 = "cat /etc/redhat-release" # 사설아이피 세팅했다면 head -n 숫자 적당히 command04 = "/sbin/ifconfig | grep \"inet addr:\" | awk '{print $2}' | head -n 1" commands = [command01,command02, command03, command04] info = {} for index,command in enumerate(commands): stdin , stdout, stderr = c.exec_command(command) if index == 0: info['cpu'] = stdout.read() elif index == 1: info['memory'] = stdout.read() elif index == 2: info['os'] = stdout.read() else: info['ip'] = stdout.read() c.close() olist[ip] = info print(olist) |
내용만 그냥 출력 해 봄.
'프로그래밍 > PHP' 카테고리의 다른 글
php-fpm 사용 시 한글 설정 (0) | 2019.12.31 |
---|---|
스핑크스 검색엔진 마리아 디비 searchd 실행 시 오류 처리 (0) | 2018.08.22 |
카카오 페이 연동을 위해 만든 클래스 (0) | 2018.04.04 |
초를 일,시, 분 추출하기... (0) | 2017.08.11 |
Laravel 프레임워크 설치 오류.. (0) | 2015.03.31 |