Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
filebeat
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段孔乐
filebeat
Commits
c1d47cff
Commit
c1d47cff
authored
Jul 01, 2021
by
段孔乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add install script
parent
89c65dd1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
64 deletions
+128
-64
filebeat-qiuck-install.sh
filebeat-qiuck-install.sh
+20
-0
install.sh
install.sh
+9
-64
uninstall.sh
uninstall.sh
+9
-0
util.sh
util.sh
+90
-0
No files found.
filebeat-qiuck-install.sh
0 → 100644
View file @
c1d47cff
#!/bin/bash
logstash_host
=
"124.71.144.118:15044"
scan_dir
=
"/data/backend-micro/**/*.log"
src
=
"https://gitlab.33.cn/dkl/filebeat/-/archive/1.0.0/filebeat-1.0.0.tar.gz"
name
=
${
src
##*/
}
folder
=
${
name
%.tar.gz
}
service
=
${
folder
%-*
}
version
=
${
folder
#*-
}
dest
=
/usr/share/filebeat
mkdir
-p
$dest
cd
$dest
||
exit
1
if
[
-e
"./
$name
"
]
;
then
rm
-rf
$name
;
fi
wget
$src
tar
-zxf
$name
rm
-rf
$name
cd
$folder
||
exit
1
source
./install.sh
install.sh
View file @
c1d47cff
# logstash_host=124.71.144.118:15044
# scan_dir=/data/backend-micro/**/*.log
# 字体颜色
blue
(){
echo
-e
"
\0
33[34m
\0
33[01m
$1
\0
33[0m"
}
green
(){
echo
-e
"
\0
33[32m
\0
33[01m
$1
\0
33[0m"
}
red
(){
echo
-e
"
\0
33[31m
\0
33[01m
$1
\0
33[0m"
}
function
checkEnv
()
{
if
[
-z
"
$logstash_host
"
]
;
then
red
"please input logstash host in this script first line"
&&
exit
1
;
fi
if
[
-z
"
$scan_dir
"
]
;
then
red
"please input scan dir in this script first line"
&&
exit
1
;
fi
}
function
initConf
(){
cat
>
./filebeat.yml
<<-
EOF
filebeat.inputs:
- type: log
paths:
- "
$scan_dir
"
exclude_files: ["stat.log
$"
]
output.logstash:
hosts: ["
$logstash_host
"]
EOF
}
function
initService
(){
#!/bin/bash
# logstash_host="124.71.144.118:15044"
# scan_dir="/data/backend-micro/**/*.log"
serviceName
=
"filebeat"
spath
=
$(
pwd
)
svcname
=
${
serviceName
}
.service
svcpath
=
${
spath
}
/
${
svcname
}
echo
"[Unit]
Description=Filebeat
Documentation=https://www.elastic.co/guide/en/beats/filebeat/current/index.html
Wants=network-online.target
After=network-online.target
[Service]
User=root
ExecStart=
${
spath
}
/filebeat -c
${
spath
}
/filebeat.yml
Restart=always
[Install]
WantedBy=multi-user.target
"
>
$svcpath
cp
$svcpath
/etc/systemd/system/
sudo
systemctl daemon-reload
sudo
systemctl
enable
$svcname
}
source
./util.sh
checkEnv
initFilebeatService
initConf
initService
\ No newline at end of file
sudo
systemctl start
${
serviceName
}
.service
green
"filebeat install success"
\ No newline at end of file
uninstall.sh
0 → 100644
View file @
c1d47cff
#!/bin/bash
source
./util.sh
sudo
systemctl disable filebeat.serivce 2>/dev/null
sudo
systemctl stop filebeat.serivce 2>/dev/null
rm
-rf
/etc/systemd/system/filebeat.serivce
rm
-rf
/usr/share/filebeat
sudo
systemctl daemon-reload
green
"uninstall succeed"
util.sh
0 → 100644
View file @
c1d47cff
# 字体颜色
blue
(){
echo
-e
"
\0
33[34m
\0
33[01m
$1
\0
33[0m"
}
green
(){
echo
-e
"
\0
33[32m
\0
33[01m
$1
\0
33[0m"
}
red
(){
echo
-e
"
\0
33[31m
\0
33[01m
$1
\0
33[0m"
}
function
confirm
()
{
while
true
do
read
-r
-p
"
$1
[y/n] "
input
case
$input
in
[
yY][eE][sS]|[yY]
)
return
1
;;
[
nN][oO]|[nN]
)
return
0
;;
*
)
red
"Invalid input,
$1
[y/n]"
;;
esac
done
}
function
initConf
(){
cat
>
./filebeat.yml
<<-
EOF
filebeat.inputs:
- type: log
paths:
- "
$scan_dir
"
exclude_files: ["stat.log
$"
]
output.logstash:
hosts: ["
$logstash_host
"]
EOF
}
serviceName
=
"filebeat"
function
initFilebeatService
(){
if
[
"
$(
systemctl list-units |grep
-c
$serviceName
)
"
-gt
0
]
;
then
\
red
"
$serviceName
service exist"
;
\
if
[
"
$(
confirm
'are you want override it?'
)
"
==
0
]
;
then
\
green
"exit"
exit
0
;
fi
fi
spath
=
$(
pwd
)
svcname
=
${
serviceName
}
.service
svcpath
=
${
spath
}
/
${
svcname
}
echo
"[Unit]
Description=Filebeat
Documentation=https://www.elastic.co/guide/en/beats/filebeat/current/index.html
Wants=network-online.target
After=network-online.target
[Service]
User=root
ExecStart=
${
spath
}
/filebeat -c
${
spath
}
/filebeat.yml
Restart=always
[Install]
WantedBy=multi-user.target
"
>
$svcpath
cp
$svcpath
/etc/systemd/system/
sudo
systemctl daemon-reload
sudo
systemctl
enable
$svcname
}
function
checkEnv
()
{
if
[
-z
"
$logstash_host
"
]
;
then
red
"please input logstash host in this script first line"
&&
exit
1
;
fi
if
[
-z
"
$scan_dir
"
]
;
then
red
"please input scan dir in this script first line"
&&
exit
1
;
fi
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment