1) 에러 내용 목록 :

modulenotfounderror: no module named 'requests'
ModuleNotFoundError: No module named 'slack_sdk'

ModuleNotFoundError: No module named 'bs4'

 

 

2) 해결 내역 :

ㄴ 팁으로, pip install을 하려면 python이 설치되어 있는 경로로 이동해서 설치해야만 한다!
경로 : C:\Users\7040_64bit\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0

C:\Users\7040_64bit\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0>pip install requests
Collecting requests
  Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting charset-normalizer<4,>=2 (from requests)
  Downloading charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl.metadata (34 kB)
Collecting idna<4,>=2.5 (from requests)
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ---------------------------------------- 61.5/61.5 kB 545.7 kB/s eta 0:00:00
Collecting urllib3<3,>=1.21.1 (from requests)
  Downloading urllib3-2.0.7-py3-none-any.whl.metadata (6.6 kB)
Collecting certifi>=2017.4.17 (from requests)
  Downloading certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB)
Downloading requests-2.31.0-py3-none-any.whl (62 kB)
   ---------------------------------------- 62.6/62.6 kB 1.7 MB/s eta 0:00:00
Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
   ---------------------------------------- 158.3/158.3 kB 3.2 MB/s eta 0:00:00
Downloading charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl (99 kB)
   ---------------------------------------- 99.9/99.9 kB 1.9 MB/s eta 0:00:00
Downloading urllib3-2.0.7-py3-none-any.whl (124 kB)
   ---------------------------------------- 124.2/124.2 kB 2.4 MB/s eta 0:00:00
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
  WARNING: The script normalizer.exe is installed in 'C:\Users\7040_64bit\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed certifi-2023.7.22 charset-normalizer-3.3.2 idna-3.4 requests-2.31.0 urllib3-2.0.7

C:\Users\7040_64bit\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0>echo $?
$?

C:\Users\7040_64bit\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0>pip install slack_sdk
Collecting slack_sdk
  Downloading slack_sdk-3.23.0-py2.py3-none-any.whl.metadata (15 kB)
Downloading slack_sdk-3.23.0-py2.py3-none-any.whl (281 kB)
   ---------------------------------------- 281.0/281.0 kB 2.2 MB/s eta 0:00:00
Installing collected packages: slack_sdk
Successfully installed slack_sdk-3.23.0

C:\Users\7040_64bit\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0>pip install beautifulsoup4
Collecting beautifulsoup4
  Downloading beautifulsoup4-4.12.2-py3-none-any.whl (142 kB)
     ---------------------------------------- 143.0/143.0 kB 606.1 kB/s eta 0:00:00
Collecting soupsieve>1.2 (from beautifulsoup4)
  Downloading soupsieve-2.5-py3-none-any.whl.metadata (4.7 kB)
Downloading soupsieve-2.5-py3-none-any.whl (36 kB)
Installing collected packages: soupsieve, beautifulsoup4
Successfully installed beautifulsoup4-4.12.2 soupsieve-2.5

C:\Users\7040_64bit\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0>pip install chardet
Collecting chardet
  Downloading chardet-5.2.0-py3-none-any.whl.metadata (3.4 kB)
Downloading chardet-5.2.0-py3-none-any.whl (199 kB)
   ---------------------------------------- 199.4/199.4 kB 1.3 MB/s eta 0:00:00
Installing collected packages: chardet
  WARNING: The script chardetect.exe is installed in 'C:\Users\7040_64bit\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed chardet-5.2.0

 

*추가에러 :
UnicodeDecodeError: 'cp949' codec can't decode byte 0xed in position 129: illegal multibyte sequence

* 해결 : 텍스트 파일의 코딩 인식이 불가해서 생기는 문제, 
             파이썬 내 config 값을 utf-8로 읽도록 설정해주면 된다.

<As is>

config.read(config_file)

 

<To be>

config.read(config_file, encoding='utf-8')

'Language > python' 카테고리의 다른 글

python 3.6 / pip 설치  (0) 2023.11.06

# 차단된 아이피 주소들
$IPAddressesToUnblock = @("222.117.28.177", "220.86.111.40", "59.24.255.87", "192.168.0.0/24", "134.237.1.0/24", "134.237.22.21")

# 차단 규칙 이름 설정
$RuleName = "Block_IP_Rule"

