简介

这是一个在实际应用场景下的软件。 通过Curl抓取网页源代码来监控目标字段的变化,实时把握库存信息,支持微信/TG频道推送。

演示地址:http://vps.hcaiyue.top/

截图

请输入图片描述

安装

Github地址:https://github.com/546669204/vps-inventory-monitoring

本教程使用的是宝塔面板,建议新手也使用这个。

1、安装宝塔

#Centos系统
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh

#Ubuntu系统
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash install.sh

#Debian系统
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && bash install.sh

安装完成后,请进入面板安装PHP至少5.4Nginxmysql环境。再添加域名。

2、下载程序

#进入根目录
cd /www/wwwroot/xx.com
git clone https://github.com/546669204/vps-inventory-monitoring.git
mv vps-inventory-monitoring/{.,}* ./
chmod -Rf 755 ./*

3、伪静态设置
左侧网站-域名设置-找到网站目录,把运行目录改成public。再找到伪静态,添加:

location / {
   if (!-e $request_filename) {
   rewrite  ^(.*)$  /index.php?s=/$1  last;
   break;
    }
 }

4、配置数据库
将根目录下的mysql.sql导入到你的数据库,编辑app/database.example.php文件,填写数据库信息,并重命名为database.php

5、修改系统配置
编辑app/index/config.php文件修改定时时间、域名等。然后打开域名访问即可。

6、自动检测
最后我们需要定时设置检测,有2种方法,自己选择吧。

1、定时任务设置
点击宝塔左侧定时计划,任务类型选择URL访问,时间设置每5分钟,URL:https://xx.com/index/index/test

2、运行验证程序,间隔时间去app/index/config.php修改
screen -S vpstest //创建screen
cd [网站根目录]
php think VpsTest
CTRL A D //退出screen
然后关闭ssh即可 重新进入查看可使用
screen -r vpstest

使用

由于原项目没有说明初始用户名和密码,所以我们需要自己注册账号后,去数据库找到xm_user删除id1的初始账户,找到自己注册账户id,并编辑app/index/config.php文件,将adduid改成自己的。

程序暂时没有删除操作,我们可以去数据库,通过操作xm_placexm_companyxm_index进行删除操作。

如果添加后不会检测,修改数据库xm_indexstatus1(1视为通过审核)。

最后总结

这是一个在实际应用场景下的软件。 通过Curl 抓取网页源代码 来监控 目标字段的变化 实时把握库存信息。需要注意的地方就是添加验证函数(PHP语言)时候,我们需要指定好关键字。

VPS-Inventory-Monitoring最大的特点是可以设置微信和TG消息提醒。

分类: 教程 标签: vps-inventory-monitoring监控脚本

评论

暂无评论数据

暂无评论数据

目录