a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 學院 > 操作系統 > 正文

bearychat+hubot chatops運維機器人

2024-06-28 16:00:31
字體:
來源:轉載
供稿:網友

1.安裝nodejs

yum安裝:[root@node1 ~]# yum install -y epel-release[root@node1 ~]# yum install -y npm[root@node1 ~]# npm -version3.10.8[root@node1 ~]# node -vv6.9.1二進制包安裝最新版:官網下載地址:https://nodejs.org/en/download/[root@node1 ~]# tar xf node-v6.9.5-linux-x64.tar.xz[root@node1 ~]# mv node-v6.9.5-linux-x64 /usr/local/nodejs[root@node1 ~]# vim /etc/PRofileexport NODE_HOME=/usr/local/nodejsexport PATH=$NODE_HOME/bin:$PATH[root@node1 ~]# source /etc/profile[root@node1 ~]# npm -version3.10.10[root@node1 ~]# node -vv6.9.5

2. 安裝hubot

[root@node1 ~]# npm install -g hubot coffee-script yo generator-hubot[root@node1 ~]# mkdir myhubot && cd myhubot[root@node1 myhubot]# yo hubot (提示沒有權限)/usr/local/nodejs/lib/node_modules/yo/node_modules/mkdirp/index.js:90 throw err0; ^Error: EACCES: permission denied, mkdir '/root/.config' at Error (native) at Object.fs.mkdirSync (fs.js:922:18) at sync (/usr/local/nodejs/lib/node_modules/yo/node_modules/mkdirp/index.js:71:13) at Function.sync (/usr/local/nodejs/lib/node_modules/yo/node_modules/mkdirp/index.js:77:24) at Object.get (/usr/local/nodejs/lib/node_modules/yo/node_modules/configstore/index.js:38:13) at Object.Configstore (/usr/local/nodejs/lib/node_modules/yo/node_modules/configstore/index.js:27:44) at new Insight (/usr/local/nodejs/lib/node_modules/yo/node_modules/insight/lib/index.js:37:34) at Object.<anonymous> (/usr/local/nodejs/lib/node_modules/yo/lib/cli.js:172:11) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10)[root@node1 myhubot]# chmod g+w /root (修改root目錄權限)[root@node1 myhubot]# yo hubot? ==========================================================================We're constantly looking for ways to make yo better! May we anonymously report usage statistics to improve the tool over time? More info: https://github.com/yeoman/insight & http://yeoman.io========================================================================== Yes _____________________________ / / /// | Extracting input for | ///// _____ | self-replication process | /////// /_____/ / / ======= |[^_//_]| /---------------------------- | | _|___@@__|__ +===+/ /// /_/ | |_/ /// HUBOT/// |___//// / // / / +---+ /____/ | | | //| +===+ /// |xx| ? Owner XXX <XXX@163.com>? Bot name myhubot? Description A simple helpful robot for your Company? Bot adapter campfire create bin/hubot create bin/hubot.cmd create Procfile create README.md create external-scripts.json create hubot-scripts.json create .gitignore create package.json create scripts/example.coffee create .editorconfig _____________________________ _____ / / / / | Self-replication process | | | _____ | complete... | |__//| /_____/ / Good luck with that. / |//+ |[^_//_]| /---------------------------- | | _|___@@__|__ +===+/ /// /_/ | |_/ /// HUBOT/// |___//// / // / / +---+ /____/ | | | //| +===+ /// |xx| myhubot@0.0.0 /root/myhubot├─┬ hubot@2.19.0 │ ├── async@0.9.2 │ ├─┬ chalk@1.1.3 │ │ ├── ansi-styles@2.2.1 │ │ ├── escape-string-regexp@1.0.5 │ │ ├─┬ has-ansi@2.0.0 │ │ │ └── ansi-regex@2.1.1 │ ││ │ ├─┬ connect@2.30.2 ......[root@node1 myhubot]# chmod g-w /root (將root目錄權限恢復原狀)[root@node1 myhubot]# npm install hubot-bearychat --savemyhubot@0.0.0 /root/myhubot└─┬ hubot-bearychat@0.3.1 ├─┬ bearychat@0.1.0 │ ├── babel-plugin-add-module-exports@0.2.1 │ ├─┬ isomorphic-fetch@2.2.1 │ │ ├─┬ node-fetch@1.6.3 │ │ │ ├─┬ encoding@0.1.12 │ │ │ │ └── iconv-lite@0.4.15 │ │ │ └── is-stream@1.1.0 │ │ └── whatwg-fetch@2.0.2 │ └── urijs@1.18.5 └─┬ ws@1.1.1 ├── options@0.0.6 └── ultron@1.0.2