# 아이피 주소들을 차단 규칙으로부터 삭제하는 함수 정의
function RemoveBlockIPRule {
    foreach ($ip in $IPAddressesToUnblock) {
        $existingRule = Get-NetFirewallRule | Where-Object { $_.DisplayName -like "$RuleName - $ip" }
        if ($existingRule -ne $null) {
            Remove-NetFirewallRule -Name $existingRule.Name
            Write-Host "아이피 주소 '$ip'의 차단 규칙이 삭제되었습니다."
        } else {
            Write-Host "아이피 주소 '$ip'의 차단 규칙이 존재하지 않습니다."
        }
    }
}

# 차단 규칙 삭제
RemoveBlockIPRule

# 스크립트가 실행되었다는 표시
Write-Host "IP 차단 규칙 삭제 스크립트가 실행되었습니다."

'Language > Power shell' 카테고리의 다른 글

고급보안방화벽 특정 IP차단  (0) 2023.11.07
윈도우 고급방화벽 ip 차단(cmd 명령어)  (0) 2023.11.07

# 차단할 아이피 주소들
$IPAddressesToBlock = @("222.117.28.177", "220.86.111.40", "59.24.255.87", "192.168.0.0/24", "134.237.1.0/24", "134.237.22.21")

# 차단 규칙 이름과 설명 설정
$RuleName = "Block_IP_Rule"
$RuleDescription = "특정 아이피 차단 규칙"

# 아이피 주소들을 차단하는 규칙 추가 함수 정의
function AddBlockIPRule {
    foreach ($ip in $IPAddressesToBlock) {
        New-NetFirewallRule -DisplayName "$RuleName - $ip" -Description $RuleDescription -Direction Inbound -Action Block -RemoteAddress $ip -Enabled True
        Write-Host "아이피 주소 '$ip'가 차단되었습니다."
    }
}

# 아이피 주소들을 차단하는 규칙 삭제 함수 정의
function RemoveBlockIPRule {
    foreach ($ip in $IPAddressesToBlock) {
        $existingRule = Get-NetFirewallRule | Where-Object { $_.DisplayName -like "$RuleName - $ip" }
        if ($existingRule -ne $null) {
            Remove-NetFirewallRule -Name $existingRule.Name
            Write-Host "아이피 주소 '$ip'의 차단 규칙이 삭제되었습니다."
        } else {
            Write-Host "아이피 주소 '$ip'의 차단 규칙이 존재하지 않습니다."
        }
    }
}

# 차단 규칙 추가
AddBlockIPRule

# 스크립트가 실행되었다는 표시
Write-Host "IP 차단 스크립트가 실행되었습니다."

netsh advfirewall firewall add rule name="BLOCK IP ADDRESS" dir=in action=block remoteip=185.11.61.0/24

 

'Language > Power shell' 카테고리의 다른 글

고급보안방화벽 특정 IP차단_해제  (0) 2023.11.07
고급보안방화벽 특정 IP차단  (0) 2023.11.07
python 3.6 / pip 설치
 
1. 파이썬 3.6.3버전 설치
[root@cobuy-1037(222.122.41.74) ~/src]# wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
[root@cobuy-1037(222.122.41.74) ~/src]# tar xvf Python-3.6.3.tar.xz
[root@cobuy-1037(222.122.41.74) ~/src]# cd Python-3.6.3
[root@cobuy-1037(222.122.41.74) ~/src/Python-3.6.3]# ./configure --prefix=/usr/local/python3.6.3
[root@cobuy-1037(222.122.41.74) ~/src/Python-3.6.3]# make -j `grep processor /proc/cpuinfo | wc -l`; make install
[root@cobuy-1037(222.122.41.74) /usr/local/python3.6.3/bin]# ./python3.6 --version
Python 3.6.3
 
# /usr/local/python3.6.3/bin/python3 --version
Python 3.6.3
 
 
2. 요청하신 get-pip.py로 설치 완료
# /usr/local/python3.6.3/bin/python3 get-pip.py
Collecting pip<22.0
  Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 33.9 MB/s           
Collecting wheel
  Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, pip
  Attempting uninstall: pip
    Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-21.3.1 wheel-0.37.1
 
# /usr/local/python3.6.3/bin/pip3.6 --version
pip 21.3.1 from /usr/local/python3.6.3/lib/python3.6/site-packages/pi

 

'Language > python' 카테고리의 다른 글

python 실행시 에러 관련 내용  (0) 2023.11.13

#!/bin/bash
# apache+tomcat install
while [ : ]
do
        echo -e "Do you want to proceed with the dependency library installation? [ y / n ]"
        read input1
        echo "Your Input : $input1"
        if [ "$input1" = "y" ]
then
yum -y install epel-release
yum -y install cmake
yum -y install make
yum -y install gcc
yum -y install gcc-c++
yum -y install ncurses-devel
yum -y install libevent
yum -y install openssl
yum -y install openssl-devel
yum -y install gnutls-devel
yum -y install libxml2
yum -y install libxml2-devel
yum -y install bison
yum -y install gdbm
yum -y install gdbm-devel
yum -y install gmp
yum -y install gmp-devel
yum -y install bzip2-devel
yum -y install curl-devel
yum -y install libjpeg-devel
yum -y install libXpm-devel
yum -y install freetype-devel
yum -y install libtool
yum -y install expat-devel
yum -y install pcre-devel
yum -y install apr-devel
yum -y install apr-util
yum -y install libzip
yum -y install libmcrypt
yum -y install libmcrypt-devel
yum -y install php-mcrypt
yum -y install libxml2-devel
yum -y install libm
yum -y install crypt-devel
yum -y install java-1.8.0-openjdk-devel.x86_64
yum -y install wget
yum -y install net-tools
yum -y install vim
fi
        echo -e '|======================================================|'
        echo -e '| SP1 : Apache 2.4  / tomcat 7                         |'
        echo -e '| SP2 : Apache 2.4  / tomcat 8                         |'
        echo -e '| SP3 : Apache 2.4  / tomcat 9                         |'
        echo -e '|======================================================|'
        echo -e "Which ApacheTomcat Version would you like yo install?"
        read input
        echo "Your Input : $input"
if [ "$input" = "SP1" ]
        then
        echo "SP 1 install [y/n]?"
        read input
        fi
if [ "$input" = "y" ]
then
mkdir /root/src
cd /root/src
wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.94/bin/apache-tomcat-7.0.94.tar.gz
tar xvfz apache-tomcat-7.0.94.tar.gz
cp -rf apache-tomcat-7.0.94 /opt/tomcat
echo -e "CATALINA_HOME=/opt/tomcat" >> /etc/profile
echo -e "PATH=$PATH:$CATALINA_HOME/bin" >> /etc/profile
echo -e "export CATALINA_HOME PATH" >> /etc/profile
source /etc/profile
wget http://archive.apache.org/dist/httpd/httpd-2.4.39.tar.gz
tar xvfz httpd-2.4.39.tar.gz
cd /root/src/httpd-2.4.39/srclib
wget https://archive.apache.org/dist/apr/apr-1.7.0.tar.gz
tar xvfz apr-1.7.0.tar.gz
wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
tar xvfz apr-util-1.6.1.tar.gz
mv apr-1.7.0 apr; mv apr-util-1.6.1 apr-util
cd /root/src/httpd-2.4.39
./configure --prefix=/opt/apache --with-mpm=prefork --enable-headers=shared --enable-rewrite=shared --enable-mods-shared=most --with-ssl --enable-ssl --with-included-apr --with-included-apr-util --with-included-apr-iconv
make -j `grep processor /proc/cpuinfo | wc -l`; make install
cd /root/src
wget https://downloads.apache.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz
tar xvfz tomcat-connectors-1.2.48-src.tar.gz
cd /root/src/tomcat-connectors-1.2.48-src/native
./configure --with-apxs=/opt/apache/bin/apxs
make && make install
cd /opt/apache/conf
touch workers.properties
echo -e "workers.tomcat_home=" \"/opt/tomcat\" >> workers.properties
echo -e "ps=/" >> workers.properties
echo -e "worker.list=ajp13" >> workers.properties
echo -e "worker.ajp13.port=8009" >> workers.properties
echo -e "worker.ajp13.host=localhost" >> workers.properties
echo -e "worker.ajp13.type=ajp13" >> workers.properties
touch mod_jk.conf
echo -e "<IfModule mod_jk.c>" >> mod_jk.conf
echo -e "JkWorkersFile" \"/opt/apache/conf/workers.properties\" >> mod_jk.conf
echo -e "JkLogFile" \"/opt/tomcat/logs/mod_jk.log\" >> mod_jk.conf
echo -e "JkLogLevel info" >> mod_jk.conf
echo -e "JkAutoAlias "\"/opt/tomcat/webapps\" >> mod_jk.conf
echo -e "JkMount /* ajp13" >> mod_jk.conf
echo -e "JkMount /*.jsp ajp13" >> mod_jk.conf
echo -e "JkMount /servlet/* ajp13" >> mod_jk.conf
echo -e "JkMount /examples/*.jsp ajp13" >> mod_jk.conf
echo -e "JkLogStampFormat" \"[\%a \%b \%d \%H:\%M:\%S \%Y]\"   >> mod_jk.conf
echo -e "JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories" >> mod_jk.conf
echo -e "JkRequestLogFormat" \"\%w \%V \%T\" >> mod_jk.conf
echo -e "</IfModule>" >> mod_jk.conf
 
cd /opt/tomcat/logs
touch mod_jk.log
sed -i '154s/$/LoadModule jk_module modules\/mod_jk.so/g' /opt/apache/conf/httpd.conf
echo -e "include conf/mod_jk.conf" >> /opt/apache/conf/httpd.conf
sed -i '93d' /opt/tomcat/conf/server.xml
sed -i '94s/address="::1"/address="0.0.0.0"/g' /opt/tomcat/conf/server.xml
sed -i '98d' /opt/tomcat/conf/server.xml
sed -i '/port="8009"/i\               secretRequired="false"' /opt/tomcat/conf/server.xml
sleep 3
/opt/tomcat/bin/startup.sh
/opt/apache/bin/apachectl start
/opt/apache/bin/apachectl -v
/opt/tomcat/bin/version.sh
sleep 1
/opt/tomcat/bin/startup.sh
netstat -nlpt
break;
fi
if [ "$input" = "SP2" ]
        then
        echo "SP 2 install [y/n]?"
        read input
        fi
if [ "$input" = "y" ]
        then
mkdir /root/src
cd /root/src
wget http://archive.apache.org/dist/tomcat/tomcat-8/v8.5.38/bin/apache-tomcat-8.5.38.tar.gz
tar xvfz apache-tomcat-8.5.38.tar.gz
cp -rf apache-tomcat-8.5.38 /opt/tomcat
echo -e "CATALINA_HOME=/opt/tomcat" >> /etc/profile
echo -e "PATH=$PATH:$CATALINA_HOME/bin" >> /etc/profile
echo -e "export CATALINA_HOME PATH" >> /etc/profile
source /etc/profile
wget http://archive.apache.org/dist/httpd/httpd-2.4.39.tar.gz
tar xvfz httpd-2.4.39.tar.gz
cd /root/src/httpd-2.4.39/srclib
wget https://archive.apache.org/dist/apr/apr-1.7.0.tar.gz
tar xvfz apr-1.7.0.tar.gz
wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
tar xvfz apr-util-1.6.1.tar.gz
mv apr-1.7.0 apr; mv apr-util-1.6.1 apr-util
cd /root/src/httpd-2.4.39
./configure --prefix=/opt/apache --with-mpm=prefork --enable-headers=shared --enable-rewrite=shared --enable-mods-shared=most --with-ssl --enable-ssl --with-included-apr --with-included-apr-util --with-included-apr-iconv
make -j `grep processor /proc/cpuinfo | wc -l`; make install
cd /root/src
wget https://downloads.apache.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz
tar xvfz tomcat-connectors-1.2.48-src.tar.gz
cd /root/src/tomcat-connectors-1.2.48-src/native
./configure --with-apxs=/opt/apache/bin/apxs
make && make install
cd /opt/apache/conf
touch workers.properties
echo -e "workers.tomcat_home=" \"/opt/tomcat\" >> workers.properties
echo -e "ps=/" >> workers.properties
echo -e "worker.list=ajp13" >> workers.properties
echo -e "worker.ajp13.port=8009" >> workers.properties
echo -e "worker.ajp13.host=localhost" >> workers.properties
echo -e "worker.ajp13.type=ajp13" >> workers.properties
touch mod_jk.conf
echo -e "<IfModule mod_jk.c>" >> mod_jk.conf
echo -e "JkWorkersFile" \"/opt/apache/conf/workers.properties\" >> mod_jk.conf
echo -e "JkLogFile" \"/opt/tomcat/logs/mod_jk.log\" >> mod_jk.conf
echo -e "JkLogLevel info" >> mod_jk.conf
echo -e "JkAutoAlias "\"/opt/tomcat/webapps\" >> mod_jk.conf
echo -e "JkMount /* ajp13" >> mod_jk.conf
echo -e "JkMount /*.jsp ajp13" >> mod_jk.conf
echo -e "JkMount /servlet/* ajp13" >> mod_jk.conf
echo -e "JkMount /examples/*.jsp ajp13" >> mod_jk.conf
echo -e "JkLogStampFormat" \"[\%a \%b \%d \%H:\%M:\%S \%Y]\"   >> mod_jk.conf
echo -e "JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories" >> mod_jk.conf
echo -e "JkRequestLogFormat" \"\%w \%V \%T\" >> mod_jk.conf
echo -e "</IfModule>" >> mod_jk.conf
 
cd /opt/tomcat/logs
touch mod_jk.log
sed -i '154s/$/LoadModule jk_module modules\/mod_jk.so/g' /opt/apache/conf/httpd.conf
echo -e "include conf/mod_jk.conf" >> /opt/apache/conf/httpd.conf
sed -i '116d' /opt/tomcat/conf/server.xml
sed -i '117s/address="::1"/address="0.0.0.0"/g' /opt/tomcat/conf/server.xml
sed -i '/port="8009"/i\               secretRequired="false"' /opt/tomcat/conf/server.xml
sed -i '121d' /opt/tomcat/conf/server.xml
sleep 3
/opt/tomcat/bin/startup.sh
/opt/apache/bin/apachectl start
/opt/apache/bin/apachectl -v
/opt/tomcat/bin/version.sh
sleep 1
/opt/tomcat/bin/startup.sh
netstat -nlpt
break;
fi
if [ "$input" = "SP3" ]
        then
        echo "SP3 install [y/n]?"
        read input
        fi
if [ "$input" = "y" ]
        then
mkdir /root/src
cd /root/src
wget http://archive.apache.org/dist/tomcat/tomcat-9/v9.0.33/bin/apache-tomcat-9.0.33.tar.gz
tar xvfz apache-tomcat-9.0.33.tar.gz
cp -rf apache-tomcat-9.0.33 /opt/tomcat
echo -e "CATALINA_HOME=/opt/tomcat" >> /etc/profile
echo -e "PATH=$PATH:$CATALINA_HOME/bin" >> /etc/profile
echo -e "export CATALINA_HOME PATH" >> /etc/profile
source /etc/profile
wget http://archive.apache.org/dist/httpd/httpd-2.4.39.tar.gz
tar xvfz httpd-2.4.39.tar.gz
cd /root/src/httpd-2.4.39/srclib
wget https://archive.apache.org/dist/apr/apr-1.7.0.tar.gz
tar xvfz apr-1.7.0.tar.gz
wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
tar xvfz apr-util-1.6.1.tar.gz
mv apr-1.7.0 apr; mv apr-util-1.6.1 apr-util
cd /root/src/httpd-2.4.39
./configure --prefix=/opt/apache --with-mpm=prefork --enable-headers=shared --enable-rewrite=shared --enable-mods-shared=most --with-ssl --enable-ssl --with-included-apr --with-included-apr-util --with-included-apr-iconv
make -j `grep processor /proc/cpuinfo | wc -l`; make install
cd /root/src
wget https://downloads.apache.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz
tar xvfz tomcat-connectors-1.2.48-src.tar.gz
cd /root/src/tomcat-connectors-1.2.48-src/native
./configure --with-apxs=/opt/apache/bin/apxs
make && make install
cd /opt/apache/conf
touch workers.properties
echo -e "workers.tomcat_home=" \"/opt/tomcat\" >> workers.properties
echo -e "ps=/" >> workers.properties
echo -e "worker.list=ajp13" >> workers.properties
echo -e "worker.ajp13.port=8009" >> workers.properties
echo -e "worker.ajp13.host=localhost" >> workers.properties
echo -e "worker.ajp13.type=ajp13" >> workers.properties
touch mod_jk.conf
echo -e "<IfModule mod_jk.c>" >> mod_jk.conf
echo -e "JkWorkersFile" \"/opt/apache/conf/workers.properties\" >> mod_jk.conf
echo -e "JkLogFile" \"/opt/tomcat/logs/mod_jk.log\" >> mod_jk.conf
echo -e "JkLogLevel info" >> mod_jk.conf
echo -e "JkAutoAlias "\"/opt/tomcat/webapps\" >> mod_jk.conf
echo -e "JkMount /* ajp13" >> mod_jk.conf
echo -e "JkMount /*.jsp ajp13" >> mod_jk.conf
echo -e "JkMount /servlet/* ajp13" >> mod_jk.conf
echo -e "JkMount /examples/*.jsp ajp13" >> mod_jk.conf
echo -e "JkLogStampFormat" \"[\%a \%b \%d \%H:\%M:\%S \%Y]\"   >> mod_jk.conf
echo -e "JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories" >> mod_jk.conf
echo -e "JkRequestLogFormat" \"\%w \%V \%T\" >> mod_jk.conf
echo -e "</IfModule>" >> mod_jk.conf
cd /opt/tomcat/logs
touch mod_jk.log
sed -i '154s/$/LoadModule jk_module modules\/mod_jk.so/g' /opt/apache/conf/httpd.conf
echo -e "include conf/mod_jk.conf" >> /opt/apache/conf/httpd.conf
sed -i '116d' /opt/tomcat/conf/server.xml
sed -i '117s/address="::1"/address="0.0.0.0"/g' /opt/tomcat/conf/server.xml
sed -i '/port="8009"/i\               secretRequired="false"' /opt/tomcat/conf/server.xml
sed -i '121d' /opt/tomcat/conf/server.xml
sleep 3
/opt/tomcat/bin/startup.sh
/opt/apache/bin/apachectl start
/opt/apache/bin/apachectl -v
/opt/tomcat/bin/version.sh
sleep 1
/opt/tomcat/bin/startup.sh
netstat -nlpt
break;
fi
done