安裝shell 命令腳本支持模塊:

[root@node1 myhubot]# npm install hubot-script-shellcmdmyhubot@0.0.0 /root/myhubot└── hubot-script-shellcmd@0.0.16[root@node1 myhubot]# cp -R node_modules/hubot-script-shellcmd/bash ./修改一下external-scripts.json,添加模塊:hubot-script-shellcmd[root@node1 myhubot]# cat external-scripts.json [ "hubot-diagnostics", "hubot-help", "hubot-heroku-keepalive", "hubot-google-images", "hubot-google-translate", "hubot-pugme", "hubot-maps", "hubot-redis-brain", "hubot-rules", "hubot-shipit", "hubot-script-shellcmd" //新增部分][root@node1 myhubot]# cd bash/handlers/[root@node1 handlers]# lshelloworld update新增腳本[root@node1 handlers]# cat disk #!/bin/bashdf -h[root@node1 handlers]# chmod +x disk

3. 注冊bearychat添加機器人

https://www.bearychat.com 注冊并登陸 這里寫圖片描述 這里寫圖片描述 這里寫圖片描述

注意:

復制Hubot Token 這個很重要Hubot URL 端口可以隨意指定【export EXPRESS_PORT=9090】

下載bearychat客戶端或者直接使用網頁版都可以

配置hubot并啟動

此處的token就是第三步添加機器人時顯示的token多個使用逗號分隔[root@node1 myhubot]# export HUBOT_BEARYCHAT_TOKENS=bd00e55956a3759886c21c1ac1fd17dd[root@node1 myhubot]# export HUBOT_BEARYCHAT_MODE=rtm[root@node1 myhubot]# export EXPRESS_PORT=9090[root@node1 myhubot]# nohup ./bin/hubot -a bearychat 2&1> hubot.log[root@node1 myhubot]# netstat -tnlp|grep 9090tcp 0 0 0.0.0.0:9090 0.0.0.0:* LISTEN 54886/node 為了以后啟動方便可以直接將變量寫人文件:[root@node1 myhubot]# cat /etc/profile.d/myhubot.sh export HUBOT_BEARYCHAT_TOKENS=bd00e5595121249886c21c1ac1fd17ddexport HUBOT_BEARYCHAT_MODE=rtmexport EXPRESS_PORT=9090[root@node1 myhubot]# source /etc/profile 這樣以后就無需手動再次export

5. 客戶端登錄并測試

這里寫圖片描述

6. 機器人腳本示例

[root@node1 ~]# cd myhubot/scripts[root@node1 scripts]# vim example.coffee (編輯并修改) ....# Uncomment the ones you want to try and experiment with.## These are from the scripting documentation: https://github.com/github/hubot/blob/master/docs/scripting.mdmodule.exports = (robot) -> robot.hear /jevic/i, (res) -> res.send "https://jevic.github.io"# robot.respond /open the (.*) doors/i, (res) ->....

這里寫圖片描述

重啟hubot [root@node1 ~]# nohup ./bin/hubot -a bearychat 2&1>> hubot.log &

測試

這里寫圖片描述

參考鏈接用slack和hubot搭建你自己的運維機器人hubot-bearychathttps://hubot.github.com
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 欧美黄色大片网站 | 国产精品视频久久久久 | 91视频电影 | 黄a免费网络 | 午夜寂寞少妇aaa片毛片 | 欧美成人第一页 | 欧美日韩1区 | 精品国产不卡一区二区三区 | 亚洲日韩中文字幕 | 四虎入口 | 在线电影一区 | 午夜精品久久久久久久久久久久 | 国产日韩欧美一区二区 | 国产精品日韩 | 日韩免费观看 | www.夜夜操.com | 色av色av色av | 中文字幕第90页 | 日本久久艹 | 成人午夜免费视频 | 国产精品久久久久久久一区探花 | 日韩精品在线观看一区 | 91亚洲精品乱码久久久久久蜜桃 | 国产美女在线精品免费观看网址 | www.久久久.com | 国产精品久久久久久久久久 | 求av网站| 国产日韩欧美在线观看 | 99热精品在线 | 成人男女激情免费视频 | 日韩一区二区在线免费观看 | 日韩在线你懂的 | 午夜视频| 国产剧情一区二区 | 欧美成人综合 | 日韩精品极品在线观看 | 国产成人久久精品一区二区三区 | 欧美视频一二三区 | 亚洲精品一区二区网址 | 日韩在线播放一区 | 密室大逃脱第六季大神版在线观看 |