'Language > bash shell' 카테고리의 다른 글

실시간 트래픽 측정하기  (0) 2023.11.04
서버 제원 체크 및 APM 실행여부 확인  (0) 2023.11.04

#!/bin/bash
 
Eno=`/sbin/ifconfig | /usr/bin/head -n 1 | /usr/bin/tail -n 1 | awk '{print $1}' | sed 's/://g'`
echo "Time : receive (Kbit/Sec) / transmit (Kbit/Sec)"
while ( true ) ;
do
        rx1=`grep $Eno /proc/net/dev | awk '{print $1}' | sed 's/://g'`
        tx1=`grep $Eno /proc/net/dev | awk '{print $9}'`
 
        sleep 3
 
        rx3=$(((rx1)/128/3))
        tx3=$(((tx1)/128/3))
 
        echo "`date '+%k:%M:%S'` : $rx3 / $tx3"
done

'Language > bash shell' 카테고리의 다른 글

apache+tomcat 설치 스크립트  (0) 2023.11.04
서버 제원 체크 및 APM 실행여부 확인  (0) 2023.11.04

용도 : 서버 제원 체크 및 apm 실행여부 확인

수준 : Centos6, Centos7 테스트 완료

특이사항 : 

  1. 서버 제원 체크
    ㄴ HDD, RAM, CPU 사용 현황 확인
    ㄴ IP, Hostname, Kernel, OS명 조회 가능
  2. apm 실행여부 확인
    ㄴ apm 각각 버전 확인 가능
    ㄴ 실행 / 미실행 구분 가능

 

 

#!/bin/bash -l
rdate -s time.bora.net; /sbin/hwclock --systohc
function _Check_Base() {
    service_type="q352 q361 q381 q382 q391 q552 q561"
    os_version=$(cat /etc/redhat-release | awk -F'.' '{print $1}' | awk '{print $NF}')
    os_fullname=$(cat /etc/redhat-release)
    kernel_name=$(uname -r)
    server_hostname=$(hostname | awk -F'.' '{print $1}')
    hostname_type=$(hostname | awk -F'-' '{print $1}')
    apache_yn=$(netstat -tnlp | grep httpd | grep -v "thttpd" | awk '{print $7}' | awk -F '/' '{print $2}')
   #apache_version=$(httpd -v | head -n1 | awk '{print $3}')
   #apache_version2=$(/usr/sbin/httpd -v | head -n1 | awk '{print $3}')
    php_yn=$(which php | awk -F 'bin/' '{print $2}')
   #php_version=$(php -v | head -n1 | awk '{print $1, $2}')
   #php_version2=$(/usr/bin/php -v | head -n1 | awk '{print $1, $2}')
    mysql_yn=$(netstat -tnlp | grep mysql | awk '{print $7}' | awk -F '/' '{print $2}')
   #mysql_version=$(mysql -V | awk '{print $5}')
   #mysql_version2=$(/usr/bin/mysql -V | awk '{print $5}')
    cpu_top=$(top -bn1 | grep -i 'cpu(s)' | awk -F ',' 'substr($4,0,length($4)-3)' | head -n1 | awk '{print $1, $2, $3 ,$4, $5, $6, $7}')
    disk_use=$(/sbin/fdisk -l | grep ^Disk | egrep /dev | head -n4 | awk '{print $2, $3, $4}')
    memory_use=$(dmidecode --type 17 | grep -E "Memory|Size|Type|Speed" | grep -v "Type Detail" | grep -v "Configured Clock Speed" | grep -v "No Module Insta
lled" | grep -v "Unknown" | grep -v "Empty")
 
    if [ ${os_version} -eq 6 ]
    then
        server_ip=$(ifconfig | egrep "inet addr" | egrep -v "127.0.0.1" | awk '{print $2}' | awk -F':' '{print $2}')
    elif [ ${os_version} -eq 7 ]
    then
        server_ip=$(ifconfig | egrep "inet" | egrep -v "127.0.0.1|inet6" | awk '{print $2}')
    else
        echo "invalid os version !!"
        exit 0
    fi
 
    check_service=$(echo ${service_type} | egrep "${hostname_type}" | wc -w)
 
    if [ ${check_service} -eq 0 ]
    then
        echo "invalid service type (hostname) !!"
        exit 0
    fi
 
 
#    if [ ${apache_yn} != "httpd" ]
#    then
#        echo "apache가 실행 되어있지 않습니다."
#        exit 0
#    fi   
 
}
 
function _Write_Message() {
 
 echo -e "==========================================================="
 echo -e "                   \033[31;1m * 서버 상태 파악 *\033[m          "
 echo -e "==========================================================="
 
 echo -e " 서버 IP는 \033[36;1m${server_ip}\033[m 입니다. "
 echo "-----------------------------------------------------------"
 echo -e " 서버 Hostname 은 \033[36;1m${server_hostname}\033[m 입니다. "
 echo "-----------------------------------------------------------"
 echo -e " 서버 OS 명은 \033[36;1m${os_fullname}\033[m 입니다. "
 echo "-----------------------------------------------------------"
 echo -e " 서버 Kernel 명은 \033[36;1m${kernel_name}\033[m 입니다. "
 echo "-----------------------------------------------------------"
    if [ -z ${apache_yn} ]
    then
         echo -e "\033[31;1m Apache가 실행 되어있지 않습니다.\033[m"
    else
         apache_version=$(httpd -v | head -n1 | awk '{print $3}')
         echo -e " 서버 Apache 버전은 \033[36;1m${apache_version}\033[m 입니다. "
    fi
 echo "-----------------------------------------------------------"
    if [ -z ${php_yn} ]
    then
         echo -e "\033[31;1m PHP가 설치 되어있지 않습니다.\033[m"
    else
         php_version=$(php -v | head -n1 | awk '{print $1, $2}')
         echo -e " 서버 PHP 버전은 \033[36;1m${php_version}\033[m 입니다. "
    fi
 echo "-----------------------------------------------------------"
    if [ -z ${mysql_yn} ]
    then
         echo -e "\033[31;1m Mysql이 실행 되어있지 않습니다.\033[m"
    else
         mysql_version=$(mysql -V | awk '{print $5}')
         echo -e " 서버 Mysql 버전은 \033[36;1m${mysql_version}\033[m 입니다. "
    fi
 echo "-----------------------------------------------------------"
 echo -e " 서버 Cpu 사용량은 \033[36;1m${cpu_top}\033[m 입니다. "
 echo "-----------------------------------------------------------"
 echo " 사용중인 서버 HDD "
 echo "-----------------------------------------------------------"
 echo -e "\033[36;1m${disk_use}\033[m"
 echo "-----------------------------------------------------------"
 echo " 사용중인 서버 Memory (Slot별로 확인가능) "
 echo "-----------------------------------------------------------"
 echo -e "\033[36;1m${memory_use}\033[m"
 echo "-----------------------------------------------------------"
}
 
 
function _Main() {
 
    _Check_Base
    _Write_Message
 
}
 
_Main

'Language > bash shell' 카테고리의 다른 글

apache+tomcat 설치 스크립트  (0) 2023.11.04
실시간 트래픽 측정하기  (0) 2023.11.04

+ Recent posts