diff --git a/src/main/java/com/nis/dao/AccountDao.java b/src/main/java/com/nis/dao/AccountDao.java deleted file mode 100644 index d90e432..0000000 --- a/src/main/java/com/nis/dao/AccountDao.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Account; -import com.nis.entity.Asset; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - -/** - * 资产 dao - */ -@Mapper -@Repository -public interface AccountDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/AlertMessageActiveDao.java b/src/main/java/com/nis/dao/AlertMessageActiveDao.java deleted file mode 100644 index 7b1f4fc..0000000 --- a/src/main/java/com/nis/dao/AlertMessageActiveDao.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.AlertMessageActiveEntity; -import com.nis.entity.AlertMessageEntity; -import org.apache.ibatis.annotations.Mapper; - - -@Mapper -public interface AlertMessageActiveDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/AlertMessageDao.java b/src/main/java/com/nis/dao/AlertMessageDao.java deleted file mode 100644 index 077b2de..0000000 --- a/src/main/java/com/nis/dao/AlertMessageDao.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.nis.entity.AlertMessageEntity; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -@Mapper -public interface AlertMessageDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/AlertMessageHistoryDao.java b/src/main/java/com/nis/dao/AlertMessageHistoryDao.java deleted file mode 100644 index b9efba3..0000000 --- a/src/main/java/com/nis/dao/AlertMessageHistoryDao.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.AlertMessageActiveEntity; -import com.nis.entity.AlertMessageEntity; -import com.nis.entity.AlertMessageHistoryEntity; - -import org.apache.ibatis.annotations.Mapper; - - -@Mapper -public interface AlertMessageHistoryDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/AlertRuleDao.java b/src/main/java/com/nis/dao/AlertRuleDao.java index fe61f4b..76cbc45 100644 --- a/src/main/java/com/nis/dao/AlertRuleDao.java +++ b/src/main/java/com/nis/dao/AlertRuleDao.java @@ -1,17 +1,14 @@ package com.nis.dao; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.AlertMessageActiveEntity; -import com.nis.entity.AlertMessageEntity; -import com.nis.entity.AlertRuleEntity; - -import java.util.List; - +import com.nis.entity.AlertRule; import org.apache.ibatis.annotations.Mapper; - +import org.springframework.stereotype.Repository; @Mapper -public interface AlertRuleDao extends BaseMapper { +@Repository +public interface AlertRuleDao extends BaseMapper { + - List selectAllDatas(); } diff --git a/src/main/java/com/nis/dao/AssetAssetDao.java b/src/main/java/com/nis/dao/AssetAssetDao.java deleted file mode 100644 index 298b262..0000000 --- a/src/main/java/com/nis/dao/AssetAssetDao.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Asset; -import com.nis.entity.AssetAsset; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - -/** - * 资产 dao - */ -@Mapper -@Repository -public interface AssetAssetDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/AssetBrandDao.java b/src/main/java/com/nis/dao/AssetBrandDao.java deleted file mode 100644 index e92e3c5..0000000 --- a/src/main/java/com/nis/dao/AssetBrandDao.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Asset; -import com.nis.entity.AssetBrand; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - -/** - * 资产 dao - */ -@Mapper -@Repository -public interface AssetBrandDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/AssetDao.java b/src/main/java/com/nis/dao/AssetDao.java deleted file mode 100644 index 188e7ff..0000000 --- a/src/main/java/com/nis/dao/AssetDao.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Asset; - -import java.util.List; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - -/** - * 资产 dao - */ -@Mapper -@Repository -public interface AssetDao extends BaseMapper { - - -} diff --git a/src/main/java/com/nis/dao/AssetFieldMetaDao.java b/src/main/java/com/nis/dao/AssetFieldMetaDao.java deleted file mode 100644 index 4a64364..0000000 --- a/src/main/java/com/nis/dao/AssetFieldMetaDao.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.nis.dao; - -import java.util.List; -import java.util.Map; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.springframework.stereotype.Repository; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.nis.entity.AssetFieldMeta; - -@Mapper -@Repository -public interface AssetFieldMetaDao extends BaseMapper{ - -} diff --git a/src/main/java/com/nis/dao/AssetFieldValueDao.java b/src/main/java/com/nis/dao/AssetFieldValueDao.java deleted file mode 100644 index 989b7b5..0000000 --- a/src/main/java/com/nis/dao/AssetFieldValueDao.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.AssetFieldValue; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - -@Mapper -@Repository -public interface AssetFieldValueDao extends BaseMapper{ - -} diff --git a/src/main/java/com/nis/dao/AssetModelDao.java b/src/main/java/com/nis/dao/AssetModelDao.java deleted file mode 100644 index ab26981..0000000 --- a/src/main/java/com/nis/dao/AssetModelDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Asset; -import com.nis.entity.AssetModel; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface AssetModelDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/AssetTypeConfDao.java b/src/main/java/com/nis/dao/AssetTypeConfDao.java deleted file mode 100644 index 01e52af..0000000 --- a/src/main/java/com/nis/dao/AssetTypeConfDao.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.AssetTypeConf; -import com.nis.entity.Dc; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface AssetTypeConfDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/ChartDao.java b/src/main/java/com/nis/dao/ChartDao.java deleted file mode 100644 index b8ff83a..0000000 --- a/src/main/java/com/nis/dao/ChartDao.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Chart; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - - -@Mapper -@Repository -public interface ChartDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/ChartElementDao.java b/src/main/java/com/nis/dao/ChartElementDao.java deleted file mode 100644 index 27721cf..0000000 --- a/src/main/java/com/nis/dao/ChartElementDao.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.ChartElement; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface ChartElementDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/DcDao.java b/src/main/java/com/nis/dao/DcDao.java deleted file mode 100644 index 20fbac6..0000000 --- a/src/main/java/com/nis/dao/DcDao.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Dc; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface DcDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/EndpointDao.java b/src/main/java/com/nis/dao/EndpointDao.java deleted file mode 100644 index e506b2b..0000000 --- a/src/main/java/com/nis/dao/EndpointDao.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Endpoint; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface EndpointDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/IdcDao.java b/src/main/java/com/nis/dao/IdcDao.java deleted file mode 100644 index e556ebe..0000000 --- a/src/main/java/com/nis/dao/IdcDao.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Dc; -import com.nis.entity.Idc; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface IdcDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/ModelDao.java b/src/main/java/com/nis/dao/ModelDao.java deleted file mode 100644 index b6014a2..0000000 --- a/src/main/java/com/nis/dao/ModelDao.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.nis.entity.Model; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.Map; - -/** - * 资产型号 dao - * - * @author shizhendong - * @date 2019-11-21 - */ -@Mapper -@Repository -public interface ModelDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/ModuleDao.java b/src/main/java/com/nis/dao/ModuleDao.java deleted file mode 100644 index f371b8c..0000000 --- a/src/main/java/com/nis/dao/ModuleDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; - -import java.util.List; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface ModuleDao extends BaseMapper { - - List selectSnmpDatas(); -} diff --git a/src/main/java/com/nis/dao/AssetTagDao.java b/src/main/java/com/nis/dao/MonitorEndpointConfigDao.java similarity index 60% rename from src/main/java/com/nis/dao/AssetTagDao.java rename to src/main/java/com/nis/dao/MonitorEndpointConfigDao.java index ac49547..5922099 100644 --- a/src/main/java/com/nis/dao/AssetTagDao.java +++ b/src/main/java/com/nis/dao/MonitorEndpointConfigDao.java @@ -1,13 +1,12 @@ package com.nis.dao; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.nis.entity.MonitorEndpointConfig; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.AssetTag; - @Mapper @Repository -public interface AssetTagDao extends BaseMapper{ +public interface MonitorEndpointConfigDao extends BaseMapper { } diff --git a/src/main/java/com/nis/dao/MonitorEndpointDao.java b/src/main/java/com/nis/dao/MonitorEndpointDao.java index fd101e1..9f09864 100644 --- a/src/main/java/com/nis/dao/MonitorEndpointDao.java +++ b/src/main/java/com/nis/dao/MonitorEndpointDao.java @@ -1,24 +1,16 @@ -/** - - * - - * - - */ - package com.nis.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Dc; -import com.nis.entity.Idc; import com.nis.entity.MonitorEndpoint; - import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; +import java.util.List; @Mapper @Repository public interface MonitorEndpointDao extends BaseMapper { - + + List getEndpointBackupData(); + } diff --git a/src/main/java/com/nis/dao/MonitorModuleDao.java b/src/main/java/com/nis/dao/MonitorModuleDao.java index 21b07b4..234d051 100644 --- a/src/main/java/com/nis/dao/MonitorModuleDao.java +++ b/src/main/java/com/nis/dao/MonitorModuleDao.java @@ -1,24 +1,18 @@ -/** - - * - - * - - */ - package com.nis.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Dc; -import com.nis.entity.Idc; import com.nis.entity.MonitorModule; - import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; +import java.util.List; @Mapper @Repository public interface MonitorModuleDao extends BaseMapper { - + + void truncateData(); + + List getModuleBackupData(); + } diff --git a/src/main/java/com/nis/dao/MonitorProjectDao.java b/src/main/java/com/nis/dao/MonitorProjectDao.java deleted file mode 100644 index 0e721dc..0000000 --- a/src/main/java/com/nis/dao/MonitorProjectDao.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.MonitorProject; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface MonitorProjectDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/PanelDao.java b/src/main/java/com/nis/dao/PanelDao.java deleted file mode 100644 index 1107a97..0000000 --- a/src/main/java/com/nis/dao/PanelDao.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Panel; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - - -@Mapper -@Repository -public interface PanelDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/ProjectDao.java b/src/main/java/com/nis/dao/ProjectDao.java deleted file mode 100644 index 22d3063..0000000 --- a/src/main/java/com/nis/dao/ProjectDao.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Project; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface ProjectDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/ProjectTopoDao.java b/src/main/java/com/nis/dao/ProjectTopoDao.java deleted file mode 100644 index df959d0..0000000 --- a/src/main/java/com/nis/dao/ProjectTopoDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Project; -import com.nis.entity.ProjectTopo; - -import java.util.List; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface ProjectTopoDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/ProjectTopoIconDao.java b/src/main/java/com/nis/dao/ProjectTopoIconDao.java deleted file mode 100644 index e50be28..0000000 --- a/src/main/java/com/nis/dao/ProjectTopoIconDao.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Project; -import com.nis.entity.ProjectTopoIcon; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - -@Mapper -@Repository -public interface ProjectTopoIconDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/SnmpCredentialDao.java b/src/main/java/com/nis/dao/SnmpCredentialDao.java deleted file mode 100644 index cd1e98e..0000000 --- a/src/main/java/com/nis/dao/SnmpCredentialDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.SnmpCredential; - -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface SnmpCredentialDao extends BaseMapper{ - -} diff --git a/src/main/java/com/nis/dao/SysConfigDao.java b/src/main/java/com/nis/dao/SysConfigDao.java deleted file mode 100644 index 9d2c48c..0000000 --- a/src/main/java/com/nis/dao/SysConfigDao.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.SysConfigEntity; - -import java.util.List; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -/** - * 系统配置信息 - * - - */ -@Mapper -public interface SysConfigDao extends BaseMapper { - - List selectSysConfigEntitys(); -} diff --git a/src/main/java/com/nis/dao/SysDictDao.java b/src/main/java/com/nis/dao/SysDictDao.java deleted file mode 100644 index c565082..0000000 --- a/src/main/java/com/nis/dao/SysDictDao.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.SysDictEntity; - -import java.util.List; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - - -@Mapper -public interface SysDictDao extends BaseMapper { - - List selectDatas(@Param("type") String type); -} diff --git a/src/main/java/com/nis/dao/SysUserDao.java b/src/main/java/com/nis/dao/SysUserDao.java deleted file mode 100644 index 568ca45..0000000 --- a/src/main/java/com/nis/dao/SysUserDao.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.Account; -import com.nis.entity.Asset; -import com.nis.entity.SysUserEntity; - -import java.util.List; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - -@Mapper -@Repository -public interface SysUserDao extends BaseMapper { - - List selectOldUsers(); - - List selectNewUsers(); -} diff --git a/src/main/java/com/nis/dao/VisualChartDao.java b/src/main/java/com/nis/dao/VisualChartDao.java deleted file mode 100644 index 37d2833..0000000 --- a/src/main/java/com/nis/dao/VisualChartDao.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.VisualChart; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - - - -@Mapper -@Repository -public interface VisualChartDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/VisualChartElementDao.java b/src/main/java/com/nis/dao/VisualChartElementDao.java deleted file mode 100644 index 4362c1c..0000000 --- a/src/main/java/com/nis/dao/VisualChartElementDao.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.VisualChartElement; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - -@Mapper -@Repository -public interface VisualChartElementDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/dao/VisualPanelDao.java b/src/main/java/com/nis/dao/VisualPanelDao.java deleted file mode 100644 index 410ae01..0000000 --- a/src/main/java/com/nis/dao/VisualPanelDao.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.nis.entity.VisualPanel; - -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - -@Mapper -@Repository -public interface VisualPanelDao extends BaseMapper { - -} diff --git a/src/main/java/com/nis/entity/Account.java b/src/main/java/com/nis/entity/Account.java deleted file mode 100644 index 6c9d5f3..0000000 --- a/src/main/java/com/nis/entity/Account.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.nis.entity; - -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.Map; - -@Data -@TableName("account") -public class Account { - @TableId - private Integer id; - - private Integer assetId; - - private String protocol; - - private Integer port; - - private Object params; - - private String seq; - -} diff --git a/src/main/java/com/nis/entity/AlertMessageActiveEntity.java b/src/main/java/com/nis/entity/AlertMessageActiveEntity.java deleted file mode 100644 index bf5865a..0000000 --- a/src/main/java/com/nis/entity/AlertMessageActiveEntity.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - - -@Data -@TableName("alert_message_active") -public class AlertMessageActiveEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId(type = IdType.INPUT) - private Integer id; - - /** - * 告警规则id - */ - private Integer ruleId; - - /** - * 告警级别 - */ - private Integer severityId; - /** - * 告警摘要 - */ - private String summary; - /** - * 告警描述 - */ - private String description; - /** - * 告警labels信息 - */ - private String labels; - /** - * 开始时间 - */ - private Date startAt; - /** - * 结束时间 - */ - private Date endAt; - /** - * 状态 - */ - private Integer state; - /** - * 关联project id - */ - private Integer projectId; - /** - * 关联module Id - */ - private Integer moduleId; - /** - * 关联endpoint_id - */ - private Integer endpointId; - /** - * 关联asset id - */ - private Integer assetId; - /** - * 关联dc - */ - private Integer dcId; - - /** - * redis hash key - * */ - private String hashKey; - - /** - * remark 修改时使用此参数 记录手动关闭的备注信息 - */ - private String remark; - - /** - * linkId对应实体类 - * */ - @TableField(exist = false) - private Object linkObject; - - @TableField(exist = false) - private AlertRuleEntity alertRule; - - /** - * 对应的project - */ - @TableField(exist = false) - private Project project; - - /** - * module - */ - @TableField(exist = false) - private Module module; - - /** - * endpoint - */ - @TableField(exist = false) - private Endpoint endpoint; - - /** - * dc - */ - @TableField(exist = false) - private Dc dc; - - @TableField(exist = false) - private String severity; -} diff --git a/src/main/java/com/nis/entity/AlertMessageEntity.java b/src/main/java/com/nis/entity/AlertMessageEntity.java deleted file mode 100644 index 0f05b90..0000000 --- a/src/main/java/com/nis/entity/AlertMessageEntity.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - - -@Data -@TableName("alert_message") -public class AlertMessageEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId - private Integer id; - - /** - * 告警规则id - */ - private Integer ruleId; - - /** - * 告警级别 - */ - @TableField(exist = false) - private Integer severityId; - /** - * 告警摘要 - */ - private String summary; - /** - * 告警描述 - */ - private String description; - /** - * 告警labels信息 - */ - private String labels; - /** - * 开始时间 - */ - private Date startAt; - /** - * 结束时间 - */ - private Date endAt; - /** - * 状态 - */ - private Integer state; - /** - * 关联project id - */ - private Integer projectId; - /** - * 关联module Id - */ - private Integer moduleId; - /** - * 关联endpoint_id - */ - private Integer endpointId; - /** - * 关联asset id - */ - private Integer assetId; - /** - * 关联dc - */ - private Integer dcId; - - /** - * redis hash key - * */ - private String hashKey; - - /** - * remark 修改时使用此参数 记录手动关闭的备注信息 - */ - private String remark; - - /** - * linkId对应实体类 - * */ - @TableField(exist = false) - private Object linkObject; - - @TableField(exist = false) - private AlertRuleEntity alertRule; - - /** - * 对应的project - */ - @TableField(exist = false) - private Project project; - - /** - * module - */ - @TableField(exist = false) - private Module module; - - /** - * endpoint - */ - @TableField(exist = false) - private Endpoint endpoint; - - private String severity; -} diff --git a/src/main/java/com/nis/entity/AlertMessageHistoryEntity.java b/src/main/java/com/nis/entity/AlertMessageHistoryEntity.java deleted file mode 100644 index 176c656..0000000 --- a/src/main/java/com/nis/entity/AlertMessageHistoryEntity.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -@Data -@TableName("alert_message_history") -public class AlertMessageHistoryEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId(type = IdType.INPUT) - private Integer id; - - /** - * 告警规则id - */ - private Integer ruleId; - - /** - * 告警级别 - */ - private Integer severityId; - /** - * 告警摘要 - */ - private String summary; - /** - * 告警描述 - */ - private String description; - /** - * 告警labels信息 - */ - private String labels; - /** - * 开始时间 - */ - private Date startAt; - /** - * 结束时间 - */ - private Date endAt; - /** - * 状态 - */ - private Integer state; - /** - * 关联project id - */ - private Integer projectId; - /** - * 关联module Id - */ - private Integer moduleId; - /** - * 关联endpoint_id - */ - private Integer endpointId; - /** - * 关联asset id - */ - private Integer assetId; - /** - * 关联dc - */ - private Integer dcId; - - /** - * redis hash key - * */ - private String hashKey; - - /** - * remark 修改时使用此参数 记录手动关闭的备注信息 - */ - private String remark; - - /** - * linkId对应实体类 - * */ - @TableField(exist = false) - private Object linkObject; - - @TableField(exist = false) - private AlertRuleEntity alertRule; - - /** - * 对应的project - */ - @TableField(exist = false) - private Project project; - - /** - * module - */ - @TableField(exist = false) - private Module module; - - /** - * endpoint - */ - @TableField(exist = false) - private Endpoint endpoint; - - /** - * dc - */ - @TableField(exist = false) - private Dc dc; - - @TableField(exist = false) - private String severity; -} diff --git a/src/main/java/com/nis/entity/AlertRule.java b/src/main/java/com/nis/entity/AlertRule.java new file mode 100644 index 0000000..8b21d58 --- /dev/null +++ b/src/main/java/com/nis/entity/AlertRule.java @@ -0,0 +1,69 @@ +package com.nis.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +@Data +@TableName("alert_rule") +public class AlertRule implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + @TableId + private Integer id; + + private String name; + + private String expr; + + private String operator; + + private Double threshold; + + private Integer unit; + + private Integer last; + + private Integer severityId; + + private String summary; + + private String description; + + private Integer autoExpired; + + private Integer schedEnable; + + private String schedDays; + + private String schedStime; + + private String schedEtime; + + private Integer notifyActive; + + private Integer notifyExpired; + + private String trbShot; + + private String receiver; + + private String method; + + private Integer buildIn; + + private String seq; + + private Integer state; + + private Integer type; + + private Integer inr; + + private Integer timeout; + +} diff --git a/src/main/java/com/nis/entity/AlertRuleEntity.java b/src/main/java/com/nis/entity/AlertRuleEntity.java deleted file mode 100644 index 6b2280f..0000000 --- a/src/main/java/com/nis/entity/AlertRuleEntity.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - - -@Data -@TableName("alert_rule") -public class AlertRuleEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键id - */ - @TableId(type = IdType.INPUT) - private Integer id; - /** - * 告警名称 - */ - private String name; - - /** - * 运算表达式 - */ - private String expr; - - /** - * 比较符号 - */ - private String operator; - - /** - * 阈值 - */ - private Double threshold; - - /** - * 单位 - */ - private Integer unit; - /** - * 持续时间,单位s - */ - private Integer last; - /** - * 告警级别 - */ - private Integer severityId; - /** - * 告警摘要 - */ - private String summary; - /** - * 告警详细描述 - */ - private String description; - - /** - * 通知用户ids 可多个 - */ - private String receiver; - - /** - * 是否为内置规则 - */ - private Integer buildIn; - - /** - * 导入唯一标识 - */ - private String seq; - - @TableField(exist = false) - private String severity; - - private Integer method; -} diff --git a/src/main/java/com/nis/entity/AlertSeverityConf.java b/src/main/java/com/nis/entity/AlertSeverityConf.java deleted file mode 100644 index a6f18af..0000000 --- a/src/main/java/com/nis/entity/AlertSeverityConf.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -@Data -@TableName("alert_severity_conf") -public class AlertSeverityConf { - - @TableId - private Integer id; - - private String name; - - private String color; - - private Integer weight; - - private String remark; - - private String methods; - -} diff --git a/src/main/java/com/nis/entity/AlertSilenceConf.java b/src/main/java/com/nis/entity/AlertSilenceConf.java deleted file mode 100644 index 43c053a..0000000 --- a/src/main/java/com/nis/entity/AlertSilenceConf.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.Date; - -@Data -@TableName("alert_silence_conf") -public class AlertSilenceConf { - - @TableId - private Integer id; - - private Integer ruleId; - - private String type; - - private Integer linkId; - - private String reason; - - private Date startAt; - - private Date endAt; - - private Date utime; - - private Integer state; - - private String seq; - - @TableField(exist = false) - private Dc datacenter; - - @TableField(exist = false) - private Project project; - - @TableField(exist = false) - private Module module; - - @TableField(exist = false) - private Asset asset; - - @TableField(exist = false) - private Endpoint endpoint; - - @TableField(exist = false) - private AlertRuleEntity alertRule; - - @TableField(exist = false) - private String ruleName; - - @TableField(exist = false) - private String linkName; -} diff --git a/src/main/java/com/nis/entity/Asset.java b/src/main/java/com/nis/entity/Asset.java deleted file mode 100644 index 70842e8..0000000 --- a/src/main/java/com/nis/entity/Asset.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.*; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -@Data -@TableName("asset") -public class Asset implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId(type = IdType.AUTO) - private Integer id; - - /** - * 资产序列化 (唯一) - */ - private String sn; - - /** - * 产品型号ID 与model表关联 - */ - private Integer modelId; - - /** - * 数据中心id - */ - private Integer idcId; - - /** - * 机柜编号 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Integer cabinetId; - - /** - * 主机地址 ip - */ - private String host; - - /** - * 资产状态 - */ - private Integer state; - - /** - * 购买日期 - */ - private String purchaseDate; - - /** - * 添加日期 - */ - private Date createAt; - - /** - * 更新日期 - */ - private Date updateAt; - - /** - * 添加人 user表关联 - */ - private Long createBy; - - /** - * 更新人 - */ - private Long updateBy; - - - /** - * 用于撤销具体某次批量导入的uuid - */ - private String seq; - - /** - * 机柜开始位置 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Integer cabinetStart; - - /** - * 机柜结束位置 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Integer cabinetEnd; - -} diff --git a/src/main/java/com/nis/entity/AssetAsset.java b/src/main/java/com/nis/entity/AssetAsset.java deleted file mode 100644 index 42e52b7..0000000 --- a/src/main/java/com/nis/entity/AssetAsset.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.*; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - - -/** - * 资产实体 - * - * @author shizhendong - * @date 2019-11-21 - */ -@Data -@TableName("asset_asset") -public class AssetAsset implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId(type = IdType.INPUT) - private Integer id; - - /** - * 资产名称 唯一 - */ - private String name; - - /** - * 资产编号 不重复 - */ - private String number; - - /** - * 资产序列化 (唯一) - */ - private String sn; - - /** - * 默认:-1 只有type vm = 1可以且必须填写此字段,且 pid.type vmh = 1 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Integer pid; - - /** - * 资产状态 - */ - private Integer stateId; - - /** - * 资产类型 - */ - private Integer typeId; - - /** - * 品牌 - */ - private Integer brandId; - - /** - * 产品型号ID 与model表关联 - */ - private Integer modelId; - - /** - * 数据中心id - */ - private Integer dcId; - - /** - * 认证服务端口 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Integer authProtocolPort; - - /** - * 认证方式 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Integer authType; - - /** - * 用户名 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private String authUsername; - - /** - * 密码 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private String authPin; - - /** - * 秘钥 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private String authPriKey; - - /** - * 用户名提示 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private String authUserTip; - - /** - * 密码提示 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private String authPinTip; - - /** - * 协议 SSH / TELNET - */ - @TableField(exist = false) - private String protocol; - - /** - * snmp凭证id - */ - private Integer snmpCredentialId; - - /** - * 机柜编号 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Integer cabinetId; - - /** - * 机柜开始位置 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Integer cabinetStart; - - /** - * 机柜结束位置 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Integer cabinetEnd; - - /** - * 管理ip - */ - private String manageIp; - - /** - * 购买日期 - */ - private String purchaseDate; - - /** - * 添加日期 - */ - private Date createAt; - - /** - * 更新日期 - */ - private Date updateAt; - - - /** - * 添加人 user表关联 - */ - private Long createBy; - - /** - * 更新人 - */ - private Long updateBy; - - /** - * 用于撤销具体某次批量导入的uuid - */ - private String seq; -} diff --git a/src/main/java/com/nis/entity/AssetBrand.java b/src/main/java/com/nis/entity/AssetBrand.java deleted file mode 100644 index ea0b726..0000000 --- a/src/main/java/com/nis/entity/AssetBrand.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; - - - -@Data -@TableName("asset_brand") -public class AssetBrand implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - private Integer id; - - /** - * 名称 - */ - private String name; - - /** - * 备注 - */ - private String remark; - - /** - * 导入seq - */ - private String seq; -} diff --git a/src/main/java/com/nis/entity/AssetFieldGroup.java b/src/main/java/com/nis/entity/AssetFieldGroup.java deleted file mode 100644 index 0d91f2e..0000000 --- a/src/main/java/com/nis/entity/AssetFieldGroup.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -@Data -@TableName("asset_field_group") -public class AssetFieldGroup { - - private Integer id; - - private String name; - - private String remark; - - private Integer buildIn; - - private String seq; - -} diff --git a/src/main/java/com/nis/entity/AssetFieldMeta.java b/src/main/java/com/nis/entity/AssetFieldMeta.java deleted file mode 100644 index e2fb986..0000000 --- a/src/main/java/com/nis/entity/AssetFieldMeta.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.nis.entity; - -import java.util.List; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -@Data -@TableName("asset_field_meta") -public class AssetFieldMeta { - - private Integer id; - - private String name; - - private String metaKey; - - private String groupId; - - private Integer search; - - private Integer display; - - private String type; - - private String param; - - private Integer buildIn; - - private String seq; - - private String remark; - - @TableField(exist = false) - private AssetFieldGroup group; - - @TableField(exist = false) - private String key; - - /** - * field value value - */ - @TableField(exist = false) - private List value; - - /** - * field value assetId - */ - @TableField(exist = false) - private Integer assetId; -} diff --git a/src/main/java/com/nis/entity/AssetFieldValue.java b/src/main/java/com/nis/entity/AssetFieldValue.java deleted file mode 100644 index bcc7484..0000000 --- a/src/main/java/com/nis/entity/AssetFieldValue.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -@Data -@TableName("asset_field_value") -public class AssetFieldValue { - - private Integer id; - - private Integer assetId; - - private Integer metaId; - - private String value; - - private String seq; - -} diff --git a/src/main/java/com/nis/entity/AssetModel.java b/src/main/java/com/nis/entity/AssetModel.java deleted file mode 100644 index c549024..0000000 --- a/src/main/java/com/nis/entity/AssetModel.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - - - -@Data -@TableName("asset_model") -public class AssetModel implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId(type = IdType.INPUT) - private Integer id; - - /** - * 品牌id - */ - private Integer brandId; - - /** - * 名称 - */ - private String name; - - /** - * 备注 - */ - private String remark; - - /** - * 导入seq - */ - private String seq; - - /** - * u位大小 - */ - private Integer usize; - - private String chartIds; - -} diff --git a/src/main/java/com/nis/entity/AssetStateConf.java b/src/main/java/com/nis/entity/AssetStateConf.java deleted file mode 100644 index 3d6b7bb..0000000 --- a/src/main/java/com/nis/entity/AssetStateConf.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; - - -@Data -@TableName("asset_state_conf") -public class AssetStateConf implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - private Integer id; - - /** - * 名称 - */ - private String name; - - /** - * 开启ping 0:关闭 1:开启 - */ - private Integer ping; - - /** - * 开启监控 0:关闭 1:开启 - */ - private Integer monitor; - - /** - * 开启告警 0:关闭 1:开启 - */ - private Integer alert; - - /** - * 是否内置 1:内置,0:非内置,默认:0 内置数据不允许删除 - */ - private Integer buildIn; - - /** - * 描述 - */ - private String remark; -} diff --git a/src/main/java/com/nis/entity/AssetTag.java b/src/main/java/com/nis/entity/AssetTag.java deleted file mode 100644 index 52512fe..0000000 --- a/src/main/java/com/nis/entity/AssetTag.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; - - -@Data -@TableName("asset_tag") -public class AssetTag implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - private Integer id; - - /** - * 关联assetId - */ - private Integer assetId; - - /** - * 键 - */ - private String tag; - - /** - * 值 - */ - private String value; - - /** - * 导入UUID - */ - private String seq; -} diff --git a/src/main/java/com/nis/entity/AssetTypeConf.java b/src/main/java/com/nis/entity/AssetTypeConf.java deleted file mode 100644 index 439662c..0000000 --- a/src/main/java/com/nis/entity/AssetTypeConf.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -@Data -@TableName("asset_type_conf") -public class AssetTypeConf implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - private Integer id; - - /** - * 父id - */ - private Integer pid; - - /** - * 父名称 - */ - @TableField(exist = false) - private String pname; - - /** - * 是否为虚拟机宿主 0:不是宿主机,不支持挂载 虚拟机 1:是宿主机,支持挂载虚拟机 - */ - private Integer vm; - - /** - * 是否为虚拟机宿主 0:不是宿主机,不支持挂载 虚拟机 1:是宿主机,支持挂载虚拟机 - */ - private Integer vmh; - - /** - * 名称 - */ - private String name; - - /** - * 认证协议 - */ - private Integer authProtocol; - - /** - * 是否支持snmp - */ - private Integer snmpEnable; - - /** - * 是否开启snmp采集 - */ - private Integer snmpCollect; - - /** - * 是否开启ssh采集 - */ - private Integer sshCollect; - - /** - * ssh自动化采集脚本路径 - */ - private String sshCollectScript; - - /** - * 描述 - */ - private String remark; - - /** - * 是否内置 1:内置,0:非内置,默认:0 内置数据不允许删除 - */ - private Integer buildIn; - -} diff --git a/src/main/java/com/nis/entity/Chart.java b/src/main/java/com/nis/entity/Chart.java deleted file mode 100644 index 49abad3..0000000 --- a/src/main/java/com/nis/entity/Chart.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.FieldStrategy; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.Date; -import java.util.List; - -@Data -@TableName("chart") -public class Chart{ - - - @TableId - public Integer id; - - /** - * 排序字段,前一个元素 - */ - public Integer prev; - - /** - * 排序字段,后一个元素 - */ - public Integer next; - - /** - * 图表id,关联panel表 - * */ - private Integer panelId; - /** - *图表标题 - * */ - private String title; - /** - * 宽 - * */ - private Integer span; - /** - * 高 - * */ - private Integer height; - /** - * 创建时间 - * */ - private Date createAt; - /** - * 图标类型 line,bar,table - * */ - private String type; - - /** - * 单位 - */ - private Integer unit; - - /** - * 默认为 0,用于chart排序 - */ - private Integer weight; - - /** - * 模板ID - */ - private Integer pid; - - /** - * 是否为内置规则 - */ - private Integer buildIn; - - /** - * 导入唯一标识 - */ - private String seq; - - private String param; -} diff --git a/src/main/java/com/nis/entity/ChartElement.java b/src/main/java/com/nis/entity/ChartElement.java deleted file mode 100644 index 53fe61d..0000000 --- a/src/main/java/com/nis/entity/ChartElement.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -@Data -@TableName("chart_element") -public class ChartElement { - - @TableId - private Integer id; - /** - *图表id - * */ - private Integer chartId; - /** - * promql表达式 - * */ - private String expression; - /** - * 表达式类型 - * normal:简单表达式,可页面解析,如:up{asset="192.168.40.40",module="kafka"} - * - * expert:用户输入表达式,解析困难,直接在页面显示 - * */ - private String type; - - /** - * 图表legend表达式 - */ - private String legend; - - /** - * 是否为内置规则 - */ - private Integer buildIn; - - /** - * 导入唯一标识 - */ - private String seq; - -} diff --git a/src/main/java/com/nis/entity/Dc.java b/src/main/java/com/nis/entity/Dc.java deleted file mode 100644 index 20922e7..0000000 --- a/src/main/java/com/nis/entity/Dc.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.FieldStrategy; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; - - -/** - * 数据中心实体 - * - */ -@Data -@TableName("dc") -public class Dc implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId(type = IdType.INPUT) - private Integer id; - - /** - * 数据中心名称 - */ - private String name; - - /** - * 数据中心位置 - */ - private String location; - - /** - * 联系电话 - */ - private String tel; - - /** - * 机房负责人 - */ - private Integer principal; - - /** - * 用于撤销具体某次批量导入的uuid - */ - private String seq; - - /** - * 列 - */ - private Integer x; - - /** - * 行 - */ - private Integer y; - - /** - * 经度 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Double longitude; - - /** - * 纬度 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Double latitude; - - /** - * 状态 - */ - private String state; - -} diff --git a/src/main/java/com/nis/entity/Endpoint.java b/src/main/java/com/nis/entity/Endpoint.java deleted file mode 100644 index 80d42d1..0000000 --- a/src/main/java/com/nis/entity/Endpoint.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.FieldStrategy; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -@Data -@TableName("endpoint") -public class Endpoint { - @TableId - private Integer id; - private Integer moduleId; - private Integer assetId; - private String host; - private Integer port; - - @TableField(strategy = FieldStrategy.IGNORED) - private String param; - - @TableField(strategy = FieldStrategy.IGNORED) - private String labels; - private String path; - private Integer enabled; - @TableField(exist = false) - private Module module; - @TableField(exist = false) - private Asset asset; - @TableField(exist = false) - private Project project; - @TableField(exist = false) - private Long lastUpdate; - @TableField(exist = false) - private Integer state; - private String seq; - @TableField(exist = false) - private StateInfo stateInfo; - @TableField(exist = false) - private Promserver promserver; - - @TableField(exist = false) - private Integer alertNum; -} diff --git a/src/main/java/com/nis/entity/Idc.java b/src/main/java/com/nis/entity/Idc.java deleted file mode 100644 index 2d4c6b9..0000000 --- a/src/main/java/com/nis/entity/Idc.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.FieldStrategy; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.util.Map; - - -@Data -@TableName("idc") -public class Idc implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId - private Integer id; - - /** - * 数据中心名称 - */ - private String name; - - /** - * 数据中心位置 - */ - private String location; - - /** - * 联系电话 - */ - private String tel; - - /** - * 机房负责人 - */ - private Integer principal; - - /** - * 用于撤销具体某次批量导入的uuid - */ - private String seq; - - /** - * 列 - */ - private Integer x; - - /** - * 行 - */ - private Integer y; - - /** - * 经度 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Double longitude; - - /** - * 纬度 - */ - @TableField(strategy = FieldStrategy.IGNORED) - private Double latitude; - - /** - * 状态 - */ - private String state; - - -} diff --git a/src/main/java/com/nis/entity/Model.java b/src/main/java/com/nis/entity/Model.java deleted file mode 100644 index d35fb63..0000000 --- a/src/main/java/com/nis/entity/Model.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; - - -/** - * 资产型号实体 - * - * @author shizhendong - * @date 2019-11-21 - */ -@Data -@TableName("model") -public class Model implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId - private Integer id; - - /** - * 型号名称 - */ - private String name; - - /** - * 厂商 - */ - @TableField(value = "vendor") - private Integer vendorCode; - - /** - * 类型 - */ - @TableField(value = "type") - private Integer typeCode; - - /** - * 备注 - */ - private String remark; - - /** - * 用于撤销具体某次批量导入的uuid - */ - private String seq; - - /** - * u位大小 - */ - private Integer usize; -} \ No newline at end of file diff --git a/src/main/java/com/nis/entity/Module.java b/src/main/java/com/nis/entity/Module.java deleted file mode 100644 index 72a1773..0000000 --- a/src/main/java/com/nis/entity/Module.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -@Data -@TableName("module") -public class Module { - @TableId - private Integer id; - @TableField(exist = false) - private Project project; - private Integer projectId; - private String name; - private Integer port; - private String param; - private String labels; - private String path; - private String remark; - private Integer buildIn; - private String seq; - - /** - * modulle 类型 可选值 : http 、snmp - */ - private String type; - - /** - * snmp配置参数 - */ - private String snmpParam; - - /** - * snmp_exporter需要的配置部分, 由web端根据snmp_param生成 - */ - private String snmpYml; -} diff --git a/src/main/java/com/nis/entity/MonitorEndpoint.java b/src/main/java/com/nis/entity/MonitorEndpoint.java index a2c9237..eaa46e0 100644 --- a/src/main/java/com/nis/entity/MonitorEndpoint.java +++ b/src/main/java/com/nis/entity/MonitorEndpoint.java @@ -12,68 +12,28 @@ import java.util.Map; @Data @TableName("monitor_endpoint") public class MonitorEndpoint implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * 主键 - */ - @TableId(type = IdType.INPUT) - private Integer id; + @TableId(type = IdType.INPUT) + private Integer id; - /** - * 名称 - */ - private String name; + private String name; - /** - * 组件id - */ - private Integer moduleId; + private Integer moduleId; - /** - * 资产id - */ - private Integer assetId; + private Integer assetId; - /** - * 配置参数 当type=HTTP,默认为 module.configs - */ - private String configs; + private String seq; - @TableField(exist = false) - private Map config; - /** - * 计算 moduleId + assetId + host + port + configs 的hash值,用于确保相同配置不重复 - */ - private String hash; + @TableField(exist = false) + private String configs; - /** - * 是否启用 可选值 - * 0:停用 - * 1:启用 - */ - private Integer enabled; + @TableField(exist = false) + private String hash; - private String seq; + @TableField(exist = false) + private Integer enabled; - @TableField(exist = false) - private Integer state; - - @TableField(exist = false) - private MonitorModule module; - - @TableField(exist = false) - private AssetAsset asset; - - @TableField(exist = false) - private Dc dc; - - @TableField(exist = false) - private MonitorProject project; - - @TableField(exist = false) - private Integer alertNum; - - @TableField(exist = false) - private Promserver promserver; + @TableField(exist = false) + private MonitorEndpointConfig endpointConfig; } diff --git a/src/main/java/com/nis/entity/MonitorEndpointConfig.java b/src/main/java/com/nis/entity/MonitorEndpointConfig.java new file mode 100644 index 0000000..9a90dfd --- /dev/null +++ b/src/main/java/com/nis/entity/MonitorEndpointConfig.java @@ -0,0 +1,32 @@ +package com.nis.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +@Data +@TableName("monitor_endpoint_config") +public class MonitorEndpointConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + private Integer id; + + private Integer endpointId; + + private String type; + + private String config; + + private Integer version; + + private Integer enable; + + private String hash; + + private String seq; + +} diff --git a/src/main/java/com/nis/entity/MonitorModule.java b/src/main/java/com/nis/entity/MonitorModule.java index cc6d0ee..ce942e6 100644 --- a/src/main/java/com/nis/entity/MonitorModule.java +++ b/src/main/java/com/nis/entity/MonitorModule.java @@ -7,63 +7,32 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; -import java.util.List; @Data @TableName("monitor_module") public class MonitorModule implements Serializable { private static final long serialVersionUID = 1L; - /** - * 主键 - */ @TableId(type = IdType.INPUT) private Integer id; - /** - * 组件名称 - */ private String name; - /** - * 业务系统id - */ private Integer projectId; - /** - * modulle 类型 可选值 : http 、snmp - */ private String type; - /** - * endpoint name模板 - * 支持 {{}} 变量替换,asset,module - * 例:{{asset.name}}-{{module.name}} - * 最终endpoint的name为: 192.168.40.1-mysql - */ private String endpointNameTmpl; - /** - * 描述 - */ private String remark; - /** - * 配置参数 - */ private String configs; - - /** - * snmp_exporter需要的配置部分, 由web端根据snmp_param生成 - */ private String snmpYml; - /** - * 是否内置 1:内置,0:非内置,默认:0 内置数据不允许删除 - */ private Integer buildIn; private String seq; + private String chartIds; } diff --git a/src/main/java/com/nis/entity/MonitorProject.java b/src/main/java/com/nis/entity/MonitorProject.java deleted file mode 100644 index 23d20db..0000000 --- a/src/main/java/com/nis/entity/MonitorProject.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -@Data -@TableName("monitor_project") -public class MonitorProject implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId(type = IdType.INPUT) - private Integer id; - - /** - * 应用名称 - */ - private String name; - - /** - * 描述 - */ - private String remark; - - /** - * 是否内置 1:内置,0:非内置,默认:0 内置数据不允许删除 - */ - private Integer buildIn; - - private String seq; - - @TableField(exist = false) - private List alertStat = new ArrayList(); - - /** - * module 列表 - */ - @TableField(exist = false) - private List children; - - /** - * module数量 - */ - @TableField(exist = false) - private Integer moduleNum; - - /** - * endpoint数量 - */ - @TableField(exist = false) - private Integer endpointNum; - - /** - * asset数量 - */ - @TableField(exist = false) - private Integer assetNum; - - /** - * alert数量 - */ - @TableField(exist = false) - private Integer alertNum; - -} diff --git a/src/main/java/com/nis/entity/Panel.java b/src/main/java/com/nis/entity/Panel.java deleted file mode 100644 index 731eb28..0000000 --- a/src/main/java/com/nis/entity/Panel.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.List; - -@Data -@TableName("panel") -public class Panel{ - - private Integer id; - /** - * 图表名 - * */ - private String name; - /** - *创建人id - * */ - private Integer createBy; - - /** - * panel类型 - */ - private String type; - - /** - * 关联id - */ - private Integer link; - - /** - * 是否为内置规则 - */ - private Integer buildIn; - - /** - * 导入唯一标识 - */ - private String seq; - - /** - * 父ID - */ - private Integer pid; - - /** - * 排序 - */ - private Integer weight; - -} diff --git a/src/main/java/com/nis/entity/Project.java b/src/main/java/com/nis/entity/Project.java deleted file mode 100644 index 08cc0f3..0000000 --- a/src/main/java/com/nis/entity/Project.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - - -@Data -@TableName("project") -public class Project { - @TableId - private Integer id; - private String name; - private String remark; - private Integer buildIn; - private String seq; -} diff --git a/src/main/java/com/nis/entity/ProjectTopo.java b/src/main/java/com/nis/entity/ProjectTopo.java deleted file mode 100644 index 331fb01..0000000 --- a/src/main/java/com/nis/entity/ProjectTopo.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.Date; - -@Data -@TableName("project_topo") -public class ProjectTopo { - @TableId - private Integer id; - - private Integer projectId; - - private Object topo; - - private Date updateAt; - - private Integer updateBy; -} \ No newline at end of file diff --git a/src/main/java/com/nis/entity/ProjectTopoIcon.java b/src/main/java/com/nis/entity/ProjectTopoIcon.java deleted file mode 100644 index c5f6f02..0000000 --- a/src/main/java/com/nis/entity/ProjectTopoIcon.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -@Data -@TableName("project_topo_icon") -public class ProjectTopoIcon { - @TableId - private Integer id; - - private String name; - - private String bytes; - - private String type; - - private String unit; - - private Integer width; - - private Integer height; -} diff --git a/src/main/java/com/nis/entity/Promserver.java b/src/main/java/com/nis/entity/Promserver.java deleted file mode 100644 index 10c85f6..0000000 --- a/src/main/java/com/nis/entity/Promserver.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import java.util.Date; - -@Data -@TableName("prom_server") -public class Promserver { - @TableId - private Integer id; - private Integer dcId; - private String host; - private Integer type; - private Integer port; - /** - * 默认:1 - * 1:正常 - * 0:异常 - * -1:认证失败 - */ - private Integer status; - private Date checkTime; - - /** - * json格式保存状态详情 - * { - * "prometheus": "UP", - * "confagent": "UP", - * "snmp_exporter": "UP" - * } - */ - private String statusInfo; - - - /** - * confagent令牌 - */ - private String token; -} diff --git a/src/main/java/com/nis/entity/SnmpCredential.java b/src/main/java/com/nis/entity/SnmpCredential.java deleted file mode 100644 index be1e50d..0000000 --- a/src/main/java/com/nis/entity/SnmpCredential.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -@Data -@TableName("snmp_credential") -public class SnmpCredential { - - private Integer id; - - private String name; - - private String remark; - - private Integer type; - - private String config; - - private Integer port; - -} diff --git a/src/main/java/com/nis/entity/StateInfo.java b/src/main/java/com/nis/entity/StateInfo.java deleted file mode 100644 index b8a01a1..0000000 --- a/src/main/java/com/nis/entity/StateInfo.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.nis.entity; - -import lombok.Data; - -@Data -public class StateInfo { - private Integer code; - private String msg; -} diff --git a/src/main/java/com/nis/entity/SysConfigEntity.java b/src/main/java/com/nis/entity/SysConfigEntity.java deleted file mode 100644 index 3a8563a..0000000 --- a/src/main/java/com/nis/entity/SysConfigEntity.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 系统配置信息 - * - - */ -@Data -@TableName("sys_config") -public class SysConfigEntity { - @TableId - private Long id; - private String paramKey; - private String paramValue; - private String status; - private String remark; - -} diff --git a/src/main/java/com/nis/entity/SysDictEntity.java b/src/main/java/com/nis/entity/SysDictEntity.java deleted file mode 100644 index 17d2620..0000000 --- a/src/main/java/com/nis/entity/SysDictEntity.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * 数据字典 - * - - */ -@Data -@TableName("sys_dict") -public class SysDictEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @TableId - private Long id; - /** - * 字典名称 - */ - private String name; - /** - * 字典类型 - */ - private String type; - /** - * 字典码 - */ - private Integer code; - /** - * 字典值 - */ - private String value; - /** - * 排序 - */ - private Integer orderNum; - /** - * 备注 - */ - private String remark; - /** - * 删除标记 -1:已删除 0:正常 - */ - @TableLogic - private Integer delFlag; - - /** - * 操作人 - */ - private Long operator; - - /** - * 操作时间 - */ - private Date opTime; - - /** - * 国际化code - */ - private String i18nCode; - - /** - * 用于撤销具体某次批量导入的uuid - */ - private String seq; - -} diff --git a/src/main/java/com/nis/entity/SysUserEntity.java b/src/main/java/com/nis/entity/SysUserEntity.java deleted file mode 100644 index bc6ad5b..0000000 --- a/src/main/java/com/nis/entity/SysUserEntity.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * 系统用户 - */ -@Data -@TableName("sys_user") -public class SysUserEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 用户ID - */ - @TableField(exist=false) - private Long id; - - @TableField(exist=false) - private Long userId; - /** - * 用户名 - */ - private String username; - - - private String password; - /** - * 密码 - */ - @TableField(exist=false) - private String pin; - - /** - * 盐 - */ - private String salt; - - /** - * 邮箱 - */ - private String email; - - /** - * 状态 0:禁用 1:正常 - */ - private Integer status; - - /** - * 语言 - */ - private String lang; - @TableField(exist=false) - private String mobile; - - /** - * 创建时间 - */ - @TableField(exist=false) - private Date createAt; - @TableField(exist=false) - private Integer createBy; - @TableField(exist=false) - private String name; - - /** - * 来源 - */ - private String source; - - @TableField(exist=false) - private String lastLoginIp; - @TableField(exist=false) - private Date lastLoginTime; - - private Date createTime; -} diff --git a/src/main/java/com/nis/entity/VisualChart.java b/src/main/java/com/nis/entity/VisualChart.java deleted file mode 100644 index e7b832d..0000000 --- a/src/main/java/com/nis/entity/VisualChart.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.nis.entity; - -import java.util.Date; -import java.util.List; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -@Data -@TableName("visual_chart") -public class VisualChart { - - @TableId(type = IdType.INPUT) - private Integer id; - - private String name; - - private Integer panelId; - - private Integer groupId; - - private Integer span; - - private Integer height; - - private Integer updateBy; - - private Date updateAt; - - private String type; - - private Integer unit; - - private Integer weight; - - private Object param; - - private Integer pid; - - private Integer buildIn; - - private String remark; - - private String seq; - - @TableField(exist = false) - private List elements; - - private Integer varType; - - private Integer varId; - -} diff --git a/src/main/java/com/nis/entity/VisualChartElement.java b/src/main/java/com/nis/entity/VisualChartElement.java deleted file mode 100644 index 2d0f513..0000000 --- a/src/main/java/com/nis/entity/VisualChartElement.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.nis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -@Data -@TableName("visual_chart_element") -public class VisualChartElement { - - @TableId(type = IdType.INPUT) - private Integer id; - - private Integer chartId; - - private String expression; - - private String type; - - private String legend; - - private Integer buildIn; - - private String seq; -} diff --git a/src/main/java/com/nis/entity/VisualPanel.java b/src/main/java/com/nis/entity/VisualPanel.java deleted file mode 100644 index c26ff6e..0000000 --- a/src/main/java/com/nis/entity/VisualPanel.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.nis.entity; - -import java.util.List; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -@Data -@TableName("visual_panel") -public class VisualPanel { - - @TableId(type = IdType.INPUT) - private Integer id; - - private String name; - - private Integer createBy; - - private String type; - - private Integer link; - - private Integer pid; - - private Integer weight; - - private Integer buildIn; - - private String seq; - - @TableField(exist = false) - private List children; - - @TableField(exist = false) - private VisualPanel parent; - - @TableField(exist = false) - private Integer chartNum; -} diff --git a/src/main/java/com/nis/handler/AfterHandler.java b/src/main/java/com/nis/handler/AfterHandler.java index 0533ed3..f4c3eec 100644 --- a/src/main/java/com/nis/handler/AfterHandler.java +++ b/src/main/java/com/nis/handler/AfterHandler.java @@ -25,13 +25,10 @@ public class AfterHandler implements CommandLineRunner { @Override public void run(String... args) throws Exception { - sqlHandler.removeTable(); - log.info("remove table successful"); - + sqlHandler.removeColumn(); + log.info("remove column successful"); sqlHandler.removeCopy(); - log.info("remove copy back successful"); - - log.info("-----------------program end-----------------------"); + log.info("remove table successful"); log.info("-----------------transfer data success-----------------------"); } diff --git a/src/main/java/com/nis/handler/BeforeHandler.java b/src/main/java/com/nis/handler/BeforeHandler.java index 471b201..04099ff 100644 --- a/src/main/java/com/nis/handler/BeforeHandler.java +++ b/src/main/java/com/nis/handler/BeforeHandler.java @@ -31,23 +31,7 @@ public class BeforeHandler implements CommandLineRunner { @Override public void run(String... args) throws Exception { - - // 每个表进行复制 进行双重备份 - sqlHandler.tableCopy(); - log.info("backup database successful"); - - // 删除触发器 - /*sqlHandler.dropTriggers(); - log.info("drop all trigger successful"); - - // 修改表结构 - sqlHandler.alterTable(); - log.info("alter table successful"); - - // 新增表 - sqlHandler.batchAddTable();*/ - - log.info("all sql execute successful , before handler close"); - + String[] tableNames = new String[] {"monitor_module", "monitor_endpoint"}; + sqlHandler.tableCopy(tableNames); } } diff --git a/src/main/java/com/nis/handler/SqlHandler.java b/src/main/java/com/nis/handler/SqlHandler.java index 6187c45..a76f8ac 100644 --- a/src/main/java/com/nis/handler/SqlHandler.java +++ b/src/main/java/com/nis/handler/SqlHandler.java @@ -1,47 +1,36 @@ package com.nis.handler; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.sql.DataSource; -import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.jdbc.datasource.init.ScriptException; import org.springframework.jdbc.datasource.init.ScriptUtils; import org.springframework.stereotype.Service; -import org.springframework.util.ResourceUtils; +import com.alibaba.fastjson.JSONObject; import com.nis.dao.SqlDao; -import com.nis.entity.SysConfigEntity; -import com.nis.entity.SysUserEntity; -import com.nis.service.AlertMessageService; -import com.nis.service.AssetAssetService; -import com.nis.service.AssetBrandService; -import com.nis.service.AssetModelService; -import com.nis.service.AssetTypeConfService; -import com.nis.service.ChartService; -import com.nis.service.DcService; -import com.nis.service.EndpointService; -import com.nis.service.ProjectTopoService; -import com.nis.service.SysConfigService; -import com.nis.service.SysUserService; -import com.nis.util.Constant; -import com.nis.util.ToolUtil; +import com.nis.entity.AlertRule; +import com.nis.entity.MonitorEndpoint; +import com.nis.entity.MonitorEndpointConfig; +import com.nis.entity.MonitorModule; +import com.nis.service.AlertRuleService; +import com.nis.service.MonitorEndpointConfigService; +import com.nis.service.MonitorEndpointService; +import com.nis.service.MonitorModuleService; -import cn.hutool.core.io.IoUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.log.Log; @@ -58,665 +47,30 @@ public class SqlHandler { @Autowired private SqlDao sqlDao; - @Autowired - private AssetBrandService assetBrandService; - - @Autowired - private AssetModelService assetModelService; - - @Autowired - private AssetAssetService assetAssetService; - - @Autowired - private DcService dcService; - - @Autowired - private AlertMessageService alertMessageService; - - @Autowired - private EndpointService endpointService; - - @Autowired - private ChartService chartService; - @Autowired private DataSource dataSource; @Autowired - private SysUserService sysUserService; - - @Autowired - private SysConfigService sysConfigService; - - @Autowired - private ProjectTopoService projectTopoService; - - @Autowired - private AssetTypeConfService assetTypeConfService; - - public void removeData() { - String assetPing = "delete from asset_ping"; - sqlDao.execute(assetPing); - - String updateChartData="update visual_chart set height = ceil(height/100) where height > 12"; - sqlDao.execute(updateChartData); - } - - public void removeTable() { - String dropSql = "drop table account;" - + "drop table alert_message;" - + "drop table asset;" - + "drop table asset_tag;" - + "drop table chart;" - + "drop table chart_element;" - + "drop table conf_event;" - + "drop table endpoint;" - + "drop table endpoint_state;" - + "drop table idc_traffic;" - + "drop table model;" - + "drop table module;" - + "drop table notification_script;" - + "drop table panel;" - + "drop table project;" - + "drop table metadata_metric;" - + "drop table metadata_label;" - + "drop table qrtz_blob_triggers;" - + "drop table qrtz_calendars;" - + "drop table qrtz_cron_triggers;" - + "drop table qrtz_fired_triggers;" - + "drop table qrtz_locks;" - + "drop table qrtz_paused_trigger_grps;" - + "drop table qrtz_scheduler_state;" - + "drop table qrtz_simple_triggers;" - + "drop table qrtz_simprop_triggers;" - + "drop table qrtz_triggers;" - + "drop table sys_area;" - + "drop table idc;" - + "drop table terminal_log;" - + "drop table user_group;" - + "drop table user_group_rel;" - + "drop table user_notification;" - + "drop table qrtz_job_details;"; - sqlDao.execute(dropSql); - } - - public void tableCopy() { - StringBuilder sb =new StringBuilder(); - List tableNames = sqlDao.allTables(); - for(String tableName : tableNames) { - sb.append("CREATE TABLE "+tableName+"_copy SELECT * FROM "+tableName+";"); - } - sqlDao.execute(sb.toString()); - } - - - public void removeCopy() { - StringBuilder sb =new StringBuilder(); - List sqls = sqlDao.allRemoveCopyTables(); - for(String sql : sqls) { - sb.append(sql); - } - sqlDao.execute(sb.toString()); - } - - public void dropTriggers() { - String databaseName = Constant.DATABASE_NAME; - log.info("databaseName is {}",databaseName); - if(StrUtil.isEmpty(databaseName)) { - throw new RuntimeException("database name error"); - } - // 批量删除触发器 - StringBuilder sb =new StringBuilder(); - List allTriggers = sqlDao.allTriggers(databaseName); - for(String trigger : allTriggers) { - sb.append("drop trigger "+trigger+";"); - } - if(StrUtil.isNotBlank(sb.toString())) { - sqlDao.execute(sb.toString()); - } - - } - - public void alterTable() { - String sysLog = "ALTER TABLE `sys_log` \r\n" - + "ADD COLUMN `sys_api_key` int(10) NULL COMMENT '关联 sys_api_key.id' AFTER `create_date`;"; - sqlDao.execute(sysLog); - - String sysMenu = "ALTER TABLE `sys_menu` \r\n" - + "ADD COLUMN `description` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,\r\n" - + "ADD COLUMN `icon` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'nz-icon nz-alert-add'," - + "ADD COLUMN `required` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '必要权限,如编辑按钮需要 勾选查看权限 填写内容为 sys_menu.id,多个逗号分隔 1,2';"; - sqlDao.execute(sysMenu); - - String alertRule = "ALTER TABLE `alert_rule` \r\n" - + "CHANGE COLUMN `alert_name` `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '告警名称',\r\n" - + "ADD COLUMN `severity_id` int(10) NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF'," - + "ADD COLUMN `method` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL;"; - sqlDao.execute(alertRule); - - String assetPing = "ALTER TABLE `asset_ping` \r\n" - + "ADD COLUMN `asset_id` int(10) NULL;"; - sqlDao.execute(assetPing); - - String cabinet = "ALTER TABLE `cabinet` \r\n" - + "CHANGE COLUMN `idc_id` `dc_id` int(10) NOT NULL COMMENT '数据中心id';"; - sqlDao.execute(cabinet); - - String link = "ALTER TABLE `link` \r\n" - + "DROP COLUMN `prev`,\r\n" - + "DROP COLUMN `next`,\r\n" - + "ADD COLUMN `weight` int(10) NULL;"; - sqlDao.execute(link); - - String projectTopo = "ALTER TABLE `project_topo` \r\n" - + "MODIFY COLUMN `topo` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '拓扑图配置信息';"; - sqlDao.execute(projectTopo); - - String projectTopoIcon = "ALTER TABLE `project_topo_icon` \r\n" - + "ADD COLUMN `unit` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'icon组',\r\n" - + "ADD COLUMN `width` int(10) NULL COMMENT '图片宽度 默认:-1 未知' ,\r\n" - + "ADD COLUMN `height` int(10) NULL COMMENT '图片高度 默认:-1 未知' ;"; - sqlDao.execute(projectTopoIcon); - - String promServer = "ALTER TABLE `prom_server` \r\n" - + "CHANGE COLUMN `idc_id` `dc_id` int(10) NOT NULL COMMENT '所在idc',\r\n" - + "ADD COLUMN `status_info` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,\r\n" - + "ADD COLUMN `token` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;"; - sqlDao.execute(promServer); - - String sysUser = "ALTER TABLE `sys_user` \r\n" - + "CHANGE COLUMN `user_id` `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + "CHANGE COLUMN `password` `pin` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',\r\n" - + "CHANGE COLUMN `create_time` `create_at` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',\r\n" - + "ADD COLUMN `name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户姓名\\r\\n\\r\\n(用于系统内展示用户名称)',\r\n" - + "ADD COLUMN `last_login_time` datetime NULL COMMENT '最后登陆时间',\r\n" - + "ADD COLUMN `last_login_ip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '最后登陆ip',\r\n" - + "ADD COLUMN `mobile` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '手机号',\r\n" - + "ADD COLUMN `create_by` int(10) NULL COMMENT '添加人',\r\n" - + "DROP PRIMARY KEY,\r\n" - + "ADD PRIMARY KEY (`id`) USING BTREE;"; - sqlDao.execute(sysUser); - } - - public void batchAddTable() { - String alertNotifyLog = "CREATE TABLE `alert_notify_log` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `message_id` int(10) NOT NULL COMMENT '关联 alert_message.id',\r\n" - + " `user_id` int(10) NOT NULL COMMENT '关联 sys_user.id',\r\n" - + " `message_state` char(1) NOT NULL COMMENT '消息状态1: active2: expired',\r\n" - + " `state` char(1) NOT NULL COMMENT '通知状态0:失败1:成功',\r\n" - + " `error_msg` varchar(1024) NOT NULL DEFAULT '' COMMENT '发送错误信息',\r\n" - + " `time` datetime NOT NULL COMMENT '发送时间',\r\n" - + " `method_id` int(10) NOT NULL COMMENT '通知方式id 关联ALERT_NOTIFICATION_METHOD.id',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String alertNotifyMethod = "CREATE TABLE `alert_notify_method` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n" - + " `name` varchar(64) NOT NULL COMMENT '通知方式名称',\r\n" - + " `file_path` varchar(255) NOT NULL COMMENT '除内置外,必填脚本路径,nz-web所在服务器路径',\r\n" - + " `account` varchar(255) NOT NULL COMMENT '可选值为user表属性id,name,username,email,mobile',\r\n" - + " `state` int(1) DEFAULT NULL COMMENT '状态0:停用1:可用',\r\n" - + " `build_in` int(1) NOT NULL COMMENT '可选值:0:非内置1:内置默认:0系统内置一条 email 通知',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String alertSeverityConf = "CREATE TABLE `alert_severity_conf` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(64) NOT NULL,\r\n" - + " `color` varchar(64) NOT NULL,\r\n" - + " `weight` int(3) NOT NULL COMMENT '1-100 顺序取值不重复,值越小告警级别越高',\r\n" - + " `remark` varchar(255) NOT NULL,\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String alertSilenceConf = "CREATE TABLE `alert_silence_conf` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n" - + " `name` varchar(255) DEFAULT NULL,\r\n" - + " `matchers` varchar(4096) NOT NULL,\r\n" - + " `reason` varchar(1024) NOT NULL COMMENT '记录告警静音原因\\r\\n\\r\\n默认:“”',\r\n" - + " `start_at` datetime NOT NULL COMMENT '开始时间',\r\n" - + " `end_at` datetime NOT NULL COMMENT '结束时间',\r\n" - + " `utime` datetime NOT NULL,\r\n" - + " `state` int(1) NOT NULL COMMENT '可选值:\\r\\n\\r\\n1:active\\r\\n\\r\\n2:pending\\r\\n\\r\\n3:expired',\r\n" - + " `seq` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '全局唯一,用于导入撤销\\r\\n\\r\\n默认:“”',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String assetAsset = "CREATE TABLE `asset_asset` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(128) NOT NULL COMMENT '不重复,唯一索引',\r\n" - + " `number` varchar(128) NOT NULL DEFAULT '' COMMENT '资产编号',\r\n" - + " `sn` varchar(128) NOT NULL DEFAULT '' COMMENT '资产序列号',\r\n" - + " `pid` int(10) NOT NULL DEFAULT -1 COMMENT '默认:-1\\r\\n\\r\\n只有type vm = 1可以且必须填写此字段,且 pid.type vmh = 1',\r\n" - + " `type_id` int(10) NOT NULL,\r\n" - + " `state_id` int(10) NOT NULL,\r\n" - + " `brand_id` int(10) NOT NULL,\r\n" - + " `model_id` int(10) NOT NULL,\r\n" - + " `dc_id` int(10) NOT NULL,\r\n" - + " `cabinet_id` int(10) DEFAULT NULL,\r\n" - + " `cabinet_start` int(10) DEFAULT NULL,\r\n" - + " `cabinet_end` int(10) DEFAULT NULL,\r\n" - + " `manage_ip` varchar(64) NOT NULL COMMENT '管理ip',\r\n" - + " `purchase_date` date DEFAULT NULL COMMENT '购买日期',\r\n" - + " `create_at` datetime DEFAULT NULL COMMENT '添加时间',\r\n" - + " `update_at` datetime DEFAULT NULL COMMENT '更新时间',\r\n" - + " `create_by` int(10) DEFAULT NULL COMMENT '添加人,与user表关联',\r\n" - + " `update_by` int(10) DEFAULT NULL COMMENT '最后更新人',\r\n" - + " `seq` varchar(64) DEFAULT NULL,\r\n" - + " `auth_protocol_port` int(10) DEFAULT NULL COMMENT '认证服务端口',\r\n" - + " `auth_type` char(1) DEFAULT NULL COMMENT '认证方式1:用户名密码\\r\\n\\r\\n2:密钥',\r\n" - + " `auth_username` varchar(64) DEFAULT NULL COMMENT '用户名',\r\n" - + " `auth_pin` varchar(256) DEFAULT NULL COMMENT '密码auth_type =1 : 记录登录密码\\r\\n\\r\\nauth_type=2 : 记录密钥密码',\r\n" - + " `auth_pri_key` text DEFAULT NULL COMMENT '秘钥',\r\n" - + " `auth_user_tip` varchar(64) DEFAULT NULL COMMENT '用户名提示 telnet协议有效',\r\n" - + " `auth_pin_tip` varchar(64) DEFAULT NULL COMMENT '密码提示 telnet协议有效',\r\n" - + " `snmp_credential_id` int(10) DEFAULT NULL COMMENT 'snmp凭证id type 开启snmp有效',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String assetBrand = "CREATE TABLE `asset_brand` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(64) DEFAULT NULL COMMENT '名称',\r\n" - + " `remark` varchar(256) DEFAULT '' COMMENT '备注',\r\n" - + " `seq` varchar(64) DEFAULT NULL,\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String assetFieldGroup = "CREATE TABLE `asset_field_group` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(64) DEFAULT NULL COMMENT '名称',\r\n" - + " `remark` varchar(1024) DEFAULT NULL,\r\n" - + " `build_in` char(1) DEFAULT NULL COMMENT '1:内置,0:非内置,默认:0\\r\\n\\r\\n内置数据不允许删除',\r\n" - + " `seq` varchar(64) DEFAULT NULL COMMENT '用户导入撤销',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String assetFieldMeta = "CREATE TABLE `asset_field_meta` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(64) NOT NULL,\r\n" - + " `meta_key` varchar(128) NOT NULL COMMENT '唯一不重复 正则:[\\\\w]+',\r\n" - + " `group_id` varchar(128) NOT NULL COMMENT '关联 asset_field_group.id',\r\n" - + " `search` char(1) NOT NULL DEFAULT '0' COMMENT '默认:0 0:不可查询\\r\\n\\r\\n1:可查询',\r\n" - + " `display` char(1) NOT NULL DEFAULT '0' COMMENT '默认:0 0:列表不展示\\r\\n\\r\\n1:列表展示',\r\n" - + " `type` varchar(32) NOT NULL DEFAULT 'TEXT' COMMENT '属性输入类型',\r\n" - + " `remark` varchar(64) DEFAULT NULL,\r\n" - + " `param` text NOT NULL COMMENT '默认:{}',\r\n" - + " `build_in` int(1) NOT NULL DEFAULT 0 COMMENT '1:内置,0:非内置,默认:0',\r\n" - + " `seq` varchar(64) DEFAULT NULL COMMENT '用户导入撤销',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String assetFieldValue = "CREATE TABLE `asset_field_value` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `asset_id` int(10) NOT NULL COMMENT ' 关联 asset.id',\r\n" - + " `meta_id` int(10) NOT NULL COMMENT '关联asset_field_meta.id',\r\n" - + " `value` text DEFAULT NULL,\r\n" - + " `seq` varchar(64) DEFAULT NULL COMMENT '用户导入撤销',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String assetModel = "CREATE TABLE `asset_model` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `brand_id` int(10) NOT NULL,\r\n" - + " `name` varchar(64) NOT NULL COMMENT '型号名称',\r\n" - + " `remark` varchar(256) NOT NULL DEFAULT '',\r\n" - + " `seq` varchar(64) DEFAULT NULL,\r\n" - + " `usize` int(2) NOT NULL DEFAULT 1,\r\n" - + " `chart_ids` varchar(4096) DEFAULT NULL COMMENT 'chart 模板id',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String assetStateConf = "CREATE TABLE `asset_state_conf` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(64) NOT NULL COMMENT '型号名称',\r\n" - + " `ping` char(1) NOT NULL COMMENT '0:关闭\\r\\n\\r\\n1:开启',\r\n" - + " `monitor` char(1) NOT NULL COMMENT '0:关闭\\r\\n\\r\\n1:开启',\r\n" - + " `alert` char(1) NOT NULL COMMENT '0:关闭\\r\\n\\r\\n1:开启',\r\n" - + " `remark` varchar(1024) NOT NULL DEFAULT '' COMMENT '默认“”',\r\n" - + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '是否内置1:内置,0:非内置,默认:0\\r\\n\\r\\n内置数据不允许删除',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String assetTypeConf = "CREATE TABLE `asset_type_conf` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `pid` int(10) NOT NULL DEFAULT 0 COMMENT '父id 默认为0',\r\n" - + " `vm` char(1) NOT NULL COMMENT '是否为虚拟机 0:不是虚拟机\\r\\n\\r\\n1:是虚拟机',\r\n" - + " `vmh` char(1) NOT NULL COMMENT '是否为虚拟机宿主 0:不是宿主机,不支持挂载 虚拟机\\r\\n\\r\\n1:是宿主机,支持挂载虚拟机',\r\n" - + " `name` varchar(64) NOT NULL COMMENT '名称',\r\n" - + " `remark` varchar(1024) NOT NULL DEFAULT '',\r\n" - + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0\\r\\n\\r\\n内置数据不允许删除',\r\n" - + " `auth_protocol` int(1) NOT NULL DEFAULT 0 COMMENT '认证协议 默认:0 \\r\\n\\r\\n0:无\\r\\n\\r\\n1:ssh\\r\\n\\r\\n2:telnet',\r\n" - + " `snmp_enable` int(1) NOT NULL DEFAULT 0 COMMENT '是否支持snmp 默认:0 \\r\\n\\r\\n0:不支持\\r\\n\\r\\n1:支持',\r\n" - + " `snmp_collect` int(1) NOT NULL DEFAULT 0 COMMENT '是否开启snmp采集 默认:0 \\r\\n\\r\\n0:不开启\\r\\n\\r\\n1:开启\\r\\n\\r\\n当snmp_enable=1时有效',\r\n" - + " `ssh_collect` int(1) NOT NULL COMMENT '是否开启ssh采集 默认:0 \\r\\n\\r\\n0:不开启\\r\\n\\r\\n1:开启\\r\\n\\r\\n当 auth_protocol=1时有效',\r\n" - + " `ssh_collect_script` varchar(256) NOT NULL DEFAULT '',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String dc = "CREATE TABLE `dc` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键自增',\r\n" - + " `name` varchar(64) NOT NULL COMMENT '名称',\r\n" - + " `location` varchar(256) DEFAULT NULL COMMENT '位置',\r\n" - + " `tel` varchar(128) DEFAULT NULL COMMENT '联系电话',\r\n" - + " `principal` int(10) DEFAULT NULL COMMENT '机房负责人',\r\n" - + " `seq` varchar(64) DEFAULT NULL COMMENT '全局唯一,用于导入撤销',\r\n" - + " `x` int(10) DEFAULT NULL COMMENT '列',\r\n" - + " `y` int(10) DEFAULT NULL COMMENT '行',\r\n" - + " `longitude` double(8,5) DEFAULT NULL COMMENT '经度 -180,180',\r\n" - + " `latitude` double(8,5) DEFAULT NULL COMMENT '纬度 -90,90',\r\n" - + " `state` varchar(8) NOT NULL DEFAULT 'ON' COMMENT '可选值:ON,OFF 默认:ON',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - - String monitorEndpoint = "CREATE TABLE `monitor_endpoint` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(128) NOT NULL COMMENT '名称',\r\n" - + " `module_id` int(10) NOT NULL,\r\n" - + " `asset_id` int(10) NOT NULL,\r\n" - + " `configs` text NOT NULL,\r\n" - + " `hash` varchar(64) NOT NULL COMMENT '计算 moduleId + assetId + host + port + configs 的hash值,用于确保相同配置不重复',\r\n" - + " `enabled` int(4) NOT NULL COMMENT '是否启用 可选值\\r\\n\\r\\n0:停用\\r\\n\\r\\n1:启用',\r\n" - + " `seq` varchar(64) DEFAULT NULL,\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String monitorEndpointState = "CREATE TABLE `monitor_endpoint_state` (\r\n" - + " `endpoint_id` int(10) NOT NULL,\r\n" - + " `state` int(4) NOT NULL COMMENT ' ',\r\n" - + " `time` datetime NOT NULL,\r\n" - + " PRIMARY KEY (`endpoint_id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String monitorEventLog = "CREATE TABLE `monitor_event_log` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `event` varchar(64) NOT NULL COMMENT '唯一不重复\\r\\n\\r\\n包含值:cmd,prometheus,rule,snmp,blackbox',\r\n" - + " `counter` int(10) NOT NULL COMMENT '描述信息,update +1',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String monitorModule = "CREATE TABLE `monitor_module` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(64) DEFAULT NULL COMMENT '组件名称 唯一索引,表内不重复',\r\n" - + " `project_id` int(10) NOT NULL,\r\n" - + " `type` varchar(64) NOT NULL COMMENT '可选值http snmp',\r\n" - + " `endpoint_name_tmpl` varchar(64) NOT NULL COMMENT 'endpoint name模板 支持 {{}} 变量替换,asset,module\\r\\n\\r\\n例:{{asset.name}}-{{module.name}}\\r\\n\\r\\n最终endpoint的name为: 192.168.40.1-mysql',\r\n" - + " `remark` varchar(256) DEFAULT NULL,\r\n" - + " `configs` text NOT NULL COMMENT '配置参数 ',\r\n" - + " `snmp_yml` text DEFAULT NULL COMMENT 'snmp_exporter需要的配置部分',\r\n" - + " `build_in` char(1) NOT NULL DEFAULT '0',\r\n" - + " `seq` varchar(64) DEFAULT NULL,\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String monitorProject = "CREATE TABLE `monitor_project` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(64) DEFAULT NULL COMMENT '应用名称',\r\n" - + " `remark` varchar(256) DEFAULT NULL COMMENT '描述信息',\r\n" - + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '是否内置 1:内置,0:非内置,默认:0',\r\n" - + " `seq` varchar(64) DEFAULT NULL,\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; + private AlertRuleService alertRuleService; - String snmpCredential = "CREATE TABLE `snmp_credential` (\r\n" - + " `id` int(11) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(64) NOT NULL COMMENT '名称',\r\n" - + " `remark` varchar(1024) DEFAULT NULL COMMENT '描述信息',\r\n" - + " `type` int(1) NOT NULL COMMENT '1,2,3 -- > V1,V2,V3 创建人id',\r\n" - + " `config` varchar(1024) DEFAULT NULL COMMENT '具体配置',\r\n" - + " `port` int(1) NOT NULL DEFAULT 161 COMMENT '端口号 默认161',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String sysApiKey = "CREATE TABLE `sys_api_key` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n" - + " `name` varchar(64) NOT NULL COMMENT '名称 唯一不重复',\r\n" - + " `token` varchar(512) NOT NULL COMMENT '密钥 唯一不重复',\r\n" - + " `role_id` int(10) NOT NULL COMMENT '角色id',\r\n" - + " `create_by` int(10) NOT NULL COMMENT '创建用户',\r\n" - + " `create_at` datetime NOT NULL COMMENT '创建时间',\r\n" - + " `expire_at` datetime DEFAULT NULL COMMENT '失效时间 为空不失效',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String sysTimezone = "CREATE TABLE `sys_timezone` (\r\n" - + " `id` int(4) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(255) NOT NULL COMMENT 'timezone id',\r\n" - + " `offset` int(10) NOT NULL COMMENT '单位:milliseconds',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String terminalCmd = "CREATE TABLE `terminal_cmd` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `uuid` varchar(256) NOT NULL COMMENT '会话id',\r\n" - + " `cmd` varchar(4096) DEFAULT NULL COMMENT '用户输入命令',\r\n" - + " `time` int(10) DEFAULT NULL COMMENT '单位:ms\\r\\n\\r\\n记录的是 session开始后的时间偏移量',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String terminalRecord = "CREATE TABLE `terminal_record` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `uuid` varchar(256) NOT NULL COMMENT '会话ID',\r\n" - + " `start_time` int(10) NOT NULL COMMENT '单位:ms\\r\\n\\r\\nrecord 开始时间,记录的是会话开始后的时间偏移量',\r\n" - + " `end_time` int(10) NOT NULL COMMENT '单位:ms\\r\\n\\r\\nrecord 结束时间,记录的是会话开始后的时间偏移量',\r\n" - + " `content` mediumblob NOT NULL COMMENT '记录的是 session开始后的时间偏移量\\r\\n\\r\\n最大储存 65K,超过部分再新增一条记录',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String terminalSession = "CREATE TABLE `terminal_session` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `uuid` varchar(256) DEFAULT NULL COMMENT '会话id',\r\n" - + " `asset_id` int(10) DEFAULT NULL COMMENT '关联资产id',\r\n" - + " `host` varchar(128) DEFAULT NULL COMMENT '登录主机',\r\n" - + " `port` int(10) DEFAULT NULL COMMENT '端口',\r\n" - + " `protocol` varchar(32) DEFAULT NULL COMMENT '协议,可选值:SSH,TELNET。统一大写',\r\n" - + " `auth_type` int(10) DEFAULT NULL COMMENT '认证类型,1:密码,2:私钥证书 认证类型,1:密码,2:私钥证书\\r\\n\\r\\nssh可选值:1、2\\r\\n\\r\\ntelnet可选值:1',\r\n" - + " `login_user` varchar(128) DEFAULT NULL COMMENT '登录主机的用户名',\r\n" - + " `user_id` int(10) NOT NULL COMMENT 'nezha系统内用户id',\r\n" - + " `remote_addr` varchar(128) NOT NULL COMMENT '客户端ip地址',\r\n" - + " `start_time` datetime NOT NULL COMMENT '开始时间',\r\n" - + " `end_time` datetime DEFAULT NULL COMMENT '结束时间',\r\n" - + " `status` int(1) NOT NULL COMMENT '0:连接中\\r\\n\\r\\n1:发送失败(没有通过ssh或telnet发送成功)\\r\\n\\r\\n2:已结束\\r\\n\\r\\n3:强制退出\\r\\n\\r\\n4:未知错误',\r\n" - + " `kill_user_id` int(10) DEFAULT NULL COMMENT '强制关闭用户id',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String visualChart = "CREATE TABLE `visual_chart` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n" - + " `name` varchar(255) NOT NULL COMMENT '图表标题',\r\n" - + " `panel_id` int(10) NOT NULL COMMENT '图表id,关联panel表\\r\\n\\r\\n当 panel_id =0 代表为模板',\r\n" - + " `group_id` int(10) NOT NULL COMMENT '关联 visual_chart.id,关联 chart 的 type 只能为 group',\r\n" - + " `span` int(10) NOT NULL COMMENT 'type = group,span = 12, 用户修改无效',\r\n" - + " `height` int(10) NOT NULL COMMENT 'type = group,height = -1,用户修改无效',\r\n" - + " `update_by` int(10) NOT NULL COMMENT '更新人',\r\n" - + " `update_at` datetime NOT NULL COMMENT '更新时间',\r\n" - + " `type` varchar(32) NOT NULL COMMENT '图表类型 line\\r\\nbar\\r\\ntable\\r\\nstackArea\\r\\nsingleStat\\r\\nurl\\r\\nassetInfo\\r\\nalertList\\r\\ngroup',\r\n" - + " `unit` int(10) NOT NULL DEFAULT 2 COMMENT '界面显示采用二级菜单',\r\n" - + " `weight` int(10) NOT NULL DEFAULT 0 COMMENT '默认为 0,用于chart排序',\r\n" - + " `param` text DEFAULT NULL COMMENT '参数 记录type的具体参数信息,数据格式为json对象\\r\\n\\r\\n当type = url时\\r\\n\\r\\n{\\r\\n\\r\\n “url”:\"https://www.baidu.com\"\\r\\n\\r\\n}',\r\n" - + " `pid` int(10) DEFAULT NULL COMMENT '模板id 图表通过模板创建时不能为空,便于后续模板修改同步修改',\r\n" - + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0',\r\n" - + " `remark` varchar(1024) NOT NULL DEFAULT '' COMMENT '默认:\"\"',\r\n" - + " `seq` varchar(64) DEFAULT NULL COMMENT '导入唯一标识',\r\n" - + " `var_type` int(1) DEFAULT NULL COMMENT '模板或使用模板创建有效,pid != null | panel_id == 0 时不能为空\\r\\n\\r\\n1: asset\\r\\n\\r\\n2: endpoint',\r\n" - + " `var_id` int(10) DEFAULT NULL COMMENT 'pid != null 时不能为空\\r\\n\\r\\n根据var_type 分别对应 asset.id, endpoint.id,用于 表达式变量替换',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String visualChartElement = "CREATE TABLE `visual_chart_element` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n" - + " `chart_id` int(10) NOT NULL COMMENT '图表id,关联chart表',\r\n" - + " `expression` varchar(4096) NOT NULL COMMENT 'promql表达式',\r\n" - + " `type` varchar(32) NOT NULL COMMENT 'normal:简单表达式,可页面解析,如:up{asset=\"192.168.40.40\",module=\"kafka\"}\\r\\n\\r\\nexpert:用户输入表达式,解析困难,直接在页面显示',\r\n" - + " `legend` varchar(512) DEFAULT NULL COMMENT '图例别名表达式',\r\n" - + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '是否内置',\r\n" - + " `seq` varchar(64) DEFAULT NULL COMMENT '导入唯一标识 用于导入撤销',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String visualPanel = "CREATE TABLE `visual_panel` (\r\n" - + " `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n" - + " `name` varchar(64) NOT NULL COMMENT '图表名',\r\n" - + " `create_by` int(10) NOT NULL COMMENT '创建人id',\r\n" - + " `type` varchar(64) NOT NULL DEFAULT 'dashboard' COMMENT '可选值:dashboard,asset,project,module,endpoint, model\\r\\n\\r\\n默认值:dashboard',\r\n" - + " `link` int(10) DEFAULT NULL COMMENT '关联id',\r\n" - + " `pid` int(10) NOT NULL DEFAULT 0 COMMENT '父id 默认0',\r\n" - + " `weight` int(10) NOT NULL DEFAULT 0 COMMENT '排序 默认0',\r\n" - + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '是否内置',\r\n" - + " `seq` varchar(64) NOT NULL DEFAULT '' COMMENT '默认:“”\\r\\n\\r\\n用于导入撤销',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String visualExpressionTmpl = "CREATE TABLE `visual_expression_tmpl` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n" - + " `name` varchar(64) NOT NULL COMMENT '模板名称',\r\n" - + " `gname` varchar(64) NOT NULL DEFAULT 'default' COMMENT '组名,默认:default',\r\n" - + " `expression` varchar(4096) NOT NULL COMMENT '表达式,不能为空',\r\n" - + " `remark` varchar(512) NOT NULL COMMENT '描述',\r\n" - + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0',\r\n" - + " `seq` varchar(64) NOT NULL DEFAULT '' COMMENT '用于导入撤销,默认:“”',\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - - String alertMessageActive = "CREATE TABLE `alert_message_active` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n" - + " `severity` varchar(64) DEFAULT NULL COMMENT '告警级别',\r\n" - + " `summary` text DEFAULT NULL COMMENT '告警摘要',\r\n" - + " `description` text DEFAULT NULL COMMENT '告警描述',\r\n" - + " `labels` text DEFAULT NULL COMMENT '告警labels信息',\r\n" - + " `start_at` datetime DEFAULT NULL COMMENT '开始时间',\r\n" - + " `end_at` datetime DEFAULT NULL COMMENT '结束时间',\r\n" - + " `state` int(10) DEFAULT NULL COMMENT '状态1:pending,2:Expired',\r\n" - + " `rule_id` int(10) NOT NULL COMMENT '告警规则ID',\r\n" - + " `project_id` int(10) DEFAULT NULL COMMENT '关联project id',\r\n" - + " `module_id` int(10) DEFAULT NULL COMMENT '关联module id',\r\n" - + " `endpoint_id` int(10) DEFAULT NULL COMMENT '关联endpoint id',\r\n" - + " `asset_id` int(10) DEFAULT NULL COMMENT '关联资产id',\r\n" - + " `dc_id` int(10) DEFAULT NULL COMMENT '关联idc id',\r\n" - + " `hash_key` varchar(255) NOT NULL DEFAULT '' COMMENT 'redis hash key',\r\n" - + " `remark` text DEFAULT NULL COMMENT '备注 记录手动关闭记录信息,格式\\r\\n\\r\\ntime username\\r\\n\\r\\nmessage',\r\n" - + " `severity_id` int(10) DEFAULT NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF',\r\n" - + " PRIMARY KEY (`id`) USING BTREE,\r\n" - + " KEY `idx_severity` (`severity`) USING BTREE,\r\n" - + " KEY `idx_state` (`state`) USING BTREE,\r\n" - + " KEY `idx_rule_id` (`rule_id`) USING BTREE,\r\n" - + " KEY `idx_project_id` (`project_id`) USING BTREE,\r\n" - + " KEY `idx_module_id` (`module_id`) USING BTREE,\r\n" - + " KEY `idx_endpoint_id` (`endpoint_id`) USING BTREE,\r\n" - + " KEY `idx_asset_id` (`asset_id`) USING BTREE,\r\n" - + " KEY `idx_dc_id` (`dc_id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;"; - - String alertMessageHistory = "CREATE TABLE `alert_message_history` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n" - + " `severity` varchar(64) DEFAULT NULL COMMENT '告警级别',\r\n" - + " `summary` text DEFAULT NULL COMMENT '告警摘要',\r\n" - + " `description` text DEFAULT NULL COMMENT '告警描述',\r\n" - + " `labels` text DEFAULT NULL COMMENT '告警labels信息',\r\n" - + " `start_at` datetime DEFAULT NULL COMMENT '开始时间',\r\n" - + " `end_at` datetime DEFAULT NULL COMMENT '结束时间',\r\n" - + " `state` int(10) DEFAULT NULL COMMENT '状态1:pending,2:Expired',\r\n" - + " `rule_id` int(10) NOT NULL COMMENT '告警规则ID',\r\n" - + " `project_id` int(10) DEFAULT NULL COMMENT '关联project id',\r\n" - + " `module_id` int(10) DEFAULT NULL COMMENT '关联module id',\r\n" - + " `endpoint_id` int(10) DEFAULT NULL COMMENT '关联endpoint id',\r\n" - + " `asset_id` int(10) DEFAULT NULL COMMENT '关联资产id',\r\n" - + " `dc_id` int(10) DEFAULT NULL COMMENT '关联idc id',\r\n" - + " `hash_key` varchar(255) NOT NULL DEFAULT '' COMMENT 'redis hash key',\r\n" - + " `remark` text DEFAULT NULL COMMENT '备注 记录手动关闭记录信息,格式\\r\\n\\r\\ntime username\\r\\n\\r\\nmessage',\r\n" - + " `severity_id` int(10) DEFAULT NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF',\r\n" - + " PRIMARY KEY (`id`) USING BTREE,\r\n" - + " KEY `idx_severity` (`severity`) USING BTREE,\r\n" - + " KEY `idx_state` (`state`) USING BTREE,\r\n" - + " KEY `idx_rule_id` (`rule_id`) USING BTREE,\r\n" - + " KEY `idx_project_id` (`project_id`) USING BTREE,\r\n" - + " KEY `idx_module_id` (`module_id`) USING BTREE,\r\n" - + " KEY `idx_endpoint_id` (`endpoint_id`) USING BTREE,\r\n" - + " KEY `idx_asset_id` (`asset_id`) USING BTREE,\r\n" - + " KEY `idx_dc_id` (`dc_id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;"; - - String alertMessageSilence = "CREATE TABLE `alert_message_silence` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n" - + " `severity` varchar(64) DEFAULT NULL COMMENT '告警级别',\r\n" - + " `summary` text DEFAULT NULL COMMENT '告警摘要',\r\n" - + " `description` text DEFAULT NULL COMMENT '告警描述',\r\n" - + " `labels` text DEFAULT NULL COMMENT '告警labels信息',\r\n" - + " `start_at` datetime DEFAULT NULL COMMENT '开始时间',\r\n" - + " `end_at` datetime DEFAULT NULL COMMENT '结束时间',\r\n" - + " `state` int(10) DEFAULT NULL COMMENT '状态1:pending,2:Expired',\r\n" - + " `rule_id` int(10) NOT NULL COMMENT '告警规则ID',\r\n" - + " `project_id` int(10) DEFAULT NULL COMMENT '关联project id',\r\n" - + " `module_id` int(10) DEFAULT NULL COMMENT '关联module id',\r\n" - + " `endpoint_id` int(10) DEFAULT NULL COMMENT '关联endpoint id',\r\n" - + " `asset_id` int(10) DEFAULT NULL COMMENT '关联资产id',\r\n" - + " `dc_id` int(10) DEFAULT NULL COMMENT '关联idc id',\r\n" - + " `hash_key` varchar(255) NOT NULL DEFAULT '' COMMENT 'redis hash key',\r\n" - + " `remark` text DEFAULT NULL COMMENT '备注 记录手动关闭记录信息,格式\\r\\n\\r\\ntime username\\r\\n\\r\\nmessage',\r\n" - + " `severity_id` int(10) DEFAULT NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF',\r\n" - + " PRIMARY KEY (`id`) USING BTREE,\r\n" - + " KEY `idx_severity` (`severity`) USING BTREE,\r\n" - + " KEY `idx_state` (`state`) USING BTREE,\r\n" - + " KEY `idx_rule_id` (`rule_id`) USING BTREE,\r\n" - + " KEY `idx_project_id` (`project_id`) USING BTREE,\r\n" - + " KEY `idx_module_id` (`module_id`) USING BTREE,\r\n" - + " KEY `idx_endpoint_id` (`endpoint_id`) USING BTREE,\r\n" - + " KEY `idx_asset_id` (`asset_id`) USING BTREE,\r\n" - + " KEY `idx_dc_id` (`dc_id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;"; - - String alertSilenceMessageRel = "CREATE TABLE `alert_silence_message_rel` (\r\n" - + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n" - + " `silence_conf_id` int(10) NOT NULL,\r\n" - + " `message_id` bigint(20) NOT NULL,\r\n" - + " `hash_key` varchar(255) NOT NULL,\r\n" - + " PRIMARY KEY (`id`) USING BTREE\r\n" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - StringBuilder sb = new StringBuilder(); - sb.append(alertSilenceConf); - sb.append(alertSeverityConf); - sb.append(alertNotifyMethod); - sb.append(alertNotifyLog); - sb.append(assetAsset); - sb.append(assetBrand); - sb.append(assetFieldGroup); - sb.append(assetFieldMeta); - sb.append(assetFieldValue); - sb.append(assetModel); - sb.append(assetStateConf); - sb.append(assetTypeConf); - sb.append(dc); - sb.append(monitorEndpoint); - sb.append(monitorEndpointState); - sb.append(monitorEventLog); - sb.append(monitorModule); - sb.append(monitorProject); - sb.append(snmpCredential); - sb.append(sysApiKey); - sb.append(sysTimezone); - sb.append(terminalCmd); - sb.append(terminalRecord); - sb.append(terminalSession); - sb.append(visualChart); - sb.append(visualChartElement); - sb.append(visualPanel); - sb.append(visualExpressionTmpl); - sb.append(alertMessageHistory); - sb.append(alertMessageSilence); - sb.append(alertMessageActive); - sb.append(alertSilenceMessageRel); - sqlDao.execute(sb.toString()); + @Autowired + private MonitorModuleService monitorModuleService; + + @Autowired + private MonitorEndpointService monitorEndpointService; + + @Autowired + private MonitorEndpointConfigService monitorEndpointConfigService; + + public void removeColumn() { + String dropColumnSql = "ALTER TABLE `monitor_module` DROP COLUMN `type`;" + + "ALTER TABLE `monitor_endpoint` DROP COLUMN `configs`;" + + "ALTER TABLE `monitor_endpoint` DROP COLUMN `hash`;" + + "ALTER TABLE `monitor_endpoint` DROP COLUMN `enabled`;"; + sqlDao.execute(dropColumnSql); } /** - * alert_severity_conf - * asset_field_group - * asset_brand - * asset_model - * asset_state_conf - * asset_type_conf - * monitor_event_log - * sys_timezone * @throws IOException * @throws SQLException * @throws ScriptException @@ -724,394 +78,116 @@ public class SqlHandler { public void initData() throws ScriptException, SQLException { Resource classPathResource = new ClassPathResource("db/init.sql"); ScriptUtils.executeSqlScript(dataSource.getConnection(), classPathResource); - // asset_brand表数据单独处理 - assetBrandService.handler(); - // asset_model表数据处理 前提先处理好brand表数据信息 - assetModelService.handler(); - // asset_type_conf表数据处理 - assetTypeConfService.handler(); - /*StringBuilder sb = new StringBuilder(); - sb.append("INSERT INTO `asset_field_group`(`id`, `name`, `remark`, `build_in`, `seq`) VALUES (1, 'default', 'Default meta group', '1', '');"); - sb.append("INSERT INTO `alert_severity_conf`(`id`, `name`, `color`, `weight`, `remark`) VALUES (1, 'P1', '#f2866e', 1, '高级告警');"); - sb.append("INSERT INTO `alert_severity_conf`(`id`, `name`, `color`, `weight`, `remark`) VALUES (2, 'P2', '#f89984', 2, '中级告警');"); - sb.append("INSERT INTO `alert_severity_conf`(`id`, `name`, `color`, `weight`, `remark`) VALUES (3, 'P3', '#f7ba78', 3, '低级告警');"); - sb.append("INSERT INTO `asset_state_conf`(`id`, `name`, `ping`, `monitor`, `alert`, `remark`, `build_in`) VALUES (1, 'In use', '1', '1', '1', '', '1');"); - sb.append("INSERT INTO `asset_state_conf`(`id`, `name`, `ping`, `monitor`, `alert`, `remark`, `build_in`) VALUES (2, 'Not in storage', '0', '0', '0', '', '1');"); - sb.append("INSERT INTO `asset_state_conf`(`id`, `name`, `ping`, `monitor`, `alert`, `remark`, `build_in`) VALUES (3, 'Idle', '1', '0', '1', '', '1');"); - sb.append("INSERT INTO `asset_state_conf`(`id`, `name`, `ping`, `monitor`, `alert`, `remark`, `build_in`) VALUES (4, 'Repair', '1', '1', '0', '', '1'); "); - sb.append("INSERT INTO `asset_state_conf`(`id`, `name`, `ping`, `monitor`, `alert`, `remark`, `build_in`) VALUES (5, 'Scrapped', '1', '0', '0', '', '1');"); - sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (1, 0, '1', '1', 'Network devices', 'Network devices', '1', 2, 1, 1, 1, '');"); - sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (2, 0, '0', '0', 'Router', '', '1', 2, 1, 0, 0, '');"); - sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (3, 0, '0', '0', 'Firewall', '', '1', 2, 1, 0, 0, '');"); - sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (4, 0, '0', '0', 'Switch', '', '1', 2, 1, 0, 0, '');"); - sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (5, 0, '0', '1', 'Computer', '', '1', 1, 0, 0, 0, '');"); - sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (6, 0, '0', '1', 'Server', '', '1', 1, 0, 0, 0, '');"); - sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (7, 0, '1', '0', 'Virtual machine', '', '1', 1, 0, 0, 0, '');"); - sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (8, 0, '0', '0', 'ADC', '', '1', 1, 1, 0, 0, '');"); - sb.append("INSERT INTO `monitor_event_log`(`event`, `counter`) VALUES ('blackbox', 0);"); - sb.append("INSERT INTO `monitor_event_log`(`event`, `counter`) VALUES ('cmd', 0);"); - sb.append("INSERT INTO `monitor_event_log`(`event`, `counter`) VALUES ('global', 0);"); - sb.append("INSERT INTO `monitor_event_log`(`event`, `counter`) VALUES ('per-datacenter', 0);"); - sb.append("INSERT INTO `monitor_event_log`(`event`, `counter`) VALUES ('snmp', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (1, 'Africa/Abidjan', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (2, 'Africa/Accra', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (3, 'Africa/Algiers', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (4, 'Africa/Bissau', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (5, 'Africa/Cairo', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (6, 'Africa/Casablanca', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (7, 'Africa/Ceuta', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (8, 'Africa/El_Aaiun', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (9, 'Africa/Johannesburg', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (10, 'Africa/Juba', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (11, 'Africa/Khartoum', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (12, 'Africa/Lagos', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (13, 'Africa/Maputo', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (14, 'Africa/Monrovia', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (15, 'Africa/Nairobi', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (16, 'Africa/Ndjamena', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (17, 'Africa/Sao_Tome', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (18, 'Africa/Tripoli', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (19, 'Africa/Tunis', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (20, 'Africa/Windhoek', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (21, 'Antarctica/Casey', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (22, 'Antarctica/Davis', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (23, 'Antarctica/DumontDUrville', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (24, 'Antarctica/Macquarie', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (25, 'Antarctica/Mawson', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (26, 'Antarctica/Palmer', -14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (27, 'Antarctica/Rothera', -10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (28, 'Antarctica/Syowa', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (29, 'Antarctica/Troll', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (30, 'Antarctica/Vostok', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (31, 'Asia/Almaty', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (32, 'Asia/Amman', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (33, 'Asia/Anadyr', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (34, 'Asia/Aqtau', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (35, 'Asia/Aqtobe', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (36, 'Asia/Ashgabat', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (37, 'Asia/Atyrau', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (38, 'Asia/Baghdad', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (39, 'Asia/Baku', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (40, 'Asia/Bangkok', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (41, 'Asia/Barnaul', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (42, 'Asia/Beirut', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (43, 'Asia/Bishkek', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (44, 'Asia/Brunei', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (45, 'Asia/Chita', 32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (46, 'Asia/Choibalsan', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (47, 'Asia/Colombo', 19800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (48, 'Asia/Damascus', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (49, 'Asia/Dhaka', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (50, 'Asia/Dili', 32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (51, 'Asia/Dubai', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (52, 'Asia/Dushanbe', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (53, 'Asia/Famagusta', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (54, 'Asia/Gaza', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (55, 'Asia/Hebron', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (56, 'Asia/Ho_Chi_Minh', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (57, 'Asia/Hong_Kong', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (58, 'Asia/Hovd', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (59, 'Asia/Irkutsk', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (60, 'Asia/Jakarta', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (61, 'Asia/Jayapura', 32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (62, 'Asia/Jerusalem', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (63, 'Asia/Kabul', 16200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (64, 'Asia/Kamchatka', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (65, 'Asia/Karachi', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (66, 'Asia/Kathmandu', 20700000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (67, 'Asia/Khandyga', 32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (68, 'Asia/Kolkata', 19800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (69, 'Asia/Krasnoyarsk', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (70, 'Asia/Kuala_Lumpur', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (71, 'Asia/Kuching', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (72, 'Asia/Macau', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (73, 'Asia/Magadan', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (74, 'Asia/Makassar', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (75, 'Asia/Manila', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (76, 'Asia/Nicosia', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (77, 'Asia/Novokuznetsk', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (78, 'Asia/Novosibirsk', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (79, 'Asia/Omsk', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (80, 'Asia/Oral', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (81, 'Asia/Pontianak', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (82, 'Asia/Pyongyang', 30600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (83, 'Asia/Qatar', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (84, 'Asia/Qostanay', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (85, 'Asia/Qyzylorda', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (86, 'Asia/Riyadh', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (87, 'Asia/Sakhalin', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (88, 'Asia/Samarkand', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (89, 'Asia/Seoul', 32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (90, 'Asia/Shanghai', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (91, 'Asia/Singapore', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (92, 'Asia/Srednekolymsk', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (93, 'Asia/Taipei', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (94, 'Asia/Tashkent', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (95, 'Asia/Tbilisi', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (96, 'Asia/Tehran', 12600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (97, 'Asia/Thimphu', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (98, 'Asia/Tokyo', 32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (99, 'Asia/Tomsk', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (100, 'Asia/Ulaanbaatar', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (101, 'Asia/Urumqi', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (102, 'Asia/Ust-Nera', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (103, 'Asia/Vladivostok', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (104, 'Asia/Yakutsk', 32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (105, 'Asia/Yangon', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (106, 'Asia/Yekaterinburg', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (107, 'Asia/Yerevan', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (108, 'Atlantic/Azores', -3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (109, 'Atlantic/Bermuda', -14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (110, 'Atlantic/Canary', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (111, 'Atlantic/Cape_Verde', -3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (112, 'Atlantic/Faroe', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (113, 'Atlantic/Madeira', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (114, 'Atlantic/Reykjavik', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (115, 'Atlantic/South_Georgia', -7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (116, 'Atlantic/Stanley', -10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (117, 'Australia/Adelaide', 34200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (118, 'Australia/Brisbane', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (119, 'Australia/Broken_Hill', 34200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (120, 'Australia/Darwin', 34200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (121, 'Australia/Eucla', 31500000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (122, 'Australia/Hobart', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (123, 'Australia/Lindeman', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (124, 'Australia/Lord_Howe', 37800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (125, 'Australia/Melbourne', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (126, 'Australia/Perth', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (127, 'Australia/Sydney', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (128, 'Etc/GMT', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (129, 'Etc/GMT+1', -3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (130, 'Etc/GMT+10', -36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (131, 'Etc/GMT+11', -39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (132, 'Etc/GMT+12', -43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (133, 'Etc/GMT+2', -7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (134, 'Etc/GMT+3', -10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (135, 'Etc/GMT+4', -14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (136, 'Etc/GMT+5', -18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (137, 'Etc/GMT+6', -21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (138, 'Etc/GMT+7', -25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (139, 'Etc/GMT+8', -28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (140, 'Etc/GMT+9', -32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (141, 'Etc/GMT-1', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (142, 'Etc/GMT-10', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (143, 'Etc/GMT-11', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (144, 'Etc/GMT-12', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (145, 'Etc/GMT-13', 46800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (146, 'Etc/GMT-14', 50400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (147, 'Etc/GMT-2', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (148, 'Etc/GMT-3', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (149, 'Etc/GMT-4', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (150, 'Etc/GMT-5', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (151, 'Etc/GMT-6', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (152, 'Etc/GMT-7', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (153, 'Etc/GMT-8', 28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (154, 'Etc/GMT-9', 32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (155, 'Etc/UTC', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (156, 'Europe/Amsterdam', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (157, 'Europe/Andorra', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (158, 'Europe/Astrakhan', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (159, 'Europe/Athens', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (160, 'Europe/Belgrade', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (161, 'Europe/Berlin', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (162, 'Europe/Brussels', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (163, 'Europe/Bucharest', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (164, 'Europe/Budapest', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (165, 'Europe/Chisinau', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (166, 'Europe/Copenhagen', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (167, 'Europe/Dublin', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (168, 'Europe/Gibraltar', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (169, 'Europe/Helsinki', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (170, 'Europe/Istanbul', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (171, 'Europe/Kaliningrad', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (172, 'Europe/Kiev', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (173, 'Europe/Kirov', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (174, 'Europe/Lisbon', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (175, 'Europe/London', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (176, 'Europe/Luxembourg', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (177, 'Europe/Madrid', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (178, 'Europe/Malta', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (179, 'Europe/Minsk', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (180, 'Europe/Monaco', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (181, 'Europe/Moscow', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (182, 'Europe/Oslo', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (183, 'Europe/Paris', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (184, 'Europe/Prague', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (185, 'Europe/Riga', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (186, 'Europe/Rome', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (187, 'Europe/Samara', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (188, 'Europe/Saratov', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (189, 'Europe/Simferopol', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (190, 'Europe/Sofia', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (191, 'Europe/Stockholm', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (192, 'Europe/Tallinn', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (193, 'Europe/Tirane', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (194, 'Europe/Ulyanovsk', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (195, 'Europe/Uzhgorod', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (196, 'Europe/Vienna', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (197, 'Europe/Vilnius', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (198, 'Europe/Volgograd', 10800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (199, 'Europe/Warsaw', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (200, 'Europe/Zaporozhye', 7200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (201, 'Europe/Zurich', 3600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (202, 'Factory', 0);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (203, 'Indian/Chagos', 21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (204, 'Indian/Christmas', 25200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (205, 'Indian/Cocos', 23400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (206, 'Indian/Kerguelen', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (207, 'Indian/Mahe', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (208, 'Indian/Maldives', 18000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (209, 'Indian/Mauritius', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (210, 'Indian/Reunion', 14400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (211, 'Pacific/Apia', 46800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (212, 'Pacific/Auckland', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (213, 'Pacific/Bougainville', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (214, 'Pacific/Chatham', 45900000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (215, 'Pacific/Chuuk', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (216, 'Pacific/Easter', -21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (217, 'Pacific/Efate', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (218, 'Pacific/Enderbury', 46800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (219, 'Pacific/Fakaofo', 46800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (220, 'Pacific/Fiji', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (221, 'Pacific/Funafuti', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (222, 'Pacific/Galapagos', -21600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (223, 'Pacific/Gambier', -32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (224, 'Pacific/Guadalcanal', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (225, 'Pacific/Guam', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (226, 'Pacific/Honolulu', -36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (227, 'Pacific/Kiritimati', 50400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (228, 'Pacific/Kosrae', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (229, 'Pacific/Kwajalein', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (230, 'Pacific/Majuro', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (231, 'Pacific/Marquesas', -34200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (232, 'Pacific/Nauru', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (233, 'Pacific/Niue', -39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (234, 'Pacific/Norfolk', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (235, 'Pacific/Noumea', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (236, 'Pacific/Pago_Pago', -39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (237, 'Pacific/Palau', 32400000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (238, 'Pacific/Pitcairn', -28800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (239, 'Pacific/Pohnpei', 39600000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (240, 'Pacific/Port_Moresby', 36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (241, 'Pacific/Rarotonga', -36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (242, 'Pacific/Tahiti', -36000000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (243, 'Pacific/Tarawa', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (244, 'Pacific/Tongatapu', 46800000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (245, 'Pacific/Wake', 43200000);"); - sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (246, 'Pacific/Wallis', 43200000);"); - sb.append("INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('asset_asset_export_header', '{\\r\\n \\\"cn\\\": {\\r\\n \\\"*资产名称\\\": \\\"资产名称,唯一标识(必填) \\\\n示例: DELL服务器\\\",\\r\\n \\\"*SN码\\\": \\\"资产序列号,唯一标识(必填) \\\\n示例: A0420200101\\\",\\r\\n \\\"虚拟机宿主\\\": \\\"虚拟机宿主,当资产为虚拟机时必填 \\\\n示例: DELL物理机\\\",\\r\\n \\\"*管理ip\\\": \\\"主机地址(必填),IP格式 \\\\n示例: 172.0.0.1\\\",\\r\\n \\\"*品牌\\\": \\\"品牌(必填) \\\\n示例: DELL\\\",\\r\\n \\\"*型号\\\": \\\"型号(必填) \\\\n示例: DELL-D3\\\",\\r\\n \\\"*数据中心\\\": \\\"数据中心(必填) \\\\n示例: 北京电信中心机房\\\",\\r\\n \\\"机柜\\\": \\\"机柜 \\\\n示例: cabinet-001\\\",\\r\\n \\\"开始U位\\\": \\\"机柜开始位置 此信息一般和机柜结束位置联合使用 \\\\n示例: 1\\\",\\r\\n \\\"结束U位\\\": \\\"机柜结束位置 此信息一般与机柜开始位置联合使用 \\\\n示例: 2\\\",\\r\\n \\\"*资产状态\\\": \\\"资产状态 \\\\n示例: 在库\\\",\\r\\n \\\"*资产类型\\\": \\\"资产类型 \\\\n示例: 服务器\\\",\\r\\n \\\"购买日期\\\": \\\"购买日期 \\\\n示例: 2020/2/25\\\",\\r\\n \\\"属性信息\\\": \\\"资产属性信息,格式: key=value 如需填写多个请使用回车换行 \\\\n示例: NetworkCard=eth0 \\\\n user=root\\\",\\r\\n \\\"认证服务端口\\\": \\\"ssh/telnet端口 \\\\n示例: 22/23\\\",\\r\\n \\\"认证方式\\\":\\\"用户名密码/密钥 \\\\n示例:111111\\\",\\r\\n \\\"用户名\\\":\\\"用户名 \\\\n示例:root\\\",\\r\\n \\\"密码\\\":\\\"auth_type =1 : 记录登录密码 auth_type=2 : 记录密钥密码\\\",\\r\\n \\\"密钥\\\":\\\"密钥内容\\\",\\r\\n \\\"用户名提示\\\":\\\"telnet协议有效\\\",\\r\\n \\\"密码提示\\\":\\\"telnet协议有效\\\",\\r\\n \\\"snmp凭证\\\":\\\"type 开启snmp有效\\\"\\r\\n },\\r\\n \\\"en\\\": {\\r\\n \\\"*Asset Name\\\": \\\"Asset name, unique identifier (required) \\\\nExample: DELL server\\\",\\r\\n \\\"*Sn\\\": \\\"Asset serial number, unique identifier (required) \\\\nExample: A0420200101\\\",\\r\\n \\\"*Virtual machine host\\\": \\\"Virtual machine host, required when the asset is a virtual machine \\\\nExample: DELL physical machine\\\",\\r\\n \\\"*Management ip\\\": \\\"Host address (required), IP format \\\\nExample: 172.0.0.1\\\",\\r\\n \\\"*Brand\\\": \\\"Brand (required) \\\\nExample: DELL\\\",\\r\\n \\\"*Model\\\": \\\"Model (required) \\\\nExample: DELL-D3\\\",\\r\\n \\\"*DC\\\": \\\"Data Center (Required) \\\\nExample: Beijing Telecom Center Computer Room\\\",\\r\\n \\\"Cabinet\\\": \\\"Cabinet \\\\nExample: cabinet-001\\\",\\r\\n \\\"Cabinet Start\\\": \\\"Cabinet start position This information is generally used in conjunction with the cabinet end position \\\\nExample: 1\\\",\\r\\n \\\"Cabinet End\\\": \\\"Cabinet end position This information is generally used in conjunction with the cabinet start position \\\\nExample: 2\\\",\\r\\n \\\"*Asset state\\\": \\\"Asset status \\\\nExample: In stock\\\",\\r\\n \\\"*Asset type\\\": \\\"Asset Type\\\\nExample: Server\\\",\\r\\n \\\"Purchase date\\\": \\\"Purchase date \\\\nExample: 2020/2/25\\\",\\r\\n \\\"Field Information\\\": \\\"Asset field information, format: key=value If you need to fill in more than one, please use carriage return and line feed \\\\nExample: NetworkCard=eth0 \\\\n user=root\\\",\\r\\n \\\"Auth protocol Port\\\": \\\"ssh/telnet \\\\nExample: 22/23\\\",\\r\\n \\\"Auth Type\\\":\\\"User name password / pri key \\\\nExample: 111111\\\",\\r\\n \\\"Auth Username\\\":\\\"username \\\\nExample: root\\\",\\r\\n \\\"Auth Pin\\\":\\\"auth_type =1 : pin value auth_type=2 : pri key pin\\\",\\r\\n \\\"Auth Pri Key\\\":\\\"pri key content\\\",\\r\\n \\\"Auth User Tip\\\":\\\"telnet protocol valid\\\",\\r\\n \\\"Auth Pin Tip\\\":\\\"telnet protocol valid\\\",\\r\\n \\\"Snmp Credential\\\":\\\"snmp protocol valid\\\"\\r\\n }\\r\\n}', 1, NULL);\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('asset_chart_tpl', '{\\\"name\\\":\\\"{{asset.sn}}\\\",\\\"type\\\":\\\"assetInfo\\\",\\\"span\\\":12,\\\"height\\\":400,\\\"unit\\\":2}', 1, NULL);\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('asset_ping_from', '2', 1, '1: global\\r\\n\\r\\n2: per-datacenter\\r\\n\\r\\n默认:1');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('confagent_name', '{\\\"centos\\\":\\\"confagent-v2.0-x86.rpm\\\",\\\"ubuntu\\\":\\\"confagent-v2.0-x86.zip\\\"}', 1, 'confagent 下载文件名称');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_auth_account', '', 1, '');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_auth_password', '', 1, '');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_host', '', 1, '');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_port', '25', 1, '');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_security_type', 'NONE', 1, 'NONE SSL TLS');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_test_account', '', 1, '');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_timeout', '10', 1, '默认:10');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('endpoint_chart_tpl', '{\\\"name\\\":\\\"{{endpoint.name}}\\\",\\\"type\\\":\\\"endpointInfo\\\",\\\"span\\\":12,\\\"height\\\":400,\\\"unit\\\":2}', 1, NULL);\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('expretmpl_export_header', '{\\\"cn\\\":{\\\"*名称\\\":\\\"模板名称(必填) \\\\n示例: CPU利用率模板\\\",\\\"组名\\\":\\\"组名 \\\\n示例: base,默认值: default\\\",\\\"*表达式\\\":\\\"表达式内容(必填) \\\\n示例: node_cpu_usage(asset=\\\\\\\"{{asset.host}}\\\\\\\",device=\\\\\\\"{{device}}\\\\\\\")\\\",\\\"描述\\\":\\\"描述 \\\\n示例: node_export CPU利用率模板\\\"},\\\"en\\\":{\\\"*Name\\\":\\\"Template name (required) \\\\nExample: CPU utilization template\\\",\\\"Group Name\\\":\\\"Group Name \\\\nExample: base, Default value: default\\\",\\\"*Expression\\\":\\\"Expression content (required) Optional: node_cpu_usage(asset=\\\\\\\"{{asset.host}}\\\\\\\",device=\\\\\\\"{{device}}\\\\\\\")\\\",\\\"Remark\\\":\\\"Remark \\\\nExample: node_export CPU utilization template\\\"}}', 1, '表达式导入导出模板表头信息');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('license', '2000NEZHAbase2021-06-03T14:52:43Z3403d697d45c594a0d147d556d94ad087272830c35af0e65b3b6d6474db62359a42adf685413144e3ff57f3551f33c54614ed8eb4d705efd25ca873a73af08912242b74d3272cef149ac0b39ac4247e7263f9b395c1892aea7dce0d941ea14ee901f052192ce555c4c438510b31d6fef30b109125a42b19fbcf3190482adab2ffc64d01c31f3dd020a712fc97138c3c52df41f0116c56543faddba8a7393581dee612fec9646ca4edb6f46bf2894eeaff1436feb126ce7155dd8b5514038320b297fab40ca4ed0402eb71951e8b00185fe7fe7f0f0ba13de3d4dc9416a5762214bb8f2bfa7ec688bd119aeaa2a4c4153383b64a463892d63301070c295404538b54f8de7d36ca7fbf40011b9e057cbb1d4a15147def@gz.comabc2021-04-16T13:52:38Ztest license1112021-03-03T14:52:43Zzhangsan', 1, '3403d697d45c594a0d147d556d94ad087272830c');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('license_token', 'abbbb', 1, NULL);\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('ldap_timeout', '30', 1, '超时时间秒');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('monitor_endpoint_export_header', '{\\\"cn\\\":{\\\"*系统\\\":\\\"系统名称(必填) \\\\n示例: Nezha\\\",\\\"*组件\\\":\\\"组件名称(必填) \\\\n示例: node_exporter\\\",\\\"名称\\\":\\\"实例名称 \\\\n示例: node_exporter\\\",\\\"资产名称\\\":\\\"资产名称(非必填) 与 主机地址 不能同时为空 \\\\n示例: A0420200101\\\",\\\"配置\\\":\\\"实例配置,JSON格式, \\\\n示例: {\\\\\\\"key\\\\\\\":\\\\\\\"value\\\\\\\"}\\\",\\\"启用\\\":\\\"启用状态(非必填) 可选 0:停用 1:启用,为空时默认为1 \\\\n示例: 1\\\"},\\\"en\\\":{\\\"*Project Name\\\":\\\"Project Name(Required) \\\\nExample: Nezha\\\",\\\"*Module Name\\\":\\\"Module Name(Required) \\\\nExample: node_exporter\\\",\\\"Name\\\":\\\"Endpoint name \\\\nExample: node_exporter\\\",\\\"Asset Name\\\":\\\"Asset name(Not required) And host address cannot be empty at the same time \\\\n示例: A0420200101\\\",\\\"Configs\\\":\\\"Endpoint Configs,JSON format, \\\\nExample: {\\\\\\\"key\\\\\\\":\\\\\\\"value\\\\\\\"}\\\",\\\"Enabled\\\":\\\"Enable state (not required) Optional values 0: Disable 1: Enable, when empty, the default is 1 \\\\nExample: 1\\\"}}', 1, 'monitor endpoint 导入表头');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('prometheus_federation_enabled', '1', 1, '配置prometheus是否开启联邦模式,1:开启,0:关闭(界面禁用 添加选择 per-datacenter agent,所有endpoint 配置信息 hash 分布到 global prometheus)');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('prom_cmd_tmpl', 'OPTION=\\\" --config.file=\\'/opt/nezha/nz-confagent/prometheus/prometheus.yml\\' --web.listen-address=\\'127.0.0.1:9090\\' --web.enable-admin-api --storage.tsdb.path=\\'/data/prometheusData\\' --web.enable-lifecycle --storage.tsdb.retention.time=${storageDays}d \\\"', 1, 'prometheus 启动参数模板');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('prom_rule_tmpl', '{\\r\\n \\\"groups\\\": [{\\r\\n \\\"name\\\": \\\"alertRule\\\",\\r\\n \\\"rules\\\": [\\r\\n <#if endpointAlert>\\r\\n {\\r\\n \\\"alert\\\": \\\"0\\\",\\r\\n \\\"expr\\\": \\\"up{endpoint!=\\'\\'}>-1\\\",\\r\\n \\\"for\\\": \\\"30s\\\",\\r\\n \\\"annotations\\\": {\\r\\n \\\"summary\\\": \\\"{{$value}}\\\"\\r\\n }\\r\\n }, \\r\\n \\r\\n <#list ruleList as rule>\\r\\n {\\r\\n \\\"alert\\\": ${rule.id?c},\\r\\n \\\"expr\\\": \\\"(${rule.expr})${rule.operator}${rule.threshold}\\\",\\r\\n \\\"for\\\": \\\"${rule.last}s\\\",\\r\\n \\\"labels\\\": {\\r\\n \\\"severity\\\": \\\"${rule.severity_name}\\\",\\r\\n \\\"severity_id\\\": ${rule.severity_id?c}\\r\\n },\\r\\n \\\"annotations\\\": {\\r\\n \\\"summary\\\": <#if rule.summary?default(\\\"\\\")?trim?length gt 1>\\r\\n \\\"${rule.summary}\\\",\\r\\n <#else>\\\"\\\",\\r\\n \\\"description\\\": <#if rule.description?default(\\\"\\\")?trim?length gt 1>\\r\\n \\\"${rule.description}\\\"\\r\\n <#else>\\\"\\\"\\r\\n \\r\\n }\\r\\n }\\r\\n <#sep>,\\r\\n ]\\r\\n }]\\r\\n}', 1, 'prometheus rule文件模板');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('prom_yml_tmpl', '{\\r\\n \\\"global\\\": {\\r\\n \\\"scrape_interval\\\": \\\"${scrape_interval}s\\\",\\r\\n \\\"scrape_timeout\\\": <#if scrape_timeout??> \\r\\n \\\"${scrape_timeout}s\\\",\\r\\n <#else>\\r\\n \\\"10s\\\",\\r\\n \\r\\n \\\"evaluation_interval\\\": \\\"${scrape_interval}s\\\"\\r\\n },\\r\\n \\r\\n <#-- alert 配置 -->\\r\\n <#if isAlert>\\r\\n \\\"alerting\\\": {\\r\\n \\\"alertmanagers\\\": [{\\r\\n \\\"path_prefix\\\": \\\"${path_prefix}\\\",\\r\\n \\\"static_configs\\\": [{\\r\\n \\\"targets\\\": [\\\"${alert_url}\\\"]\\r\\n }]\\r\\n }],\\r\\n \\\"alert_relabel_configs\\\": [{\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }, {\\r\\n \\\"regex\\\": \\\"replica\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }]\\r\\n },\\r\\n \\\"rule_files\\\": [\\\"rule.yml\\\"],\\r\\n \\r\\n \\r\\n \\r\\n \\r\\n <#-- per-datacenter 配置 -->\\r\\n <#if !isGlobal>\\r\\n \\\"scrape_configs\\\": [\\r\\n <#list endpointList as endpoint>\\r\\n {\\r\\n \\\"job_name\\\": ${endpoint.id?c},\\r\\n \\\"metrics_path\\\": <#if endpoint.config.metrics_path?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.metrics_path}\\\",\\r\\n <#else>\\r\\n \\\"/metrics\\\",\\r\\n \\r\\n \\\"scrape_interval\\\": <#if endpoint.config.scrape_interval?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.scrape_interval}s\\\",\\r\\n <#else>\\r\\n \\\"${scrape_interval}s\\\",\\r\\n \\r\\n \\\"scrape_timeout\\\": <#if endpoint.config.scrape_timeout?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.scrape_timeout}s\\\",\\r\\n <#else>\\r\\n <#if scrape_timeout??> \\r\\n \\\"${scrape_timeout}s\\\",\\r\\n <#else>\\r\\n \\\"10s\\\",\\r\\n \\r\\n \\r\\n\\r\\n\\r\\n\\r\\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\\r\\n <#if endpoint.config.basic_auth.username?default(\\\"\\\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"basic_auth\\\":{\\r\\n \\\"username\\\": \\\"${endpoint.config.basic_auth.username}\\\",\\r\\n \\\"password\\\": \\\"${endpoint.config.basic_auth.password}\\\"\\r\\n },\\r\\n \\r\\n \\r\\n \\r\\n \\r\\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\\r\\n \\\"authorization\\\":{\\r\\n \\\"type\\\":\\\"Bearer\\\",\\r\\n \\\"credentials\\\":\\\"${endpoint.config.bearer_token}\\\"\\r\\n },\\r\\n \\r\\n\\r\\n \\r\\n <#-- params 不为空且类型为 http ,添加 params -->\\r\\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.module.type == \\\"http\\\">\\r\\n \\\"params\\\":{\\r\\n <#list endpoint.config.params?keys as itemKey>\\r\\n \\\"${itemKey}\\\":[\\r\\n <#list endpoint.config.params[itemKey] as pojo>\\r\\n \\\"${pojo}\\\"\\r\\n <#sep>,\\r\\n \\r\\n ]\\r\\n <#sep>,\\r\\n \\r\\n },\\r\\n <#elseif endpoint.module.type == \\\"snmp\\\">\\r\\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\\r\\n \\\"params\\\":{\\r\\n \\\"target\\\":[ \\\"${endpoint.config.host}:${endpoint.config.port?c}\\\" ],\\r\\n \\\"module\\\":[ \\\"${endpoint.module.name}\\\" ]\\r\\n },\\r\\n \\r\\n \\r\\n \\\"static_configs\\\": [{\\r\\n \\\"targets\\\": [<#if endpoint.module.type == \\\"http\\\">\\r\\n \\\"${endpoint.config.host}:${endpoint.config.port?c}\\\"\\r\\n <#else>\\r\\n \\\"127.0.0.1:9116\\\"\\r\\n \\r\\n ],\\r\\n \\\"labels\\\": {\\r\\n \\\"datacenter\\\": \\\"${endpoint.dc.name}\\\",\\r\\n \\\"datacenter_id\\\":${endpoint.dc.id?c},\\r\\n \\r\\n \\\"project\\\": \\\"${endpoint.project.name}\\\",\\r\\n \\\"project_id\\\": ${endpoint.project.id?c},\\r\\n \\r\\n \\\"asset\\\": \\\"${endpoint.asset.name}\\\",\\r\\n \\\"asset_id\\\": ${endpoint.asset.id?c},\\r\\n \\r\\n \\\"module\\\": \\\"${endpoint.module.name}\\\",\\r\\n \\\"module_id\\\": ${endpoint.module.id?c},\\r\\n \\r\\n \\\"endpoint\\\": \\\"${endpoint.name}\\\",\\r\\n \\\"endpoint_id\\\": ${endpoint.id?c},\\r\\n \\r\\n \\\"nz_agent_id\\\": ${endpoint.promserver.id?c}\\r\\n \\r\\n \\r\\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\\r\\n ,\\r\\n \\r\\n <#-- 补充用户自定义 Labels -->\\r\\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\\r\\n <#list endpoint.config.labels?keys as key>\\r\\n <#if key != \\\"datacenter\\\" && key != \\\"datacenter_id\\\" && key != \\\"project\\\" && key != \\\"project_id\\\" && key != \\\"asset\\\" && key != \\\"asset_id\\\" && key != \\\"module\\\" && key != \\\"module_id\\\" && key != \\\"endpoint\\\" && key != \\\"endpoint_id\\\">\\r\\n \\\"${key}\\\":\\\"${endpoint.config.labels[key]}\\\"<#sep>,\\r\\n \\r\\n \\r\\n \\r\\n }\\r\\n }],\\r\\n \\\"relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n },\\r\\n {\\r\\n \\\"regex\\\": \\\"job\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ],\\r\\n \\\"metric_relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n <#sep>,\\r\\n \\r\\n \\r\\n <#-- ping 配置 -->\\r\\n \\r\\n <#if endpointList??&&(endpointList?size>0)>\\r\\n ,\\r\\n \\r\\n \\r\\n <#list assetList as asset>\\r\\n {\\r\\n \\\"job_name\\\": \\\"asset_ping_${asset.id?c}\\\",\\r\\n \\\"metrics_path\\\": \\\"/probe\\\",\\r\\n \\\"scrape_interval\\\": <#if asset.assetPingInterval?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${asset.assetPingInterval}s\\\",\\r\\n <#else>\\r\\n \\\"${scrape_interval}s\\\",\\r\\n \\r\\n \\\"scrape_timeout\\\": <#if asset.scrape_timeout?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${asset.scrape_timeout}s\\\",\\r\\n <#else>\\r\\n <#if scrape_timeout??> \\r\\n \\\"${scrape_timeout}s\\\",\\r\\n <#else>\\r\\n \\\"10s\\\",\\r\\n \\r\\n \\r\\n \\\"params\\\": {\\r\\n \\\"target\\\":[ \\\"${asset.manageIp}\\\" ],\\r\\n \\\"module\\\":[ \\\"ping\\\" ]\\r\\n },\\r\\n \\\"static_configs\\\": [{\\r\\n \\\"targets\\\": [\\\"127.0.0.1:9115\\\"],\\r\\n \\\"labels\\\": {\\r\\n \\\"datacenter\\\": \\\"${asset.dc.name}\\\",\\r\\n \\\"host\\\": \\\"${asset.manageIp}\\\",\\r\\n \\\"module\\\": \\\"ping\\\",\\r\\n \\\"source_ip\\\": \\\"${asset.promserver.host}\\\",\\r\\n \\\"nz_agent_id\\\": ${asset.promserver.id?c}\\r\\n }\\r\\n }],\\r\\n \\\"relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ],\\r\\n \\\"metric_relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n <#sep>,\\r\\n \\r\\n ]\\r\\n <#else>\\r\\n <#-- global 配置 -->\\r\\n \\\"scrape_configs\\\": [\\r\\n <#list jobList as jobPojo>\\r\\n {\\r\\n \\\"job_name\\\": \\\"${jobPojo.job_name}\\\",\\r\\n <#if jobPojo.isFederate> \\r\\n \\\"honor_labels\\\": ${jobPojo.honor_labels},\\r\\n \\\"params\\\": {\\r\\n \\\"match[]\\\": [\\r\\n <#-- 开启联邦 -->\\r\\n <#if jobPojo.fedeEnabled>\\r\\n <#if jobPojo.scrapePing> \\r\\n \\\"{job=~\\\\\\\"asset_ping_.+\\\\\\\",nz_agent_id != \\\\\\\"${jobPojo.excludeAgentId}\\\\\\\"}\\\"\\r\\n <#else>\\r\\n \\\"{__name__=~\\\\\\\".+\\\\\\\",nz_agent_id != \\\\\\\"${jobPojo.excludeAgentId}\\\\\\\"}\\\"\\r\\n \\r\\n <#else>\\r\\n <#-- 联邦关闭,抓取所有指标即可 -->\\r\\n \\\"{__name__=~\\\\\\\".+\\\\\\\",nz_agent_id != \\\\\\\"${jobPojo.excludeAgentId}\\\\\\\"}\\\"\\r\\n \\r\\n ]\\r\\n },\\r\\n \\\"authorization\\\":{\\r\\n \\\"type\\\":\\\"Bearer\\\",\\r\\n \\\"credentials\\\":\\\"${jobPojo.token}\\\"\\r\\n },\\r\\n \\r\\n \\\"metrics_path\\\": <#if jobPojo.metrics_path?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${jobPojo.metrics_path}\\\",\\r\\n <#else>\\r\\n \\\"/metrics\\\",\\r\\n \\r\\n \\\"static_configs\\\":[\\r\\n <#list jobPojo.staticConfigList as staticConf >\\r\\n {\\r\\n \\\"targets\\\": [\\r\\n <#list staticConf.targets as targetConf>\\r\\n \\\"${targetConf}\\\"<#sep>,\\r\\n \\r\\n ]\\r\\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\\r\\n ,\\r\\n \\\"labels\\\": {\\r\\n <#list staticConf.labels?keys as itemKey>\\r\\n \\\"${itemKey}\\\":<#if staticConf.labels[itemKey]?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${staticConf.labels[itemKey]}\\\"\\r\\n <#else>\\\"\\\"<#sep>,\\r\\n \\r\\n } \\r\\n \\r\\n }<#sep>,\\r\\n \\r\\n ],\\r\\n \\\"relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"job\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n <#if jobPojo.instanceRelabel> \\r\\n ,\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n \\r\\n ],\\r\\n \\\"metric_relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ]\\r\\n }<#sep>,\\r\\n \\r\\n \\r\\n <#-- ping 配置 -->\\r\\n \\r\\n <#if jobList??&&(jobList?size>0)>\\r\\n ,\\r\\n \\r\\n \\r\\n <#list assetList as asset>\\r\\n {\\r\\n \\\"job_name\\\": \\\"asset_ping_${asset.id?c}\\\",\\r\\n \\\"metrics_path\\\": \\\"/probe\\\",\\r\\n \\\"scrape_interval\\\": <#if asset.assetPingInterval?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${asset.assetPingInterval}s\\\",\\r\\n <#else>\\r\\n \\\"${scrape_interval}s\\\",\\r\\n \\r\\n \\\"scrape_timeout\\\": <#if asset.scrape_timeout?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${asset.scrape_timeout}s\\\",\\r\\n <#else>\\r\\n <#if scrape_timeout??> \\r\\n \\\"${scrape_timeout}s\\\",\\r\\n <#else>\\r\\n \\\"10s\\\",\\r\\n \\r\\n \\r\\n \\\"params\\\": {\\r\\n \\\"target\\\":[ \\\"${asset.manageIp}\\\" ],\\r\\n \\\"module\\\":[ \\\"ping\\\" ]\\r\\n },\\r\\n \\\"static_configs\\\": [{\\r\\n \\\"targets\\\": [\\\"127.0.0.1:9115\\\"],\\r\\n \\\"labels\\\": {\\r\\n \\\"datacenter\\\": \\\"${asset.dc.name}\\\",\\r\\n \\\"host\\\": \\\"${asset.manageIp}\\\",\\r\\n \\\"module\\\": \\\"ping\\\",\\r\\n \\\"source_ip\\\": \\\"${asset.promserver.host}\\\",\\r\\n \\\"nz_agent_id\\\": ${asset.promserver.id?c}\\r\\n }\\r\\n }],\\r\\n \\\"relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ],\\r\\n \\\"metric_relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n <#sep>,\\r\\n \\r\\n \\r\\n \\r\\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\\r\\n ,\\r\\n \\r\\n \\r\\n <#list endpointList as endpoint>\\r\\n {\\r\\n \\\"job_name\\\": ${endpoint.id?c},\\r\\n \\\"metrics_path\\\": <#if endpoint.config.metrics_path?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.metrics_path}\\\",\\r\\n <#else>\\r\\n \\\"/metrics\\\",\\r\\n \\r\\n \\\"scrape_interval\\\": <#if endpoint.config.scrape_interval?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.scrape_interval}s\\\",\\r\\n <#else>\\r\\n \\\"${scrape_interval}s\\\",\\r\\n \\r\\n \\\"scrape_timeout\\\": <#if endpoint.config.scrape_timeout?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.scrape_timeout}s\\\",\\r\\n <#else>\\r\\n <#if scrape_timeout??> \\r\\n \\\"${scrape_timeout}s\\\",\\r\\n <#else>\\r\\n \\\"10s\\\",\\r\\n \\r\\n \\r\\n\\r\\n\\r\\n\\r\\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\\r\\n <#if endpoint.config.basic_auth.username?default(\\\"\\\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"basic_auth\\\":{\\r\\n \\\"username\\\": \\\"${endpoint.config.basic_auth.username}\\\",\\r\\n \\\"password\\\": \\\"${endpoint.config.basic_auth.password}\\\"\\r\\n },\\r\\n \\r\\n \\r\\n \\r\\n \\r\\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\\r\\n \\\"authorization\\\":{\\r\\n \\\"type\\\":\\\"Bearer\\\",\\r\\n \\\"credentials\\\":\\\"${endpoint.config.bearer_token}\\\"\\r\\n },\\r\\n \\r\\n\\r\\n \\r\\n <#-- params 不为空且类型为 http ,添加 params -->\\r\\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.module.type == \\\"http\\\">\\r\\n \\\"params\\\":{\\r\\n <#list endpoint.config.params?keys as itemKey>\\r\\n \\\"${itemKey}\\\":[\\r\\n <#list endpoint.config.params[itemKey] as pojo>\\r\\n \\\"${pojo}\\\"\\r\\n <#sep>,\\r\\n \\r\\n ]\\r\\n <#sep>,\\r\\n \\r\\n },\\r\\n <#elseif endpoint.module.type == \\\"snmp\\\">\\r\\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\\r\\n \\\"params\\\":{\\r\\n \\\"target\\\":[ \\\"${endpoint.config.host}:${endpoint.config.port?c}\\\" ],\\r\\n \\\"module\\\":[ \\\"${endpoint.module.name}\\\" ]\\r\\n },\\r\\n \\r\\n \\r\\n \\\"static_configs\\\": [{\\r\\n \\\"targets\\\": [<#if endpoint.module.type == \\\"http\\\">\\r\\n \\\"${endpoint.config.host}:${endpoint.config.port?c}\\\"\\r\\n <#else>\\r\\n \\\"127.0.0.1:9116\\\"\\r\\n \\r\\n ],\\r\\n \\\"labels\\\": {\\r\\n \\\"datacenter\\\": \\\"${endpoint.dc.name}\\\",\\r\\n \\\"datacenter_id\\\":${endpoint.dc.id?c},\\r\\n \\r\\n \\\"project\\\": \\\"${endpoint.project.name}\\\",\\r\\n \\\"project_id\\\": ${endpoint.project.id?c},\\r\\n \\r\\n \\\"asset\\\": \\\"${endpoint.asset.name}\\\",\\r\\n \\\"asset_id\\\": ${endpoint.asset.id?c},\\r\\n \\r\\n \\\"module\\\": \\\"${endpoint.module.name}\\\",\\r\\n \\\"module_id\\\": ${endpoint.module.id?c},\\r\\n \\r\\n \\\"endpoint\\\": \\\"${endpoint.name}\\\",\\r\\n \\\"endpoint_id\\\": ${endpoint.id?c},\\r\\n \\r\\n \\\"nz_agent_id\\\": ${endpoint.promserver.id?c}\\r\\n \\r\\n \\r\\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\\r\\n ,\\r\\n \\r\\n <#-- 补充用户自定义 Labels -->\\r\\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\\r\\n <#list endpoint.config.labels?keys as key>\\r\\n <#if key != \\\"datacenter\\\" && key != \\\"datacenter_id\\\" && key != \\\"project\\\" && key != \\\"project_id\\\" && key != \\\"asset\\\" && key != \\\"asset_id\\\" && key != \\\"module\\\" && key != \\\"module_id\\\" && key != \\\"endpoint\\\" && key != \\\"endpoint_id\\\">\\r\\n \\\"${key}\\\":\\\"${endpoint.config.labels[key]}\\\"<#sep>,\\r\\n \\r\\n \\r\\n \\r\\n }\\r\\n }],\\r\\n \\\"relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n },\\r\\n {\\r\\n \\\"regex\\\": \\\"job\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ],\\r\\n \\\"metric_relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n <#sep>,\\r\\n \\r\\n \\r\\n ]\\r\\n \\r\\n}', 1, 'prometheus config文件模板');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('session_timeout', '30', 1, '默认:30,不小于 15 单位:minute');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('system_logo', '', 1, NULL);\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('unsaved_change', 'on', 1, '未保存提示开关');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('terminal_record_local_retention', '365', 1, '默认:365,单位:天,record数据保留天数');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('terminal_telnet_pin_tip', 'assword:', 1, '默认:assword:');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('terminal_telnet_user_tip', 'ogin:', 1, '默认:ogin:');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('terminal_timeout', '30', 1, '默认:30,单位:minute');\r\n" - + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('snmp_trap_listen_port', '160', 1, 'snmp trap接收端口');\r\n" - + "update sys_config set param_key =\"default_scrape_interval\" where param_key=\"scrape_interval\";\r\n" - + "update sys_config set param_key =\"default_scrape_timeout\" where param_key=\"scrape_timeout\";\r\n" - + "update sys_config set param_value =\"Asia/Almaty\" where param_key=\"timezone\";\r\n" - ); - // 修改sys_user表数据 初始化name字段内容 - sb.append("update sys_user set name = username;"); - sqlDao.execute(sb.toString()); - */ } - public void transferData() { - // dc数据同步 - dcService.handler(); - // 资产数据同步 snmp认证表数据同步 tag相关数据同步 - assetAssetService.handler(); - - // 告警相关数据同步 - alertMessageService.handler(); - - // 图表相关数据同步 - chartService.handler(); - - // project module endpoint 数据同步 - endpointService.handler(); - // 将原来数据库的数据数据还原 - this.dataRestore(); - - // project topo相关图表数据同步 - projectTopoService.handler(); - } - public void dataRestore() { - StringBuilder sb =new StringBuilder(); - // sys_user表数据还原 - List users = sysUserService.queryNewUsers(); - List oldUsers = sysUserService.queryOldUsers(); - Map userIdAndEntity = users.stream().collect(Collectors.toMap(SysUserEntity::getId, Function.identity())); - for(SysUserEntity user : oldUsers) { - SysUserEntity sysUserEntity = userIdAndEntity.get(user.getUserId()); - if(ToolUtil.isNotEmpty(sysUserEntity)) { - sb.append("update sys_user set id='"+user.getUserId()+"',username='"+user.getUsername()+"',pin='" - +user.getPassword()+"',salt='"+user.getSalt()+"',email='"+user.getEmail()+"',status='" - +user.getStatus()+"',lang='"+user.getLang() - +"',source='"+user.getSource()+"',name='"+user.getUsername()+"';"); - }else { - sb.append("insert into sys_user (id,username,pin,salt,email,status," - + "lang,source,name) values('"+user.getUserId()+"','"+user.getUsername()+"','"+user.getPassword() - +"','"+user.getSalt()+"','"+user.getEmail()+"','"+user.getStatus() - +"','"+user.getLang()+"','"+user.getSource()+"','"+user.getUsername()+"');"); - } - } - // - sqlDao.execute(sb.toString()); - - // sys_config表数据 - List newDatas = sysConfigService.list(); - List oldDatas = sysConfigService.querySysConfigEntitys(); - Map oldDataMap = oldDatas.stream().collect(Collectors.toMap(SysConfigEntity::getParamKey, SysConfigEntity::getParamValue)); - for(SysConfigEntity data : newDatas) { - if(data.getParamKey().equals("default_scrape_interval")) { - data.setParamValue(oldDataMap.get("scrape_interval")); - }else if(data.getParamKey().equals("default_scrape_timeout")) { - data.setParamValue(oldDataMap.get("scrape_timeout")); - }else if(data.getParamKey().equals("timezone")) { - data.setParamValue("Asia/Shanghai"); - }else if(data.getParamKey().endsWith("confagent_path") || data.getParamKey().equals("system_version")){ - continue; - }else { - String value = oldDataMap.get(data.getParamKey()); - if(value!=null) { - data.setParamValue(value); - } - } - } - sysConfigService.updateBatchById(newDatas); - - // prom_server snmp_mib link project_topo表数据同步 - StringBuilder restoreData = new StringBuilder(); - restoreData.append("INSERT INTO prom_server (id, dc_id, `host`, `port`, type, `status`, check_time,token ) SELECT id, idc_id,`host`,`port`,type,`status`,check_time,\"\" FROM prom_server_copy;\r\n" - + " INSERT INTO project_topo (id, project_id, topo,update_at,update_by) SELECT id, project_id, topo,update_at,update_by from project_topo_copy;\r\n" - + " INSERT INTO project_topo_icon (id,name,bytes,type,unit) select id,name,bytes,type,-1 from project_topo_icon_copy where id > 4;\r\n" - + " INSERT INTO snmp_mib (id,name,file_name,content,models,remark,update_by,update_at,tree) select id,name,file_name,content,models,remark,update_by,update_at,tree from snmp_mib_copy;\r\n" - + " INSERT INTO link (id,name,create_by,url,build_in,weight) select id,name,create_by,url,build_in,0 from link_copy;" - + " INSERT INTO cabinet (id,name,dc_id,u_size,remark,seq,x,y) select id,name,idc_id,u_size,remark,seq,x,y from cabinet_copy;"); - sqlDao.execute(restoreData.toString()); - } + public void tableCopy(String[] backupTableNames) { + // 为空时,备份所有表 + List backupTableNameList = Arrays.asList(backupTableNames); + if (CollectionUtil.isEmpty(backupTableNameList)) { + backupTableNameList = sqlDao.allTables(); + } + StringBuilder sb = new StringBuilder(); + for (String tableName : backupTableNameList) { + sb.append("CREATE TABLE " + tableName + "_copy SELECT * FROM " + tableName + ";"); + } + sqlDao.execute(sb.toString()); + } + + public void removeCopy() { + StringBuilder sb = new StringBuilder(); + List sqls = sqlDao.allRemoveCopyTables(); + for (String sql : sqls) { + sb.append(sql); + } + sqlDao.execute(sb.toString()); + } + + /** + * 处理数据变化 + */ + public void transferData() { + // 1. 处理 Module 数据变化 + // 获取 之前数据 + List moduleBackupList = monitorModuleService.getModuleBackupData(); + Map moduleIdAndTypeMap = moduleBackupList.stream().collect(Collectors.toMap(MonitorModule::getId, Function.identity())); + + // 清除现有表数据 + monitorModuleService.truncateData(); + + List saveModule = new ArrayList<>(moduleBackupList.size()); + for (MonitorModule module : moduleBackupList) { + String configsBackup = module.getConfigs(); + String configStr = String.format("%s%s%s", "[{\"type\":\"metrics\",\"config\":", configsBackup, "},{\"type\":\"logs\",\"config\":[{\"type\":\"file\",\"fileName\":\"\",\"labels\":{},\"pipeline\":[]}],\"enable\":0}]"); + List configMapList = JSONObject.parseArray(configStr, Map.class); + Map metricsConfigMap = configMapList.stream().filter(map -> { + String configType = (String) map.get("type"); + return StrUtil.equals("metrics", configType); + }).findFirst().orElse(new HashMap()); + metricsConfigMap.put("enable", 1); + Map configMap = (Map) metricsConfigMap.get("config"); + configMap.put("protocol", module.getType()); + module.setConfigs(JSONObject.toJSONString(configMapList)); + saveModule.add(module); + } + monitorModuleService.saveBatch(saveModule); + + // 2. 处理 endpoint + List endpointBackupList = monitorEndpointService.getEndpointBackupData(); + List saveEndpointConfigList = new ArrayList<>(); + + for (MonitorEndpoint endpoint : endpointBackupList) { + // metrics + Map metricsConfigMap = JSONObject.parseObject(endpoint.getConfigs(), Map.class); + // protocol 为关联 module type 类型 + MonitorModule monitorModule = moduleIdAndTypeMap.get(endpoint.getModuleId()); + metricsConfigMap.put("protocol", monitorModule.getType()); + if (StrUtil.equals("snmp", monitorModule.getType())) { + // 补充 snmpCredentialsId + List moduleConfigMapList = JSONObject.parseArray(monitorModule.getConfigs(), Map.class); + Map moduleMetricsMap = moduleConfigMapList.stream().filter(map -> { + String configType = (String) map.get("type"); + return StrUtil.equals("metrics", configType); + }).findFirst().orElse(new HashMap()); + Map moduleMetricsConfigMap = (Map) moduleMetricsMap.get("config"); + metricsConfigMap.put("snmpCredentialsId", moduleMetricsConfigMap.get("snmpCredentialsId")); + metricsConfigMap.put("walk",moduleMetricsConfigMap.get("walk")); + } + + MonitorEndpointConfig metricseEndpointConfig = new MonitorEndpointConfig(); + metricseEndpointConfig.setEndpointId(endpoint.getId()); + metricseEndpointConfig.setType("metrics"); + metricseEndpointConfig.setConfig(JSONObject.toJSONString(metricsConfigMap)); + metricseEndpointConfig.setVersion(1); + metricseEndpointConfig.setEnable(endpoint.getEnabled()); + metricseEndpointConfig.setHash(endpoint.getHash()); + saveEndpointConfigList.add(metricseEndpointConfig); + + // logs + MonitorEndpointConfig logsEndpointConfig = new MonitorEndpointConfig(); + logsEndpointConfig.setEnable(0); + logsEndpointConfig.setEndpointId(endpoint.getId()); + logsEndpointConfig.setVersion(1); + logsEndpointConfig.setType("logs"); + logsEndpointConfig.setConfig("[{\"pipeline\":[],\"fileName\":\"\",\"type\":\"file\",\"labels\":{}}]"); + logsEndpointConfig.setHash("1781397008110808010"); + + saveEndpointConfigList.add(logsEndpointConfig); + } + monitorEndpointConfigService.saveBatch(saveEndpointConfigList); + + // 3. 处理 alert rule 数据 + List ruleList = alertRuleService.list(); + for (AlertRule alertRule : ruleList) { + String receiver = alertRule.getReceiver(); + if (StrUtil.isNotEmpty(receiver)) { + alertRule.setNotifyActive(1); + alertRule.setNotifyExpired(1); + } else { + alertRule.setNotifyActive(0); + alertRule.setNotifyExpired(0); + } + } + alertRuleService.saveOrUpdateBatch(ruleList); + } } diff --git a/src/main/java/com/nis/handler/TransferDataHandler.java b/src/main/java/com/nis/handler/TransferDataHandler.java index 1b5df6b..f603dfe 100644 --- a/src/main/java/com/nis/handler/TransferDataHandler.java +++ b/src/main/java/com/nis/handler/TransferDataHandler.java @@ -2,10 +2,8 @@ package com.nis.handler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; -import org.springframework.context.annotation.DependsOn; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import com.nis.service.AssetService; import cn.hutool.log.Log; @@ -32,10 +30,6 @@ public class TransferDataHandler implements CommandLineRunner { // 新旧表数据同步 sqlHandler.transferData(); - log.info("transfer data successful"); - - // 表清空数据 - sqlHandler.removeData(); - log.info("remove data successful"); + log.info("transfer data successful"); } } diff --git a/src/main/java/com/nis/service/AccountService.java b/src/main/java/com/nis/service/AccountService.java deleted file mode 100644 index 39c1804..0000000 --- a/src/main/java/com/nis/service/AccountService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Account; -import com.nis.entity.Asset; - -public interface AccountService extends IService { - - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/AlertMessageActiveService.java b/src/main/java/com/nis/service/AlertMessageActiveService.java deleted file mode 100644 index e1d2175..0000000 --- a/src/main/java/com/nis/service/AlertMessageActiveService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.nis.service; - -import java.util.List; -import java.util.Map; -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AlertMessageActiveEntity; -import com.nis.entity.AlertMessageEntity; - - -public interface AlertMessageActiveService extends IService { - - -} - diff --git a/src/main/java/com/nis/service/AlertMessageHistoryService.java b/src/main/java/com/nis/service/AlertMessageHistoryService.java deleted file mode 100644 index 9a9461b..0000000 --- a/src/main/java/com/nis/service/AlertMessageHistoryService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.nis.service; - -import java.util.List; -import java.util.Map; -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AlertMessageEntity; -import com.nis.entity.AlertMessageHistoryEntity; - - - -public interface AlertMessageHistoryService extends IService { - -} - diff --git a/src/main/java/com/nis/service/AlertMessageService.java b/src/main/java/com/nis/service/AlertMessageService.java deleted file mode 100644 index 7d1d1eb..0000000 --- a/src/main/java/com/nis/service/AlertMessageService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.nis.service; - -import java.util.List; -import java.util.Map; -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AlertMessageEntity; - - - -public interface AlertMessageService extends IService { - - public void handler(); -} - diff --git a/src/main/java/com/nis/service/AlertRuleService.java b/src/main/java/com/nis/service/AlertRuleService.java index 70a6557..dd906a5 100644 --- a/src/main/java/com/nis/service/AlertRuleService.java +++ b/src/main/java/com/nis/service/AlertRuleService.java @@ -1,16 +1,10 @@ package com.nis.service; -import java.util.List; -import java.util.Map; + import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AlertMessageEntity; -import com.nis.entity.AlertMessageHistoryEntity; -import com.nis.entity.AlertRuleEntity; +import com.nis.entity.AlertRule; +public interface AlertRuleService extends IService { - -public interface AlertRuleService extends IService { - - List queryAllDatas(); } diff --git a/src/main/java/com/nis/service/AssetAssetService.java b/src/main/java/com/nis/service/AssetAssetService.java deleted file mode 100644 index dd138ef..0000000 --- a/src/main/java/com/nis/service/AssetAssetService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AssetAsset; - -/** - * 资产 service - */ -public interface AssetAssetService extends IService { - - public void handler(); -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/AssetBrandService.java b/src/main/java/com/nis/service/AssetBrandService.java deleted file mode 100644 index d15c9a2..0000000 --- a/src/main/java/com/nis/service/AssetBrandService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AssetBrand; - -/** - * 资产品牌 service - */ -public interface AssetBrandService extends IService { - - public void handler(); -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/AssetFieldMetaService.java b/src/main/java/com/nis/service/AssetFieldMetaService.java deleted file mode 100644 index deed0eb..0000000 --- a/src/main/java/com/nis/service/AssetFieldMetaService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.nis.service; - -import java.util.List; -import java.util.Map; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AssetFieldMeta; - - -public interface AssetFieldMetaService extends IService{ - -} diff --git a/src/main/java/com/nis/service/AssetFieldValueService.java b/src/main/java/com/nis/service/AssetFieldValueService.java deleted file mode 100644 index 9e3a7aa..0000000 --- a/src/main/java/com/nis/service/AssetFieldValueService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AssetFieldValue; - -public interface AssetFieldValueService extends IService{ - -} diff --git a/src/main/java/com/nis/service/AssetModelService.java b/src/main/java/com/nis/service/AssetModelService.java deleted file mode 100644 index 3d3ee2e..0000000 --- a/src/main/java/com/nis/service/AssetModelService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AssetModel; - -/** - * 资产类型 service - */ -public interface AssetModelService extends IService { - - public void handler(); - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/AssetService.java b/src/main/java/com/nis/service/AssetService.java deleted file mode 100644 index 620ee98..0000000 --- a/src/main/java/com/nis/service/AssetService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Asset; - -public interface AssetService extends IService { - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/AssetTagService.java b/src/main/java/com/nis/service/AssetTagService.java deleted file mode 100644 index 136c410..0000000 --- a/src/main/java/com/nis/service/AssetTagService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.nis.service; - -import java.util.List; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AssetTag; - -public interface AssetTagService extends IService { - -} diff --git a/src/main/java/com/nis/service/AssetTypeConfService.java b/src/main/java/com/nis/service/AssetTypeConfService.java deleted file mode 100644 index 73d0a61..0000000 --- a/src/main/java/com/nis/service/AssetTypeConfService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.AssetTypeConf; - - -public interface AssetTypeConfService extends IService { - - public void handler(); -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/ChartElementService.java b/src/main/java/com/nis/service/ChartElementService.java deleted file mode 100644 index 4ec6a37..0000000 --- a/src/main/java/com/nis/service/ChartElementService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.ChartElement; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; - - -public interface ChartElementService extends IService { - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/ChartService.java b/src/main/java/com/nis/service/ChartService.java deleted file mode 100644 index db313a9..0000000 --- a/src/main/java/com/nis/service/ChartService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Chart; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; - - -public interface ChartService extends IService { - - public void handler(); - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/DcService.java b/src/main/java/com/nis/service/DcService.java deleted file mode 100644 index 61093eb..0000000 --- a/src/main/java/com/nis/service/DcService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Asset; -import com.nis.entity.Dc; - -/** - * 资产 service - */ -public interface DcService extends IService { - - public void handler(); -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/EndpointService.java b/src/main/java/com/nis/service/EndpointService.java deleted file mode 100644 index 174b762..0000000 --- a/src/main/java/com/nis/service/EndpointService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Endpoint; -import com.nis.entity.Idc; - - -public interface EndpointService extends IService { - - public void handler(); - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/IdcService.java b/src/main/java/com/nis/service/IdcService.java deleted file mode 100644 index 3390e5d..0000000 --- a/src/main/java/com/nis/service/IdcService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; - - -public interface IdcService extends IService { - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/ModelService.java b/src/main/java/com/nis/service/ModelService.java deleted file mode 100644 index b105a35..0000000 --- a/src/main/java/com/nis/service/ModelService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Model; - -import java.util.Map; - -public interface ModelService extends IService { - -} - diff --git a/src/main/java/com/nis/service/ModuleService.java b/src/main/java/com/nis/service/ModuleService.java deleted file mode 100644 index d96d18a..0000000 --- a/src/main/java/com/nis/service/ModuleService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.nis.service; - -import java.util.List; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; - - -public interface ModuleService extends IService { - - List querySnmpDatas(); -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/MonitorEndpointConfigService.java b/src/main/java/com/nis/service/MonitorEndpointConfigService.java new file mode 100644 index 0000000..2c21c8a --- /dev/null +++ b/src/main/java/com/nis/service/MonitorEndpointConfigService.java @@ -0,0 +1,10 @@ +package com.nis.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.nis.entity.MonitorEndpointConfig; + +public interface MonitorEndpointConfigService extends IService { + + +} diff --git a/src/main/java/com/nis/service/MonitorEndpointService.java b/src/main/java/com/nis/service/MonitorEndpointService.java index 3c55112..eb32e9c 100644 --- a/src/main/java/com/nis/service/MonitorEndpointService.java +++ b/src/main/java/com/nis/service/MonitorEndpointService.java @@ -1,11 +1,12 @@ package com.nis.service; + import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; import com.nis.entity.MonitorEndpoint; +import java.util.List; public interface MonitorEndpointService extends IService { -} \ No newline at end of file + List getEndpointBackupData(); +} diff --git a/src/main/java/com/nis/service/MonitorModuleService.java b/src/main/java/com/nis/service/MonitorModuleService.java index b2e7d30..4f02352 100644 --- a/src/main/java/com/nis/service/MonitorModuleService.java +++ b/src/main/java/com/nis/service/MonitorModuleService.java @@ -1,11 +1,14 @@ package com.nis.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; import com.nis.entity.MonitorModule; +import java.util.List; public interface MonitorModuleService extends IService { -} \ No newline at end of file + void truncateData(); + + List getModuleBackupData(); + +} diff --git a/src/main/java/com/nis/service/MonitorProjectService.java b/src/main/java/com/nis/service/MonitorProjectService.java deleted file mode 100644 index 1b44756..0000000 --- a/src/main/java/com/nis/service/MonitorProjectService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.MonitorProject; - - -public interface MonitorProjectService extends IService { - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/PanelService.java b/src/main/java/com/nis/service/PanelService.java deleted file mode 100644 index ea8e59e..0000000 --- a/src/main/java/com/nis/service/PanelService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.Panel; - - -public interface PanelService extends IService { - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/ProjectService.java b/src/main/java/com/nis/service/ProjectService.java deleted file mode 100644 index 50ed214..0000000 --- a/src/main/java/com/nis/service/ProjectService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Project; - - -public interface ProjectService extends IService { - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/ProjectTopoIconService.java b/src/main/java/com/nis/service/ProjectTopoIconService.java deleted file mode 100644 index 8831c9c..0000000 --- a/src/main/java/com/nis/service/ProjectTopoIconService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Project; -import com.nis.entity.ProjectTopo; -import com.nis.entity.ProjectTopoIcon; - - -public interface ProjectTopoIconService extends IService { - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/ProjectTopoService.java b/src/main/java/com/nis/service/ProjectTopoService.java deleted file mode 100644 index 1b165dd..0000000 --- a/src/main/java/com/nis/service/ProjectTopoService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Project; -import com.nis.entity.ProjectTopo; - - -public interface ProjectTopoService extends IService { - - public void handler(); -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/SnmpCredentialService.java b/src/main/java/com/nis/service/SnmpCredentialService.java deleted file mode 100644 index 5dc6229..0000000 --- a/src/main/java/com/nis/service/SnmpCredentialService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.nis.service; - -import java.util.Map; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.SnmpCredential; - -public interface SnmpCredentialService extends IService{ - -} diff --git a/src/main/java/com/nis/service/SysConfigService.java b/src/main/java/com/nis/service/SysConfigService.java deleted file mode 100644 index 30b502f..0000000 --- a/src/main/java/com/nis/service/SysConfigService.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.SysConfigEntity; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -/** - * 系统配置信息 - * - - */ -public interface SysConfigService extends IService { - - List querySysConfigEntitys(); -} diff --git a/src/main/java/com/nis/service/SysDictService.java b/src/main/java/com/nis/service/SysDictService.java deleted file mode 100644 index 54ed78f..0000000 --- a/src/main/java/com/nis/service/SysDictService.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.SysDictEntity; - -import java.util.List; -import java.util.Map; - -/** - * 数据字典 - * - - */ -public interface SysDictService extends IService { - - List queryDatas(String type); -} - diff --git a/src/main/java/com/nis/service/SysUserService.java b/src/main/java/com/nis/service/SysUserService.java deleted file mode 100644 index d1d2145..0000000 --- a/src/main/java/com/nis/service/SysUserService.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.SysUserEntity; - -import java.util.List; -import java.util.Map; - - -/** - * 系统用户 - * - - */ -public interface SysUserService extends IService { - - List queryOldUsers(); - - List queryNewUsers(); -} diff --git a/src/main/java/com/nis/service/VisualChartElementService.java b/src/main/java/com/nis/service/VisualChartElementService.java deleted file mode 100644 index 2001ed1..0000000 --- a/src/main/java/com/nis/service/VisualChartElementService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.VisualChartElement; - - -public interface VisualChartElementService extends IService { - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/VisualChartService.java b/src/main/java/com/nis/service/VisualChartService.java deleted file mode 100644 index f5af787..0000000 --- a/src/main/java/com/nis/service/VisualChartService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.VisualChart; - - -public interface VisualChartService extends IService { - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/VisualPanelService.java b/src/main/java/com/nis/service/VisualPanelService.java deleted file mode 100644 index d8551a1..0000000 --- a/src/main/java/com/nis/service/VisualPanelService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.nis.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.VisualPanel; - - -public interface VisualPanelService extends IService { - -} \ No newline at end of file diff --git a/src/main/java/com/nis/service/impl/AccountServiceImpl.java b/src/main/java/com/nis/service/impl/AccountServiceImpl.java deleted file mode 100644 index ab982bf..0000000 --- a/src/main/java/com/nis/service/impl/AccountServiceImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AccountDao; -import com.nis.dao.AssetDao; -import com.nis.entity.Account; -import com.nis.entity.Asset; -import com.nis.entity.AssetAsset; -import com.nis.service.AccountService; -import com.nis.service.AssetAssetService; -import com.nis.service.AssetService; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - -/** - * 资产 serviceImpl - * - */ -@Service("accountService") -public class AccountServiceImpl extends ServiceImpl implements AccountService { - private static Log logger = Log.get(); - -} diff --git a/src/main/java/com/nis/service/impl/AlertMessageActiveServiceImpl.java b/src/main/java/com/nis/service/impl/AlertMessageActiveServiceImpl.java deleted file mode 100644 index f6cfabf..0000000 --- a/src/main/java/com/nis/service/impl/AlertMessageActiveServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.nis.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AlertMessageActiveDao; -import com.nis.dao.AlertMessageDao; -import com.nis.entity.AlertMessageActiveEntity; -import com.nis.entity.AlertMessageEntity; -import com.nis.service.AlertMessageActiveService; -import com.nis.service.AlertMessageService; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - - - -@Service("alertMessageActiveService") -public class AlertMessageActiveServiceImpl extends ServiceImpl implements AlertMessageActiveService { - - - -} diff --git a/src/main/java/com/nis/service/impl/AlertMessageHistoryServiceImpl.java b/src/main/java/com/nis/service/impl/AlertMessageHistoryServiceImpl.java deleted file mode 100644 index 3dee934..0000000 --- a/src/main/java/com/nis/service/impl/AlertMessageHistoryServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.nis.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AlertMessageDao; -import com.nis.dao.AlertMessageHistoryDao; -import com.nis.entity.AlertMessageEntity; -import com.nis.entity.AlertMessageHistoryEntity; -import com.nis.service.AlertMessageHistoryService; -import com.nis.service.AlertMessageService; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - - - -@Service("alertMessageHistoryService") -public class AlertMessageHistoryServiceImpl extends ServiceImpl implements AlertMessageHistoryService { - - - -} diff --git a/src/main/java/com/nis/service/impl/AlertMessageServiceImpl.java b/src/main/java/com/nis/service/impl/AlertMessageServiceImpl.java deleted file mode 100644 index 29b83f8..0000000 --- a/src/main/java/com/nis/service/impl/AlertMessageServiceImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.nis.service.impl; - - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AlertMessageDao; -import com.nis.entity.AlertMessageActiveEntity; -import com.nis.entity.AlertMessageEntity; -import com.nis.entity.AlertMessageHistoryEntity; -import com.nis.entity.AlertRuleEntity; -import com.nis.service.AlertMessageActiveService; -import com.nis.service.AlertMessageHistoryService; -import com.nis.service.AlertMessageService; -import com.nis.service.AlertRuleService; -import com.nis.util.DateUtil; -import com.nis.util.ToolUtil; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.date.DateTime; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.SimpleTimeZone; -import java.util.TimeZone; - -import javax.tools.Tool; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - -@Service("alertMessageService") -public class AlertMessageServiceImpl extends ServiceImpl implements AlertMessageService { - - @Autowired - private AlertMessageActiveService alertMessageActiveService; - - @Autowired - private AlertMessageHistoryService alertMessageHistoryService; - - @Autowired - private AlertRuleService alertRuleService; - - @Override - public void handler() { - - // alert rule数据修改 - List rules = alertRuleService.queryAllDatas(); - for(AlertRuleEntity rule : rules) { - if(rule.getSeverity().equals("P1")) { - rule.setSeverityId(1); - }else if(rule.getSeverity().equals("P2")) { - rule.setSeverityId(2); - }else if(rule.getSeverity().equals("P3")){ - rule.setSeverityId(3); - } - rule.setMethod(1); - } - - alertRuleService.remove(new QueryWrapper()); - if(ToolUtil.isNotEmpty(rules)) { - alertRuleService.saveBatch(rules); - } - - List messages = this.list(); - - List activeMessages = new ArrayList(); - List historyMessages = new ArrayList(); - - for(AlertMessageEntity message : messages) { - if(message.getSeverity().equals("P1")) { - message.setSeverityId(1); - }else if(message.getSeverity().equals("P2")) { - message.setSeverityId(2); - }else if(message.getSeverity().equals("P3")){ - message.setSeverityId(3); - } - if(message.getState().equals(1)) { - AlertMessageActiveEntity activeMessage = new AlertMessageActiveEntity(); - BeanUtil.copyProperties(message, activeMessage); - Date utcTime = DateUtil.getUTCTimeByConfigTimeZone(); - DateTime date = DateUtil.offsetSecond(utcTime, 600); - activeMessage.setEndAt(date); - activeMessages.add(activeMessage); - }else { - AlertMessageHistoryEntity historyMessage = new AlertMessageHistoryEntity(); - message.setState(3); - BeanUtil.copyProperties(message, historyMessage); - historyMessages.add(historyMessage); - } - } - - if(ToolUtil.isNotEmpty(activeMessages)) { - alertMessageActiveService.saveBatch(activeMessages); - } - if(ToolUtil.isNotEmpty(historyMessages)) { - alertMessageHistoryService.saveBatch(historyMessages); - } - } - - -} diff --git a/src/main/java/com/nis/service/impl/AlertRuleServiceImpl.java b/src/main/java/com/nis/service/impl/AlertRuleServiceImpl.java index 0013707..68514b9 100644 --- a/src/main/java/com/nis/service/impl/AlertRuleServiceImpl.java +++ b/src/main/java/com/nis/service/impl/AlertRuleServiceImpl.java @@ -1,33 +1,16 @@ package com.nis.service.impl; +import cn.hutool.log.Log; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AlertMessageDao; -import com.nis.dao.AlertMessageHistoryDao; import com.nis.dao.AlertRuleDao; -import com.nis.entity.AlertMessageEntity; -import com.nis.entity.AlertMessageHistoryEntity; -import com.nis.entity.AlertRuleEntity; -import com.nis.service.AlertMessageHistoryService; -import com.nis.service.AlertMessageService; +import com.nis.entity.AlertRule; import com.nis.service.AlertRuleService; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - - - @Service -public class AlertRuleServiceImpl extends ServiceImpl implements AlertRuleService { +public class AlertRuleServiceImpl extends ServiceImpl implements AlertRuleService { - @Override - public List queryAllDatas() { - return this.baseMapper.selectAllDatas(); - } - - + private static Log log = Log.get(); } diff --git a/src/main/java/com/nis/service/impl/AssetAssetServiceImpl.java b/src/main/java/com/nis/service/impl/AssetAssetServiceImpl.java deleted file mode 100644 index 5093e65..0000000 --- a/src/main/java/com/nis/service/impl/AssetAssetServiceImpl.java +++ /dev/null @@ -1,244 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.core.lang.UUID; -import cn.hutool.core.lang.hash.MurmurHash; -import cn.hutool.core.util.StrUtil; -import cn.hutool.log.Log; - -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AssetAssetDao; -import com.nis.entity.Account; -import com.nis.entity.Asset; -import com.nis.entity.AssetAsset; -import com.nis.entity.AssetFieldMeta; -import com.nis.entity.AssetFieldValue; -import com.nis.entity.AssetModel; -import com.nis.entity.AssetTag; -import com.nis.entity.AssetTypeConf; -import com.nis.entity.Model; -import com.nis.entity.SnmpCredential; -import com.nis.entity.SysDictEntity; -import com.nis.service.AccountService; -import com.nis.service.AssetAssetService; -import com.nis.service.AssetFieldMetaService; -import com.nis.service.AssetFieldValueService; -import com.nis.service.AssetModelService; -import com.nis.service.AssetService; -import com.nis.service.AssetTagService; -import com.nis.service.AssetTypeConfService; -import com.nis.service.ModelService; -import com.nis.service.SnmpCredentialService; -import com.nis.service.SysDictService; -import com.nis.util.ToolUtil; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - -/** - * 资产 serviceImpl - * - */ -@Service("assetAssetService") -public class AssetAssetServiceImpl extends ServiceImpl implements AssetAssetService { - private static Log logger = Log.get(); - - @Autowired - private AssetService assetService; - - @Autowired - private AccountService accountService; - - @Autowired - private AssetModelService assetModelService; - - @Autowired - private ModelService modelService; - - @Autowired - private SysDictService sysDictService; - - @Autowired - private AssetTypeConfService assetTypeConfService; - - @Autowired - private SnmpCredentialService snmpCredentialService; - - @Autowired - private AssetTagService assetTagService; - - @Autowired - private AssetFieldMetaService assetFieldMetaService; - - @Autowired - private AssetFieldValueService assetFieldValueService; - - @Override - public void handler() { - List assets = assetService.list(); - - // 查询model关联品牌信息 - List assetModels = assetModelService.list(); - Map modelAndBrand = assetModels.stream().collect(Collectors.toMap(AssetModel::getId, AssetModel::getBrandId)); - - // 查询model关联资产类型信息 - List models = modelService.list(); - Map modelAndType = models.stream().collect(Collectors.toMap(Model::getId, Model::getTypeCode)); - List sysDicts = sysDictService.queryDatas("assetType"); - Map dictAndType = sysDicts.stream().collect(Collectors.toMap(SysDictEntity::getCode, SysDictEntity::getValue)); - Map modelIdAndTypeName = new HashMap(); - for(Integer key : modelAndType.keySet()) { - Integer typeId = modelAndType.get(key); - String typeName = dictAndType.get(typeId); - modelIdAndTypeName.put(key,typeName); - } - //查询所有assetType数据信息 - List assetTypeConfs = assetTypeConfService.list(); - Map assetTypeNameAndId = assetTypeConfs.stream().collect(Collectors.toMap(AssetTypeConf::getName,AssetTypeConf::getId)); - Map> assetAccountInfo = new HashMap>(); - - List accounts = accountService.list(); - Map> assetIdAccounts = accounts.stream().collect(Collectors.groupingBy(Account::getAssetId)); - - Map assetIdAndSnmpCredential = new HashMap(); - List snmpCredentials = new ArrayList(); - - Map snmpCredentialDistinctMap = new HashMap(); - //snmp凭证表添加数据信息 - for(Account account : accounts) { - if(account.getProtocol().equals("SNMP")) { - String params = (String) account.getParams(); - Map map = (Map) JSON.parse(params); - Map config = new HashMap(); - if(((Integer)map.get("version")).equals(2)) { - config.put("readCommunity","public"); - config.put("writeCommunity","public"); - }else { - config.put("username",map.get("username")); - config.put("contextname",map.get("contextname")); - config.put("securityLevel",map.get("securityLevel")); - config.put("authProtocol",map.get("authProtocol")); - config.put("authPin",map.get("password")); - config.put("privProtocol",map.get("privProtocol")); - config.put("privPin",map.get("privPassword")); - } - - SnmpCredential snmpCredential = new SnmpCredential(); - snmpCredential.setName("import_"+UUID.randomUUID().toString()); - snmpCredential.setType((Integer)map.get("version")); - snmpCredential.setPort(account.getPort()); - snmpCredential.setConfig(JSON.toJSONString(config)); - String hash = String.valueOf(Math.abs(MurmurHash.hash64(snmpCredential.getConfig()+snmpCredential.getType()+snmpCredential.getPort()))); - SnmpCredential snmpObject = snmpCredentialDistinctMap.get(hash); - if(ToolUtil.isEmpty(snmpObject)) { - snmpCredentialDistinctMap.put(hash, snmpCredential); - snmpCredentials.add(snmpCredential); - assetIdAndSnmpCredential.put(account.getAssetId(), snmpCredential); - }else { - assetIdAndSnmpCredential.put(account.getAssetId(), snmpObject); - } - }else { - String params = (String) account.getParams(); - Map map = (Map) JSON.parse(params); - map.put("authProtocolPort", account.getPort()); - assetAccountInfo.put(account.getAssetId(), map); - } - } - - if(ToolUtil.isNotEmpty(snmpCredentials)) { - snmpCredentialService.saveBatch(snmpCredentials); - } - - List assetAssets = new ArrayList(); - for(Asset asset : assets) { - AssetAsset assetAsset = new AssetAsset(); - assetAsset.setId(asset.getId()); - assetAsset.setName(asset.getHost()); - assetAsset.setNumber(asset.getSn()); - assetAsset.setSn(asset.getSn()); - assetAsset.setPid(-1); - assetAsset.setBrandId(modelAndBrand.get(asset.getModelId())); - Integer typeId = assetTypeNameAndId.get(modelIdAndTypeName.get(asset.getModelId())); - assetAsset.setTypeId(ToolUtil.isNotEmpty(typeId)?typeId:9); - assetAsset.setModelId(asset.getModelId()); - assetAsset.setStateId(asset.getState()); - assetAsset.setDcId(asset.getIdcId()); - assetAsset.setCabinetId(asset.getCabinetId()); - assetAsset.setCabinetStart(asset.getCabinetStart()); - assetAsset.setCabinetEnd(asset.getCabinetEnd()); - assetAsset.setManageIp(asset.getHost()); - assetAsset.setPurchaseDate(asset.getPurchaseDate()); - assetAsset.setCreateAt(asset.getCreateAt()); - assetAsset.setUpdateAt(asset.getUpdateAt()); - assetAsset.setCreateBy(asset.getCreateBy()); - assetAsset.setUpdateBy(asset.getUpdateBy()); - assetAsset.setSeq(asset.getSeq()); - Map sshInfo = assetAccountInfo.get(asset.getId()); - if(ToolUtil.isNotEmpty(sshInfo)) { - assetAsset.setAuthProtocolPort((Integer)sshInfo.get("authProtocolPort")); - String method = (String) sshInfo.get("method"); - if(StrUtil.equals(method, "key")) { - assetAsset.setAuthType(2); - assetAsset.setAuthPin((String) sshInfo.get("keyPassword")); - }else { - assetAsset.setAuthType(1); - assetAsset.setAuthPin((String) sshInfo.get("password")); - } - assetAsset.setAuthUsername((String) sshInfo.get("username")); - - assetAsset.setAuthPriKey((String) sshInfo.get("key")); - } - SnmpCredential snmpCredential = assetIdAndSnmpCredential.get(asset.getId()); - assetAsset.setSnmpCredentialId(ToolUtil.isEmpty(snmpCredential)? null : snmpCredential.getId()); - assetAssets.add(assetAsset); - } - - if(ToolUtil.isNotEmpty(assetAssets)) { - this.saveBatch(assetAssets); - } - - - //处理meta value关系 - List tags = assetTagService.list(); - Map> collectMap = tags.stream().collect(Collectors.groupingBy(AssetTag::getTag)); - Set keySets = collectMap.keySet(); - - Map keyAndMeta = new HashMap(); - List assetFieldMetas = new ArrayList(); - List assetFieldValues = new ArrayList(); - for(String key : keySets) { - AssetFieldMeta assetFieldMeta = new AssetFieldMeta(); - assetFieldMeta.setName("import_"+key); - assetFieldMeta.setMetaKey(key); - assetFieldMeta.setGroupId("1"); - assetFieldMeta.setType("TEXT"); - assetFieldMeta.setParam("{}"); - assetFieldMetas.add(assetFieldMeta); - keyAndMeta.put(key,assetFieldMeta); - } - - if(ToolUtil.isNotEmpty(assetFieldMetas)) { - assetFieldMetaService.saveBatch(assetFieldMetas); - - for(AssetTag tag : tags) { - AssetFieldValue value = new AssetFieldValue(); - value.setAssetId(tag.getAssetId()); - value.setMetaId(keyAndMeta.get(tag.getTag()).getId()); - value.setValue(tag.getValue()); - assetFieldValues.add(value); - } - - if(ToolUtil.isNotEmpty(assetFieldValues)) { - assetFieldValueService.saveBatch(assetFieldValues); - } - } - } -} diff --git a/src/main/java/com/nis/service/impl/AssetBrandServiceImpl.java b/src/main/java/com/nis/service/impl/AssetBrandServiceImpl.java deleted file mode 100644 index c6ceb17..0000000 --- a/src/main/java/com/nis/service/impl/AssetBrandServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AssetBrandDao; -import com.nis.entity.AssetBrand; -import com.nis.entity.SysDictEntity; -import com.nis.service.AssetBrandService; -import com.nis.service.SysDictService; -import com.nis.util.Constant; -import com.nis.util.ToolUtil; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - -/** - * 资产 serviceImpl - * - */ -@Service("assetBrandService") -public class AssetBrandServiceImpl extends ServiceImpl implements AssetBrandService { - private static Log logger = Log.get(); - - @Autowired - private SysDictService sysDictService; - - @Override - public void handler() { - // 初始化数据 - this.initData(); - } - - public void initData() { - List brands = sysDictService.queryDatas("vendor"); - - List assetBrands = new ArrayList(); - for(SysDictEntity brand : brands) { - AssetBrand assetBrand = new AssetBrand(); - assetBrand.setName(brand.getName()); - assetBrand.setRemark(brand.getRemark()); - assetBrands.add(assetBrand); - Constant.assetBrands.put(brand.getCode(), assetBrand); - } - - if(ToolUtil.isNotEmpty(assetBrands)) { - this.saveBatch(assetBrands); - } - } - -} diff --git a/src/main/java/com/nis/service/impl/AssetFieldMetaServiceImpl.java b/src/main/java/com/nis/service/impl/AssetFieldMetaServiceImpl.java deleted file mode 100644 index 4e039ae..0000000 --- a/src/main/java/com/nis/service/impl/AssetFieldMetaServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.nis.service.impl; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AssetFieldMetaDao; -import com.nis.entity.AssetFieldMeta; -import com.nis.service.AssetFieldMetaService; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; - -@Service("assetFieldMetaService") -public class AssetFieldMetaServiceImpl extends ServiceImpl implements AssetFieldMetaService{ - -} diff --git a/src/main/java/com/nis/service/impl/AssetFieldValueServiceImpl.java b/src/main/java/com/nis/service/impl/AssetFieldValueServiceImpl.java deleted file mode 100644 index 05f19d2..0000000 --- a/src/main/java/com/nis/service/impl/AssetFieldValueServiceImpl.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.nis.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AssetFieldValueDao; -import com.nis.entity.AssetFieldValue; -import com.nis.service.AssetFieldValueService; - -import org.springframework.stereotype.Service; - -@Service -public class AssetFieldValueServiceImpl extends ServiceImpl implements AssetFieldValueService { - -} diff --git a/src/main/java/com/nis/service/impl/AssetModelServiceImpl.java b/src/main/java/com/nis/service/impl/AssetModelServiceImpl.java deleted file mode 100644 index d9211db..0000000 --- a/src/main/java/com/nis/service/impl/AssetModelServiceImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AssetModelDao; -import com.nis.entity.AssetBrand; -import com.nis.entity.AssetModel; -import com.nis.entity.Model; -import com.nis.service.AssetModelService; -import com.nis.service.ModelService; -import com.nis.util.Constant; -import com.nis.util.ToolUtil; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - -@Service("assetModelService") -public class AssetModelServiceImpl extends ServiceImpl implements AssetModelService { - private static Log logger = Log.get(); - - @Autowired - private ModelService modelService; - - @Override - public void handler() { - // 初始化数据 - this.initData(); - } - - public void initData() { - List models = modelService.list(); - - List assetModels = new ArrayList(); - - for(Model model : models) { - AssetModel assetModel = new AssetModel(); - assetModel.setId(model.getId()); - assetModel.setName(model.getName()); - assetModel.setRemark(model.getRemark()); - assetModel.setSeq(model.getSeq()); - assetModel.setUsize(model.getUsize()); - AssetBrand assetBrand = Constant.assetBrands.get(model.getVendorCode()); - assetModel.setBrandId(assetBrand.getId()); - assetModels.add(assetModel); - } - - if(ToolUtil.isNotEmpty(assetModels)) { - this.saveBatch(assetModels); - } - } - - -} diff --git a/src/main/java/com/nis/service/impl/AssetServiceImpl.java b/src/main/java/com/nis/service/impl/AssetServiceImpl.java deleted file mode 100644 index 875613c..0000000 --- a/src/main/java/com/nis/service/impl/AssetServiceImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AssetDao; -import com.nis.entity.Asset; -import com.nis.entity.AssetAsset; -import com.nis.service.AssetAssetService; -import com.nis.service.AssetService; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - -/** - * 资产 serviceImpl - * - */ -@Service("assetService") -public class AssetServiceImpl extends ServiceImpl implements AssetService { - private static Log logger = Log.get(); - -} diff --git a/src/main/java/com/nis/service/impl/AssetTagServiceImpl.java b/src/main/java/com/nis/service/impl/AssetTagServiceImpl.java deleted file mode 100644 index 20e08e6..0000000 --- a/src/main/java/com/nis/service/impl/AssetTagServiceImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.nis.service.impl; - -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AssetTagDao; -import com.nis.entity.AssetTag; -import com.nis.service.AssetTagService; - -@Service -public class AssetTagServiceImpl extends ServiceImpl implements AssetTagService { - -} - diff --git a/src/main/java/com/nis/service/impl/AssetTypeConfServiceImpl.java b/src/main/java/com/nis/service/impl/AssetTypeConfServiceImpl.java deleted file mode 100644 index fea68d9..0000000 --- a/src/main/java/com/nis/service/impl/AssetTypeConfServiceImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.AssetTypeConfDao; -import com.nis.dao.DcDao; -import com.nis.dao.SqlDao; -import com.nis.entity.AssetTypeConf; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.SysDictEntity; -import com.nis.service.AssetTypeConfService; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.SysDictService; -import com.nis.util.ToolUtil; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service("assetTypeConfService") -public class AssetTypeConfServiceImpl extends ServiceImpl implements AssetTypeConfService { - private static Log logger = Log.get(); - - @Autowired - private SysDictService sysDictService; - - @Autowired - private SqlDao sqlDao; - - @Override - public void handler() { - // 初始化数据 - this.initData(); - } - - public void initData() { - /*List types = sysDictService.queryDatas("assetType"); - List list = this.list(); - List assetTypeConfs = new ArrayList(); - Map nameAndData = list.stream().collect(Collectors.toMap(AssetTypeConf::getName, Function.identity())); - for(SysDictEntity type : types) { - AssetTypeConf assetTypeConf = nameAndData.get(type.getValue()); - if(ToolUtil.isEmpty(assetTypeConf)) { - assetTypeConf = new AssetTypeConf(); - assetTypeConf.setPid(0); - assetTypeConf.setVm(0); - assetTypeConf.setVmh(0); - assetTypeConf.setName(type.getValue()); - assetTypeConf.setRemark(""); - assetTypeConf.setBuildIn(0); - assetTypeConf.setAuthProtocol(0); - assetTypeConf.setSnmpEnable(0); - assetTypeConf.setSnmpCollect(0); - assetTypeConf.setSshCollect(0); - assetTypeConf.setSshCollectScript(""); - assetTypeConfs.add(assetTypeConf); - } - } - - if(ToolUtil.isNotEmpty(assetTypeConfs)) { - this.saveBatch(assetTypeConfs); - }*/ - sqlDao.execute("INSERT INTO asset_type_conf(`id`,`pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (9,0, '0', '0', 'Other', '', '1', 0, 0, 0, 0, '')"); - } -} diff --git a/src/main/java/com/nis/service/impl/ChartElementServiceImpl.java b/src/main/java/com/nis/service/impl/ChartElementServiceImpl.java deleted file mode 100644 index 7154413..0000000 --- a/src/main/java/com/nis/service/impl/ChartElementServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.ChartElementDao; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.ModuleDao; -import com.nis.entity.ChartElement; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.service.ChartElementService; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.ModuleService; - -import org.springframework.stereotype.Service; - -@Service -public class ChartElementServiceImpl extends ServiceImpl implements ChartElementService { - private static Log logger = Log.get(); - -} diff --git a/src/main/java/com/nis/service/impl/ChartServiceImpl.java b/src/main/java/com/nis/service/impl/ChartServiceImpl.java deleted file mode 100644 index 4e8d05d..0000000 --- a/src/main/java/com/nis/service/impl/ChartServiceImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.log.Log; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.ChartDao; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.ModuleDao; -import com.nis.entity.AssetModel; -import com.nis.entity.Chart; -import com.nis.entity.ChartElement; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.Panel; -import com.nis.entity.VisualChart; -import com.nis.entity.VisualChartElement; -import com.nis.entity.VisualPanel; -import com.nis.service.AssetModelService; -import com.nis.service.ChartElementService; -import com.nis.service.ChartService; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.ModuleService; -import com.nis.service.PanelService; -import com.nis.service.VisualChartElementService; -import com.nis.service.VisualChartService; -import com.nis.service.VisualPanelService; -import com.nis.util.ToolUtil; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ChartServiceImpl extends ServiceImpl implements ChartService { - private static Log logger = Log.get(); - - @Autowired - private PanelService panelService; - - @Autowired - private VisualPanelService visualPanelService; - - @Autowired - private VisualChartService visualChartService; - - @Autowired - private VisualChartElementService visualChartElementService; - - @Autowired - private ChartElementService chartElementService; - - @Autowired - private AssetModelService assetModelService; - - @Override - public void handler() { - - // 同步panel - List visualPanels = new ArrayList(); - List panels = panelService.list(); - Map panelIdAndPanel = panels.stream().collect(Collectors.toMap(Panel::getId, Function.identity())); - for(Panel panel:panels) { - if(panel.getType().equals("model")) { - continue; - } - VisualPanel visualPanel = new VisualPanel(); - BeanUtil.copyProperties(panel, visualPanel, "prev","next"); - visualPanels.add(visualPanel); - } - if(ToolUtil.isNotEmpty(visualPanels)) { - visualPanelService.saveBatch(visualPanels); - } - - // 同步chart - Map modelIdAndChartIds = new HashMap(); - List visualCharts = new ArrayList(); - List charts = this.list(); - for(Chart chart : charts) { - VisualChart visualChart = new VisualChart(); - visualChart.setId(chart.getId()); - visualChart.setGroupId(0); - visualChart.setName(chart.getTitle()); - visualChart.setHeight(chart.getHeight()); - if(!chart.getType().equals("assetInfo")) { - visualChart.setPid(chart.getPid()); - } - Panel panel = panelIdAndPanel.get(chart.getPanelId()); - if(panel.getType().equals("model")&& !chart.getType().equals("assetInfo")) { - visualChart.setPanelId(0); - String string = modelIdAndChartIds.get(panel.getLink()); - if(StrUtil.isBlank(string)) { - string = ""+chart.getId(); - }else { - string = string +","+chart.getId(); - } - visualChart.setVarType(1); - modelIdAndChartIds.put(panel.getLink(), string); - }else { - visualChart.setPanelId(chart.getPanelId()); - } - visualChart.setSpan(chart.getSpan()); - visualChart.setUpdateAt(chart.getCreateAt()); - visualChart.setType(chart.getType()); - visualChart.setUnit(chart.getUnit()); - visualChart.setWeight(chart.getWeight()); - visualChart.setParam(chart.getParam()); - visualChart.setBuildIn(chart.getBuildIn()); - visualChart.setSeq(chart.getSeq()); - visualChart.setUpdateBy(-1); - visualCharts.add(visualChart); - } - if(ToolUtil.isNotEmpty(visualCharts)) { - visualChartService.saveBatch(visualCharts); - } - - // 同步chartElement - List visualChartElements = new ArrayList(); - List chartElements = chartElementService.list(); - - Pattern pattern = Pattern.compile("\"(.*?)\""); - - for(ChartElement chartElement:chartElements) { - VisualChartElement visualChartElement = new VisualChartElement(); - String expression = chartElement.getExpression(); - expression = expression.replaceAll("endpoint=", "endpoint_id="); - expression = expression.replaceAll("asset.host","asset.name"); - if(expression.startsWith("sum(nz_asset_nums)")&&expression.endsWith("sum(nz_asset_online_nums)")) { - expression = "sum(nz_asset_nums{state='Not in storage'})"; - } - if(expression.startsWith("sum(nz_asset_nums)-count(nz_asset_ping)")) { - expression = "count(probe_success==0)"; - } - if(expression.startsWith("nz_asset_ping{host=")) { - Matcher matcher = pattern.matcher(expression); - String host=""; - if(matcher.find()) { - host = matcher.group(); - } - if(StrUtil.isNotBlank(host)) { - expression="probe_icmp_duration_seconds{phase='rtt',host="+host+"} * 1000"; - } - } - chartElement.setExpression(expression); - BeanUtil.copyProperties(chartElement, visualChartElement); - visualChartElements.add(visualChartElement); - } - if(ToolUtil.isNotEmpty(visualChartElements)) { - visualChartElementService.saveBatch(visualChartElements); - } - - // 将chart归属model的赋值给asset_model - Set keySet = modelIdAndChartIds.keySet(); - List assetModels = assetModelService.list(new QueryWrapper().lambda().in(ToolUtil.isNotEmpty(keySet),AssetModel::getId, keySet)); - for(AssetModel assetModel : assetModels) { - String chatIds = modelIdAndChartIds.get(assetModel.getId()); - assetModel.setChartIds(chatIds); - } - if(ToolUtil.isNotEmpty(assetModels)) { - assetModelService.updateBatchById(assetModels); - } - - // 删除panel类型为model的数据 - visualPanelService.remove(new QueryWrapper().lambda().eq(VisualPanel::getType, "model")); - } - -} diff --git a/src/main/java/com/nis/service/impl/DcServiceImpl.java b/src/main/java/com/nis/service/impl/DcServiceImpl.java deleted file mode 100644 index 67f8b43..0000000 --- a/src/main/java/com/nis/service/impl/DcServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.util.ToolUtil; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service("dcService") -public class DcServiceImpl extends ServiceImpl implements DcService { - private static Log logger = Log.get(); - - @Autowired - private IdcService idcService; - - @Override - public void handler() { - List idcs = idcService.list(); - List dcs = new ArrayList(); - - for(Idc idc : idcs) { - Dc dc = new Dc(); - dc.setId(idc.getId()); - dc.setName(idc.getName()); - dc.setLocation(idc.getLocation()); - dc.setTel(idc.getTel()); - dc.setPrincipal(idc.getPrincipal()); - dc.setSeq(idc.getSeq()); - dc.setX(idc.getX()); - dc.setY(idc.getY()); - dc.setLongitude(idc.getLongitude()); - dc.setLatitude(idc.getLatitude()); - dc.setState(idc.getState()); - dcs.add(dc); - } - - if(ToolUtil.isNotEmpty(idcs)) { - this.saveBatch(dcs); - } - } - - -} diff --git a/src/main/java/com/nis/service/impl/EndpointServiceImpl.java b/src/main/java/com/nis/service/impl/EndpointServiceImpl.java deleted file mode 100644 index f7e4b54..0000000 --- a/src/main/java/com/nis/service/impl/EndpointServiceImpl.java +++ /dev/null @@ -1,290 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.lang.UUID; -import cn.hutool.core.lang.hash.MurmurHash; -import cn.hutool.core.util.StrUtil; -import cn.hutool.log.Log; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.EndpointDao; -import com.nis.dao.IdcDao; -import com.nis.entity.Asset; -import com.nis.entity.Dc; -import com.nis.entity.Endpoint; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.MonitorEndpoint; -import com.nis.entity.MonitorModule; -import com.nis.entity.MonitorProject; -import com.nis.entity.Project; -import com.nis.entity.SnmpCredential; -import com.nis.entity.VisualChart; -import com.nis.entity.VisualPanel; -import com.nis.service.AssetService; -import com.nis.service.DcService; -import com.nis.service.EndpointService; -import com.nis.service.IdcService; -import com.nis.service.ModuleService; -import com.nis.service.MonitorEndpointService; -import com.nis.service.MonitorModuleService; -import com.nis.service.MonitorProjectService; -import com.nis.service.ProjectService; -import com.nis.service.SnmpCredentialService; -import com.nis.service.VisualChartService; -import com.nis.service.VisualPanelService; -import com.nis.util.DateUtil; -import com.nis.util.ToolUtil; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class EndpointServiceImpl extends ServiceImpl implements EndpointService { - private static Log logger = Log.get(); - - @Autowired - private ProjectService projectService; - - @Autowired - private MonitorProjectService monitorProjectService; - - @Autowired - private ModuleService moduleService; - - @Autowired - private MonitorModuleService monitorModuleService; - - @Autowired - private MonitorEndpointService monitorEndpointService; - - @Autowired - private EndpointService endpointService; - - @Autowired - private SnmpCredentialService snmpCredentialService; - - @Autowired - private AssetService assetService; - - @Autowired - private VisualPanelService visualPanelService; - - @Autowired - private VisualChartService visualChartService; - - @Override - public void handler() { - - // 同步project数据 - List monitorProjects = new ArrayList(); - List projects = projectService.list(); - for(Project project : projects) { - MonitorProject monitorProject = new MonitorProject(); - BeanUtil.copyProperties(project, monitorProject); - monitorProjects.add(monitorProject); - } - - // 先清空表 - monitorProjectService.remove(new QueryWrapper()); - if(ToolUtil.isNotEmpty(monitorProjects)) { - monitorProjectService.saveBatch(monitorProjects); - } - - - // 同步module数据 首先需要将module中snmp类型的新增凭证 - List snmpCredentials = new ArrayList(); - List snmpModules = moduleService.querySnmpDatas(); - Map moduleIdAndSnmpcredentialMap = new HashMap(); - for(Module snmpModule : snmpModules) { - String snmpParam = snmpModule.getSnmpParam(); - if(StrUtil.isNotBlank(snmpParam)) { - Map config = new HashMap(); - Map snmpParamMap = JSON.parseObject(snmpParam,Map.class); - Object object = snmpParamMap.get("walk"); - Integer version = (Integer) snmpParamMap.get("version"); - if(version.equals(2)) { - config.put("readCommunity","public"); - config.put("writeCommunity","public"); - }else { - Object auth = snmpParamMap.get("auth"); - Map authMap = JSON.parseObject(JSON.toJSONString(auth),Map.class); - config.put("username",authMap.get("username")); - config.put("contextname",authMap.get("context_name")); - config.put("securityLevel",authMap.get("security_level")); - config.put("authProtocol",authMap.get("auth_protocol")); - config.put("authPin",authMap.get("password")); - config.put("privProtocol",authMap.get("priv_protocol")); - config.put("privPin",authMap.get("priv_password")); - } - SnmpCredential snmpCredential = new SnmpCredential(); - snmpCredential.setName("import_"+UUID.randomUUID().toString()); - snmpCredential.setType((Integer)snmpParamMap.get("version")); - snmpCredential.setPort(snmpModule.getPort()); - snmpCredential.setConfig(JSON.toJSONString(config)); - snmpCredentials.add(snmpCredential); - moduleIdAndSnmpcredentialMap.put(snmpModule.getId(), snmpCredential); - } - } - - if(ToolUtil.isNotEmpty(snmpCredentials)) { - snmpCredentialService.saveBatch(snmpCredentials); - } - - - List monitorModules =new ArrayList(); - List modules = moduleService.list(); - Map moduleIdAndData = modules.stream().collect(Collectors.toMap(Module::getId, Function.identity())); - for(Module module : modules) { - Map configs =new HashMap(); - configs.put("metrics_path", module.getPath()); - configs.put("port", module.getPort()); - configs.put("host", "{{asset.manageIp}}"); - if(StrUtil.isNotBlank(module.getParam())) { - String param = module.getParam(); - Map paramMap = JSON.parseObject(param,Map.class); - Map params = new HashMap(); - for(String key : paramMap.keySet()) { - Object value = paramMap.get(key); - List values = new ArrayList(); - values.add(value); - params.put(key, values); - } - configs.put("params", params); - } - if(module.getType().equals("snmp")) { - String snmpParam = module.getSnmpParam(); - if(StrUtil.isNotBlank(snmpParam)) { - Map snmpParamMap = JSON.parseObject(snmpParam,Map.class); - Object object = snmpParamMap.get("walk"); - configs.put("walk", object); - } - SnmpCredential snmpCredential = moduleIdAndSnmpcredentialMap.get(module.getId()); - configs.put("snmpCredentialsId", ToolUtil.isNotEmpty(snmpCredential)?snmpCredential.getId() : ""); - } - String labels = module.getLabels(); - if(StrUtil.isNotBlank(labels)) { - configs.put("labels",JSON.parseObject(labels)); - } - MonitorModule monitorModule = new MonitorModule(); - monitorModule.setName(module.getName()); - monitorModule.setId(module.getId()); - monitorModule.setProjectId(module.getProjectId()); - monitorModule.setRemark(module.getRemark()); - monitorModule.setSeq(module.getSeq()); - monitorModule.setBuildIn(module.getBuildIn()); - monitorModule.setType(module.getType()); - monitorModule.setEndpointNameTmpl("{{asset.name}}-{{module.name}}"); - monitorModule.setConfigs(JSON.toJSONString(configs)); - monitorModules.add(monitorModule); - } - - if(ToolUtil.isNotEmpty(monitorModules)) { - monitorModuleService.saveBatch(monitorModules); - } - - // 查询所有asset信息 - List assets = assetService.list(); - Map assetIdAndData = assets.stream().collect(Collectors.toMap(Asset::getId, Function.identity())); - // 同步endpoint信息 - List endpoints = endpointService.list(); - List monitorEndpoints =new ArrayList(); - - Map endpointAndPanel = new HashMap(); - Map endpointAndChart = new HashMap(); - for(Endpoint endpoint : endpoints) { - Map configs =new HashMap(); - configs.put("metrics_path", endpoint.getPath()); - configs.put("port", endpoint.getPort()); - configs.put("host", endpoint.getHost()); - if(StrUtil.isNotBlank(endpoint.getParam())) { - String param = endpoint.getParam(); - Map paramMap = JSON.parseObject(param,Map.class); - Map params = new HashMap(); - for(String key : paramMap.keySet()) { - Object value = paramMap.get(key); - List values = new ArrayList(); - values.add(value); - params.put(key, values); - } - configs.put("params", params); - } - String labels = endpoint.getLabels(); - if(StrUtil.isNotBlank(labels)) { - configs.put("labels",JSON.parseObject(labels)); - } - MonitorEndpoint monitorEndpoint = new MonitorEndpoint(); - monitorEndpoint.setId(endpoint.getId()); - monitorEndpoint.setEnabled(endpoint.getEnabled()); - monitorEndpoint.setModuleId(endpoint.getModuleId()); - monitorEndpoint.setAssetId(endpoint.getAssetId()); - Asset asset = assetIdAndData.get(endpoint.getAssetId()); - Module module = moduleIdAndData.get(endpoint.getModuleId()); - monitorEndpoint.setName(asset.getHost()+"-"+module.getName()); - monitorEndpoint.setSeq(endpoint.getSeq()); - monitorEndpoint.setConfigs(JSON.toJSONString(configs)); - String hash = endpoint.getModuleId() + endpoint.getAssetId() + JSON.toJSONString(configs); - monitorEndpoint.setHash(String.valueOf(Math.abs(MurmurHash.hash64(hash)))); - monitorEndpoints.add(monitorEndpoint); - - //创建endpoint panel - VisualPanel panel = new VisualPanel(); - endpointAndPanel.put(monitorEndpoint, panel); - //创建endpoint chart endpointInfo - VisualChart chart =new VisualChart(); - endpointAndChart.put(monitorEndpoint, chart); - } - - if(ToolUtil.isNotEmpty(monitorEndpoints)) { - monitorEndpointService.saveBatch(monitorEndpoints); - } - - VisualPanel lastPanel = visualPanelService.getOne(new QueryWrapper().orderByDesc("id").last("limit 1")); - Integer id = lastPanel.getId()+10; - List charts =new ArrayList(); - for(MonitorEndpoint monitorEndpoint:monitorEndpoints) { - VisualPanel visualPanel = endpointAndPanel.get(monitorEndpoint); - visualPanel.setId(id); - visualPanel.setName("endpoint_panel_" + monitorEndpoint.getId()); - visualPanel.setType("endpoint"); - visualPanel.setPid(0); - visualPanel.setLink(monitorEndpoint.getId()); - visualPanel.setWeight(0); - visualPanel.setCreateBy(1); - visualPanelService.save(visualPanel); - - VisualChart visualChart = endpointAndChart.get(monitorEndpoint); - visualChart.setName("{{endpoint.name}}"); - visualChart.setType("endpointInfo"); - visualChart.setSpan(12); - visualChart.setHeight(4); - visualChart.setUnit(2); - visualChart.setParam(null); - visualChart.setPanelId(id); - visualChart.setGroupId(0); - visualChart.setUpdateBy(1); - Date utcTime = DateUtil.getUTCTimeByConfigTimeZone(); - visualChart.setUpdateAt(utcTime); - charts.add(visualChart); - - id++; - } - - if(ToolUtil.isNotEmpty(charts)) { - visualChartService.saveBatch(charts); - } - } - -} diff --git a/src/main/java/com/nis/service/impl/IdcServiceImpl.java b/src/main/java/com/nis/service/impl/IdcServiceImpl.java deleted file mode 100644 index 88350a4..0000000 --- a/src/main/java/com/nis/service/impl/IdcServiceImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.service.DcService; -import com.nis.service.IdcService; - -import org.springframework.stereotype.Service; - -@Service("idcService") -public class IdcServiceImpl extends ServiceImpl implements IdcService { - -} diff --git a/src/main/java/com/nis/service/impl/ModelServiceImpl.java b/src/main/java/com/nis/service/impl/ModelServiceImpl.java deleted file mode 100644 index 96d02de..0000000 --- a/src/main/java/com/nis/service/impl/ModelServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.nis.service.impl; - -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.ModelDao; -import com.nis.entity.Model; -import com.nis.service.ModelService; - -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import java.util.stream.Collectors; - - -@Service("modelService") -public class ModelServiceImpl extends ServiceImpl implements ModelService { - -} diff --git a/src/main/java/com/nis/service/impl/ModuleServiceImpl.java b/src/main/java/com/nis/service/impl/ModuleServiceImpl.java deleted file mode 100644 index c1d61a7..0000000 --- a/src/main/java/com/nis/service/impl/ModuleServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.ModuleDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.ModuleService; - -import java.util.List; - -import org.springframework.stereotype.Service; - -@Service -public class ModuleServiceImpl extends ServiceImpl implements ModuleService { - - @Override - public List querySnmpDatas() { - return this.baseMapper.selectSnmpDatas(); - } - -} diff --git a/src/main/java/com/nis/service/impl/MonitorEndpointConfigServiceImpl.java b/src/main/java/com/nis/service/impl/MonitorEndpointConfigServiceImpl.java new file mode 100644 index 0000000..62a4cd1 --- /dev/null +++ b/src/main/java/com/nis/service/impl/MonitorEndpointConfigServiceImpl.java @@ -0,0 +1,13 @@ +package com.nis.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.nis.dao.MonitorEndpointConfigDao; +import com.nis.entity.MonitorEndpointConfig; +import com.nis.service.MonitorEndpointConfigService; +import org.springframework.stereotype.Service; + +@Service +public class MonitorEndpointConfigServiceImpl extends ServiceImpl implements MonitorEndpointConfigService { + +} diff --git a/src/main/java/com/nis/service/impl/MonitorEndpointServiceImpl.java b/src/main/java/com/nis/service/impl/MonitorEndpointServiceImpl.java index 9ae49d2..323e9d3 100644 --- a/src/main/java/com/nis/service/impl/MonitorEndpointServiceImpl.java +++ b/src/main/java/com/nis/service/impl/MonitorEndpointServiceImpl.java @@ -2,19 +2,24 @@ package com.nis.service.impl; import cn.hutool.log.Log; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; import com.nis.dao.MonitorEndpointDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; import com.nis.entity.MonitorEndpoint; -import com.nis.service.DcService; -import com.nis.service.IdcService; import com.nis.service.MonitorEndpointService; - +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class MonitorEndpointServiceImpl extends ServiceImpl implements MonitorEndpointService { - + + private static Log log = Log.get(); + + @Autowired + private MonitorEndpointDao monitorEndpointDao; + + @Override + public List getEndpointBackupData() { + return monitorEndpointDao.getEndpointBackupData(); + } } diff --git a/src/main/java/com/nis/service/impl/MonitorModuleServiceImpl.java b/src/main/java/com/nis/service/impl/MonitorModuleServiceImpl.java index 34ccd47..a71bc14 100644 --- a/src/main/java/com/nis/service/impl/MonitorModuleServiceImpl.java +++ b/src/main/java/com/nis/service/impl/MonitorModuleServiceImpl.java @@ -1,20 +1,29 @@ package com.nis.service.impl; -import cn.hutool.log.Log; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; import com.nis.dao.MonitorModuleDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; import com.nis.entity.MonitorModule; -import com.nis.service.DcService; -import com.nis.service.IdcService; import com.nis.service.MonitorModuleService; - +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class MonitorModuleServiceImpl extends ServiceImpl implements MonitorModuleService { - + + @Autowired + private MonitorModuleDao monitorModuleDao; + + @Override + public void truncateData() { + monitorModuleDao.truncateData(); + } + + @Override + public List getModuleBackupData() { + return monitorModuleDao.getModuleBackupData(); + } + + } diff --git a/src/main/java/com/nis/service/impl/MonitorProjectServiceImpl.java b/src/main/java/com/nis/service/impl/MonitorProjectServiceImpl.java deleted file mode 100644 index 779f809..0000000 --- a/src/main/java/com/nis/service/impl/MonitorProjectServiceImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.MonitorProjectDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.MonitorProject; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.MonitorProjectService; - -import org.springframework.stereotype.Service; - -@Service -public class MonitorProjectServiceImpl extends ServiceImpl implements MonitorProjectService { - -} diff --git a/src/main/java/com/nis/service/impl/PanelServiceImpl.java b/src/main/java/com/nis/service/impl/PanelServiceImpl.java deleted file mode 100644 index f630708..0000000 --- a/src/main/java/com/nis/service/impl/PanelServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.ModuleDao; -import com.nis.dao.PanelDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.Panel; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.ModuleService; -import com.nis.service.PanelService; - -import org.springframework.stereotype.Service; - -@Service -public class PanelServiceImpl extends ServiceImpl implements PanelService { - -} diff --git a/src/main/java/com/nis/service/impl/ProjectServiceImpl.java b/src/main/java/com/nis/service/impl/ProjectServiceImpl.java deleted file mode 100644 index 632b2a8..0000000 --- a/src/main/java/com/nis/service/impl/ProjectServiceImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.ProjectDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Project; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.ProjectService; - -import org.springframework.stereotype.Service; - -@Service("projectService") -public class ProjectServiceImpl extends ServiceImpl implements ProjectService { - -} diff --git a/src/main/java/com/nis/service/impl/ProjectTopoIconServiceImpl.java b/src/main/java/com/nis/service/impl/ProjectTopoIconServiceImpl.java deleted file mode 100644 index 91859ac..0000000 --- a/src/main/java/com/nis/service/impl/ProjectTopoIconServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.ProjectDao; -import com.nis.dao.ProjectTopoIconDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Project; -import com.nis.entity.ProjectTopoIcon; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.ProjectService; -import com.nis.service.ProjectTopoIconService; - -import org.springframework.stereotype.Service; - -@Service -public class ProjectTopoIconServiceImpl extends ServiceImpl implements ProjectTopoIconService { - -} diff --git a/src/main/java/com/nis/service/impl/ProjectTopoServiceImpl.java b/src/main/java/com/nis/service/impl/ProjectTopoServiceImpl.java deleted file mode 100644 index 6001180..0000000 --- a/src/main/java/com/nis/service/impl/ProjectTopoServiceImpl.java +++ /dev/null @@ -1,347 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.core.util.StrUtil; -import cn.hutool.log.Log; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.ProjectDao; -import com.nis.dao.ProjectTopoDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.Project; -import com.nis.entity.ProjectTopo; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.ModuleService; -import com.nis.service.ProjectService; -import com.nis.service.ProjectTopoService; -import com.nis.util.ToolUtil; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ProjectTopoServiceImpl extends ServiceImpl implements ProjectTopoService { - - @Autowired - private ProjectService projectService; - - @Autowired - private ModuleService moduleService; - - @Override - public void handler() { - // 处理project_topo中的数据 - List projectTopos = this.list(); - for(ProjectTopo projectTopo : projectTopos) { - Project project = projectService.getById(projectTopo.getProjectId()); - Map topoData =new LinkedHashMap(); - List pens = new ArrayList(); - Map topo = JSONObject.parseObject(projectTopo.getTopo().toString(), Map.class); - if(ToolUtil.isEmpty(topo.get("nodes"))) { - continue; - } - List nodes = JSONObject.parseArray(topo.get("nodes").toString(),Map.class); - List lines = JSONObject.parseArray(topo.get("lines").toString(),Map.class); - Map moduleAndNode = new HashMap(); - for(Map node : nodes) { - Map result = this.createNodeOrLine(0, node,moduleAndNode); - pens.add(result); - } - for(Map line : lines) { - Map result = this.createNodeOrLine(1, line,moduleAndNode); - pens.add(result); - } - topoData.put("pens", pens); - topoData.put("lineName", "curve"); - topoData.put("scale", 1); - topoData.put("locked", 0); - Map mqttOptions =new HashMap(); - mqttOptions.put("clientId", ""); - topoData.put("mqttOptions", mqttOptions); - topoData.put("lineWidth", 1); - topoData.put("bkColor", "#FFFFFF"); - topoData.put("gridColor", "#ededed"); - topoData.put("gridSize", 0); - topoData.put("ruleColor", "#4e4e4e"); - topoData.put("data", new HashMap()); - topoData.put("name", project.getName()); - topoData.put("projectId", projectTopo.getProjectId()); - topoData.put("rule", false); - topoData.put("grid", false); - projectTopo.setTopo(JSON.toJSONString(topoData)); - } - - if(ToolUtil.isNotEmpty(projectTopos)) { - this.updateBatchById(projectTopos); - } - } - - - public Map createNodeOrLine(Integer type,Map object,Map moduleAndNode) { - Module module = null; - if(type==0) { - Integer moduleId = (Integer) object.get("moduleId"); - module = moduleService.getById(moduleId); - moduleAndNode.put(moduleId, object); - } - String colorData = null; - if(type==1) { - Object colorObject = object.get("color"); - if(colorObject instanceof java.util.Map) { - colorData = (String) ((Map)colorObject).get("color"); - }else { - if(ToolUtil.isNotEmpty(colorObject)) { - colorData = (String)colorObject; - } - } - if(StrUtil.isBlank(colorData)) { - colorData = "#222222"; - } - } - - Map result =new LinkedHashMap(); - result.put("type", type==0 ? 0:1); - Integer x = (Integer)object.get("x"); - Integer y = (Integer)object.get("y"); - Map rect =new HashMap(); - rect.put("x", type==0 ? x : 0); - rect.put("y", type==0 ? y : 0); - rect.put("width", type==0 ? 100 : 0); - rect.put("height", type==0 ? 100 : 0); - /*if(type==1) { - rect.put("ex", 0); - rect.put("ey", 0); - }*/ - Map center = new HashMap(); - center.put("x", type==0 ? x+50 : 0); - center.put("y", type==0 ? y+50 : 0); - rect.put("center", center); - result.put("rect", rect); - - result.put("lineWidth", 1); - result.put("rotate", 0); - result.put("offsetRotate", 0); - result.put("globalAlpha",1); - result.put("dash",0); - result.put("strokeStyle",type==0 ? "#222222" : colorData); - - Map font =new HashMap(); - font.put("color", type==0 ? "#222222" : colorData); - font.put("fontSize", 12); - font.put("lineHeight", 1.5); - font.put("fontStyle", "normal"); - font.put("fontWeight", "normal"); - font.put("textAlign", "center"); - font.put("textBaseline", "middle"); - if(type==1) { - font.put("background","#fff"); - } - result.put("font",font); - result.put("animatePos",0); - result.put("events",new ArrayList()); - - List eventFns =new ArrayList(); - eventFns.add("link"); - eventFns.add("doStartAnimate"); - eventFns.add("doFn"); - eventFns.add("doWindowFn"); - eventFns.add(""); - eventFns.add("doPauseAnimate"); - eventFns.add("doStopAnimate"); - result.put("eventFns",eventFns); - - String name = "rectangleImg"; - if(type==1) { - Map smooth = (Map) object.get("smooth"); - String smoothType = (String) smooth.get("type"); - if(StrUtil.isNotBlank(smoothType)) { - name = "curve"; - }else { - name = "line"; - } - - } - result.put("id", type == 0 ? module.getId() : ""); - result.put("name", name); - result.put("tags",new ArrayList()); - result.put("lineDashOffset", 0); - result.put("textOffsetX", 0); - result.put("textOffsetY", 0); - result.put("visible", true); - if(type==0) { - result.put("text", module.getName()); - } - - Map data = new HashMap(); - if(type==0) { - data.put("imageId", object.get("iconId")); - data.put("moduleId", module.getId()); - data.put("moduleName", module.getName()); - data.put("show", false); - data.put("error", false); - data.put("fillStyle", ""); - data.put("strokeStyle", "#000000"); - data.put("gradientColor", "#bae7ff"); - data.put("gradientType", 0); - data.put("lineWidth", 0); - data.put("iconToolState", true); - }else if(type==1) { - data.put("strokeStyle", "#222222"); - data.put("animateColor", "#FA901C"); - data.put("arrowColor", "#000000"); - data.put("fromArrowColor", "#000000"); - data.put("toArrowColor", "#000000"); - data.put("lineWidth", 1); - data.put("moduleName", ""); - } - data.put("animatePlay", false); - - List valueMapping =new ArrayList(); - Map vm =new HashMap(); - Map color =new HashMap(); - color.put("line","#000000"); - color.put("fill","#ffffff"); - color.put("text","#000000"); - vm.put("color", color); - vm.put("value", "base"); - vm.put("animateType", "base"); - vm.put("level", 0); - vm.put("base", true); - valueMapping.add(vm); - data.put("valueMapping", valueMapping); - data.put("valueMappingSort", "asc"); - data.put("expressArr",new ArrayList()); - data.put("legends",new ArrayList()); - data.put("tooltipShow", true); - data.put("panelName", "topologyName"); - data.put("unit", 2); - data.put("type", "line"); - data.put("displayChart", true); - data.put("aggregation", "last"); - data.put("title", type==0 ? module.getName() : ""); - data.put("url", ""); - result.put("data", data); - - if(type==0) { - result.put("zRotate", 0); - result.put("imageRatio", true); - result.put("animateDuration", 0); - result.put("animateFrames", new ArrayList()); - result.put("animateFrame", 0); - result.put("borderRadius", 0); - result.put("icon", ""); - result.put("image", ""); - result.put("imageAlign", "center"); - result.put("bkType", 0); - result.put("gradientAngle", 0); - result.put("gradientRadius", 0.01); - result.put("paddingTop", 5); - result.put("paddingBottom", 5); - result.put("paddingLeft", 5); - result.put("paddingRight", 5); - result.put("paddingLeftNum", 5); - result.put("paddingRightNum", 5); - result.put("paddingTopNum", 5); - result.put("paddingBottomNum", 5); - result.put("animatePlay", false); - result.put("animateReady", null); - }else if(type==1) { - Integer sourceId = (Integer) object.get("source"); - Integer targetId = (Integer) object.get("target"); - Map sourceNode = (Map) moduleAndNode.get(sourceId); - Map targetNode = (Map) moduleAndNode.get(targetId); - - Integer sourceX = (Integer) sourceNode.get("x"); - Integer sourceY = (Integer) sourceNode.get("y"); - Integer targetX = (Integer) targetNode.get("x"); - Integer targetY = (Integer) targetNode.get("y"); - - List controlPoints =new ArrayList(); - Map m1 =new HashMap(); - m1.put("x", sourceX+50); - m1.put("y", sourceY+50); - m1.put("direction", 0); - m1.put("anchorIndex", 0); - m1.put("id", sourceId); - Map m2 =new HashMap(); - m2.put("x", targetX+50); - m2.put("y", targetY+50); - m2.put("direction", 0); - m2.put("anchorIndex", 0); - m2.put("id", targetId); - controlPoints.add(m1); - controlPoints.add(m2); - - result.put("controlPoints",controlPoints); - result.put("fromArrowSize",5); - result.put("toArrowSize",5); - result.put("toArrowColor", colorData); - result.put("fromArrowColor", colorData); - result.put("borderWidth",0); - result.put("borderColor","#000000"); - result.put("animateColor","#FA901C"); - result.put("animateSpan",1); - result.put("isAnimate",false); - result.put("animateFromSize",0); - result.put("animateToSize",0); - result.put("animateDotSize",3); - Map from = new HashMap(); - from.put("x", sourceX+50); - from.put("y", sourceY+50); - from.put("direction", 0); - from.put("anchorIndex", 0); - from.put("id", sourceId); - from.put("autoAnchor", true); - - result.put("from", from); - Map to = new HashMap(); - to.put("x", targetX+50); - to.put("y", targetY+50); - to.put("direction", 0); - to.put("anchorIndex", 0); - to.put("id", targetId); - to.put("autoAnchor", true); - result.put("to", to); - - //判断是否之前为虚线 - if(type==1) { - Object dash = object.get("dashes"); - if(!dash.equals(false)) { - result.put("dash", 2); - } - } - if(type==1) { - //判断arrow 空 from to from to - String arrows = (String) object.get("arrows"); - if(arrows.equals("0")) { - result.put("toArrow",""); - result.put("fromArrow", ""); - }else if(arrows.equals("to")) { - result.put("toArrow","triangleSolid"); - result.put("fromArrow", ""); - }else if(arrows.equals("from")) { - result.put("toArrow",""); - result.put("fromArrow", "triangleSolid"); - }else { - result.put("toArrow","triangleSolid"); - result.put("fromArrow", "triangleSolid"); - } - } - result.put("animatePlay",false); - } - - return result; - } -} diff --git a/src/main/java/com/nis/service/impl/SnmpCredentialServiceImpl.java b/src/main/java/com/nis/service/impl/SnmpCredentialServiceImpl.java deleted file mode 100644 index db6d21f..0000000 --- a/src/main/java/com/nis/service/impl/SnmpCredentialServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.nis.service.impl; - -import java.util.Arrays; -import java.util.Map; - -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.SnmpCredentialDao; -import com.nis.entity.SnmpCredential; -import com.nis.service.SnmpCredentialService; - -import cn.hutool.core.util.ObjectUtil; - -@Service -public class SnmpCredentialServiceImpl extends ServiceImpl implements SnmpCredentialService{ - -} diff --git a/src/main/java/com/nis/service/impl/SysConfigServiceImpl.java b/src/main/java/com/nis/service/impl/SysConfigServiceImpl.java deleted file mode 100644 index 7fe8a4f..0000000 --- a/src/main/java/com/nis/service/impl/SysConfigServiceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.SysConfigDao; -import com.nis.entity.SysConfigEntity; -import com.nis.service.SysConfigService; - -import org.springframework.stereotype.Service; - - -import java.util.*; - - -@Service("sysConfigService") -public class SysConfigServiceImpl extends ServiceImpl implements SysConfigService { - - @Override - public List querySysConfigEntitys() { - return this.baseMapper.selectSysConfigEntitys(); - } - - -} diff --git a/src/main/java/com/nis/service/impl/SysDictServiceImpl.java b/src/main/java/com/nis/service/impl/SysDictServiceImpl.java deleted file mode 100644 index 0c20769..0000000 --- a/src/main/java/com/nis/service/impl/SysDictServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - - * - - * - - */ - -package com.nis.service.impl; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.SysDictDao; -import com.nis.entity.SysDictEntity; -import com.nis.service.SysDictService; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; -import java.util.stream.Collectors; - - -@Service("sysDictService") -public class SysDictServiceImpl extends ServiceImpl implements SysDictService { - - @Override - public List queryDatas(String type) { - return this.baseMapper.selectDatas(type); - } - -} diff --git a/src/main/java/com/nis/service/impl/SysUserServiceImpl.java b/src/main/java/com/nis/service/impl/SysUserServiceImpl.java deleted file mode 100644 index 93a3bcd..0000000 --- a/src/main/java/com/nis/service/impl/SysUserServiceImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.nis.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.SysUserDao; -import com.nis.entity.SysUserEntity; -import com.nis.service.SysUserService; - -import java.util.List; - -import org.springframework.stereotype.Service; - -@Service("sysUserService") -public class SysUserServiceImpl extends ServiceImpl implements SysUserService { - - @Override - public List queryOldUsers() { - return this.baseMapper.selectOldUsers(); - } - - @Override - public List queryNewUsers() { - return this.baseMapper.selectNewUsers(); - } - -} diff --git a/src/main/java/com/nis/service/impl/VisualChartElementServiceImpl.java b/src/main/java/com/nis/service/impl/VisualChartElementServiceImpl.java deleted file mode 100644 index 2ee7e08..0000000 --- a/src/main/java/com/nis/service/impl/VisualChartElementServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.ModuleDao; -import com.nis.dao.VisualChartElementDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.VisualChartElement; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.ModuleService; -import com.nis.service.VisualChartElementService; - -import org.springframework.stereotype.Service; - -@Service -public class VisualChartElementServiceImpl extends ServiceImpl implements VisualChartElementService { - private static Log logger = Log.get(); - -} diff --git a/src/main/java/com/nis/service/impl/VisualChartServiceImpl.java b/src/main/java/com/nis/service/impl/VisualChartServiceImpl.java deleted file mode 100644 index e4dc32f..0000000 --- a/src/main/java/com/nis/service/impl/VisualChartServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.ModuleDao; -import com.nis.dao.VisualChartDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.VisualChart; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.ModuleService; -import com.nis.service.VisualChartService; - -import org.springframework.stereotype.Service; - -@Service -public class VisualChartServiceImpl extends ServiceImpl implements VisualChartService { - private static Log logger = Log.get(); - -} diff --git a/src/main/java/com/nis/service/impl/VisualPanelServiceImpl.java b/src/main/java/com/nis/service/impl/VisualPanelServiceImpl.java deleted file mode 100644 index 631fb73..0000000 --- a/src/main/java/com/nis/service/impl/VisualPanelServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.nis.service.impl; - -import cn.hutool.log.Log; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.nis.dao.DcDao; -import com.nis.dao.IdcDao; -import com.nis.dao.ModuleDao; -import com.nis.dao.PanelDao; -import com.nis.dao.VisualPanelDao; -import com.nis.entity.Dc; -import com.nis.entity.Idc; -import com.nis.entity.Module; -import com.nis.entity.Panel; -import com.nis.entity.VisualPanel; -import com.nis.service.DcService; -import com.nis.service.IdcService; -import com.nis.service.ModuleService; -import com.nis.service.PanelService; -import com.nis.service.VisualPanelService; - -import org.springframework.stereotype.Service; - -@Service -public class VisualPanelServiceImpl extends ServiceImpl implements VisualPanelService { - -} diff --git a/src/main/java/com/nis/util/Constant.java b/src/main/java/com/nis/util/Constant.java index e2774e2..587fddd 100644 --- a/src/main/java/com/nis/util/Constant.java +++ b/src/main/java/com/nis/util/Constant.java @@ -8,22 +8,16 @@ package com.nis.util; -import cn.hutool.core.util.StrUtil; -import cn.hutool.log.Log; -import org.apache.ibatis.mapping.DatabaseIdProvider; - -import com.nis.entity.AssetBrand; -import com.nis.entity.AssetTypeConf; -import com.nis.entity.SysDictEntity; - -import javax.sql.DataSource; - import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; + +import javax.sql.DataSource; + +import org.apache.ibatis.mapping.DatabaseIdProvider; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.log.Log; /** * 常量 @@ -64,6 +58,4 @@ public class Constant { DB_TYPE = databaseId; DATABASE_NAME = databaseName; } - - public static Map assetBrands = new HashMap(); } diff --git a/src/main/resources/db/init.sql b/src/main/resources/db/init.sql index 38ffdd3..1d4772d 100644 --- a/src/main/resources/db/init.sql +++ b/src/main/resources/db/init.sql @@ -17,1855 +17,321 @@ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; --- ---------------------------- --- Table structure for alert_message_active --- ---------------------------- -DROP TABLE IF EXISTS `alert_message_active`; -CREATE TABLE `alert_message_active` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', - `summary` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '告警摘要', - `description` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '告警描述', - `labels` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '告警labels信息', - `start_at` datetime(0) NULL DEFAULT NULL COMMENT '开始时间', - `end_at` datetime(0) NULL DEFAULT NULL COMMENT '结束时间', - `state` int(10) NULL DEFAULT NULL COMMENT '状态1:pending,2:Expired', - `rule_id` int(10) NOT NULL COMMENT '告警规则ID', - `project_id` int(10) NULL DEFAULT NULL COMMENT '关联project id', - `module_id` int(10) NULL DEFAULT NULL COMMENT '关联module id', - `endpoint_id` int(10) NULL DEFAULT NULL COMMENT '关联endpoint id', - `asset_id` int(10) NULL DEFAULT NULL COMMENT '关联资产id', - `dc_id` int(10) NULL DEFAULT NULL COMMENT '关联idc id', - `hash_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'redis hash key', - `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '备注 记录手动关闭记录信息,格式\r\n\r\ntime username\r\n\r\nmessage', - `severity_id` int(10) NULL DEFAULT NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_state`(`state`) USING BTREE, - INDEX `idx_rule_id`(`rule_id`) USING BTREE, - INDEX `idx_project_id`(`project_id`) USING BTREE, - INDEX `idx_module_id`(`module_id`) USING BTREE, - INDEX `idx_endpoint_id`(`endpoint_id`) USING BTREE, - INDEX `idx_asset_id`(`asset_id`) USING BTREE, - INDEX `idx_dc_id`(`dc_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of alert_message_active --- ---------------------------- - --- ---------------------------- --- Table structure for alert_message_history --- ---------------------------- -DROP TABLE IF EXISTS `alert_message_history`; -CREATE TABLE `alert_message_history` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', - `summary` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '告警摘要', - `description` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '告警描述', - `labels` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '告警labels信息', - `start_at` datetime(0) NULL DEFAULT NULL COMMENT '开始时间', - `end_at` datetime(0) NULL DEFAULT NULL COMMENT '结束时间', - `state` int(10) NULL DEFAULT NULL COMMENT '状态1:pending,2:Expired', - `rule_id` int(10) NOT NULL COMMENT '告警规则ID', - `project_id` int(10) NULL DEFAULT NULL COMMENT '关联project id', - `module_id` int(10) NULL DEFAULT NULL COMMENT '关联module id', - `endpoint_id` int(10) NULL DEFAULT NULL COMMENT '关联endpoint id', - `asset_id` int(10) NULL DEFAULT NULL COMMENT '关联资产id', - `dc_id` int(10) NULL DEFAULT NULL COMMENT '关联idc id', - `hash_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'redis hash key', - `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '备注 记录手动关闭记录信息,格式\r\n\r\ntime username\r\n\r\nmessage', - `severity_id` int(10) NULL DEFAULT NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_state`(`state`) USING BTREE, - INDEX `idx_rule_id`(`rule_id`) USING BTREE, - INDEX `idx_project_id`(`project_id`) USING BTREE, - INDEX `idx_module_id`(`module_id`) USING BTREE, - INDEX `idx_endpoint_id`(`endpoint_id`) USING BTREE, - INDEX `idx_asset_id`(`asset_id`) USING BTREE, - INDEX `idx_dc_id`(`dc_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of alert_message_history --- ---------------------------- - --- ---------------------------- --- Table structure for alert_message_silence --- ---------------------------- -DROP TABLE IF EXISTS `alert_message_silence`; -CREATE TABLE `alert_message_silence` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', - `summary` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '告警摘要', - `description` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '告警描述', - `labels` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '告警labels信息', - `start_at` datetime(0) NULL DEFAULT NULL COMMENT '开始时间', - `end_at` datetime(0) NULL DEFAULT NULL COMMENT '结束时间', - `state` int(10) NULL DEFAULT NULL COMMENT '状态1:pending,2:Expired', - `rule_id` int(10) NOT NULL COMMENT '告警规则ID', - `project_id` int(10) NULL DEFAULT NULL COMMENT '关联project id', - `module_id` int(10) NULL DEFAULT NULL COMMENT '关联module id', - `endpoint_id` int(10) NULL DEFAULT NULL COMMENT '关联endpoint id', - `asset_id` int(10) NULL DEFAULT NULL COMMENT '关联资产id', - `dc_id` int(10) NULL DEFAULT NULL COMMENT '关联idc id', - `hash_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'redis hash key', - `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '备注 记录手动关闭记录信息,格式\r\n\r\ntime username\r\n\r\nmessage', - `severity_id` int(10) NULL DEFAULT NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_state`(`state`) USING BTREE, - INDEX `idx_rule_id`(`rule_id`) USING BTREE, - INDEX `idx_project_id`(`project_id`) USING BTREE, - INDEX `idx_module_id`(`module_id`) USING BTREE, - INDEX `idx_endpoint_id`(`endpoint_id`) USING BTREE, - INDEX `idx_asset_id`(`asset_id`) USING BTREE, - INDEX `idx_dc_id`(`dc_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of alert_message_silence --- ---------------------------- - --- ---------------------------- --- Table structure for alert_notify_log --- ---------------------------- -DROP TABLE IF EXISTS `alert_notify_log`; -CREATE TABLE `alert_notify_log` ( +CREATE TABLE `monitor_endpoint_config` ( `id` int(10) NOT NULL AUTO_INCREMENT, - `message_id` bigint(20) NOT NULL COMMENT '关联 alert_message.id', - `user_id` int(10) NOT NULL COMMENT '关联 sys_user.id', - `method_id` int(10) NOT NULL COMMENT '关联ALERT_NOTIFICATION_METHOD.id', - `message_state` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '消息状态1: active2: expired', - `state` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '通知状态0:失败1:成功', - `error_msg` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '发送错误信息', - `time` datetime(0) NOT NULL COMMENT '发送时间', + `endpoint_id` int(10) NOT NULL, + `type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '可选值:\r\n\r\nmetrics,logs,trace(预留)', + `config` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `version` int(10) NOT NULL DEFAULT 1 COMMENT '默认:1\r\n\r\nupdate +1', + `enable` int(1) NOT NULL DEFAULT 1 COMMENT '默认:1\r\n\r\n1:开启\r\n\r\n0:关闭\r\n\r\n-1: 未配置', + `hash` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '计算 endpointId+ type + config 的hash值,用于确保相同配置不重复', + `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +DROP TABLE IF EXISTS `asset_talon_status`; +CREATE TABLE `asset_talon_status` ( + `asset_id` int(10) NOT NULL, + `status` int(10) NOT NULL COMMENT '1: OK\r\n2: 连接超时\r\n3:认证失败\r\n4:未知错误', + `msg` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '默认:“”\r\n\r\n记录 错误描述信息', + `last_update` datetime(0) NULL DEFAULT NULL COMMENT '最后更新时间', + PRIMARY KEY (`asset_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +DROP TABLE IF EXISTS `asset_talon_status`; +CREATE TABLE `asset_talon_status` ( + `asset_id` int(10) NOT NULL, + `status` int(10) NOT NULL COMMENT '1: OK\r\n2: 连接超时\r\n3:认证失败\r\n4:未知错误', + `msg` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '默认:“”\r\n\r\n记录 错误描述信息', + `last_update` datetime(0) NULL DEFAULT NULL COMMENT '最后更新时间' +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +DROP TABLE IF EXISTS `alert_rule_eval_log`; +CREATE TABLE `alert_rule_eval_log` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `rule_id` int(10) NOT NULL, + `state` int(10) NOT NULL, + `msg` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `stts` bigint(20) NOT NULL, + `etts` bigint(20) NOT NULL, PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_message_id`(`message_id`) USING BTREE, + INDEX `idx_rule_id`(`rule_id`) USING BTREE, INDEX `idx_state`(`state`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; --- ---------------------------- --- Records of alert_notify_log --- ---------------------------- - --- ---------------------------- --- Table structure for alert_notify_method --- ---------------------------- -DROP TABLE IF EXISTS `alert_notify_method`; -CREATE TABLE `alert_notify_method` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '通知方式名称', - `file_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '除内置外,必填脚本路径,nz-web所在服务器路径', - `account` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '可选值为user表属性id,name,username,email,mobile', - `state` int(1) NULL DEFAULT NULL COMMENT '状态0:停用1:可用', - `build_in` int(1) NOT NULL COMMENT '可选值:0:非内置1:内置默认:0系统内置一条 email 通知', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of alert_notify_method --- ---------------------------- -INSERT INTO `alert_notify_method` VALUES (1, 'emai', '', 'email', 0, 1); - --- ---------------------------- --- Table structure for alert_rule --- ---------------------------- -DROP TABLE IF EXISTS `alert_rule`; -CREATE TABLE `alert_rule` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键id', - `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '告警名称', - `expr` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '运算表达式', - `last` int(10) NOT NULL, - `summary` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '告警摘要', - `description` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '告警详细描述', - `receiver` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - `build_in` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0\r\n\r\n内置规则不允许编辑删除,系统内置一条 snmptrap 规则', - `operator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '比较符号', - `threshold` double(20, 5) NULL DEFAULT NULL COMMENT '阈值', - `unit` int(10) NOT NULL COMMENT '单位', - `seq` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '导入唯一标识 全局唯一,用于导入撤销', - `severity_id` int(10) NULL DEFAULT NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF', - `method` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'receiver 不为空时,必填', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_severity_id`(`severity_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; - --- ---------------------------- --- Records of alert_rule --- ---------------------------- -INSERT INTO `alert_rule` VALUES (1, 'SNMP TRAP', ' ', 600, NULL, NULL, NULL, '1', '', NULL, 0, NULL, 1, NULL); - --- ---------------------------- --- Table structure for alert_severity_conf --- ---------------------------- -DROP TABLE IF EXISTS `alert_severity_conf`; -CREATE TABLE `alert_severity_conf` ( +DROP TABLE IF EXISTS `alert_rule_sched_log`; +CREATE TABLE `alert_rule_sched_log` ( `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `color` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `weight` int(3) NOT NULL COMMENT '1-100 顺序取值不重复,值越小告警级别越高', - `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `rule_id` int(10) NOT NULL, + `rule_state` int(1) NOT NULL, + `state` int(10) NOT NULL, + `msg` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `ts` bigint(20) NOT NULL, PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of alert_severity_conf --- ---------------------------- -INSERT INTO `alert_severity_conf` VALUES (1, 'P1', '#eb1010', 1, '高级告警'); -INSERT INTO `alert_severity_conf` VALUES (2, 'P2', '#f89984', 2, '中级告警'); -INSERT INTO `alert_severity_conf` VALUES (3, 'P3', '#f7ba78', 3, '低级告警'); - --- ---------------------------- --- Table structure for alert_silence_conf --- ---------------------------- -DROP TABLE IF EXISTS `alert_silence_conf`; -CREATE TABLE `alert_silence_conf` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `matchers` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '记录告警静音原因\r\n\r\n默认:“”', - `start_at` datetime(0) NOT NULL COMMENT '开始时间', - `end_at` datetime(0) NOT NULL COMMENT '结束时间', - `utime` datetime(0) NOT NULL, - `state` int(1) NOT NULL COMMENT '可选值:\r\n\r\n1:active\r\n\r\n2:pending\r\n\r\n3:expired', - `seq` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '全局唯一,用于导入撤销\r\n\r\n默认:“”', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_matchers`(`matchers`(768)) USING BTREE + INDEX `idx_rule_id`(`rule_id`) USING BTREE, + INDEX `idx_state`(`state`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; --- ---------------------------- --- Records of alert_silence_conf --- ---------------------------- - --- ---------------------------- --- Table structure for alert_silence_message_rel --- ---------------------------- -DROP TABLE IF EXISTS `alert_silence_message_rel`; -CREATE TABLE `alert_silence_message_rel` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `silence_conf_id` int(10) NOT NULL, - `message_id` bigint(20) NOT NULL, - `hash_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of alert_silence_message_rel --- ---------------------------- - --- ---------------------------- --- Table structure for asset_asset --- ---------------------------- -DROP TABLE IF EXISTS `asset_asset`; -CREATE TABLE `asset_asset` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '不重复,唯一索引', - `number` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '资产编号', - `sn` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '资产序列号', - `pid` int(10) NOT NULL DEFAULT -1 COMMENT '默认:-1\r\n\r\n只有type vm = 1可以且必须填写此字段,且 pid.type vmh = 1', - `type_id` int(10) NOT NULL, - `state_id` int(10) NOT NULL, - `brand_id` int(10) NOT NULL, - `model_id` int(10) NOT NULL, - `dc_id` int(10) NOT NULL, - `cabinet_id` int(10) NULL DEFAULT NULL, - `cabinet_start` int(10) NULL DEFAULT NULL, - `cabinet_end` int(10) NULL DEFAULT NULL, - `manage_ip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '管理ip', - `purchase_date` date NULL DEFAULT NULL COMMENT '购买日期', - `create_at` datetime(0) NULL DEFAULT NULL COMMENT '添加时间', - `update_at` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', - `create_by` int(10) NULL DEFAULT NULL COMMENT '添加人,与user表关联', - `update_by` int(10) NULL DEFAULT NULL COMMENT '最后更新人', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - `auth_protocol_port` int(10) NULL DEFAULT NULL COMMENT '认证服务端口', - `auth_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '认证方式1:用户名密码\r\n\r\n2:密钥', - `auth_username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户名', - `auth_pin` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码auth_type =1 : 记录登录密码\r\n\r\nauth_type=2 : 记录密钥密码', - `auth_pri_key` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '秘钥', - `auth_user_tip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户名提示 telnet协议有效', - `auth_pin_tip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码提示 telnet协议有效', - `snmp_credential_id` int(10) NULL DEFAULT NULL COMMENT 'snmp凭证id type 开启snmp有效', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_manage_ip`(`manage_ip`) USING BTREE, - INDEX `idx_sn`(`sn`) USING BTREE, - INDEX `idx_type_id`(`type_id`) USING BTREE, - INDEX `idx_state_id`(`state_id`) USING BTREE, - INDEX `idx_brand_id`(`brand_id`) USING BTREE, - INDEX `idx_model_id`(`model_id`) USING BTREE, - INDEX `idx_dc_id`(`dc_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of asset_asset --- ---------------------------- - --- ---------------------------- --- Table structure for asset_brand --- ---------------------------- -DROP TABLE IF EXISTS `asset_brand`; -CREATE TABLE `asset_brand` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '名称', - `remark` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of asset_brand --- ---------------------------- - --- ---------------------------- --- Table structure for asset_feature --- ---------------------------- -DROP TABLE IF EXISTS `asset_feature`; -CREATE TABLE `asset_feature` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `asset_id` int(10) NOT NULL COMMENT '资产id', - `item` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, - `source` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '采集方式,ssh/snmp', - `update_at` datetime(0) NOT NULL COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_asset_id`(`asset_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of asset_feature --- ---------------------------- - --- ---------------------------- --- Table structure for asset_field_group --- ---------------------------- -DROP TABLE IF EXISTS `asset_field_group`; -CREATE TABLE `asset_field_group` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', - `remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', - `build_in` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0\r\n\r\n内置数据不允许删除', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户导入撤销', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of asset_field_group --- ---------------------------- -INSERT INTO `asset_field_group` VALUES (1, 'default', 'Default meta group', '1', ''); - --- ---------------------------- --- Table structure for asset_field_meta --- ---------------------------- -DROP TABLE IF EXISTS `asset_field_meta`; -CREATE TABLE `asset_field_meta` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `meta_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '唯一不重复 正则:[\\w]+', - `group_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '关联 asset_field_group.id', - `search` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '默认:0 0:不可查询\r\n\r\n1:可查询', - `display` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '默认:0 0:列表不展示\r\n\r\n1:列表展示', - `type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'TEXT' COMMENT '属性输入类型', - `remark` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', - `param` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '默认:{}', - `build_in` int(1) NOT NULL DEFAULT 0 COMMENT '1:内置,0:非内置,默认:0', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户导入撤销', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_meta_key`(`meta_key`) USING BTREE, - INDEX `idx_group_id`(`group_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of asset_field_meta --- ---------------------------- - --- ---------------------------- --- Table structure for asset_field_value --- ---------------------------- -DROP TABLE IF EXISTS `asset_field_value`; -CREATE TABLE `asset_field_value` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `asset_id` int(10) NOT NULL COMMENT ' 关联 asset.id', - `meta_id` int(10) NOT NULL COMMENT '关联asset_field_meta.id', - `value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户导入撤销', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_asset_id`(`asset_id`) USING BTREE, - INDEX `idx_meta_id`(`meta_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of asset_field_value --- ---------------------------- - --- ---------------------------- --- Table structure for asset_model --- ---------------------------- -DROP TABLE IF EXISTS `asset_model`; -CREATE TABLE `asset_model` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `brand_id` int(10) NOT NULL, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '型号名称', - `remark` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - `usize` int(2) NOT NULL DEFAULT 1, - `chart_ids` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'chart 模板id', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_brand_id`(`brand_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of asset_model --- ---------------------------- - --- ---------------------------- --- Table structure for asset_ping --- ---------------------------- -DROP TABLE IF EXISTS `asset_ping`; -CREATE TABLE `asset_ping` ( - `host` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ip地址', - `status` int(1) NOT NULL COMMENT '是否可达 可达为1 不可达为0', - `rtt` double(7, 2) NULL DEFAULT NULL COMMENT '传输的时间延迟Round-Trip Time ,单位:ms', - `last_update` datetime(0) NULL DEFAULT NULL COMMENT '最后更新时间', - `asset_id` int(10) NOT NULL, - INDEX `idx_host`(`host`) USING BTREE, - INDEX `idx_status`(`status`) USING BTREE, - INDEX `idx_asset_id`(`asset_id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of asset_ping --- ---------------------------- - --- ---------------------------- --- Table structure for asset_state_conf --- ---------------------------- -DROP TABLE IF EXISTS `asset_state_conf`; -CREATE TABLE `asset_state_conf` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '型号名称', - `ping` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '0:关闭\r\n\r\n1:开启', - `monitor` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '0:关闭\r\n\r\n1:开启', - `alert` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '0:关闭\r\n\r\n1:开启', - `remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '默认“”', - `build_in` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '是否内置1:内置,0:非内置,默认:0\r\n\r\n内置数据不允许删除', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of asset_state_conf --- ---------------------------- -INSERT INTO `asset_state_conf` VALUES (1, 'In use', '1', '1', '1', '', '1'); -INSERT INTO `asset_state_conf` VALUES (2, 'Not in storage', '0', '0', '0', '', '1'); -INSERT INTO `asset_state_conf` VALUES (3, 'Idle', '1', '0', '1', '', '1'); -INSERT INTO `asset_state_conf` VALUES (4, 'Repair', '1', '1', '0', '', '1'); -INSERT INTO `asset_state_conf` VALUES (5, 'Scrapped', '1', '0', '0', '', '1'); - --- ---------------------------- --- Table structure for asset_type_conf --- ---------------------------- -DROP TABLE IF EXISTS `asset_type_conf`; -CREATE TABLE `asset_type_conf` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `pid` int(10) NOT NULL DEFAULT 0 COMMENT '父id 默认为0', - `vm` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '是否为虚拟机 0:不是虚拟机\r\n\r\n1:是虚拟机', - `vmh` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '是否为虚拟机宿主 0:不是宿主机,不支持挂载 虚拟机\r\n\r\n1:是宿主机,支持挂载虚拟机', - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', - `remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', - `build_in` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0\r\n\r\n内置数据不允许删除', - `auth_protocol` int(1) NOT NULL DEFAULT 0 COMMENT '认证协议 默认:0 \r\n\r\n0:无\r\n\r\n1:ssh\r\n\r\n2:telnet', - `snmp_enable` int(1) NOT NULL DEFAULT 0 COMMENT '是否支持snmp 默认:0 \r\n\r\n0:不支持\r\n\r\n1:支持', - `snmp_collect` int(1) NOT NULL DEFAULT 0 COMMENT '是否开启snmp采集 默认:0 \r\n\r\n0:不开启\r\n\r\n1:开启\r\n\r\n当snmp_enable=1时有效', - `ssh_collect` int(1) NOT NULL COMMENT '是否开启ssh采集 默认:0 \r\n\r\n0:不开启\r\n\r\n1:开启\r\n\r\n当 auth_protocol=1时有效', - `ssh_collect_script` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of asset_type_conf --- ---------------------------- -INSERT INTO `asset_type_conf` VALUES (1, 0, '1', '1', 'Network devices', 'Network devices', '1', 2, 1, 1, 1, ''); -INSERT INTO `asset_type_conf` VALUES (2, 0, '0', '0', 'Router', '', '1', 2, 1, 0, 0, ''); -INSERT INTO `asset_type_conf` VALUES (3, 0, '0', '0', 'Firewall', '', '1', 2, 1, 0, 0, ''); -INSERT INTO `asset_type_conf` VALUES (4, 0, '0', '0', 'Switch', '', '1', 2, 1, 0, 0, ''); -INSERT INTO `asset_type_conf` VALUES (5, 0, '0', '1', 'Computer', '', '1', 1, 0, 0, 0, ''); -INSERT INTO `asset_type_conf` VALUES (6, 0, '0', '1', 'Server', '', '1', 1, 0, 0, 0, ''); -INSERT INTO `asset_type_conf` VALUES (7, 0, '1', '0', 'Virtual machine', '', '1', 1, 0, 0, 0, ''); -INSERT INTO `asset_type_conf` VALUES (8, 0, '0', '0', 'ADC', '', '1', 1, 1, 0, 0, ''); - --- ---------------------------- --- Table structure for cabinet --- ---------------------------- -DROP TABLE IF EXISTS `cabinet`; -CREATE TABLE `cabinet` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '机柜名称', - `dc_id` int(11) NOT NULL COMMENT '数据中心id', - `u_size` int(10) NULL DEFAULT NULL COMMENT 'u位容量', - `remark` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', - `seq` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '全局唯一,用于导入撤销', - `x` int(10) NULL DEFAULT NULL COMMENT '在机房的那一列', - `y` int(10) NULL DEFAULT NULL COMMENT '在机房的那一行', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_dc_id`(`dc_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; - --- ---------------------------- --- Records of cabinet --- ---------------------------- - --- ---------------------------- --- Table structure for dc --- ---------------------------- -DROP TABLE IF EXISTS `dc`; -CREATE TABLE `dc` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键自增', - `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称', - `location` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '位置', - `tel` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '联系电话', - `principal` int(10) NULL DEFAULT NULL COMMENT '机房负责人', - `seq` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '全局唯一,用于导入撤销', - `x` int(10) NULL DEFAULT NULL COMMENT '列', - `y` int(10) NULL DEFAULT NULL COMMENT '行', - `longitude` double(8, 5) NULL DEFAULT NULL COMMENT '经度 -180,180', - `latitude` double(8, 5) NULL DEFAULT NULL COMMENT '纬度 -90,90', - `state` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'ON' COMMENT '可选值:ON,OFF 默认:ON', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; - --- ---------------------------- --- Records of dc --- ---------------------------- - --- ---------------------------- --- Table structure for flyway_schema_history --- ---------------------------- -DROP TABLE IF EXISTS `flyway_schema_history`; -CREATE TABLE `flyway_schema_history` ( - `installed_rank` int(11) NOT NULL, - `version` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - `description` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `script` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `checksum` int(11) NULL DEFAULT NULL, - `installed_by` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `installed_on` timestamp(0) NOT NULL DEFAULT current_timestamp(0), - `execution_time` int(11) NOT NULL, - `success` tinyint(1) NOT NULL, - PRIMARY KEY (`installed_rank`) USING BTREE, - INDEX `flyway_schema_history_s_idx`(`success`) USING BTREE +DROP TABLE IF EXISTS `sys_component`; +CREATE TABLE `sys_component` ( + `serverid` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `component` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '组件名称', + `host` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'ip地址', + `port` int(10) NOT NULL COMMENT '端口号', + `protocol` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'http/https', + `utime` bigint(20) NOT NULL COMMENT '最后更新时间', + PRIMARY KEY (`serverid`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -INSERT INTO `flyway_schema_history`(`installed_rank`, `version`, `description`, `type`, `script`, `checksum`, `installed_by`, `installed_on`, `execution_time`, `success`) VALUES (1, '2021.05.14', 'init db', 'SQL', 'V2021.05.14__init db.sql', 1947485866, 'root', '2021-05-12 13:33:32', 23395, 1); +ALTER TABLE `monitor_endpoint_state` DROP PRIMARY KEY; +ALTER TABLE `monitor_endpoint_state` ADD COLUMN `config_id` int(10) NOT NULL AFTER `endpoint_id`; +ALTER TABLE `monitor_endpoint_state` ADD COLUMN `type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'metrics,logs' AFTER `config_id`; +ALTER TABLE `monitor_endpoint_state` ADD COLUMN `ver` int(10) NOT NULL AFTER `state`; +ALTER TABLE `asset_type_conf` ADD COLUMN `client_enable` int(1) NOT NULL DEFAULT 0 COMMENT '默认:0 0:不开启 1:开启'; +ALTER TABLE `asset_asset` ADD COLUMN `client_host` varchar(64) NOT NULL DEFAULT '' COMMENT '默认:“{{asset.manageIp}}”'; +ALTER TABLE `asset_asset` ADD COLUMN `client_port` int(5) NOT NULL DEFAULT 10092 COMMENT '默认:10092'; +ALTER TABLE `asset_asset` ADD COLUMN `client_user` varchar(64) NOT NULL DEFAULT 'nezha' COMMENT '默认:nezha'; +ALTER TABLE `asset_asset` ADD COLUMN `client_pin` varchar(64) NOT NULL DEFAULT 'nezha' COMMENT '默认:nezha'; +ALTER TABLE `asset_asset` ADD COLUMN `client_token` varchar(255) NOT NULL DEFAULT '' COMMENT '默认:""'; +ALTER TABLE `asset_asset` ADD COLUMN `client_enable` int(1) NOT NULL DEFAULT 0 COMMENT '默认:0'; +ALTER TABLE `sys_user` ADD COLUMN `mfa_level` int(1) NOT NULL DEFAULT 0 COMMENT '默认:0,0:关闭,1:开启,2:强制开启' ; +ALTER TABLE `sys_user` ADD COLUMN `otp_key` varchar(255) NOT NULL DEFAULT '' COMMENT 'mfa 私钥'; +ALTER TABLE `sys_user` ADD COLUMN `recovery_code` varchar(1024) NOT NULL DEFAULT '' COMMENT '恢复码' ; +ALTER TABLE `sys_user` ADD COLUMN `pin_time` datetime NOT NULL COMMENT '最后修改密码时间'; +ALTER TABLE `sys_user` MODIFY COLUMN `username` varchar(64) NOT NULL COMMENT '用户名'; +ALTER TABLE `alert_rule` ADD COLUMN `state` int(1) NOT NULL DEFAULT 1 COMMENT '默认:1 0:关闭 1:开启'; +ALTER TABLE `alert_rule` ADD COLUMN `type` int(1) NOT NULL DEFAULT 1 COMMENT '1:Metrics\r\n\r\n2:Logs\r\n\r\n3:SNMP TRAP'; +ALTER TABLE `alert_rule` ADD COLUMN `inr` int(10) NOT NULL DEFAULT 0 COMMENT '默认值:0,单位:s\r\n\r\n不小于 15 \r\n\r\n当 < 15, 则为 Scrape interval '; +ALTER TABLE `alert_rule` ADD COLUMN `timeout` int(10) NOT NULL DEFAULT 0 COMMENT '默认值:0,单位:s\r\n\r\n不小于 15 \r\n\r\n当 < 15, 则为 Scrape timeout'; +ALTER TABLE `alert_rule` ADD COLUMN `auto_expired` int(1) NOT NULL DEFAULT 1 COMMENT '默认:1\r\n1:开启自动失效判断\r\n0:关闭自动失效判断'; +ALTER TABLE `alert_rule` ADD COLUMN `sched_enable` int(1) NOT NULL DEFAULT 0 COMMENT '默认:0\r\n1:开启\r\n0:关闭'; +ALTER TABLE `alert_rule` ADD COLUMN `sched_days` varchar(64) NOT NULL DEFAULT '1,2,3,4,5,6,7' COMMENT '默认:"1,2,3,4,5,6,7"\r\n多个逗号分隔\r\n例:1,2,3,4,5,6,7\r\nsched_enable = 1 时,不能为空'; +ALTER TABLE `alert_rule` ADD COLUMN `sched_stime` varchar(64) NOT NULL DEFAULT '00:00' COMMENT '默认:00:00'; +ALTER TABLE `alert_rule` ADD COLUMN `sched_etime` varchar(64) NOT NULL DEFAULT '23:59' COMMENT '默认:23:59'; +ALTER TABLE `alert_rule` ADD COLUMN `notify_active` int(1) NOT NULL DEFAULT 1 COMMENT 'active通知开关\r\n默认:1\r\n1:开启\r\n0:关闭'; +ALTER TABLE `alert_rule` ADD COLUMN `notify_expired` int(1) NOT NULL DEFAULT 1 COMMENT '默认:1\r\n1:开启\r\n0:关闭'; +ALTER TABLE `alert_rule` ADD COLUMN `trb_shot` text NOT NULL; +update alert_rule set summary = '' where summary is null; +ALTER TABLE `alert_rule` MODIFY COLUMN `summary` varchar(512) NOT NULL DEFAULT '' COMMENT '告警摘要'; +update alert_rule set description = '' where description is null; +ALTER TABLE `alert_rule` MODIFY COLUMN `description` varchar(512) NOT NULL DEFAULT '' COMMENT '告警详细描述'; +update alert_rule set receiver = '' where receiver is null; +ALTER TABLE `alert_rule` MODIFY COLUMN `receiver` varchar(64) NOT NULL DEFAULT ''; +update alert_rule set method = '' where method is null; +ALTER TABLE `alert_rule` MODIFY COLUMN `method` varchar(256) NOT NULL DEFAULT '' COMMENT 'receiver 不为空时,必填'; +update alert_rule set operator = '' where operator is null; +ALTER TABLE `alert_rule` MODIFY COLUMN `operator` varchar(64) CHARACTER SET utf8mb4 NOT NULL DEFAULT '' COMMENT '比较符号'; +ALTER TABLE `alert_rule` MODIFY COLUMN `timeout` int(10) NOT NULL DEFAULT 300 COMMENT '默认值:0,单位:s\r\n\r\n不小于 15 \r\n\r\n当 < 15, 则为 Scrape timeout'; +ALTER TABLE `asset_field_meta` MODIFY COLUMN `remark` varchar(256) NOT NULL DEFAULT ''; +ALTER TABLE `prom_server` ADD COLUMN `protocol` varchar(32) NOT NULL DEFAULT 'http' COMMENT 'https,http'; +ALTER TABLE `visual_chart` ADD COLUMN `x` int(10) NOT NULL DEFAULT 0 COMMENT 'x轴起点'; +ALTER TABLE `visual_chart` ADD COLUMN `y` int(10) NOT NULL DEFAULT 0 COMMENT 'y轴起点'; +ALTER TABLE `sys_user` ADD COLUMN `theme` int(10) NOT NULL DEFAULT 1 COMMENT '主题 默认:1 1: light 2:dark'; +ALTER TABLE `sys_role` MODIFY COLUMN `i18n` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT ''; +ALTER TABLE `dc` MODIFY COLUMN `longitude` double(10, 7) NULL DEFAULT NULL COMMENT '经度 -180,180' AFTER `y`; +ALTER TABLE `dc` MODIFY COLUMN `latitude` double(10, 7) NULL DEFAULT NULL COMMENT '纬度 -90,90' AFTER `longitude`; --- ---------------------------- --- Records of flyway_schema_history --- ---------------------------- --- ---------------------------- --- Table structure for link --- ---------------------------- -DROP TABLE IF EXISTS `link`; -CREATE TABLE `link` ( - `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', - `create_by` int(10) NULL DEFAULT NULL COMMENT '创建人id', - `url` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'url', - `build_in` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0', - `weight` int(10) NOT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; --- ---------------------------- --- Records of link --- ---------------------------- +DELETE from `sys_config` where param_key = "asset_asset_export_header"; +INSERT INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'asset_asset_export_header', '{\"cn\":{\"*资产名称\":\"资产名称,唯一标识(必填) \\n示例: DELL服务器\",\"*SN码\":\"资产序列号,唯一标识(必填) \\n示例: A0420200101\",\"虚拟机宿主\":\"虚拟机宿主,当资产为虚拟机时必填 \\n示例: DELL物理机\",\"*管理ip\":\"主机地址(必填),IP格式 \\n示例: 172.0.0.1\",\"*品牌\":\"品牌(必填) \\n示例: DELL\",\"*型号\":\"型号(必填) \\n示例: DELL-D3\",\"*数据中心\":\"数据中心(必填) \\n示例: 北京电信中心机房\",\"机柜\":\"机柜 \\n示例: cabinet-001\",\"开始U位\":\"机柜开始位置 此信息一般和机柜结束位置联合使用 \\n示例: 1\",\"结束U位\":\"机柜结束位置 此信息一般与机柜开始位置联合使用 \\n示例: 2\",\"*资产状态\":\"资产状态 \\n示例: 在库\",\"*资产类型\":\"资产类型 \\n示例: 服务器\",\"购买日期\":\"购买日期 \\n示例: 2020/2/25\",\"属性信息\":\"资产属性信息,格式: key=value 如需填写多个请使用回车换行 \\n示例: NetworkCard=eth0 \\n user=root\",\"认证服务端口\":\"认证服务端口 \\n示例: 22\",\"认证方式\":\"认证方式,可选值: 1:用户名密码; 2: 密钥 \\n示例: 1\",\"用户名\":\"用户名, \\n示例:root\",\"密码\":\"密码 ,认证方式为1,记录登录密码; 认证方式为2,记录密钥密码. \\n示例: pass\",\"密钥\":\"登录密钥 \\n示例: ssh-rsa CFdv7Jez6K...\",\"用户名提示\":\"TELNET用户名提示 \\n示例: login:\",\"密码提示\":\"TELNET密码提示 \\n示例: pass:\",\"SNMP凭证\":\"snmp凭证名称 \\n实例: system-snmpv2\",\"Talon用户名\":\"Talon用户名 为空时默认:nezha \\n示例: admin\",\"Talon密码\":\"Talon密码 为空时默认:nezha \\n示例: yourpass\",\"Talon管理ip\":\"Talon管理ip 为空时默认:\\\"{{asset.manageIp}}\\\" \\n示例: 127.0.0.1\",\"Talon服务端口\":\"Talon服务端口 为空时默认:10092 \\n示例: 10092\"},\"en\":{\"*Asset Name\":\"Asset name, unique identifier (required) \\nExample: DELL server\",\"*Sn\":\"Asset serial number, unique identifier (required) \\nExample: A0420200101\",\"*Virtual machine host\":\"Virtual machine host, required when the asset is a virtual machine \\nExample: DELL physical machine\",\"*Management ip\":\"Host address (required), IP format \\nExample: 172.0.0.1\",\"*Brand\":\"Brand (required) \\nExample: DELL\",\"*Model\":\"Model (required) \\nExample: DELL-D3\",\"*DC\":\"Data Center (Required) \\nExample: Beijing Telecom Center Computer Room\",\"Cabinet\":\"Cabinet \\nExample: cabinet-001\",\"Cabinet Start\":\"Cabinet start position This information is generally used in conjunction with the cabinet end position \\nExample: 1\",\"Cabinet End\":\"Cabinet end position This information is generally used in conjunction with the cabinet start position \\nExample: 2\",\"*Asset state\":\"Asset status \\nExample: In stock\",\"*Asset type\":\"Asset Type\\nExample: Server\",\"Purchase date\":\"Purchase date \\nExample: 2020/2/25\",\"Field Information\":\"Asset field information, format: key=value If you need to fill in more than one, please use carriage return and line feed \\nExample: NetworkCard=eth0 \\n user=root\",\"Server port\":\"Server port \\nExample: 22\",\"Auth methed\":\"Auth methed,Optional values: 1: username and password; 2: key \\nExample: 1\",\"User name\":\"User name, \\nExample:root\",\"Password\":\"Password ,The auth method is 1, record the login password; the auth method is 2, record the key password. \\nExample: pass\",\"PrivateKey\":\"PrivateKey \\nExample: ssh-rsa CFdv7Jez6K...\",\"User Tip\":\"TELNET username prompt \\nExample: login:\",\"Password Tip\":\"TELNET password prompt \\nExample: pass:\",\"SNMP credential\":\"SNMP credential name \\nExample: system-snmpv2\",\"Talon username\":\"Default when Talon username is empty: nezha \\nExample: nezha\",\"Talon password\":\"Default when Talon password is empty: nezha \\nExample: yourpass\",\"Talon management ip\":\"Default when Talon management ip is empty: \\\"{{asset.manageIp}}\\\" \\nExample: 127.0.0.1\",\"Talon service port\":\"When the Talon service port is empty, the default: 10092 \\nExample: 10092\"}}', 1, 'asset 导入导出表头信息'); --- ---------------------------- --- Table structure for maintenance_record --- ---------------------------- -DROP TABLE IF EXISTS `maintenance_record`; -CREATE TABLE `maintenance_record` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `asset_id` int(10) NULL DEFAULT NULL COMMENT '资产id', - `content` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '维修内容', - `create_at` datetime(0) NULL DEFAULT NULL COMMENT '添加时间', - `create_by` int(10) NULL DEFAULT NULL COMMENT '添加人', - `update_at` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', - `update_by` int(10) NULL DEFAULT NULL COMMENT '更新人', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +DELETE from `sys_config` where param_key = "lokilog_query_max_series"; +DELETE from `sys_config` where param_key = "lokilog_query_node_num"; --- ---------------------------- --- Records of maintenance_record --- ---------------------------- +INSERT INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'lokilog_query_max_series', '-1', 1, 'log 查询最大条数限制,-1代表不做限制'); +INSERT INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'lokilog_query_node_num', '100', 1, 'log节点数量'); --- ---------------------------- --- Table structure for monitor_endpoint --- ---------------------------- -DROP TABLE IF EXISTS `monitor_endpoint`; -CREATE TABLE `monitor_endpoint` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', - `module_id` int(10) NOT NULL, - `asset_id` int(10) NOT NULL, - `configs` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `hash` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计算 moduleId + assetId + host + port + configs 的hash值,用于确保相同配置不重复', - `enabled` int(4) NOT NULL COMMENT '是否启用 可选值\r\n\r\n0:停用\r\n\r\n1:启用', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_module_id`(`module_id`) USING BTREE, - INDEX `idx_asset_id`(`asset_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +DELETE from `sys_config` where param_key = "module_export_header"; +INSERT INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'module_export_header', '{\"cn\":{\"*名称\":\"名称(必填)\\n示例:Basic\",\"*系统\":\"系统名称(必填)\\n示例:System\",\"Endpoint名称模板\":\"Endpoint名称模板 默认 {{asse.host}}-{{module.name}} \\n示例:{{asse.host}}-{{module.name}}\",\"配置\":\"配置信息 JSON 格式 \\n示例:\\\"[{\\\"type\\\":\\\"metrics\\\",\\\"config\\\":{\\\"protocol\\\":\\\"SNMP\\\",\\\"walk\\\":[\\\"1.3.6.1.2.1.1\\\"],\\\"snmpCredentialsId\\\":1,\\\"host\\\":\\\"{{asset.manageIp}}\\\"},\\\"enable\\\":1},{\\\"type\\\":\\\"logs\\\",\\\"enable\\\":1}]\\\"\",\"图表\":\"Endpoint 类型的图表模板 \\n示例:服务器模板,基本模板\",\"描述\":\"描述 \\n示例:Basic\"},\"en\":{\"*Name\":\"Name(Required) \\nExample: Basic\",\"*Project\":\"Project name(Required) \\nExample: System\",\"Endpoint name template\":\"Endpoint name template Default {{asse.host}}-{{module.name}} \\nExample: {{asse.host}}-{{module.name}}\",\"Config\":\"Configuration information JSON format\\nExample:\\\"[{\\\"type\\\":\\\"metrics\\\",\\\"config\\\":{\\\"protocol\\\":\\\"SNMP\\\",\\\" walk\\\":[\\\"1.3.6.1.2.1.1\\\"],\\\"snmpCredentialsId\\\":1,\\\"host\\\":\\\"{{asset.manageIp}}\\\"},\\\"enable\\\" :1},{\\\"type\\\":\\\"logs\\\",\\\"enable\\\":1}]\\\"\",\"Chart templates\":\"Endpoint chart templates \\nExample: Server Template,Basic Template\",\"Description\":\"Description \\nExample: This is basic module\"}}', 1, 'module 导入导出模板'); --- ---------------------------- --- Records of monitor_endpoint --- ---------------------------- +DELETE from `sys_config` where param_key = "loki_query_range_default_limit"; +INSERT INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'loki_query_range_default_limit', '1000', 1, 'LOKI LOG query range 默认 Limit 值 默认 1000'); --- ---------------------------- --- Table structure for monitor_endpoint_state --- ---------------------------- -DROP TABLE IF EXISTS `monitor_endpoint_state`; -CREATE TABLE `monitor_endpoint_state` ( - `endpoint_id` int(10) NOT NULL, - `state` int(4) NOT NULL COMMENT ' ', - `time` datetime(0) NOT NULL, - PRIMARY KEY (`endpoint_id`) USING BTREE, - INDEX `idx_state`(`state`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +DELETE from `sys_config` where param_key = "monitor_endpoint_export_header"; +INSERT INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'monitor_endpoint_export_header', '{\"cn\":{\"*系统\":\"系统名称(必填) \\n示例: Nezha\",\"*组件\":\"组件名称(必填) \\n示例: node_exporter\",\"名称\":\"实例名称 \\n示例: node_exporter\",\"资产名称\":\"资产名称(非必填) 与 主机地址 不能同时为空 \\n示例: A0420200101\",\"配置\":\"实例配置,JSON格式, \\n示例: {\\\"key\\\":\\\"value\\\"}\"},\"en\":{\"*Project Name\":\"Project Name(Required) \\nExample: Nezha\",\"*Module Name\":\"Module Name(Required) \\nExample: node_exporter\",\"Name\":\"Endpoint name \\nExample: node_exporter\",\"Asset Name\":\"Asset name(Not required) And host address cannot be empty at the same time \\n示例: A0420200101\",\"Configs\":\"Endpoint Configs,JSON format, \\nExample: {\\\"key\\\":\\\"value\\\"}\"}}', 1, 'monitor endpoint 导入表头'); --- ---------------------------- --- Records of monitor_endpoint_state --- ---------------------------- +INSERT ignore INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('mfa_auth_enable', '0', 1, '1:开启,0:关闭'); --- ---------------------------- --- Table structure for monitor_event_log --- ---------------------------- -DROP TABLE IF EXISTS `monitor_event_log`; -CREATE TABLE `monitor_event_log` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `event` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '唯一不重复\r\n\r\n包含值:cmd,prometheus,rule,snmp,blackbox', - `counter` int(10) NOT NULL COMMENT '描述信息,update +1', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +truncate monitor_event_log; +INSERT INTO `monitor_event_log`(`id`, `event`, `counter`) VALUES (1, 'blackbox', 0); +INSERT INTO `monitor_event_log`(`id`, `event`, `counter`) VALUES (2, 'prometheus', 0); +INSERT INTO `monitor_event_log`(`id`, `event`, `counter`) VALUES (3, 'rule', 0); +INSERT INTO `monitor_event_log`(`id`, `event`, `counter`) VALUES (4, 'cmd', 0); +INSERT INTO `monitor_event_log`(`id`, `event`, `counter`) VALUES (5, 'snmp', 0); +INSERT INTO `monitor_event_log`(`id`, `event`, `counter`) VALUES (6, 'cortex', 0); +INSERT INTO `monitor_event_log`(`id`, `event`, `counter`) VALUES (7, 'loki', 0); +INSERT INTO `monitor_event_log`(`id`, `event`, `counter`) VALUES (8, 'promtail', 0); --- ---------------------------- --- Records of monitor_event_log --- ---------------------------- -INSERT INTO `monitor_event_log` VALUES (1, 'blackbox', 0); -INSERT INTO `monitor_event_log` VALUES (2, 'prometheus', 0); -INSERT INTO `monitor_event_log` VALUES (3, 'rule', 0); -INSERT INTO `monitor_event_log` VALUES (4, 'cmd', 0); -INSERT INTO `monitor_event_log` VALUES (5, 'snmp', 0); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'rule_export_header', '{\"cn\":{\"*告警规则名称\":\"告警规则名称(必填) \\n示例: cpuAlert\",\"*告警类型\":\"告警类型(必填) 可选:1: Metrics 2:Logs 3:SNMP TRAP \\n示例: 1\",\"执行周期\":\"执行周期 默认值:0,单位:s 不小于 15 当 < 15, 则为 Scrape interval \\n示例: 30\",\"超时时间\":\"执行周期超时时间 默认值:0,单位:s 不小于 15 当 < 15, 则为 Scrape timeout \\n示例: 30\",\"*运算表达式\":\"运算表达式(必填) \\n示例: 100-(avg(irate(node_cpu_seconds_total{mode=\'idle\'}[5m])) by(instance)* 100)\",\"*比较符号\":\"比较符号(必填) 可选: >,<,<=,>=,==,!= \\n示例: >\",\"*阈值\":\"阈值(必填) \\n示例: 10\",\"*单位\":\"单位(必填) 可选: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\n示例: short\",\"*持续时间\":\"持续时间(必填),默认单位(秒) \\n示例:60\",\"*告警级别\":\"告警级别(必填) 可选 P1、P2、P3 \\n示例: P1\",\"*告警摘要\":\"告警摘要(必填) \\n示例: cpu告警\",\"告警详细描述\":\"告警详细描述 \\n示例: cpu使用率超过10%的告警规则\",\"告警通知人\":\"告警通知人,多个使用逗号分隔 \\n示例: admin / admin,root\",\"通知方式\":\"告警通知方式,告警通知人不为空时,必填.多个使用逗号分隔 \\n示例: email / email,telephone\",\"告警状态\":\"告警状态,默认开启 开启:1 关闭:0 \\n示例:1\",\"自动失效\":\"是否自动失效 默认开启 开启:1 关闭:0 \\n示例:1\",\"定时\":\"定时是否开启 默认:关闭 1:开启 0:关闭 \\n示例:1\",\"定时开启定义\":\"定时开启天(星期几)定时开启时必填, 默认:1,2,3,4,5,6,7,多个逗号分隔, 例:1,2,3 \\n示例: 1,2,3,4,6\",\"开始时间\":\"开始时间 定时开启时必填,默认:00:00 \\n示例: 06:30\",\"关闭时间\":\"关闭时间 定时开启时必填,默认:23:59 \\n示例: 20:30\",\"告警激活通知\":\"告警激活通知开关 默认:开启 1:开启 0:关闭 \\n示例:1\",\"告警失效通知\":\"告警失效通知开关 默认:开启 1:开启 0:关闭 \\n示例:1\",\"故障排查\":\"故障排查描述信息 \\n示例:排查日志信息....\"},\"en\":{\"*Alert name\":\"Alert rule name (required) \\nExample: cpuAlert\",\"*Alert type\":\"Alert type (required) option: 1: metrics 2: logs 3: SNMP TRAP \\nExample: 1\",\"Execution cycle\":\"Performance Cycle Default: 0, unit: S is not less than 15 When <15, Scrape Interval \\nExample: 30\",\"Timeout\":\"Perform cycle timeout time default value: 0, unit: S is not less than 15 When <15, SCRAPE TIMEOUT \\nExample: 30\",\"*Expr\":\"Operation expression (required) \\nExample: 100-(avg(irate(node_cpu_seconds_total{mode=\'idle\')[5m])) by(instance)* 100)\",\"*Operator\":\"Operation symbol (required) Optional: >,<,<=,>=,==,!= \\nExample:>\",\"*Threshold\":\"Threshold (required) \\nExample: 10\",\"*Unit\":\"Unit (required) Optional: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\nExample:short\",\"*Last\":\"Last (required), the default unit (seconds) \\nExample: 60\",\"*Severity\":\"Alert severity (required) optional P1, P2, P3 \\nExample: P1\",\"*Summary\":\"Alert summary \\nExample: Cpu warning\",\"Description\":\"Alert description \\nExample: Alarm rule for cpu usage exceeding 10%\",\"Receiver\":\"Alert receiver, separated by commas \\nExample: admin / admin,root\",\"Notification method\":\"Alarm notification method. When the receiver is not empty, it is required. Multiple use commas to separate \\nExample: email / email,telephone\",\"State\":\"Alarm status, the default enablement: 1 Close: 0 \\nExample: 1\",\"Automatic expired\":\"Whether automatic expired defaults to turn on: 1 Turn off: 0 \\nExample: 1\",\"Schedule\":\"schedule to turn on the default: Close 1: Open 0: Close \\nExample: 1\",\"Schedule days config\":\"schedule open day (week) Timer is turned on, default: 1,2,3,4,5,6,7 multiple comma separation \\nExample: 1,2,3,4,6\",\"Schedule start time\":\"Schedule start time is required when schedule is open, Default: 00:00 \\nExample: 06:30\",\"Schedule close time\":\"Schedule close time is required when schedule is open, default: 23: 59 \\nExample: 20:30\",\"Alarm activate notification\":\"Alarm activate notification switch Default: Open 1: Open 0: Close \\nExample: 1\",\"Alarm expired notification\":\"Alarm expired notification Switch Default: Open 1: Open 0: Close \\nExample: 1\",\"Trouble shooting\":\"Trouble shooting Description Information \\nExample: Check Log Information ....\"}}', 1, NULL); +REPLACE INTO `sys_config` VALUES (NULL, 'metrics_query_max_series', '-1', 1, '限制 prometheus query_range 接口 result 数组大小 区间范围[-1 - 1000] -1表示不限制'); +REPLACE INTO `sys_config` VALUES (NULL, 'logs_query_range_default_limit', '1000', 1, 'LOKI LOG query range 默认 Limit 值 默认 1000'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_query_stat_max_points', '100', 1, '日志级别折线图数据点'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_storage_type', '1', 1, '指标存储模式,1: 本地文件存储,2:S3对象存储'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_storage_s3_endpoint', '127.0.0.1:9001', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_storage_s3_bucket', 'cortex-tsdb', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_storage_s3_access_key', 'admin', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_storage_s3_secret_access_key', 'q1234567', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_storage_retention', '30', 1, '指标存储天数,默认30天,单位天'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_storage_local_path', '/opt/nezha/prometheus/data ', 1, '指标本地数据保存路径'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_storage_s3_insecure', 'true', 1, '是否使用https\r\n'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_storage_retention', '7', 1, '日志存储天数,默认7天,单位天'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_storage_type', '1', 1, '日志存储模式,1: 本地文件存储,2:S3对象存储'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_storage_local_path', '/opt/nezha/loki', 1, '日志本地存储路径'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_storage_s3_endpoint', '127.0.0.1:9001', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_storage_s3_bucket', 'loki-tsdb', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_storage_s3_access_key', 'nezha', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_storage_s3_secret_access_key', '12345678', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_storage_s3_insecure', 'true', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_storage_type', '1', 1, '指标存储模式,1: 本地文件存储,2:S3对象存储'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'cortex_yml_tmpl', '{\r\n \"auth_enabled\": false,\r\n \"server\": {\r\n \"http_listen_port\": <#if port?default(\"\")?trim?length gt 0> ${port?c} <#else>10093,\r\n \"grpc_server_max_recv_msg_size\": 104857600,\r\n \"grpc_server_max_send_msg_size\": 104857600,\r\n \"grpc_server_max_concurrent_streams\": 1000\r\n },\r\n \"distributor\": {\r\n \"shard_by_all_labels\": true,\r\n \"pool\": {\r\n \"health_check_ingesters\": true\r\n }\r\n },\r\n \"ingester_client\": {\r\n \"grpc_client_config\": {\r\n \"max_recv_msg_size\": 104857600,\r\n \"max_send_msg_size\": 104857600,\r\n \"grpc_compression\": \"gzip\"\r\n }\r\n },\r\n \"ingester\": {\r\n \"lifecycler\": {\r\n \"id\": \"Ingester ${ip}\",\r\n \"join_after\": \"10s\",\r\n \"min_ready_duration\": \"0s\",\r\n \"final_sleep\": \"5s\",\r\n \"num_tokens\": 512,\r\n \"ring\": {\r\n \"kvstore\": {\r\n \"store\": \"memberlist\"\r\n },\r\n \"replication_factor\": 1\r\n }\r\n }\r\n },\r\n \"memberlist\": {\r\n \"bind_port\": <#if gossIp?default(\"\")?trim?length gt 0>${gossIp?c}<#else>10094,\r\n \"join_members\": [\r\n <#list joinMemberList as joinIp>\r\n \"${joinIp}:<#if gossIp?default(\"\")?trim?length gt 0>${gossIp?c}<#else>10094\"\r\n <#sep>,\r\n \r\n ],\r\n \"abort_if_cluster_join_fails\": false\r\n },\r\n \"querier\": {\r\n \"query_ingesters_within\": \"3h\"\r\n },\r\n \"storage\": {\r\n \"engine\": \"blocks\"\r\n },\r\n \"blocks_storage\": {\r\n \"tsdb\": {\r\n \"dir\": \"/opt/nezha/cortex/tsdb\"\r\n },\r\n \"bucket_store\": {\r\n \"sync_dir\": \"/opt/nezha/cortex/tsdb-sync\"\r\n },\r\n \"backend\": \"s3\",\r\n \"filesystem\": {\r\n \"dir\": \"/opt/nezha/cortex/data/tsdb\"\r\n },\r\n \"s3\": {\r\n \"endpoint\": \"${objectStroageUrl}\",\r\n \"bucket_name\": \"${bucketName}\",\r\n \"access_key_id\": \"${accessKey}\",\r\n \"secret_access_key\": \"${secret}\",\r\n \"insecure\": <#if insecure?default(\"\")?trim?length gt 0>${insecure}<#else>true\r\n }\r\n },\r\n \"store_gateway\": {\r\n \"sharding_enabled\": true,\r\n \"sharding_ring\": {\r\n \"kvstore\": {\r\n \"store\": \"memberlist\"\r\n }\r\n }\r\n },\r\n \"compactor\": {\r\n \"data_dir\": \"/opt/nezha/cortex/compactor\",\r\n \"sharding_ring\": {\r\n \"kvstore\": {\r\n \"store\": \"memberlist\"\r\n }\r\n }\r\n },\r\n \"frontend_worker\": {\r\n \"match_max_concurrent\": true\r\n },\r\n \"ruler\": {\r\n \"enable_api\": true,\r\n \"enable_sharding\": true,\r\n \"rule_path\": \"/opt/nezha/cortex/rules\",\r\n \"ring\": {\r\n \"num_tokens\": 512,\r\n \"kvstore\": {\r\n \"store\": \"memberlist\"\r\n }\r\n }\r\n },\r\n \"ruler_storage\": {\r\n \"backend\": \"local\",\r\n \"local\": {\r\n \"directory\": \"/opt/nezha/cortex/rules\"\r\n }\r\n }\r\n}', 1, 'cortex.yml 配置文件模板'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'loki_yml_tmpl', '{\r\n \"auth_enabled\": false,\r\n \"server\": {\r\n \"http_listen_port\": <#if httpPort?default(\"\")?trim?length gt 0> ${httpPort?c} <#else>13100\r\n },\r\n \"ingester\": {\r\n \"lifecycler\": {\r\n \"ring\": {\r\n \"kvstore\": {\r\n \"store\": \"inmemory\"\r\n },\r\n \"replication_factor\": 1\r\n },\r\n \"final_sleep\": \"0s\"\r\n },\r\n \"chunk_idle_period\": \"5m\",\r\n \"chunk_retain_period\": \"30s\"\r\n },\r\n \"schema_config\": {\r\n \"configs\": [\r\n {\r\n \"from\": \"${schemaConfigFrom}\",\r\n <#if openAws>\r\n \"store\": \"boltdb-shipper\",\r\n \"object_store\": \"aws\",\r\n \"schema\": \"v11\",\r\n \"index\": {\r\n \"prefix\": \"index_\",\r\n \"period\": \"24h\"\r\n }\r\n <#else> \r\n \"store\": \"boltdb\",\r\n \"object_store\": \"filesystem\",\r\n \"schema\": \"v11\",\r\n \"index\": {\r\n \"prefix\": \"index_\",\r\n \"period\": \"${storageRetention}h\"\r\n }\r\n \r\n }\r\n ]\r\n },\r\n<#if openAws>\r\n \"compactor\": {\r\n \"working_directory\": \"/loki/compactor\",\r\n \"shared_store\": \"aws\"\r\n },\r\n \"storage_config\": {\r\n \"boltdb_shipper\": {\r\n \"shared_store\": \"aws\",\r\n \"active_index_directory\": \"/loki/index\",\r\n \"cache_location\": \"/loki/boltdb-cache\"\r\n },\r\n \"aws\": {\r\n \"s3\": \"s3://${accessKey}:${secret}@${objectStroageUrl}/${bucketName}\",\r\n \"s3forcepathstyle\": true,\r\n \"insecure\": <#if insecure?default(\"\")?trim?length gt 0>${insecure}<#else>false\r\n }\r\n }\r\n<#else> \r\n \"storage_config\": {\r\n \"boltdb\": {\r\n \"directory\": \"${storageLocalPath}/index\"\r\n },\r\n \"filesystem\": {\r\n \"directory\": \"${storageLocalPath}/chunks\"\r\n }\r\n },\r\n \"limits_config\": {\r\n \"enforce_metric_name\": false,\r\n \"reject_old_samples\": true,\r\n \"reject_old_samples_max_age\": \"${storageRetention}h\"\r\n },\r\n \"chunk_store_config\": {\r\n \"max_look_back_period\": \"2160h\"\r\n }\r\n\r\n}', 1, 'loki.yml 配置文件模板'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'promtail_yml_tmpl', '{\r\n \"server\": {\r\n \"http_listen_address\": \"127.0.0.1\",\r\n \"http_listen_port\": 19080\r\n },\r\n \"clients\": [\r\n {\r\n <#list clientsMapList as clientMap>\r\n \"url\" : \"${clientMap.url}\",\r\n \"bearer_token\": \"${clientMap.token}\"\r\n <#sep>,\r\n \r\n }\r\n ],\r\n \"positions\": {\r\n \"filename\": \"/tmp/positions.yaml\"\r\n },\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": \"${endpoint.id?c}_${endpoint_index}\",\r\n \"pipeline_stages\": [\r\n <#if endpoint.config.pipeline??&&(endpoint.config.pipeline?size>0)>\r\n <#list endpoint.config.pipeline as pipeline>\r\n {\r\n <#if pipeline.type == \"regex\">\r\n \"regex\": {\r\n \"expression\": \"${pipeline.expression}\",\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"json\">\r\n \"json\": {\r\n \"expressions\": {\r\n <#if pipeline.expressions??&& (pipeline.expressions?size >0)>\r\n <#list pipeline.expressions?keys as key>\r\n \"${key}\":\"${pipeline.expressions[key]}\"\r\n <#sep>,\r\n \r\n \r\n },\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"template\">\r\n \"template\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"template\": \"${pipeline.template}\"\r\n }\r\n \r\n <#if pipeline.type == \"timestamp\">\r\n \"timestamp\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"format\": \"${pipeline.format}\"\r\n }\r\n \r\n <#if pipeline.type == \"labels\"> \r\n \"labels\": { \r\n <#if pipeline.labels??&& (pipeline.labels?size >0)>\r\n <#list pipeline.labels?keys as key>\r\n \"${key}\":\"${pipeline.labels[key]}\"\r\n <#sep>,\r\n \r\n \r\n }\r\n \r\n <#if pipeline.type == \"output\"> \r\n \"output\": {\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ],\r\n <#if endpoint.config.type == \"file\">\r\n \"static_configs\": [\r\n {\r\n \"labels\": {\r\n \"__path__\": \"${endpoint.config.fileName}\",\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n }\r\n }\r\n ]\r\n <#elseif endpoint.config.type == \"syslog\">\r\n \"syslog\": {\r\n \"listen_address\": \"${endpoint.config.listenAddress}\",\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__syslog_message_app_name\"\r\n ],\r\n \"target_label\": \"${endpoint.config.appName}\"\r\n }\r\n ] \r\n <#elseif endpoint.config.type == \"journal\">\r\n \"journal\": {\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__journal__systemd_unit\"\r\n ],\r\n \"target_label\": \"${endpoint.config.unit}\"\r\n }\r\n ] \r\n \r\n }\r\n <#sep>,\r\n \r\n ]\r\n}', 1, 'promtail.yml 配置模板'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n \r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n \r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n <#-- 开启联邦 -->\r\n <#if jobPojo.fedeEnabled>\r\n <#if jobPojo.scrapePing> \r\n \"{job=~\\\"asset_ping_.+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n <#else>\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n <#else>\r\n <#-- 联邦关闭,抓取所有指标即可 -->\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n \r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }<#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n \r\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\r\n ,\r\n \r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n \r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n ]\r\n \r\n <#-- cortex 处理 -->\r\n <#if !isLocalStorage>\r\n ,\r\n \"remote_write\": [\r\n {\r\n \"url\": \"http://127.0.0.1:${agentPort?c}${agentPath}/cortex/proxy/api/v1/push\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${agentToken}\"\r\n }\r\n }\r\n ]\r\n \r\n \r\n \r\n}', 1, 'prometheus config文件模板'); --- ---------------------------- --- Table structure for monitor_module --- ---------------------------- -DROP TABLE IF EXISTS `monitor_module`; -CREATE TABLE `monitor_module` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件名称 唯一索引,表内不重复', - `project_id` int(10) NOT NULL, - `type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '可选值http snmp', - `endpoint_name_tmpl` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'endpoint name模板 支持 {{}} 变量替换,asset,module\r\n\r\n例:{{asset.name}}-{{module.name}}\r\n\r\n最终endpoint的name为: 192.168.40.1-mysql', - `remark` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - `configs` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置参数 ', - `snmp_yml` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'snmp_exporter需要的配置部分', - `chart_ids` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'chart 模板id', - `build_in` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_type`(`type`) USING BTREE, - INDEX `idx_project_id`(`project_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +truncate asset_ping; +truncate monitor_endpoint_state; --- ---------------------------- --- Records of monitor_module --- ---------------------------- +REPLACE INTO `sys_config` VALUES (NULL, 'metrics_query_max_series', '-1', 1, '限制 prometheus query_range 接口 result 数组大小 区间范围[-1 - 1000] -1表示不限制'); +REPLACE INTO `sys_config` VALUES (NULL, 'logs_query_range_default_limit', '1000', 1, 'LOKI LOG query range 默认 Limit 值 默认 1000'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_proxy_push_type', '1', 1, '日志推送模式,1: agent proxy 2:联邦开启模式下,promtail先推送至 agent代理,再push global loki,3:promtail push global loki'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_proxy_push_type', '1', 1, '指标代理模式, 1: 经过 agent 代理推送 cortex 2: 直接推送 cortex'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'promtail_yml_tmpl', '{\r\n \"server\": {\r\n \"http_listen_address\": \"0.0.0.0\",\r\n \"http_listen_port\": 19080,\r\n \"grpc_listen_port\": 19081\r\n },\r\n \"clients\": [\r\n {\r\n <#list clientsMapList as clientMap>\r\n \"url\" : \"${clientMap.url}\",\r\n \"bearer_token\": \"${clientMap.token}\"\r\n <#sep>,\r\n \r\n }\r\n ],\r\n \"positions\": {\r\n \"filename\": \"/tmp/positions.yaml\"\r\n },\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": \"${endpoint.id?c}_${endpoint_index}\",\r\n \"pipeline_stages\": [\r\n <#if endpoint.config.pipeline??&&(endpoint.config.pipeline?size>0)>\r\n <#list endpoint.config.pipeline as pipeline>\r\n {\r\n <#if pipeline.type == \"regex\">\r\n \"regex\": {\r\n \"expression\": \"${pipeline.expression}\",\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"json\">\r\n \"json\": {\r\n \"expressions\": {\r\n <#if pipeline.expressions??&& (pipeline.expressions?size >0)>\r\n <#list pipeline.expressions?keys as key>\r\n \"${key}\":\"${pipeline.expressions[key]}\"\r\n <#sep>,\r\n \r\n \r\n },\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"template\">\r\n \"template\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"template\": \"${pipeline.template}\"\r\n }\r\n \r\n <#if pipeline.type == \"timestamp\">\r\n \"timestamp\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"format\": \"${pipeline.format}\"\r\n }\r\n \r\n <#if pipeline.type == \"labels\"> \r\n \"labels\": { \r\n <#if pipeline.labels??&& (pipeline.labels?size >0)>\r\n <#list pipeline.labels?keys as key>\r\n \"${key}\":\"${pipeline.labels[key]}\"\r\n <#sep>,\r\n \r\n \r\n }\r\n \r\n <#if pipeline.type == \"output\"> \r\n \"output\": {\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ],\r\n <#if endpoint.config.type == \"file\">\r\n \"static_configs\": [\r\n {\r\n \"labels\": {\r\n \"__path__\": \"${endpoint.config.fileName}\",\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n\r\n }\r\n }\r\n ]\r\n <#elseif endpoint.config.type == \"syslog\">\r\n \"syslog\": {\r\n \"listen_address\": \"${endpoint.config.listenAddress}\",\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n\r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__syslog_message_app_name\"\r\n ],\r\n \"target_label\": \"${endpoint.config.appName}\"\r\n }\r\n ] \r\n <#elseif endpoint.config.type == \"journal\">\r\n \"journal\": {\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n\r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__journal__systemd_unit\"\r\n ],\r\n \"target_label\": \"${endpoint.config.unit}\"\r\n }\r\n ] \r\n \r\n }\r\n <#sep>,\r\n \r\n ]\r\n}', 1, 'promtail.yml 配置模板'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n \r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n \r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n <#-- 开启联邦 -->\r\n <#if jobPojo.fedeEnabled>\r\n <#if jobPojo.scrapePing> \r\n \"{job=~\\\"asset_ping_.+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n <#else>\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n <#else>\r\n <#-- 联邦关闭,抓取所有指标即可 -->\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n \r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }<#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n \r\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\r\n ,\r\n \r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n \r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ]\r\n \r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n { \r\n \"url\": <#if metricsProxyPushType == \"1\">\r\n \"http://127.0.0.1:${agentPort?c}${agentPath}/cortex/proxy/api/v1/push\",\r\n <#else>\r\n \"http://127.0.0.1:${cortexDefaultPort?c}/api/v1/push\",\r\n \r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${agentToken}\"\r\n }\r\n }\r\n ]\r\n \r\n \r\n}', 1, 'prometheus config文件模板'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'cortex_yml_tmpl', '{\r\n \"auth_enabled\": false,\r\n \"server\": {\r\n \"http_listen_port\": <#if port?default(\"\")?trim?length gt 0> ${port?c} <#else>10093,\r\n \"grpc_listen_port\":10094,\r\n \"grpc_server_max_recv_msg_size\": 104857600,\r\n \"grpc_server_max_send_msg_size\": 104857600,\r\n \"grpc_server_max_concurrent_streams\": 1000\r\n },\r\n \"distributor\": {\r\n \"shard_by_all_labels\": true,\r\n \"pool\": {\r\n \"health_check_ingesters\": true\r\n }\r\n },\r\n \"ingester_client\": {\r\n \"grpc_client_config\": {\r\n \"max_recv_msg_size\": 104857600,\r\n \"max_send_msg_size\": 104857600,\r\n \"grpc_compression\": \"gzip\"\r\n }\r\n },\r\n <#if isMemberlistStore>\r\n \"ingester\": {\r\n \"lifecycler\": {\r\n \"join_after\": \"10s\",\r\n \"min_ready_duration\": \"0s\",\r\n \"final_sleep\": \"5s\",\r\n \"num_tokens\": 512,\r\n \"ring\": {\r\n \"kvstore\": {\r\n \"store\": \"memberlist\"\r\n }\r\n }\r\n }\r\n },\r\n \"memberlist\": {\r\n \"bind_port\": <#if gossIp?default(\"\")?trim?length gt 0>${gossIp?c}<#else>7946,\r\n \"join_members\": [\r\n <#list joinMemberList as joinIp>\r\n \"${joinIp}:<#if gossIp?default(\"\")?trim?length gt 0>${gossIp?c}<#else>7946\"\r\n <#sep>,\r\n \r\n ],\r\n \"abort_if_cluster_join_fails\": false\r\n },\r\n <#else>\r\n \"ingester\": {\r\n \"lifecycler\": {\r\n \"join_after\": \"10s\",\r\n \"min_ready_duration\": \"0s\",\r\n \"final_sleep\": \"5s\",\r\n \"num_tokens\": 512,\r\n \"ring\": {\r\n \"kvstore\": {\r\n \"store\": \"inmemory\"\r\n },\r\n \"replication_factor\": 1\r\n }\r\n }\r\n },\r\n \r\n \r\n \"storage\": {\r\n \"engine\": \"blocks\"\r\n },\r\n \"blocks_storage\": {\r\n \"tsdb\": {\r\n \"dir\": \"/opt/nezha/cortex/tsdb\"\r\n },\r\n \"bucket_store\": {\r\n \"sync_dir\": \"/opt/nezha/cortex/tsdb-sync\"\r\n },\r\n <#if isLocalStorage>\r\n \"backend\": \"filesystem\",\r\n \"filesystem\": {\r\n \"dir\": \"/opt/nezha/cortex/data/tsdb\"\r\n }\r\n <#else>\r\n \"backend\": \"s3\",\r\n \"s3\": {\r\n \"endpoint\": \"${objectStroageUrl}\",\r\n \"bucket_name\": \"${bucketName}\",\r\n \"access_key_id\": \"${accessKey}\",\r\n \"secret_access_key\": \"${secret}\",\r\n \"insecure\": <#if insecure?default(\"\")?trim?length gt 0>${insecure}<#else>true\r\n }\r\n \r\n },\r\n \"store_gateway\": {\r\n \"sharding_enabled\": true,\r\n \"sharding_ring\": {\r\n \"kvstore\": {\r\n \"store\": <#if isMemberlistStore> \"memberlist\" <#else> \"inmemory\" \r\n }\r\n }\r\n },\r\n \"compactor\": {\r\n \"data_dir\": \"/opt/nezha/cortex/compactor\",\r\n \"sharding_ring\": {\r\n \"kvstore\": {\r\n \"store\": <#if isMemberlistStore> \"memberlist\" <#else> \"inmemory\" \r\n }\r\n }\r\n },\r\n \"frontend_worker\": {\r\n \"match_max_concurrent\": true\r\n },\r\n \"ruler\": {\r\n \"enable_api\": true,\r\n \"enable_sharding\": true,\r\n \"rule_path\": \"/opt/nezha/cortex/rules\",\r\n \"ring\": {\r\n \"num_tokens\": 512,\r\n \"kvstore\": {\r\n \"store\": <#if isMemberlistStore> \"memberlist\" <#else> \"inmemory\" \r\n }\r\n }\r\n }\r\n}', 1, 'cortex.yml 配置文件模板'); --- ---------------------------- --- Table structure for monitor_project --- ---------------------------- -DROP TABLE IF EXISTS `monitor_project`; -CREATE TABLE `monitor_project` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '应用名称', - `remark` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述信息', - `build_in` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '是否内置 1:内置,0:非内置,默认:0', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n \r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n \r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n }\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n <#-- 开启联邦 -->\r\n <#if jobPojo.fedeEnabled>\r\n <#if jobPojo.scrapePing> \r\n \"{job=~\\\"asset_ping_.+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n <#else>\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n <#else>\r\n <#-- 联邦关闭,抓取所有指标即可 -->\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n \r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }<#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n \r\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\r\n ,\r\n \r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n \r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ]\r\n \r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n }\r\n }\r\n <#sep>,\r\n \r\n ] \r\n \r\n}', 1, 'prometheus config文件模板'); --- ---------------------------- --- Records of monitor_project --- ---------------------------- -INSERT INTO `monitor_project` VALUES (1, 'Common', NULL, '1', NULL); --- ---------------------------- --- Table structure for project_topo --- ---------------------------- -DROP TABLE IF EXISTS `project_topo`; -CREATE TABLE `project_topo` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `project_id` int(10) NOT NULL COMMENT 'project id', - `topo` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '拓扑图配置信息', - `update_at` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', - `update_by` int(10) NULL DEFAULT NULL COMMENT '更新人id', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uni_projectid`(`project_id`) USING BTREE COMMENT '唯一索引' -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'asset_asset_export_header', '{\r\n \"cn\": {\r\n \"*资产名称\": \"资产名称,唯一标识(必填) \\n示例: DELL服务器\",\r\n \"*SN码\": \"资产序列号,唯一标识(必填) \\n示例: A0420200101\",\r\n \"虚拟机宿主\": \"虚拟机宿主,当资产为虚拟机时必填 \\n示例: DELL物理机\",\r\n \"*管理ip\": \"主机地址(必填),IP格式 \\n示例: 172.0.0.1\",\r\n \"*品牌\": \"品牌(必填) \\n示例: DELL\",\r\n \"*型号\": \"型号(必填) \\n示例: DELL-D3\",\r\n \"*数据中心\": \"数据中心(必填) \\n示例: 北京电信中心机房\",\r\n \"机柜\": \"机柜 \\n示例: cabinet-001\",\r\n \"开始U位\": \"机柜开始位置 此信息一般和机柜结束位置联合使用 \\n示例: 1\",\r\n \"结束U位\": \"机柜结束位置 此信息一般与机柜开始位置联合使用 \\n示例: 2\",\r\n \"*资产状态\": \"资产状态 \\n示例: 在库\",\r\n \"*资产类型\": \"资产类型 \\n示例: 服务器\",\r\n \"购买日期\": \"购买日期 \\n示例: 2020/2/25\",\r\n \"属性信息\": \"资产属性信息,格式: key=value 如需填写多个请使用回车换行 \\n示例: NetworkCard=eth0 \\n user=root\",\r\n \"认证服务端口\": \"认证服务端口 \\n示例: 22\",\r\n \"认证方式\": \"认证方式,可选值: 1:用户名密码; 2: 密钥 \\n示例: 1\",\r\n \"用户名\": \"用户名, \\n示例:root\",\r\n \"密码\": \"密码 ,认证方式为1,记录登录密码; 认证方式为2,记录密钥密码. \\n示例: pass\",\r\n \"密钥\": \"登录密钥 \\n示例: ssh-rsa CFdv7Jez6K...\",\r\n \"用户名提示\": \"TELNET用户名提示 \\n示例: login:\",\r\n \"密码提示\": \"TELNET密码提示 \\n示例: pass:\",\r\n \"SNMP凭证\": \"snmp凭证名称 \\n实例: system-snmpv2\",\r\n \"Talon用户名\": \"Talon用户名 为空时默认:nezha \\n示例: admin\",\r\n \"Talon密码\": \"Talon密码 为空时默认:nezha \\n示例: yourpass\",\r\n \"Talon令牌\":\"Talon连接令牌, talon 状态开启时必填 \\n示例: e415da63\",\r\n \"Talon服务端口\": \"Talon服务端口 为空时默认:10092 \\n示例: 10092\",\r\n \"Talon开启状态\":\"Talon开启状态 为空时默认为0, 1: 开启 0: 关闭 \\n示例: 1\"\r\n },\r\n \"en\": {\r\n \"*Asset Name\": \"Asset name, unique identifier (required) \\nExample: DELL server\",\r\n \"*Sn\": \"Asset serial number, unique identifier (required) \\nExample: A0420200101\",\r\n \"*Virtual machine host\": \"Virtual machine host, required when the asset is a virtual machine \\nExample: DELL physical machine\",\r\n \"*Management ip\": \"Host address (required), IP format \\nExample: 172.0.0.1\",\r\n \"*Brand\": \"Brand (required) \\nExample: DELL\",\r\n \"*Model\": \"Model (required) \\nExample: DELL-D3\",\r\n \"*DC\": \"Data Center (Required) \\nExample: Beijing Telecom Center Computer Room\",\r\n \"Cabinet\": \"Cabinet \\nExample: cabinet-001\",\r\n \"Cabinet Start\": \"Cabinet start position This information is generally used in conjunction with the cabinet end position \\nExample: 1\",\r\n \"Cabinet End\": \"Cabinet end position This information is generally used in conjunction with the cabinet start position \\nExample: 2\",\r\n \"*Asset state\": \"Asset status \\nExample: In stock\",\r\n \"*Asset type\": \"Asset Type\\nExample: Server\",\r\n \"Purchase date\": \"Purchase date \\nExample: 2020/2/25\",\r\n \"Field Information\": \"Asset field information, format: key=value If you need to fill in more than one, please use carriage return and line feed \\nExample: NetworkCard=eth0 \\n user=root\",\r\n \"Server port\": \"Server port \\nExample: 22\",\r\n \"Auth methed\": \"Auth methed,Optional values: 1: username and password; 2: key \\nExample: 1\",\r\n \"User name\": \"User name, \\nExample:root\",\r\n \"Password\": \"Password ,The auth method is 1, record the login password; the auth method is 2, record the key password. \\nExample: pass\",\r\n \"PrivateKey\": \"PrivateKey \\nExample: ssh-rsa CFdv7Jez6K...\",\r\n \"User Tip\": \"TELNET username prompt \\nExample: login:\",\r\n \"Password Tip\": \"TELNET password prompt \\nExample: pass:\",\r\n \"SNMP credential\": \"SNMP credential name \\nExample: system-snmpv2\",\r\n \"Talon username\": \"Default when Talon username is empty: nezha \\nExample: nezha\",\r\n \"Talon password\": \"Default when Talon password is empty: nezha \\nExample: yourpass\",\r\n \"Talon token\":\"Talon connection token, talon is required to open \\nExample: e415da63\",\r\n \"Talon service port\": \"When the Talon service port is empty, the default: 10092 \\nExample: 10092\",\r\n \"Talon open status\":\"Talon open status Default is 0, 1: Open 0: Close \\nExample: 1\"\r\n }\r\n}', 1, 'asset 导入导出表头信息'); --- ---------------------------- --- Records of project_topo --- ---------------------------- --- ---------------------------- --- Table structure for project_topo_icon --- ---------------------------- -DROP TABLE IF EXISTS `project_topo_icon`; -CREATE TABLE `project_topo_icon` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'icon名称 为空时使用 文件名', - `bytes` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'icon图片字节', - `type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '截取自图片后缀,支持jpg,jpeg,png,gif', - `unit` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'icon组', - `width` int(10) NULL DEFAULT -1 COMMENT '图片宽度 默认:-1 未知', - `height` int(10) NULL DEFAULT -1 COMMENT '图片高度 默认:-1 未知', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'promtail_yml_tmpl', '{\r\n \"server\": {\r\n \"http_listen_address\": \"0.0.0.0\",\r\n \"http_listen_port\": 19080,\r\n \"grpc_listen_port\": 19081\r\n },\r\n \"clients\": [\r\n {\r\n <#list clientsMapList as clientMap>\r\n \"url\" : \"${clientMap.url}\",\r\n \"bearer_token\": \"${clientMap.token}\"\r\n <#sep>,\r\n \r\n }\r\n ],\r\n \"positions\": {\r\n \"filename\": \"/tmp/positions.yaml\"\r\n },\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": \"${endpoint.id?c}_${endpoint_index}\",\r\n \"pipeline_stages\": [\r\n <#if endpoint.config.pipeline??&&(endpoint.config.pipeline?size>0)>\r\n <#list endpoint.config.pipeline as pipeline>\r\n {\r\n <#if pipeline.type == \"regex\">\r\n \"regex\": {\r\n \"expression\": \"${pipeline.expression}\",\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"json\">\r\n \"json\": {\r\n \"expressions\": {\r\n <#if pipeline.expressions??&& (pipeline.expressions?size >0)>\r\n <#list pipeline.expressions?keys as key>\r\n \"${key}\":\"${pipeline.expressions[key]}\"\r\n <#sep>,\r\n \r\n \r\n },\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"template\">\r\n \"template\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"template\": \"${pipeline.template}\"\r\n }\r\n \r\n <#if pipeline.type == \"timestamp\">\r\n \"timestamp\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"format\": \"${pipeline.format}\"\r\n }\r\n \r\n <#if pipeline.type == \"labels\"> \r\n \"labels\": { \r\n <#if pipeline.labels??&& (pipeline.labels?size >0)>\r\n <#list pipeline.labels?keys as key>\r\n \"${key}\":\"${pipeline.labels[key]}\"\r\n <#sep>,\r\n \r\n \r\n }\r\n \r\n <#if pipeline.type == \"output\"> \r\n \"output\": {\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ],\r\n <#if endpoint.config.type == \"file\">\r\n \"static_configs\": [\r\n {\r\n \"labels\": {\r\n \"__path__\": \"${endpoint.config.fileName}\",\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n\r\n }\r\n }\r\n ]\r\n <#elseif endpoint.config.type == \"syslog\">\r\n \"syslog\": {\r\n \"listen_address\": \"${endpoint.config.listenAddress}\",\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n \r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__syslog_message_app_name\"\r\n ],\r\n \"target_label\": \"${endpoint.config.appName}\"\r\n }\r\n ] \r\n <#elseif endpoint.config.type == \"journal\">\r\n \"journal\": {\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n\r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__journal__systemd_unit\"\r\n ],\r\n \"target_label\": \"${endpoint.config.unit}\"\r\n }\r\n ] \r\n \r\n }\r\n <#sep>,\r\n \r\n ]\r\n}', 1, 'promtail.yml 配置模板'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n \r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n \r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n }\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n <#-- 开启联邦 -->\r\n <#if jobPojo.fedeEnabled>\r\n <#if jobPojo.scrapePing> \r\n \"{job=~\\\"asset_ping_.+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n <#else>\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n <#else>\r\n <#-- 联邦关闭,抓取所有指标即可 -->\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n \r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }<#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n \r\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\r\n ,\r\n \r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n \r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ]\r\n \r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n }\r\n }\r\n <#sep>,\r\n \r\n ] \r\n \r\n}', 1, 'prometheus config文件模板'); --- ---------------------------- --- Records of project_topo_icon --- ---------------------------- -INSERT INTO `project_topo_icon` VALUES (1, 'common', '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', 'png', '', -1, -1); -INSERT INTO `project_topo_icon` VALUES (2, 'mysql', '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', 'png', '', -1, -1); -INSERT INTO `project_topo_icon` VALUES (3, 'oracle', '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', 'png', '', -1, -1); -INSERT INTO `project_topo_icon` VALUES (4, 'redis', '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', 'png', '', -1, -1); --- ---------------------------- --- Table structure for prom_server --- ---------------------------- -DROP TABLE IF EXISTS `prom_server`; -CREATE TABLE `prom_server` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键id', - `dc_id` int(11) NOT NULL COMMENT '数据中心id', - `host` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '部署ip', - `port` int(10) NOT NULL DEFAULT 9090 COMMENT '端口 默认9090', - `type` int(10) NOT NULL COMMENT '1:global,负责汇聚所有per-datacenter采集的数据及告警配置\r\n\r\n2:per-datacenter,负责根据exporter配置采集监测数据', - `status` int(1) NOT NULL DEFAULT 0, - `check_time` datetime(1) NULL DEFAULT NULL COMMENT '最后操作时间', - `status_info` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '', - `token` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_type`(`type`) USING BTREE, - INDEX `idx_port`(`port`) USING BTREE, - INDEX `idx_host`(`host`) USING BTREE, - INDEX `idx_dc_id`(`dc_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'promtail_yml_tmpl', '{\r\n \"server\": {\r\n \"http_listen_address\": \"0.0.0.0\",\r\n \"http_listen_port\": 19080,\r\n \"grpc_listen_port\": 19081\r\n },\r\n \"clients\": [\r\n {\r\n <#list clientsMapList as clientMap>\r\n \"url\" : \"${clientMap.url}\",\r\n \"bearer_token\": \"${clientMap.token}\"\r\n <#sep>,\r\n \r\n }\r\n ],\r\n \"positions\": {\r\n \"filename\": \"/tmp/positions.yaml\"\r\n },\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": \"${endpoint.id?c}_${endpoint_index}\",\r\n \"pipeline_stages\": [\r\n <#if endpoint.config.pipeline??&&(endpoint.config.pipeline?size>0)>\r\n <#list endpoint.config.pipeline as pipeline>\r\n {\r\n <#if pipeline.type == \"regex\">\r\n \"regex\": {\r\n \"expression\": \"${pipeline.expression}\",\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"json\">\r\n \"json\": {\r\n \"expressions\": {\r\n <#if pipeline.expressions??&& (pipeline.expressions?size >0)>\r\n <#list pipeline.expressions?keys as key>\r\n \"${key}\":\"${pipeline.expressions[key]}\"\r\n <#sep>,\r\n \r\n \r\n },\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"template\">\r\n \"template\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"template\": \"${pipeline.template}\"\r\n }\r\n \r\n <#if pipeline.type == \"timestamp\">\r\n \"timestamp\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"format\": \"${pipeline.format}\"\r\n }\r\n \r\n <#if pipeline.type == \"labels\"> \r\n \"labels\": { \r\n <#if pipeline.labels??&& (pipeline.labels?size >0)>\r\n <#list pipeline.labels?keys as key>\r\n \"${key}\":\"${pipeline.labels[key]}\"\r\n <#sep>,\r\n \r\n \r\n }\r\n \r\n <#if pipeline.type == \"output\"> \r\n \"output\": {\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ],\r\n <#if endpoint.config.type == \"file\">\r\n \"static_configs\": [\r\n {\r\n \"labels\": {\r\n \"__path__\": \"${endpoint.config.fileName}\",\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n\r\n }\r\n }\r\n ]\r\n <#elseif endpoint.config.type == \"syslog\">\r\n \"syslog\": {\r\n \"listen_address\": \"${endpoint.config.listenAddress}\",\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n \r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__syslog_message_app_name\"\r\n ],\r\n \"regex\":\"${endpoint.config.appName}\",\r\n \"action\":\"keep\"\r\n },\r\n {\r\n \"source_labels\": [\r\n \"__syslog_message_app_name\"\r\n ],\r\n \"target_label\": \"appName\"\r\n }\r\n ] \r\n <#elseif endpoint.config.type == \"journal\">\r\n \"journal\": {\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n\r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__journal__systemd_unit\"\r\n ],\r\n \"regex\":\"${endpoint.config.unit}\",\r\n \"action\":\"keep\"\r\n },\r\n {\r\n \"source_labels\": [\r\n \"__journal__systemd_unit\"\r\n ],\r\n \"target_label\": \"unit\"\r\n }\r\n ] \r\n \r\n }\r\n <#sep>,\r\n \r\n ]\r\n}', 1, 'promtail.yml 配置模板'); --- ---------------------------- --- Records of prom_server --- ---------------------------- --- ---------------------------- --- Table structure for snmp_credential --- ---------------------------- -DROP TABLE IF EXISTS `snmp_credential`; -CREATE TABLE `snmp_credential` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', - `remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述信息', - `type` int(1) NOT NULL COMMENT '1,2,3 -- > V1,V2,V3 创建人id', - `config` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '具体配置', - `port` int(1) NOT NULL DEFAULT 161 COMMENT '端口号 默认161', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'rule_export_header', '{\"cn\":{\"*告警规则名称\":\"告警规则名称(必填) \\n示例: cpuAlert\",\"*运算表达式\":\"运算表达式(必填) \\n示例: 100-(avg(irate(node_cpu_seconds_total{mode=\'idle\'}[5m])) by(instance)* 100)\",\"*比较符号\":\"比较符号(必填) 可选: >,<,<=,>=,==,!= \\n示例: >\",\"*阈值\":\"阈值(必填) \\n示例: 10\",\"*单位\":\"单位(必填) 可选: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\n示例: short\",\"*持续时间\":\"持续时间(必填),默认单位(秒) \\n示例:60\",\"*告警级别\":\"告警级别(必填) 可选 P1、P2、P3 \\n示例: P1\",\"*告警摘要\":\"告警摘要(必填) \\n示例: cpu告警\",\"告警详细描述\":\"告警详细描述 \\n示例: cpu使用率超过10%的告警规则\",\"告警通知人\":\"告警通知人,多个使用逗号分隔 \\n示例: admin / admin,root\",\"通知方式\":\"告警通知方式,告警通知人不为空时,必填.多个使用逗号分隔 \\n示例: email / email,telephone\",\"告警状态\":\"告警状态,默认开启 开启:1 关闭:0 \\n示例:1\"},\"en\":{\"*AlertName\":\"Alert rule name (required) \\nExample: cpuAlert\",\"*Expr\":\"Operation expression (required) \\nExample: 100-(avg(irate(node_cpu_seconds_total{mode=\'idle\')[5m])) by(instance)* 100)\",\"*Operator\":\"Operation symbol (required) Optional: >,<,<=,>=,==,!= \\nExample:>\",\"*Threshold\":\"Threshold (required) \\nExample: 10\",\"*Unit\":\"Unit (required) Optional: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\nExample:short\",\"*Last\":\"Last (required), the default unit (seconds) \\nExample: 60\",\"*Severity\":\"Alert severity (required) optional P1, P2, P3 \\nExample: P1\",\"*Summary\":\"Alert summary \\nExample: Cpu warning\",\"Description\":\"Alert description \\nExample: Alarm rule for cpu usage exceeding 10%\",\"Receiver\":\"Alert receiver, separated by commas \\nExample: admin / admin,root\",\"Notification method\":\"Alarm notification method. When the receiver is not empty, it is required. Multiple use commas to separate \\nExample: email / email,telephone\",\"State\":\"Alarm status, the default enablement: 1 Close: 0 \\nExample: 1\"}}', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'cortex_yml_tmpl', '{\r\n \"auth_enabled\": false,\r\n \"server\": {\r\n \"http_listen_port\": <#if port?default(\"\")?trim?length gt 0> ${port?c} <#else>10093,\r\n \"grpc_listen_port\":10094,\r\n \"grpc_server_max_recv_msg_size\": 104857600,\r\n \"grpc_server_max_send_msg_size\": 104857600,\r\n \"grpc_server_max_concurrent_streams\": 1000\r\n },\r\n \"distributor\": {\r\n \"shard_by_all_labels\": true,\r\n \"pool\": {\r\n \"health_check_ingesters\": true\r\n }\r\n },\r\n \"ingester_client\": {\r\n \"grpc_client_config\": {\r\n \"max_recv_msg_size\": 104857600,\r\n \"max_send_msg_size\": 104857600,\r\n \"grpc_compression\": \"gzip\"\r\n }\r\n },\r\n <#if isMemberlistStore>\r\n \"ingester\": {\r\n \"lifecycler\": {\r\n \"join_after\": \"10s\",\r\n \"min_ready_duration\": \"0s\",\r\n \"final_sleep\": \"5s\",\r\n \"num_tokens\": 512,\r\n \"ring\": {\r\n \"kvstore\": {\r\n \"store\": \"memberlist\"\r\n },\r\n \"replication_factor\": 1\r\n }\r\n }\r\n },\r\n \"memberlist\": {\r\n \"bind_port\": <#if gossIp?default(\"\")?trim?length gt 0>${gossIp?c}<#else>7946,\r\n \"join_members\": [\r\n <#list joinMemberList as joinIp>\r\n \"${joinIp}:<#if gossIp?default(\"\")?trim?length gt 0>${gossIp?c}<#else>7946\"\r\n <#sep>,\r\n \r\n ],\r\n \"abort_if_cluster_join_fails\": false\r\n },\r\n <#else>\r\n \"ingester\": {\r\n \"lifecycler\": {\r\n \"join_after\": \"10s\",\r\n \"min_ready_duration\": \"0s\",\r\n \"final_sleep\": \"5s\",\r\n \"num_tokens\": 512,\r\n \"ring\": {\r\n \"kvstore\": {\r\n \"store\": \"inmemory\"\r\n },\r\n \"replication_factor\": 1\r\n }\r\n }\r\n },\r\n \r\n \r\n \"storage\": {\r\n \"engine\": \"blocks\"\r\n },\r\n \"blocks_storage\": {\r\n \"tsdb\": {\r\n \"dir\": \"/opt/nezha/cortex/tsdb\"\r\n },\r\n \"bucket_store\": {\r\n \"sync_dir\": \"/opt/nezha/cortex/tsdb-sync\"\r\n },\r\n <#if isLocalStorage>\r\n \"backend\": \"filesystem\",\r\n \"filesystem\": {\r\n \"dir\": \"/opt/nezha/cortex/data/tsdb\"\r\n }\r\n <#else>\r\n \"backend\": \"s3\",\r\n \"s3\": {\r\n \"endpoint\": \"${objectStroageUrl}\",\r\n \"bucket_name\": \"${bucketName}\",\r\n \"access_key_id\": \"${accessKey}\",\r\n \"secret_access_key\": \"${secret}\",\r\n \"insecure\": <#if insecure?default(\"\")?trim?length gt 0>${insecure}<#else>true\r\n }\r\n \r\n },\r\n \"store_gateway\": {\r\n \"sharding_enabled\": true,\r\n \"sharding_ring\": {\r\n \"kvstore\": {\r\n \"store\": <#if isMemberlistStore> \"memberlist\" <#else> \"inmemory\" \r\n }\r\n }\r\n },\r\n \"compactor\": {\r\n \"data_dir\": \"/opt/nezha/cortex/compactor\",\r\n \"sharding_ring\": {\r\n \"kvstore\": {\r\n \"store\": <#if isMemberlistStore> \"memberlist\" <#else> \"inmemory\" \r\n }\r\n }\r\n },\r\n \"frontend_worker\": {\r\n \"match_max_concurrent\": true\r\n },\r\n \r\n <#if isAlert>\r\n \"ruler\": {\r\n \"enable_api\": true,\r\n \"enable_sharding\": true,\r\n \"rule_path\": \"/opt/nezha/cortex/rules\",\r\n \"ring\": {\r\n \"num_tokens\": 512,\r\n \"kvstore\": {\r\n \"store\": <#if isMemberlistStore> \"memberlist\" <#else> \"inmemory\" \r\n }\r\n },\r\n \"alertmanager_url\":\"http://${systemConfig.alert_api}${systemConfig.alert_path_prefix}\"\r\n },\r\n \"ruler_storage\":{\r\n \"backend\":\"local\",\r\n \"local\":{\r\n \"directory\":\"/opt/nezha/cortex/rules\"\r\n }\r\n },\r\n \r\n \"limits\":{\r\n \"max_series_per_metric\": 500000000\r\n },\r\n \"api\":{\r\n \"alertmanager_http_prefix\":\"/\"\r\n }\r\n}', 1, 'cortex.yml 配置文件模板'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n \r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n <#if jobPojo.instanceRelabel> \r\n {\r\n \"source_labels\": [\r\n \"instance\"\r\n ],\r\n \"regex\": \"(.+)\",\r\n \"target_label\": \"target\"\r\n }\r\n <#else>\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }<#sep>,\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n \r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"queue_config\":{\r\n \"capacity\":10,\r\n \"max_shards\":10\r\n }\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n <#-- 开启联邦 -->\r\n <#if jobPojo.fedeEnabled>\r\n <#if jobPojo.scrapePing> \r\n \"{job=~\\\"asset_ping_.+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n <#else>\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n <#else>\r\n <#-- 联邦关闭,抓取所有指标即可 -->\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n \r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n <#if jobPojo.instanceRelabel> \r\n {\r\n \"source_labels\": [\r\n \"instance\"\r\n ],\r\n \"regex\": \"(.+)\",\r\n \"target_label\": \"target\"\r\n }\r\n <#else>\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }<#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n \r\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\r\n ,\r\n \r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n \r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ]\r\n \r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"queue_config\":{\r\n \"capacity\":10,\r\n \"max_shards\":10\r\n }\r\n }\r\n <#sep>,\r\n \r\n ] \r\n \r\n}', 1, 'prometheus config文件模板'); --- ---------------------------- --- Records of snmp_credential --- ---------------------------- +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n \r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ]\r\n }<#sep>,\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n \r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"queue_config\":{\r\n \"capacity\":10,\r\n \"max_shards\":10\r\n }\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n <#-- 开启联邦 -->\r\n <#if jobPojo.fedeEnabled>\r\n <#if jobPojo.scrapePing> \r\n \"{job=~\\\"asset_ping_.+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n <#else>\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n <#else>\r\n <#-- 联邦关闭,抓取所有指标即可 -->\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n \r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ]\r\n }<#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n \r\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\r\n ,\r\n \r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n \r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ]\r\n \r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"queue_config\":{\r\n \"capacity\":10,\r\n \"max_shards\":10\r\n }\r\n }\r\n <#sep>,\r\n \r\n ] \r\n \r\n}', 1, 'prometheus config文件模板'); --- ---------------------------- --- Table structure for snmp_mib --- ---------------------------- -DROP TABLE IF EXISTS `snmp_mib`; -CREATE TABLE `snmp_mib` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键id', - `name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'mib文件名称,默认去掉后缀', - `file_name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '二进制文件名称', - `content` mediumblob NOT NULL COMMENT 'mib二进制文件', - `models` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '为空时:所有型号适用\r\n\r\n不为空时:可关联多个型号,用逗号分隔,如:1,2,3', - `remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '备注', - `update_by` int(10) NULL DEFAULT NULL COMMENT '更新人', - `update_at` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', - `tree` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'MIB文件解析tree', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +DELETE from sys_dict where type = "chartType" and value = "logs"; +INSERT INTO `sys_dict`(`id`, `name`, `type`, `code`, `value`, `i18n_code`, `order_num`, `remark`, `del_flag`, `operator`, `op_time`, `seq`) VALUES (NULL, '图表类型', 'chartType', 12, 'logs', '', 0, 'logs图表', 0, 1, '2021-06-24 17:53:19', NULL); --- ---------------------------- --- Records of snmp_mib --- ---------------------------- --- ---------------------------- --- Table structure for sys_api_key --- ---------------------------- -DROP TABLE IF EXISTS `sys_api_key`; -CREATE TABLE `sys_api_key` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称 唯一不重复', - `token` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密钥 唯一不重复', - `role_id` int(10) NOT NULL COMMENT '角色id', - `create_by` int(10) NOT NULL COMMENT '创建用户', - `create_at` datetime(0) NOT NULL COMMENT '创建时间', - `expire_at` datetime(0) NULL DEFAULT NULL COMMENT '失效时间 为空不失效', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_role_id`(`role_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'chart_export_header', '{\"cn\":{\"*面板\":\"面板名称(必填) \\n示例: 系统面板/主面板 (使用 / 作为字符分隔,表示 父子节点关系)\",\"图表组名\":\"组名 \\n示例: default\",\"*图表名称\":\"图表名称(必填) \\n示例: CPU使用率\",\"*图表类型\":\"图表类型(必填) 可选: 曲线图,柱状图,表格,堆叠区域图,SingleStat,URL,告警列表,文本,图表组,Diagram,Logs \\n示例: 曲线图\",\"*宽度\":\"宽度(必填) 可选:1-12 \\n示例: 10\",\"*高度\":\"高度(必填),可选:1-12 \\n示例: 10\",\"单位\":\"单位(必填) 可选: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\n示例: short\",\"*参数\":\"单位 根据type不同,内容不同,格式为JSON格式 \\n示例: {\\\"statistics\\\":\\\"average\\\"}\",\"元素\":\"当type=line,bar,stackArea时,包含 elements key,值为对象数组。\\n 示例:[{\\\"expression\\\":\\\"sum(up)\\\",\\\"legend\\\":\\\"test\\\"}]\"},\"en\":{\"*Panel Name\":\"Panel(Required) \\nExample: System panel/Main panel (use / as a character separation to indicate the relationship between parent and child nodes)\",\"Chart Group\":\"Group name \\nExample: default\",\"*Chart Title\":\"Chart title(Required) \\nExample: CPU usage\",\"*Chart Type\":\"Chart type(Required) Optional: Line Chart,Histogram,Table,Stack Area,SingleStat,URL,Alert list,Text,Group,Diagram,Logs \\nExample: Line Chart\",\"*Width\":\"width(Required) Optional:1-12 \\nExample: 10\",\"*Height\":\"height(Required) Optional:1-12 \\nExample: 10\",\"Unit\":\"unit(Required) Optional: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\nExample: short\",\"*Parameter\":\"Parameters match type,The format is JSON format \\nExample: {\\\"statistics\\\":\\\"average\\\"}\",\"Elements\":\"When the type is line, table, stackArea, singleStat, histogram, it contains elements key and the value is an object array.\\nExample:[{\\\"expression\\\":\\\"sum(up)\\\",\\\"legend\\\":\\\"test\\\"}]\"}}', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'asset_chart_export_header', '{\"cn\":{\"图表组名\":\"组名 \\n示例: default\",\"*图表名称\":\"图表名称(必填) \\n示例: CPU使用率\",\"*图表类型\":\"图表类型(必填) 可选: 曲线图,柱状图,表格,堆叠区域图,SingleStat,URL,告警列表,文本,图表组,Diagram,Logs \\n示例: 曲线图\",\"变量类型\":\"变量类型 当类型是 template 时必填,可选:Asset,Endpoint \\n示例: Asset\",\"*宽度\":\"宽度(必填) 可选:1-12 \\n示例: 10\",\"*高度\":\"高度(必填),可选:1-12 \\n示例: 10\",\"单位\":\"单位(必填) 可选: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\n示例: short\",\"*参数\":\"单位 根据type不同,内容不同,格式为JSON格式 \\n示例: {\\\"statistics\\\":\\\"average\\\"}\",\"元素\":\"当type=line,bar,stackArea时,包含 elements key,值为对象数组。\\n 示例:[{\\\"expression\\\":\\\"sum(up)\\\",\\\"legend\\\":\\\"test\\\"}]\"},\"en\":{\"Chart Group\":\"Group name \\nExample: default\",\"*Chart Title\":\"Chart title(Required) \\nExample: CPU usage\",\"*Chart Type\":\"Chart type(Required) Optional: Line Chart,Histogram,Table,Stack Area,SingleStat,URL,Alert list,Text,Group,Diagram,Logs \\nExample: Line Chart\",\"Variable type\":\"Variable type Required when type is template, optional: Asset, Endpoint \\nExample: Asset\",\"*Width\":\"width(Required) Optional:1-12 \\nExample: 10\",\"*Height\":\"height(Required),Optional:1-12 \\nExample: 10\",\"Unit\":\"unit(Required) Optional: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\nExample: short\",\"*Parameter\":\"Parameters match type,The format is JSON format \\nExample: {\\\"statistics\\\":\\\"average\\\"}\",\"Elements\":\"When the type is line, table, stackArea, singleStat, histogram, it contains elements key and the value is an object array.\\nExample:[{\\\"expression\\\":\\\"sum(up)\\\",\\\"legend\\\":\\\"test\\\"}]\"}}', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'i18n_mapping', '{\"chartType\":{\"en\":{\"line\":\"Line Chart\",\"bar\":\"Histogram\",\"table\":\"Table\",\"stackArea\":\"Stack Area\",\"singleStat\":\"SingleStat\",\"url\":\"URL\",\"alertList\":\"Alert list\",\"text\":\"Text\",\"group\":\"Group\",\"pie\":\"Pie\",\"diagram\":\"Diagram\",\"logs\":\"Logs\"},\"cn\":{\"line\":\"曲线图\",\"bar\":\"柱状图\",\"table\":\"表格\",\"stackArea\":\"堆叠区域图\",\"singleStat\":\"SingleStat\",\"url\":\"URL\",\"alertList\":\"告警列表\",\"text\":\"文本\",\"group\":\"图表组\",\"pie\":\"饼图\",\"diagram\":\"Diagram\",\"logs\":\"Logs\"}}}', 1, NULL); --- ---------------------------- --- Records of sys_api_key --- ---------------------------- +UPDATE `alert_rule` SET `name` = 'Default snmptrap', `expr` = '1.3.6.1', `last` = 3600, `summary` = '{{$message}}', `description` = '{{$variables}}', `receiver` = '', `build_in` = '0', `operator` = '', `threshold` = NULL, `unit` = 0, `seq` = NULL, `severity_id` = 3, `method` = '', `state` = 1, `type` = 3, `inr` = 0, `timeout` = 0 WHERE `id` = 1; --- ---------------------------- --- Table structure for sys_config --- ---------------------------- -DROP TABLE IF EXISTS `sys_config`; -CREATE TABLE `sys_config` ( - `id` bigint(19) NOT NULL AUTO_INCREMENT, - `param_key` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'key', - `param_value` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, - `status` tinyint(4) NULL DEFAULT 1 COMMENT '状态 0:隐藏 1:显示', - `remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `param_key`(`param_key`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 229 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统配置表' ROW_FORMAT = Compact; +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'rule_export_header', '{\"cn\":{\"*告警规则名称\":\"告警规则名称(必填) \\n示例: cpuAlert\",\"*告警类型\":\"告警类型(必填) 可选:1: Metrics 2:Logs 3:SNMP TRAP \\n示例: 1\",\"执行周期\":\"执行周期 默认值:0,单位:s 不小于 15 当 < 15, 则为 Scrape interval \\n示例: 30\",\"超时时间\":\"执行周期超时时间 默认值:0,单位:s 不小于 15 当 < 15, 则为 Scrape timeout \\n示例: 30\",\"*运算表达式\":\"运算表达式(必填) \\n示例: 100-(avg(irate(node_cpu_seconds_total{mode=\'idle\'}[5m])) by(instance)* 100)\",\"*比较符号\":\"比较符号(必填) 可选: >,<,<=,>=,==,!= \\n示例: >\",\"*阈值\":\"阈值(必填) \\n示例: 10\",\"*单位\":\"单位(必填) 可选: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\n示例: short\",\"*持续时间\":\"持续时间(必填),默认单位(秒) \\n示例:60\",\"*告警级别\":\"告警级别(必填) 可选 P1、P2、P3 \\n示例: P1\",\"*告警摘要\":\"告警摘要(必填) \\n示例: cpu告警\",\"告警详细描述\":\"告警详细描述 \\n示例: cpu使用率超过10%的告警规则\",\"告警通知人\":\"告警通知人,多个使用逗号分隔 \\n示例: admin / admin,root\",\"通知方式\":\"告警通知方式,告警通知人不为空时,必填.多个使用逗号分隔 \\n示例: email / email,telephone\",\"告警状态\":\"告警状态,默认开启 开启:1 关闭:0 \\n示例:1\"},\"en\":{\"*Alert name\":\"Alert rule name (required) \\nExample: cpuAlert\",\"*Alert type\":\"Alert type (required) option: 1: metrics 2: logs 3: SNMP TRAP \\nExample: 1\",\"Execution cycle\":\"Performance Cycle Default: 0, unit: S is not less than 15 When <15, Scrape Interval \\nExample: 30\",\"Timeout\":\"Perform cycle timeout time default value: 0, unit: S is not less than 15 When <15, SCRAPE TIMEOUT \\nExample: 30\",\"*Expr\":\"Operation expression (required) \\nExample: 100-(avg(irate(node_cpu_seconds_total{mode=\'idle\')[5m])) by(instance)* 100)\",\"*Operator\":\"Operation symbol (required) Optional: >,<,<=,>=,==,!= \\nExample:>\",\"*Threshold\":\"Threshold (required) \\nExample: 10\",\"*Unit\":\"Unit (required) Optional: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\nExample:short\",\"*Last\":\"Last (required), the default unit (seconds) \\nExample: 60\",\"*Severity\":\"Alert severity (required) optional P1, P2, P3 \\nExample: P1\",\"*Summary\":\"Alert summary \\nExample: Cpu warning\",\"Description\":\"Alert description \\nExample: Alarm rule for cpu usage exceeding 10%\",\"Receiver\":\"Alert receiver, separated by commas \\nExample: admin / admin,root\",\"Notification method\":\"Alarm notification method. When the receiver is not empty, it is required. Multiple use commas to separate \\nExample: email / email,telephone\",\"State\":\"Alarm status, the default enablement: 1 Close: 0 \\nExample: 1\"}}', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'nz_alert_rule_eval_enable', '1', 1, 'nzweb 支持告警开关 默认为1 , 1:nzweb 支持告警 0:cortex 支持告警'); --- ---------------------------- --- Records of sys_config --- ---------------------------- -INSERT INTO `sys_config` VALUES (3, 'alert_api', '', 1, 'alert api 地址'); -INSERT INTO `sys_config` VALUES (4, 'alert_path_prefix', '', 1, '告警推送请求前缀'); -INSERT INTO `sys_config` VALUES (5, 'alert_interval', '15', 1, '告警间隔时间'); -INSERT INTO `sys_config` VALUES (14, 'confagent_port', '10090', 1, 'confagent内置端口'); -INSERT INTO `sys_config` VALUES (15, 'confagent_path', '/nz-agent', 1, 'confagent内置路径'); -INSERT INTO `sys_config` VALUES (17, 'telnet_user_tip', 'ogin:', 1, 'telnet用户名提示'); -INSERT INTO `sys_config` VALUES (18, 'telnet_password_tip', 'assword:', 1, 'telnet密码提示'); -INSERT INTO `sys_config` VALUES (19, 'telnet_relogin_password_tip', 'assword:', 1, 'telnet relogin密码提示'); -INSERT INTO `sys_config` VALUES (21, 'ldap_address', '', 1, NULL); -INSERT INTO `sys_config` VALUES (22, 'ldap_dn', '', 1, NULL); -INSERT INTO `sys_config` VALUES (23, 'ldap_password', '', 1, NULL); -INSERT INTO `sys_config` VALUES (30, 'ldap_user_filter', '', 1, NULL); -INSERT INTO `sys_config` VALUES (31, 'ldap_mapping', '', 1, NULL); -INSERT INTO `sys_config` VALUES (32, 'ldap_enable', 'off', 1, NULL); -INSERT INTO `sys_config` VALUES (33, 'geoJson', '{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"name\":\"Akmola Province\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@ÔdƊijʪŠèāƂNŎ‹ǀ\\\\ǔ§DȆȨC˔ŷLjƾ»ìƞ¦ƪXÄĢʈĤÉŤļÂRƌŸÐŁLĉǂâHƚƬјƬËjĜ̚ɐUŒűȞW¿ūǖCĠŋŘLOôŘXAĆτEUąȦu˖ĴƖǯiŗĥ…¾ąȸùʒŽCĶȺ…Μ¦¾ėeǩŸˆή눿ͦSà¥@ԣǛƭMŅǸd|™ȊÙɱmƛ½ŧƉŗzɥ^čƂJ޳ƍûȳ‹AÓǃ¹NjvĽśƿYÛ·äÏċ©ĥŒą­ré͕R[ȔťĂˇÇɷƑL¥ǭ}ëígšĽŒŵ«ÖïȽõƩ]nŀéò̧Éćþ˭ڎĥ˵ÍǵÀCɰ˜¢RȪʏJ̯ƻȓŽnēſËȏBΣďÇŬœüĵˆɡʓĊįsÙŤĝŇŴštÓġƹosÆ®ƾǧĸļƄހȌ³²řBĞƪRȚÐĞɦŊÂPȖ\",\"@@ÒõƒkƈĊ¿Ŧǽrĭſ\"],\"encodeOffsets\":[[67591,53693],[72928,52338]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Aktobe Province\"},\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[\"@@žЛ̉ƸƬŨLŖĴf\"],[\"@@ƖʆǎĀǬQ˄˄zŜı²^żÙÊČÀâŀƾø¥ĎfƤŏpDĔƒXƊğȢ•dçȦţɶāͤŒêºœƺƴ‹ĈĦĨľÿÆøǂ]Ɏxưŧƶɪ¼ƪOˆǮĈʸx¼Śf”ÓŜRĬć›įƴ«ĎĭҚ¿ĊğʠPƸŞdŬƘ—ŤĝО[՞ŲĴδĺdȊNŽķưCŶ·­đǜĿŹ©SƇƢ¢¾ǁńġĎſƂũÀŏƃeLJיŅį§ŏƽȰȳď¯ĒƱʠƙƦäĢÅåė|Û˴ã̖ůȶʃĔƗƂđɗǑƝÅLJĻΫŻɳƛ̱ªrðɯǞĵ^ŗƬųĖӅQyֱ͟έXiǯ́_̡țǩƍϗϑåTćơbŏÍŭɡӵŋ੉ʁřؾŝǦsĞĿŖyŘҥĮʋĆǽŮħdžįŜÆɂCŖ²DŽmƬƇŠ~Ƣ÷Ą¦ǬaŔƍˆƗgíџļ@DއȂƅyǝĆ\"]],\"encodeOffsets\":[[[60468,46905]],[[54918,50423]]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Almaty\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@ʴ¤wēČěıĵhűèÏƮ\"],\"encodeOffsets\":[[78580,44354]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Almaty Province\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@ĖŘӠ͜ɴ~ʶŀʄXτšƨċŤ¬ĨÁľŽϾ—ÜûĪXÚÒǼP÷ҐŦ¤ɒŬĦņûƊŞ˶ǃłO¤ïϒ†˄ʩϞŖƢ­I«֚ȭɘOĜßɸÝƶƇ‚ÃŦ×ĘȟĮŋJħÖÛĎEɪќÝKĿę•ǧÄ̃YĵńƛBƱā˧Ÿȅ÷ǙPɕ‰ȉ×»|ɩšŶęŒnªąĀuĈýÁҏǃWƳňʑȒ̑ÅōĀuFơǏCǕőŜĽȿ‘ĩǵ¶ûXƷªħė]ǭǰϵxƃŤƏĄdĚɧ}ʍÌų¸š͏GƿÂ̛\\\\ǁaá¼ʭNţÙƻfƭ½űÐƕiùœħ_ƅĈʉä×ȔĆŞˇøă¾ʠǘ_ͤÈ]IJƇĪǝòDž^șņFǶĵĒɧĦǶ˧oƒİ~ÊɺAŸĀç̬ĨŦžĤ\",\"@@ÐƭŲçĶgIJċĜxĔʳ£\"],\"encodeOffsets\":[[75839,47106],[78580,44354]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Astana\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@ĮƀǾqÀťƇĉƑlÑö\"],\"encodeOffsets\":[[72928,52338]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Atyrau\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@ֺÃݒÇɸ©ЬŋOĔʾUȊvǠŞҦȺʒì´ĮǨTĴŠΤ£UğłVŌ·ŜhȂéĜDBǀÜƤĐIOȠĴ¬π}̰ȈǞąƆzˆȁ@ǃѠϐîƘhƎ‡bœ¥ǫøă}ơƈşnƫ±ǃDŕÅɁİśĨDžǾŭʌąҦĭzŗŀŕtĝ́nƑĘÓgãƖǛ\\\\īĊǽŷƱXɍ_ŝ“ϓÕɯEÝijǯĥЯEǦʎcDŽ獙Ŕ긅źǯĺӕʅtď°ǑãȩŒŭÛĥjoØı¢ȳt÷†ū¥ǷYēóƑc«ỚŁįí³ĉčIYŏ±û}ƃǃŽī•í°ƿ¨ċöı\\\\ȋö°ȯn^â̤ªÜ¤çŚǡǸDžˈËAȩɾċ¬ϯ^ȥâſDžâYĀŋŦ¼Ȥ\"],\"encodeOffsets\":[[48242,49392]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"East Kazakhstan\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@΢Ĺʜ¿ǘ¨ǦȜ‘ŊÙnkȆƅ[DzDĒƳ˜ąŠįĖŊ¸ːœƸ昞Ȱc̚ɒͤѣ̀ϟPúĠÒʐ̇ȬǀC˜Ģɜµk‘ɐµįǵ̒zŒȁŐ[ʬ¾˲ÉňǼ{ƞĔKÞƬgʔðǤhȰ·ˆŹ[¯ȎǏüǍaÇƄåȀBȒıƘ‘ÛǸȷXġ̼[ĀÁǦbðãŦŒöµÐĮČV˜Ǹ֙ƙƃȎ»FÙČ¥GÑĊûȴqJıƛŠǻeřımÁöÿ—ŗřÿ©ñŧ³œBċ«˽Cęûŷџ›ǁöΣyÝÔÙDǯėí_ßɗJ̗ǝǩŶȅ…Ïzѹ…˳ðȉĪʫ¨·Ɖǣ̹¡ƣŗ̏±ƫķTťñƭ\\\\ËčFÕÜIĨĭŌėȠťØÄƵƈɷÞěàɗP֙ȮJ¬ơ®ϝŕ˃ʪϑ…£ðŁP˵DŽƉŝŅüūĥɑť£ȡ^ûāɉυĠpŸƸsŸǔ~ÜNJÔb˜ɂđŎǿŐĴŐǔWŲވޓæ·›ÏĀ\\\\ĔǚŠŇèEÂʿnj^¶кŘøú[ǂĴâƾ¾ȎŲYÜ\"],\"encodeOffsets\":[[79562,51428]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Jambyl Province\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@ቒP٢I׸Aੈ@ģħťè̫ ÿɹB}Ʉį˨pžǵɨĥĶđEǵȚŅdž]Ǟñƈĩ^ı£Ç`ĵʟǗĄ½ˈ÷ąŝØȓʊãƆćęţŭ„˵pͅŪďSƣŦũ‚śÜщɝsͯŵ—ÿ]ƛËǹ®ōƟ’I¼Dž†ǫcƓĖȷžǻØƉmɍĄȏÅęŠɇmąƛƭsƷ÷çǗ՟âȫźơ¾dǒċŌǩŚʇªďžZĒĝhļŀļǨvɜIJŒěвÃȠ»ÊŅ͐ėƆýɬǗȘ\"],\"encodeOffsets\":[[70725,47104]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Karagandy Province\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@ɴƜάżLjļƞÆɘǒƁĒēƘɢƬ±Ĩ̐¦ġƎȖB¢ɚجğɤ¸nĂʠV˸ȾŊzĠƾƼĺǢÎ˨ʒɞƲOIJˬäņŰŹômĔȔ̰ƼʐIQȩ—¡DɯǶ¿˶΍ĦˮÙĈý̨ÊêñmĿƪ^ȾöÕðŶ¬ľ‹hŢìîǮ~K¦ɸƒˈÈŦā\\\\ȓ͖QqêĆ®Ħ‹ČªãÐܸǀZľŜnjuDŽºBÔȴŒƎüŝ´ƁI]Ďɦ‚Řy̠Ýdēµũ¬ĝĹÃwīČ­ɀTƀ–Ȓ¯˶ǑLçƘÙǡÏŏݖÇƖUˊŤˀbÀœŦ}ǂ®ư›´þɆtŀµŌˌ¤ȚxƪčǔaǐïƽƱZÛȍűƽ½ijá\\\\ǁ÷ùйŗ]µˀNjFÁňçǙ‰[ēÐÿΈœ”凚űšǓXijŏȀŏĒō—ɁÓaÛljŽ} ǓƷtoŷ†ğɊčüĂȢ]øҏǻOÙÑĩWÛüϽ˜ĽħÂţ«ƧČσ™ʃWʵĿɳ}ӟ͛ĕŗੇ@׷B١JቑOۡBࢿ@Ťȡ|ȋ[ڇhʱ†ǵČșƐǗtгǀɥ¬˥ĀĝIȗĊǥ–ĔŤ͛îËO\"],\"encodeOffsets\":[[64461,48324]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Kostanay Province\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@RȃþŁũ•ʊűƗuƽÛìǑŎDKœÃ§DįŜBPʹŦBÅǏHſjáɂW[ëǃNTŇğEY˝OȕʼnÁĝɥșÏƩQ€ĝŚA´±ȋƃݎĻǨķ­ƽtÅƺpÔĢŢsňųАÚţİtʔĉɢžĶ‡›ûÈūΤĐȐAƀÌźóŅů˫ãPıɝƱ˧ʑǡÍƻĹğƽʼny˷ȽʟUmāɣ·ثĠ¡əȕAĢƍ̏¥²ħɡƫȵʄ̕Ű˳ä{ÜæĘġÆƥãʟƚđƲаȯȴŐƾݨšņLjØƄf¿ŐƁŪčƀŃ̽ǂơ¡TƈźªǛŀ®Ēŵ¸ƯDĸȉMşÌ™êʫ°ǟNÁŮͯDī|NŶɣĀŇläǒEˀƔǦA̎Ljïƈŝ^DĴŅlEĐĺTʊDzŊ¦Ŝ™äœƎéΜɒ£Ɯ’Wĺ˭Ôġèū§Ń¸ƥRÏļŤĘŊ±ƒÐÈƋTƧāªȁX˜ƘûĞƄƜƾRø×ƀlŎÉƾ[ö˪IĚėĞN˜ŚǬ’ɰOÒâ̰pʈÄƲBмĂɎYȤÐŬÿİœuƀΞĠĪ…ĈøŘjĀÝ\"],\"encodeOffsets\":[[67662,55952]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Kyzylorda Province\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@ÌP͜íēţǦ•ȘĉĞJ˦ÿɦ«дƿǘsȚƏǶċʲ…ڈgȌ\\\\Ȣ{Žţ@Çňí¾ûãù›ɩÇăǼıŀ…Sċj̵eǯċĶÓŴoØėɆŝāû\\\\ŏ™ăąÉĕƅsĥŵԏȏċ«ࠍӛß`rȒD̺Ʌãʇδ̽ǦƵȂÏjͭƑ֩zёªङŏȧYӡдʋȐŔĭª࠽Ӻٌvʌ·ĊƧœă˵ϹdžМ¢ÖIJWlłǓéSĈæžϘϒǪƎ̢Ȝ̂`jǰήWֲ͠žzӆRŴĕŘƫĶ]ɰǝqï̲©\"],\"encodeOffsets\":[[64461,48324]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Mangystau Province\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@аFǰĦÞĴɰFϔÖŞ”Ɏ`ƲWǾŸĬĉǜ[äƕÔhƒė̂mŞǥŚؽصƩ@Ӂ@ַFᎭĿN̓ãƷŞǙȂƓȈDÖƟŪҽ˞խùӯƕЧ˗AŦÑŞ|ĎļňĚȬÎØ]ĞĿÐş‚ōQǙ®ȡŸŝǚĕ΍è˳~ʰĪĩÐŋƦ{ńŃĈ{ƌÚ̃¬ƯüSƈÖĎβ—ŮTǬřČ@ĂÆŀ‹\\\\ĈįGķʐìņ}žŠŘǔŠŢ¼ʔNʒąƼT͆ǭWȂĨŲG˴ŝ̭ĻăùóŹșˏPÃIJwľĸŖǶPúǘŶŚmǤÊƞfɬW;ȢŘ©äƧÎěĺĩ‚vÈƿŨȯkÕāɱƧƕǎ̙ÊJúöƈ\"],\"encodeOffsets\":[[54469,47117]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"North Kazakhstan\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@ʲÂݶĺ¨¢Ș{Ǯ–žîǴiǞfŒĬãÆö°̲HĔƘǀµIĸȨµ„©Вjƶ±îïɸ¿Ⱦł˜GǂǝƱŜơǎŸķý°ȋȓ_ƬȯĸünjuA¹ȞN‚Ű˼ĔŜè•vĹľŧµĉIJ•ŒŞàĀ͖ÔĥȞ—ǮIRÆȾ¨ÝǕȧjǵʷƆ”ñŢœűOsŁĠ{ŜÐĺ•ǗƁúُijŜIȈĸœąȗŝµÇƨ…ͥT‡Àέìŷ‡fǪ½ĘΛ¥ȹ†Dĵʑȷú½ĆĦ†jŘƕǰ˕ijȥvVĆσFBąŗWPóŗKğŌǕDÀŬȝX‹ŲɏVę™iěƫÌїžƙƫáGĊǁłK ÏQƋĻÁÊţʇģÃġƩWƝ¥¼ëLJƽ˓ŸȧDCȅǓ¨ƿ[ōŒƁMçĂʩ‰ƉĴÓcZ˞ĠFSňDŽM\\\\ìɁXiâƀ‚ǐGAÆťOʺśACİĨLŔōCëǒƾÜƘvʉŲŪ–ýłQȄ\"],\"encodeOffsets\":[[67662,55952]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Pavlodar Province\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@ǦIJƪtâÔƞkǸËĔėĆĪyĸƦk’ðĸÎɄ˦ƖCĢȈ|ԔƊ²ĊȀ“ǘx°ÖŰĭĹşģ‹ǭCĒĻڪͻӊʭͲ΁Ϫэ˔˳Ɇ˥̙ɑȯd—ŽƷåˏ›ʼn·İĕĆşƴ—CđȱƆ\\\\lȅÚm’ʼnǥțǗ§ʛÀΡĺą²žƾǏðǓbƩĎșwÁ£ŋˋĿ¶Ʌs³ýƯœǁ­ť~¿›ʿaˉţƕV•ÈŐÞǢÐƗÚKè˵ǒȑ°ſ•ȿSċ®xĬĺīжŪcĔ̟ÞŨƊƜ¾ɲnȉÚ{šǷcNņǜƮ@ԤߦƧ†¶ÈȘŞ›ĆȇķśJĴùÚǘƂŖśÏğ|tłŲPšŔ\"],\"encodeOffsets\":[[75202,54718]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"South Kazakhstan Province\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@à_ࠎӜȬԐȐŶíŽtĦĖƆĆʚĄ[ŐĂüɅŞ×ĘųpĵԞČfǰi̶TČĿ†ǻIJÈĄœɪäú½üŇî@Èࣀ@ۢAǘȗþɫĘƅņ͏¼ÉÄȟĜбıőuɛĻǧĻĿĞgYđНʈ©ǪřČŋcǑƢ½ȬŹ áǘŏdğíEģñ«ėƃĀſÓƋƿƳÏe›˷ÑùċÇLƅŋɓÓCġȡŝƇơÅcJǻxōĝFʅĞȭŦĤĀ@ĘĕIeľč]ō¢̱±փ\\\\ċ̒×͒҅ºFΤÎm\"],\"encodeOffsets\":[[67657,43355]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"West Kazakhstan\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[\"@@áĿċ¿ÚÉ]ŻIJ±yś˃˃ǫRǍÿƕʅ̯ȇο~ij«PȟďJÛƣAƿěCȁêśgŋ¸ŁUVĠΣ¤ij‰ǧS³ĭʑëҥȹǟŝȉuʽVPēЫŌɷªݑÈֹÄZˆ̓îɉäʌѤĨ~ŘĜŤǷĜĸѲɼÒƞƆăĈ˜Ĥ̄ÈîŜ–ŴĹƪĉƀţŠđŚřƴqʜðƄĆƟȪã̀ƌKǐòİĒʘÄsȮ͎bɚŨǴ~òĎǢèIŀ̚üФ‘¨ƓǬÂ`÷Ƅ¢—îļĐǒqȶîȘɽȌ¨Ī‹Ъ\\\\ƴÇhıÈÙ̮ËĠ¯Àťè­Ɇ½ķȓŊý\"],\"encodeOffsets\":[[55853,51741]]}}],\"UTF8Encoding\":true}', 1, NULL); -INSERT INTO `sys_config` VALUES (36, 'generator_path', '/opt/nezha/nz-web/generator', 1, 'generator路径'); -INSERT INTO `sys_config` VALUES (45, 'asset_ping_interval', '300', 1, NULL); -INSERT INTO `sys_config` VALUES (48, 'system_name', 'One-stop monitoring system', 1, NULL); -INSERT INTO `sys_config` VALUES (49, 'ldap_ou', '', 1, NULL); -INSERT INTO `sys_config` VALUES (50, 'timezone', 'Asia/Shanghai', 1, NULL); -INSERT INTO `sys_config` VALUES (52, 'export_pagesize', '1000', 1, 'alert_message到处时默认的每批次查询数量'); -INSERT INTO `sys_config` VALUES (54, 'alert_notify_interval', '300', 1, '单位:s'); -INSERT INTO `sys_config` VALUES (69, 'email_template', '
${alertMessage.description}
', 1, '邮件模板'); -INSERT INTO `sys_config` VALUES (71, 'test_email_send_template', '
Nezha test sending email.
', 1, NULL); -INSERT INTO `sys_config` VALUES (72, 'reset_table_infos', '[\"Delete from alert_rule where build_in !=1 \",\"Delete from asset_asset\",\"Delete from cabinet\",\"Delete from visual_chart\",\"Delete from visual_chart_element\",\"Delete from monitor_endpoint\",\"Delete from monitor_endpoint_state\",\"Delete from dc\",\"Delete from maintenance_record\",\"Delete from asset_ping\",\"Delete from asset_model\",\"Delete from asset_brand\",\"Delete from asset_feature\",\"Delete from asset_field_value\",\"Delete from asset_field_group where build_in !=1 \",\"Delete from asset_field_meta where build_in !=1 \",\"Delete from monitor_module where build_in !=1 \",\"Delete from viausl_panel where build_in !=1 \",\"Delete from monitor_project where build_in !=1 \",\"Delete from project_topo\",\"Delete from prom_server\",\"Delete from snmp_credential\",\"Delete from sys_api_key\",\"Delete from snmp_mib\",\"Delete from terminal_cmd\",\"Delete from terminal_record\",\"Delete from terminal_session\",\"Delete from sys_log\",\"Delete from sys_user where username!=\'admin\'\",\"Delete from alert_notify_log\",\"Delete from alert_notify_method where build_in !=1 \",\"Delete from alert_silence_conf\",\"Delete from alert_silence_message_rel\",\"Delete from link where build_in !=1 \",\"Delete from visual_chart where build_in !=1 \",\"Delete from visual_chart_element where build_in !=1 \",\"Delete from visual_expression_tmpl where build_in !=1 \"]', 1, '清空项目数据信息'); -INSERT INTO `sys_config` VALUES (107, 'default_cabinet_usize', '40', 1, '机柜默认U位值'); -INSERT INTO `sys_config` VALUES (114, 'alert_export_header', '{\"cn\":{\"ID\":\"ID\",\"告警名称\":\"告警名称\",\"数据中心\":\"数据中心\",\"应用名称\":\"应用名称\",\"组件名称\":\"组件名称\",\"Endpoint\":\"Endpoint\",\"主机地址\":\"主机地址\",\"告警tag信息\":\"告警tag信息\",\"告警级别\":\"告警级别\",\"告警摘要\":\"告警摘要\",\"告警描述\":\"告警描述\",\"开始时间\":\"开始时间\",\"结束时间\":\"结束时间\",\"状态\":\"状态\"},\"en\":{\"ID\":\"ID\",\"Alert Name\":\"Alert Name\",\"Datacenter\":\"Datacenter\",\"Project\":\"Project\",\"Module\":\"Module\",\"Endpoint\":\"Endpoint\",\"Asset\":\"Asset\",\"Labels\":\"Labels\",\"Severity\":\"Severity\",\"Summary\":\"Summary\",\"Description\":\"Description\",\"StartAt\":\"StartAt\",\"EndAt\":\"EndAt\",\"State\":\"State\"}}', 1, 'alert_message导出表头'); -INSERT INTO `sys_config` VALUES (118, 'map_center_config', '{\"longitude\":71.45,\"latitude\":51.16,\"zoom\":4,\"minZoom\":3,\"maxZoom\":7}', 1, '地图配置'); -INSERT INTO `sys_config` VALUES (139, 'system_version', '21.04', 1, 'nezha系统版本'); -INSERT INTO `sys_config` VALUES (142, 'query_max_series', '50', 1, '限制 prometheus query_range 接口 result 数组大小 区间范围[-1 - 1000] -1表示不限制'); -INSERT INTO `sys_config` VALUES (143, 'export_max_line', '10000', 1, '告警导出最大行数'); -INSERT INTO `sys_config` VALUES (149, 'develop_admin', 'admin', 1, NULL); -INSERT INTO `sys_config` VALUES (150, 'ldap_query_timeout', '3000', 1, 'ldap template 查询超时时间,单位 milliseconds 毫秒'); -INSERT INTO `sys_config` VALUES (153, 'unsaved_change', 'on', 1, '未保存提示开关'); -INSERT INTO `sys_config` VALUES (154, 'expretmpl_export_header', '{\"cn\":{\"*名称\":\"模板名称(必填) \\n示例: CPU利用率模板\",\"组名\":\"组名 \\n示例: base,默认值: default\",\"*表达式\":\"表达式内容(必填) \\n示例: node_cpu_usage(asset=\\\"{{asset.host}}\\\",device=\\\"{{device}}\\\")\",\"描述\":\"描述 \\n示例: node_export CPU利用率模板\"},\"en\":{\"*Name\":\"Template name (required) \\nExample: CPU utilization template\",\"Group Name\":\"Group Name \\nExample: base, Default value: default\",\"*Expression\":\"Expression content (required) Optional: node_cpu_usage(asset=\\\"{{asset.host}}\\\",device=\\\"{{device}}\\\")\",\"Remark\":\"Remark \\nExample: node_export CPU utilization template\"}}', 1, '表达式导入导出模板表头信息'); -INSERT INTO `sys_config` VALUES (157, 'confagent_name', '{\"centos\":\"nz-agent-21.04-Release.x86_64.rpm\",\"ubuntu\":\"nz-agent-21.04-Release.x86_64.rpm\"}', 1, 'confagent 下载文件名称'); -INSERT INTO `sys_config` VALUES (189, 'asset_asset_export_header', '{\"cn\":{\"*资产名称\":\"资产名称,唯一标识(必填) \\n示例: DELL服务器\",\"*SN码\":\"资产序列号,唯一标识(必填) \\n示例: A0420200101\",\"虚拟机宿主\":\"虚拟机宿主,当资产为虚拟机时必填 \\n示例: DELL物理机\",\"*管理ip\":\"主机地址(必填),IP格式 \\n示例: 172.0.0.1\",\"*品牌\":\"品牌(必填) \\n示例: DELL\",\"*型号\":\"型号(必填) \\n示例: DELL-D3\",\"*数据中心\":\"数据中心(必填) \\n示例: 北京电信中心机房\",\"机柜\":\"机柜 \\n示例: cabinet-001\",\"开始U位\":\"机柜开始位置 此信息一般和机柜结束位置联合使用 \\n示例: 1\",\"结束U位\":\"机柜结束位置 此信息一般与机柜开始位置联合使用 \\n示例: 2\",\"*资产状态\":\"资产状态 \\n示例: 在库\",\"*资产类型\":\"资产类型 \\n示例: 服务器\",\"购买日期\":\"购买日期 \\n示例: 2020/2/25\",\"属性信息\":\"资产属性信息,格式: key=value 如需填写多个请使用回车换行 \\n示例: NetworkCard=eth0 \\n user=root\",\"认证服务端口\":\"认证服务端口 \\n示例: 22\",\"认证方式\":\"认证方式,可选值: 1:用户名密码; 2: 密钥 \\n示例: 1\",\"用户名\":\"用户名, \\n示例:root\",\"密码\":\"密码 ,认证方式为1,记录登录密码; 认证方式为2,记录密钥密码. \\n示例: pass\",\"密钥\":\"登录密钥 \\n示例: ssh-rsa CFdv7Jez6K...\",\"用户名提示\":\"TELNET用户名提示 \\n示例: login:\",\"密码提示\":\"TELNET密码提示 \\n示例: pass:\",\"SNMP凭证\":\"snmp凭证名称 \\n实例: system-snmpv2\"},\"en\":{\"*Asset Name\":\"Asset name, unique identifier (required) \\nExample: DELL server\",\"*Sn\":\"Asset serial number, unique identifier (required) \\nExample: A0420200101\",\"*Virtual machine host\":\"Virtual machine host, required when the asset is a virtual machine \\nExample: DELL physical machine\",\"*Management ip\":\"Host address (required), IP format \\nExample: 172.0.0.1\",\"*Brand\":\"Brand (required) \\nExample: DELL\",\"*Model\":\"Model (required) \\nExample: DELL-D3\",\"*DC\":\"Data Center (Required) \\nExample: Beijing Telecom Center Computer Room\",\"Cabinet\":\"Cabinet \\nExample: cabinet-001\",\"Cabinet Start\":\"Cabinet start position This information is generally used in conjunction with the cabinet end position \\nExample: 1\",\"Cabinet End\":\"Cabinet end position This information is generally used in conjunction with the cabinet start position \\nExample: 2\",\"*Asset state\":\"Asset status \\nExample: In stock\",\"*Asset type\":\"Asset Type\\nExample: Server\",\"Purchase date\":\"Purchase date \\nExample: 2020/2/25\",\"Field Information\":\"Asset field information, format: key=value If you need to fill in more than one, please use carriage return and line feed \\nExample: NetworkCard=eth0 \\n user=root\",\"Server port\":\"Server port \\nExample: 22\",\"Auth methed\":\"Auth methed,Optional values: 1: username and password; 2: key \\nExample: 1\",\"User name\":\"User name, \\nExample:root\",\"Password\":\"Password ,The auth method is 1, record the login password; the auth method is 2, record the key password. \\nExample: pass\",\"PrivateKey\":\"PrivateKey \\nExample: ssh-rsa CFdv7Jez6K...\",\"User Tip\":\"TELNET username prompt \\nExample: login:\",\"Password Tip\":\"TELNET password prompt \\nExample: pass:\",\"SNMP credential\":\"SNMP credential name \\nExample: system-snmpv2\"}}', 1, NULL); -INSERT INTO `sys_config` VALUES (190, 'prom_cmd_tmpl', 'OPTION=\" --config.file=\'/opt/nezha/nz-agent/prometheus/prometheus.yml\' --web.listen-address=\'127.0.0.1:10091\' --web.enable-admin-api --storage.tsdb.path=\'/data/prometheusData\' --web.enable-lifecycle --storage.tsdb.retention.time=${storageDays}d \"', 1, 'prometheus 启动参数模板'); -INSERT INTO `sys_config` VALUES (192, 'prom_rule_tmpl', '{\r\n \"groups\": [{\r\n \"name\": \"alertRule\",\r\n \"rules\": [\r\n <#if endpointAlert>\r\n {\r\n \"alert\": \"0\",\r\n \"expr\": \"up{endpoint!=\'\'}>-1\",\r\n \"for\": \"30s\",\r\n \"annotations\": {\r\n \"summary\": \"{{$value}}\"\r\n }\r\n }, \r\n \r\n <#list ruleList as rule>\r\n {\r\n \"alert\": ${rule.id?c},\r\n \"expr\": \"(${rule.expr})${rule.operator}${rule.threshold}\",\r\n \"for\": \"${rule.last?c}s\",\r\n \"labels\": {\r\n \"severity\": \"${rule.severity_name}\",\r\n \"severity_id\": ${rule.severity_id?c}\r\n },\r\n \"annotations\": {\r\n \"summary\": <#if rule.summary?default(\"\")?trim?length gt 1>\r\n \"${rule.summary}\",\r\n <#else>\"\",\r\n \"description\": <#if rule.description?default(\"\")?trim?length gt 1>\r\n \"${rule.description}\"\r\n <#else>\"\"\r\n \r\n }\r\n }\r\n <#sep>,\r\n ]\r\n }]\r\n}', 1, 'prometheus rule文件模板'); -INSERT INTO `sys_config` VALUES (194, 'monitor_endpoint_export_header', '{\"cn\":{\"*系统\":\"系统名称(必填) \\n示例: Nezha\",\"*组件\":\"组件名称(必填) \\n示例: node_exporter\",\"名称\":\"实例名称 \\n示例: node_exporter\",\"*资产名称\":\"资产名称(必填) \\n示例: A0420200101\",\"配置\":\"实例配置,JSON格式, \\n示例: {\\\"key\\\":\\\"value\\\"}\",\"启用\":\"启用状态(非必填) 可选 0:停用 1:启用,为空时默认为1 \\n示例: 1\"},\"en\":{\"*Project Name\":\"Project Name(Required) \\nExample: Nezha\",\"*Module Name\":\"Module Name(Required) \\nExample: node_exporter\",\"Name\":\"Endpoint name \\nExample: node_exporter\",\"*Asset Name\":\"Asset name(Required) \\nExample: A0420200101\",\"Configs\":\"Endpoint Configs,JSON format, \\nExample: {\\\"key\\\":\\\"value\\\"}\",\"Enabled\":\"Enable state (not required) Optional values 0: Disable 1: Enable, when empty, the default is 1 \\nExample: 1\"}}', 1, 'monitor endpoint 导入表头'); -INSERT INTO `sys_config` VALUES (195, 'system_logo', '', 1, '系统 logo'); -INSERT INTO `sys_config` VALUES (196, 'default_scrape_interval', '60', 1, '默认60s'); -INSERT INTO `sys_config` VALUES (197, 'default_scrape_timeout', '30', 1, '默认30s'); -INSERT INTO `sys_config` VALUES (198, 'terminal_timeout', '30', 1, '默认:30,单位:minute'); -INSERT INTO `sys_config` VALUES (199, 'terminal_telnet_user_tip', 'ogin:', 1, '默认:ogin:'); -INSERT INTO `sys_config` VALUES (200, 'terminal_telnet_pin_tip', 'assword:', 1, '默认:assword:'); -INSERT INTO `sys_config` VALUES (201, 'terminal_record_local_retention', '365', 1, '默认:365,单位:天,record数据保留天数'); -INSERT INTO `sys_config` VALUES (202, 'email_enable', 'off', 1, '是否启用邮件'); -INSERT INTO `sys_config` VALUES (203, 'email_host', '', 1, ''); -INSERT INTO `sys_config` VALUES (204, 'email_port', '25', 1, ''); -INSERT INTO `sys_config` VALUES (205, 'email_timeout', '10', 1, '默认:10'); -INSERT INTO `sys_config` VALUES (206, 'email_auth_account', '', 1, ''); -INSERT INTO `sys_config` VALUES (207, 'email_auth_password', '', 1, ''); -INSERT INTO `sys_config` VALUES (208, 'email_send_account', '', 1, ''); -INSERT INTO `sys_config` VALUES (209, 'email_test_account', '', 1, ''); -INSERT INTO `sys_config` VALUES (210, 'email_security_type', 'NONE', 1, 'NONE SSL TLS'); -INSERT INTO `sys_config` VALUES (211, 'session_timeout', '30', 1, '默认:30,不小于 15 单位:minute'); -INSERT INTO `sys_config` VALUES (215, 'asset_ping_from', '2', 1, '1: global\r\n\r\n2: per-datacenter\r\n\r\n默认:1'); -INSERT INTO `sys_config` VALUES (216, 'prometheus_federation_enabled', '1', 1, '配置prometheus是否开启联邦模式,1:开启,0:关闭(界面禁用 添加选择 per-datacenter agent,所有endpoint 配置信息 hash 分布到 global prometheus)'); -INSERT INTO `sys_config` VALUES (217, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n \r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.module.type == \"http\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n \r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.module.type == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.module.type == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.module.type == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n <#-- 开启联邦 -->\r\n <#if jobPojo.fedeEnabled>\r\n <#if jobPojo.scrapePing> \r\n \"{job=~\\\"asset_ping_.+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n <#else>\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n <#else>\r\n <#-- 联邦关闭,抓取所有指标即可 -->\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n \r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }<#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n \r\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\r\n ,\r\n \r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.module.type == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.module.type == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.module.type == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n ]\r\n \r\n}', 1, 'prometheus config文件模板'); -INSERT INTO `sys_config` VALUES (218, 'license', 'NEZHAbased3613a0b4ed2109e5dbb933f3e0c2a5684e86cf8057775d4a10de5efe61e13f04d2259a1ffd0c2954ca5d3ef0b118fdc051e4bc0b4f03c42a9a7e5c5fd744731d11b27f9584267fead3b366f7fc0e5b6a99628d8a4d6e7af976e799efc7567266baf771bd41d7b9e8e269262b10bf2c434e064badd2eb649806dba68b101a5833e58fbcbaa3ff05277f6920c488725e3cb86dc1b7e00461902b6e4a0ef797c39d2685e03872e4bac4c8e61f46b929385674022116bd254a237f256d7cae6d35da654e6d5a92785203f996c02dd9ff5087f668899a7386872485b532915c064cc7156bef3d539dc109d44182cd31e54ac5189a5d89b83703b74cde8e36afd2ba85590e646fc9c404296de4b891ca303055b0a24e1admin2021-06-01T03:13:59Z202106011100admin', 1, '3403d697d45c594a0d147d556d94ad087272830c'); -INSERT INTO `sys_config` VALUES (219, 'license_token', 'abbbb', 1, NULL); -INSERT INTO `sys_config` VALUES (220, 'rule_export_header', '{\"cn\":{\"*告警规则名称\":\"告警规则名称(必填) \\n示例: cpuAlert\",\"*运算表达式\":\"运算表达式(必填) \\n示例: 100-(avg(irate(node_cpu_seconds_total{mode=\'idle\'}[5m])) by(instance)* 100)\",\"*比较符号\":\"比较符号(必填) 可选: >,<,<=,>=,==,!= \\n示例: >\",\"*阈值\":\"阈值(必填) \\n示例: 10\",\"*单位\":\"单位(必填) 可选: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\n示例: short\",\"*持续时间\":\"持续时间(必填),默认单位(秒) \\n示例:60\",\"*告警级别\":\"告警级别(必填) 可选 P1、P2、P3 \\n示例: P1\",\"*告警摘要\":\"告警摘要(必填) \\n示例: cpu告警\",\"告警详细描述\":\"告警详细描述 \\n示例: cpu使用率超过10%的告警规则\",\"告警通知人\":\"告警通知人,多个使用逗号分隔 \\n示例: admin / admin,root\",\"通知方式\":\"告警通知方式,告警通知人不为空时,必填.多个使用逗号分隔 \\n示例: email / email,telephone\"},\"en\":{\"*AlertName\":\"Alert rule name (required) \\nExample: cpuAlert\",\"*Expr\":\"Operation expression (required) \\nExample: 100-(avg(irate(node_cpu_seconds_total{mode=\'idle\')[5m])) by(instance)* 100)\",\"*Operator\":\"Operation symbol (required) Optional: >,<,<=,>=,==,!= \\nExample:>\",\"*Threshold\":\"Threshold (required) \\nExample: 10\",\"*Unit\":\"Unit (required) Optional: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\nExample:short\",\"*Last\":\"Last (required), the default unit (seconds) \\nExample: 60\",\"*Severity\":\"Alert severity (required) optional P1, P2, P3 \\nExample: P1\",\"*Summary\":\"Alert summary \\nExample: Cpu warning\",\"Description\":\"Alert description \\nExample: Alarm rule for cpu usage exceeding 10%\",\"Receiver\":\"Alert receiver, separated by commas \\nExample: admin / admin,root\",\"Notification method\":\"Alarm notification method. When the receiver is not empty, it is required. Multiple use commas to separate \\nExample: email / email,telephone\"}}', 1, 'alert rule 导入导出表头'); -INSERT INTO `sys_config` VALUES (221, 'asset_chart_tpl', '{\"name\":\"{{asset.sn}}\",\"type\":\"assetInfo\",\"span\":12,\"height\":4,\"unit\":2}', 1, 'asset添加时,默认chart配置'); -INSERT INTO `sys_config` VALUES (222, 'endpoint_chart_tpl', '{\"name\":\"{{endpoint.name}}\",\"type\":\"endpointInfo\",\"span\":12,\"height\":4,\"unit\":2}', 1, 'endpoint添加时,默认chart配置'); -INSERT INTO `sys_config` VALUES (223, 'ldap_timeout', '30', 1, '超时时间秒'); -INSERT INTO `sys_config` VALUES (224, 'storage_local_retention', '15', 1, 'prometheus 本地数据保存天数 单位 d'); -INSERT INTO `sys_config` VALUES (225, 'snmp_trap_listen_port', '162', 1, NULL); -INSERT INTO `sys_config` VALUES (226, 'i18n_mapping', '{\"chartType\":{\"en\":{\"line\":\"Line Chart\",\"bar\":\"Histogram\",\"table\":\"Table\",\"stackArea\":\"Stack Area\",\"singleStat\":\"SingleStat\",\"url\":\"URL\",\"alertList\":\"Alert list\",\"text\":\"Text\",\"group\":\"Group\",\"pie\":\"Pie\"},\"cn\":{\"line\":\"曲线图\",\"bar\":\"柱状图\",\"table\":\"表格\",\"stackArea\":\"堆叠区域图\",\"singleStat\":\"SingleStat\",\"url\":\"URL\",\"alertList\":\"告警列表\",\"text\":\"文本\",\"group\":\"图表组\",\"pie\":\"饼图\"}}}', 1, NULL); -INSERT INTO `sys_config` VALUES (227, 'chart_export_header', '{\"cn\":{\"*面板\":\"面板名称(必填) \\n示例: 系统面板/主面板 (使用 / 作为字符分隔,表示 父子节点关系)\",\"图表组名\":\"组名 \\n示例: default\",\"*图表名称\":\"图表名称(必填) \\n示例: CPU使用率\",\"*图表类型\":\"图表类型(必填) 可选: 曲线图,柱状图,表格,堆叠区域图,SingleStat,URL,告警列表,文本,图表组 \\n示例: 曲线图\",\"*宽度\":\"宽度(必填) 可选:1-12 \\n示例: 10\",\"*高度\":\"高度(必填),可选:1-12 \\n示例: 10\",\"单位\":\"单位(必填) 可选: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\n示例: short\",\"*参数\":\"单位 根据type不同,内容不同,格式为JSON格式 \\n示例: {\\\"statistics\\\":\\\"average\\\"}\",\"元素\":\"当type=line,bar,stackArea时,包含 elements key,值为对象数组。\\n 示例:[{\\\"expression\\\":\\\"sum(up)\\\",\\\"legend\\\":\\\"test\\\"}]\"},\"en\":{\"*Panel Name\":\"Panel(Required) \\nExample: System panel/Main panel (use / as a character separation to indicate the relationship between parent and child nodes)\",\"Chart Group\":\"Group name \\nExample: default\",\"*Chart Title\":\"Chart title(Required) \\nExample: CPU usage\",\"*Chart Type\":\"Chart type(Required) Optional: Line Chart,Histogram,Table,Stack Area,SingleStat,URL,Alert list,Text,Group \\nExample: Line Chart\",\"*Width\":\"width(Required) Optional:1-12 \\nExample: 10\",\"*Height\":\"height(Required) Optional:1-12 \\nExample: 10\",\"Unit\":\"unit(Required) Optional: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\nExample: short\",\"*Parameter\":\"Parameters match type,The format is JSON format \\nExample: {\\\"statistics\\\":\\\"average\\\"}\",\"Elements\":\"When the type is line, table, stackArea, singleStat, histogram, it contains elements key and the value is an object array.\\nExample:[{\\\"expression\\\":\\\"sum(up)\\\",\\\"legend\\\":\\\"test\\\"}]\"}}', 1, NULL); -INSERT INTO `sys_config` VALUES (228, 'asset_chart_export_header', '{\"cn\":{\"图表组名\":\"组名 \\n示例: default\",\"*图表名称\":\"图表名称(必填) \\n示例: CPU使用率\",\"*图表类型\":\"图表类型(必填) 可选: 曲线图,柱状图,表格,堆叠区域图,SingleStat,URL,告警列表,文本,图表组 \\n示例: 曲线图\",\"*宽度\":\"宽度(必填) 可选:1-12 \\n示例: 10\",\"*高度\":\"高度(必填),可选:1-12 \\n示例: 10\",\"单位\":\"单位(必填) 可选: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\n示例: short\",\"*参数\":\"单位 根据type不同,内容不同,格式为JSON格式 \\n示例: {\\\"statistics\\\":\\\"average\\\"}\",\"元素\":\"当type=line,bar,stackArea时,包含 elements key,值为对象数组。\\n 示例:[{\\\"expression\\\":\\\"sum(up)\\\",\\\"legend\\\":\\\"test\\\"}]\"},\"en\":{\"Chart Group\":\"Group name \\nExample: default\",\"*Chart Title\":\"Chart title(Required) \\nExample: CPU usage\",\"*Chart Type\":\"Chart type(Required) Optional: Line Chart,Histogram,Table,Stack Area,SingleStat,URL,Alert list,Text,Group \\nExample: Line Chart\",\"*Width\":\"width(Required) Optional:1-12 \\nExample: 10\",\"*Height\":\"height(Required),Optional:1-12 \\nExample: 10\",\"Unit\":\"unit(Required) Optional: \\nMisc: none,short,percent(0-100),percent(0.0-1.0),local format\\nData: bits,bytes,kilobytes,megabytes,gigabytes,terabytes,petabytes\\nDataRate: packets/sec,bits/sec,bytes/sec,kilobytes/sec,kilobits/sec,megabytes/sec,megabits/sec,gigabytes/sec,gigabits/sec,terabytes/sec,terabits/sec,petabytes/sec,petabits/sec\\nTime: Hertz(1/s),nanoseconds(ns),microseconds(us),milliseconds(ms),seconds(s),minutes(m),hours(h),days(d),YYYY-MM-DD HH:mm:ss,MM/DD/YYYY h:mm:ss a \\nExample: short\",\"*Parameter\":\"Parameters match type,The format is JSON format \\nExample: {\\\"statistics\\\":\\\"average\\\"}\",\"Elements\":\"When the type is line, table, stackArea, singleStat, histogram, it contains elements key and the value is an object array.\\nExample:[{\\\"expression\\\":\\\"sum(up)\\\",\\\"legend\\\":\\\"test\\\"}]\"}}', 1, NULL); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'terminal_record_local_retention', '365', 1, '默认:365,单位:天,record数据保留天数'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'alert_rule_eval_log_local_retention', '30', 1, '默认:30,单位:天,record数据保留天数'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'alert_rule_sched_log_local_retention', '30', 1, '默认:30,单位:天,record数据保留天数'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'clean_alert_message_enable', '0', 1, '默认:0,0:不清理,1:清理'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'alert_message_local_retention', '365', 1, '默认:365,单位:天,record数据保留天数'); --- ---------------------------- --- Table structure for sys_dict --- ---------------------------- -DROP TABLE IF EXISTS `sys_dict`; -CREATE TABLE `sys_dict` ( - `id` bigint(19) NOT NULL AUTO_INCREMENT, - `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字典名称', - `type` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字典类型', - `code` int(11) NOT NULL COMMENT '字典码', - `value` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字典值', - `i18n_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'i18n code', - `order_num` int(11) NOT NULL DEFAULT 0 COMMENT '排序', - `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', - `del_flag` tinyint(4) NOT NULL DEFAULT 0 COMMENT '删除标记 1:删除,0:未删除', - `operator` bigint(19) NOT NULL COMMENT '操作人', - `op_time` datetime(0) NOT NULL COMMENT '操作时间', - `seq` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '全局唯一,用于导入撤销', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `type`(`type`, `code`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统字典表' ROW_FORMAT = Compact; --- ---------------------------- --- Records of sys_dict --- ---------------------------- -INSERT INTO `sys_dict` VALUES (1, '图表类型', 'chartType', 1, 'line', '', 1, '折线图', 0, 1, '2019-12-13 17:53:19', NULL); -INSERT INTO `sys_dict` VALUES (2, '图表类型', 'chartType', 2, 'bar', '', 2, '条形图', 0, 1, '2019-12-13 17:53:19', NULL); -INSERT INTO `sys_dict` VALUES (3, '图表类型', 'chartType', 3, 'table', '', 3, '表格', 0, 1, '2019-12-13 17:53:19', NULL); -INSERT INTO `sys_dict` VALUES (4, '图表类型', 'chartType', 4, 'stackArea', '', 4, '堆栈面积图', 0, 1, '2019-12-13 17:53:19', NULL); -INSERT INTO `sys_dict` VALUES (5, '图表类型', 'chartType', 5, 'singleStat', '', 5, 'singleStat', 0, 1, '2020-03-31 10:57:30', NULL); -INSERT INTO `sys_dict` VALUES (6, '图表类型', 'chartType', 6, 'url', '', 6, 'url', 0, 1, '2020-03-31 10:57:33', NULL); -INSERT INTO `sys_dict` VALUES (7, '图表类型', 'chartType', 7, 'alertList', '', 0, '告警', 0, 1, '2020-05-27 17:50:33', NULL); -INSERT INTO `sys_dict` VALUES (8, '图表类型', 'chartType', 8, 'text', '', 8, '告警', 0, 1, '2020-05-27 17:50:33', NULL); -INSERT INTO `sys_dict` VALUES (9, '图表类型', 'chartType', 9, 'pie', '', 9, '饼图', 0, 1, '2021-02-05 10:57:33', NULL); -INSERT INTO `sys_dict` VALUES (10, '图表类型', 'chartType', 10, 'group', '', 10, '组', 0, 1, '2021-04-06 14:30:18', NULL); -INSERT INTO `sys_dict` VALUES (11, '表达式类型', 'exprType', 1, 'normal', '', 1, '简单表达式', 0, 1, '2019-12-13 17:53:19', NULL); -INSERT INTO `sys_dict` VALUES (12, '表达式类型', 'exprType', 2, 'expert', '', 2, '用户输入表达式', 0, 1, '2019-12-13 17:53:19', NULL); +UPDATE alert_rule SET timeout = 300 WHERE timeout = 0; --- ---------------------------- --- Table structure for sys_i18n --- ---------------------------- -DROP TABLE IF EXISTS `sys_i18n`; -CREATE TABLE `sys_i18n` ( - `id` bigint(19) NOT NULL COMMENT '主键', - `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'i18n code', - `lang` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '语言', - `value` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '翻译值', - `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '备注信息', - `operator` bigint(19) NOT NULL COMMENT '操作人', - `op_time` datetime(0) NOT NULL COMMENT '操作时间', - `del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0' COMMENT '0正常,1删除', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'i18n信息表' ROW_FORMAT = Compact; --- ---------------------------- --- Records of sys_i18n --- ---------------------------- +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'system_version', '21.09', 1, 'nezha系统版本'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'promtail_yml_tmpl', '{\r\n \"server\": {\r\n \"http_listen_address\": \"0.0.0.0\",\r\n \"http_listen_port\": 19080,\r\n \"grpc_listen_port\": 19081\r\n },\r\n \"clients\": [\r\n {\r\n <#list clientsMapList as clientMap>\r\n \"url\" : \"${clientMap.url}\",\r\n \"bearer_token\": \"${clientMap.token}\"\r\n <#sep>,\r\n \r\n }\r\n ],\r\n \"positions\": {\r\n \"filename\": \"/opt/nezha/promtail/positions.yaml\"\r\n },\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": \"${endpoint.id?c}_${endpoint_index}\",\r\n \"pipeline_stages\": [\r\n <#if endpoint.config.pipeline??&&(endpoint.config.pipeline?size>0)>\r\n <#list endpoint.config.pipeline as pipeline>\r\n {\r\n <#if pipeline.type == \"regex\">\r\n \"regex\": {\r\n \"expression\": \"${pipeline.expression}\",\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"json\">\r\n \"json\": {\r\n \"expressions\": {\r\n <#if pipeline.expressions??&& (pipeline.expressions?size >0)>\r\n <#list pipeline.expressions?keys as key>\r\n \"${key}\":\"${pipeline.expressions[key]}\"\r\n <#sep>,\r\n \r\n \r\n },\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"template\">\r\n \"template\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"template\": \"${pipeline.template}\"\r\n }\r\n \r\n <#if pipeline.type == \"timestamp\">\r\n \"timestamp\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"format\": \"${pipeline.format}\"\r\n }\r\n \r\n <#if pipeline.type == \"labels\"> \r\n \"labels\": { \r\n <#if pipeline.labels??&& (pipeline.labels?size >0)>\r\n <#list pipeline.labels?keys as key>\r\n \"${key}\":\"${pipeline.labels[key]}\"\r\n <#sep>,\r\n \r\n \r\n }\r\n \r\n <#if pipeline.type == \"output\"> \r\n \"output\": {\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ],\r\n <#if endpoint.config.type == \"file\">\r\n \"static_configs\": [\r\n {\r\n \"labels\": {\r\n \"__path__\": \"${endpoint.config.fileName}\",\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n\r\n }\r\n }\r\n ]\r\n <#elseif endpoint.config.type == \"syslog\">\r\n \"syslog\": {\r\n \"listen_address\": \"${endpoint.config.listenAddress}\",\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n \r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__syslog_message_app_name\"\r\n ],\r\n \"regex\":\"${endpoint.config.appName}\",\r\n \"action\":\"keep\"\r\n },\r\n {\r\n \"source_labels\": [\r\n \"__syslog_message_app_name\"\r\n ],\r\n \"target_label\": \"appName\"\r\n }\r\n ] \r\n <#elseif endpoint.config.type == \"journal\">\r\n \"journal\": {\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n\r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__journal__systemd_unit\"\r\n ],\r\n \"regex\":\"${endpoint.config.unit}\",\r\n \"action\":\"keep\"\r\n },\r\n {\r\n \"source_labels\": [\r\n \"__journal__systemd_unit\"\r\n ],\r\n \"target_label\": \"unit\"\r\n }\r\n ] \r\n \r\n }\r\n <#sep>,\r\n \r\n ]\r\n}', 1, 'promtail.yml 配置模板'); --- ---------------------------- --- Table structure for sys_log --- ---------------------------- -DROP TABLE IF EXISTS `sys_log`; -CREATE TABLE `sys_log` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `user_id` int(10) NOT NULL DEFAULT -1, - `operation` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '用户操作', - `type` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '可选值\r\n\r\nasset\r\n\r\nendpoint\r\n\r\nproject\r\n\r\nmodule\r\n\r\nalert rule\r\n\r\nalert message\r\n\r\npanel\r\n\r\nchart\r\n\r\ndatacenter\r\n\r\ncabinet', - `opera_id` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '-1', - `method` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '请求方法', - `params` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '请求参数', - `time` bigint(19) NULL DEFAULT NULL COMMENT '执行时长(毫秒)', - `ip` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'IP地址', - `state` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '请求结果', - `response` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, - `exception` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, - `create_date` datetime(0) NOT NULL COMMENT '创建时间', - `api_key_id` int(10) NULL DEFAULT NULL COMMENT '关联 sys_api_key.id', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_type`(`type`) USING BTREE, - INDEX `idx_operation`(`operation`) USING BTREE, - INDEX `idx_time`(`time`) USING BTREE, - INDEX `idx_ip`(`ip`) USING BTREE, - INDEX `idx_user_id`(`user_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统日志表' ROW_FORMAT = Compact; +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prometheus_fed_mode', '2', 1, 'prometheus数据采集模式,只在 metrics本地存储时有效,1:global 使用federation job 集中收集各个 per-datacenter 数据,2:global使用 remote_write 集中收集各个 per-datacenter数据'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_cmd_tmpl', 'OPTION=\" --config.file=\'/opt/nezha/nz-agent/prometheus/prometheus.yml\' --web.listen-address=\'0.0.0.0:10091\' --web.enable-admin-api --enable-feature=remote-write-receiver --storage.tsdb.path=\'/data/prometheusData\' --web.enable-lifecycle --storage.tsdb.retention.time=${storageDays}d \"', 1, 'prometheus 启动参数模板'); --- ---------------------------- --- Records of sys_log --- ---------------------------- +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n \r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ]\r\n }<#sep>,\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n \r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if endpoint.config.relabel_config??&& (endpoint.config.relabel_config?size >0)>\r\n <#list endpoint.config.relabel_config as relabel>\r\n ,{\r\n <#if relabel.action?? && (relabel.action == \'labeldrop\' || relabel.action == \'labelkeep\')>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n \r\n <#if relabel.action?? && relabel.action == \'labelmap\'>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\"\r\n \r\n <#if relabel.action?? && (relabel.action == \'drop\' || relabel.action == \'keep\')>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,\r\n \r\n ],\r\n \r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n \r\n <#if relabel.action?? && relabel.action == \'replace\'>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,\r\n \r\n ],\r\n \r\n \"separator\": \";\",\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"target_label\": \"${(relabel.target_label)!\'\'}\"\r\n \r\n }\r\n \r\n \r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"queue_config\":{\r\n \"capacity\":10,\r\n \"max_shards\":10\r\n }\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n <#-- 开启联邦 -->\r\n <#if jobPojo.fedeEnabled>\r\n <#if jobPojo.scrapePing> \r\n \"{job=~\\\"asset_ping_.+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n <#else>\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n <#else>\r\n <#-- 联邦关闭,抓取所有指标即可 -->\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n \r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ]\r\n }<#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n \r\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\r\n ,\r\n \r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n \r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if endpoint.config.relabel_config??&& (endpoint.config.relabel_config?size >0)>\r\n <#list endpoint.config.relabel_config as relabel>\r\n ,{\r\n <#if relabel.action?? && (relabel.action == \'labeldrop\' || relabel.action == \'labelkeep\')>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n \r\n <#if relabel.action?? && relabel.action == \'labelmap\'>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\"\r\n \r\n <#if relabel.action?? && (relabel.action == \'drop\' || relabel.action == \'keep\')>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,\r\n \r\n ],\r\n \r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n \r\n <#if relabel.action?? && relabel.action == \'replace\'>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,\r\n \r\n ],\r\n \r\n \"separator\": \";\",\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"target_label\": \"${(relabel.target_label)!\'\'}\"\r\n \r\n }\r\n \r\n \r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n ]\r\n \r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"queue_config\":{\r\n \"capacity\":10,\r\n \"max_shards\":10\r\n }\r\n }\r\n <#sep>,\r\n \r\n ] \r\n \r\n}', 1, 'prometheus config文件模板'); --- ---------------------------- --- Table structure for sys_menu --- ---------------------------- -DROP TABLE IF EXISTS `sys_menu`; -CREATE TABLE `sys_menu` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '唯一主键,前端根据此字段判断是否显示按钮或菜单', - `i18n` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `parent_id` int(10) NOT NULL, - `perms` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '多个用逗号分隔,后台根据此字段判断用户是否有权限访问接口', - `type` int(1) NOT NULL COMMENT '1:菜单 2:按钮', - `route` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - `order_num` int(10) NOT NULL COMMENT '默认: 1', - `icon` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'nz-icon nz-alert-add', - `required` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '必要权限,如编辑按钮需要 勾选查看权限\r\n填写内容为 sys_menu.id,多个逗号分隔\r\n1,2', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2191 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; --- ---------------------------- --- Records of sys_menu --- ---------------------------- -INSERT INTO `sys_menu` VALUES (1, 'dashboard', 'dashboard', 'dashboard.title', 0, '', 1, '', 1, 'nz-icon nz-icon-menu-dashboard', ''); -INSERT INTO `sys_menu` VALUES (2, 'overview', 'overview', 'dashboard.overview.title', 1, '', 1, '/overview', 1, '', ''); -INSERT INTO `sys_menu` VALUES (3, 'panel', 'panel', 'dashboard.panel.title', 1, '', 1, '/panel', 2, '', ''); -INSERT INTO `sys_menu` VALUES (4, 'explore', 'explore', 'dashboard.metricPreview.title', 1, '', 1, '/explore', 3, '', ''); -INSERT INTO `sys_menu` VALUES (5, 'asset', 'asset', 'overall.asset', 2147, '', 1, '/asset', 1, '', ''); -INSERT INTO `sys_menu` VALUES (6, 'monitor', 'monitor', 'overall.monitor', 0, '', 1, '', 3, 'nz-icon nz-icon-menu-project', ''); -INSERT INTO `sys_menu` VALUES (7, 'alert', 'alert', 'alert.alert', 0, '', 1, '', 4, 'nz-icon nz-icon-menu-alert', ''); -INSERT INTO `sys_menu` VALUES (8, 'alertMessage', 'alertMessage', 'alert.alertMessage', 7, '', 1, '/alertMessage', 1, '', ''); -INSERT INTO `sys_menu` VALUES (9, 'alertRule', 'alertRule', 'alert.alertRule', 7, '', 1, '/alertRule', 2, '', ''); -INSERT INTO `sys_menu` VALUES (10, 'settings', 'settings', 'overall.config', 0, '', 1, '', 5, 'nz-icon nz-icon-menu-setting', ''); -INSERT INTO `sys_menu` VALUES (11, 'User', 'user', 'config.user.user', 2149, '', 1, '/user', 1, '', ''); -INSERT INTO `sys_menu` VALUES (12, 'role', 'role', 'config.roles.roles', 2149, '', 1, '/roles', 2, '', ''); -INSERT INTO `sys_menu` VALUES (13, 'Agent', 'agent', 'config.agent.agent.agent', 10, '', 1, '/agent', 3, '', ''); -INSERT INTO `sys_menu` VALUES (14, 'dc', 'dc', 'config.dc.dc', 10, '', 1, '/dc', 1, '', ''); -INSERT INTO `sys_menu` VALUES (15, 'model', 'model', 'config.model.model', 2147, '', 1, '/model', 1, '', ''); -INSERT INTO `sys_menu` VALUES (16, 'SNMP', 'snmp', 'SNMP', 10, '', 1, '/snmp', 6, '', ''); -INSERT INTO `sys_menu` VALUES (17, 'system', 'system', 'config.system.system', 10, '', 1, '/system', 7, '', ''); -INSERT INTO `sys_menu` VALUES (18, 'Terminal log', 'terminalLog', 'config.terminallog.terminallog', 2149, '', 1, '/terminalLog', 12, '', ''); -INSERT INTO `sys_menu` VALUES (19, 'operationLog', 'operationLog', 'config.operationlog.operationlog', 2149, '', 1, '/operationLog', 9, '', ''); -INSERT INTO `sys_menu` VALUES (20, 'about', 'about', 'overall.about', 0, '', 1, '/about', 99, 'nz-icon nz-icon-about', ''); -INSERT INTO `sys_menu` VALUES (301, 'Add', 'panel_add', 'buttons.add', 3, 'visual:panel:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (302, 'Edit panel', 'panel_edit', 'buttons.edit', 3, 'visual:panel:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (303, 'Delete panel', 'panel_delete', 'buttons.delete', 3, 'visual:panel:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (305, 'Add chart', 'panel_chart_add', 'buttons.panel.addChart', 3, 'visual:chart:save', 2, '', 30, '', ''); -INSERT INTO `sys_menu` VALUES (308, 'Edit chart', 'panel_chart_edit', 'buttons.panel.editChart', 3, 'visual:chart:update', 2, '', 45, '', ''); -INSERT INTO `sys_menu` VALUES (310, 'Delete chart', 'panel_chart_delete', 'buttons.panel.deleteChart', 3, 'visual:chart:delete', 2, '', 55, '', ''); -INSERT INTO `sys_menu` VALUES (312, 'panel_view', 'panel_view', 'buttons.view', 3, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (501, 'Add asset', 'asset_add', 'buttons.add', 5, 'asset:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (502, 'Edit asset', 'asset_edit', 'buttons.edit', 5, 'asset:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (504, 'asset_delete', 'asset_delete', 'buttons.delete', 5, 'asset:delete', 2, '', 25, '', ''); -INSERT INTO `sys_menu` VALUES (508, 'asset_connect', 'asset_connect', 'buttons.asset.connect', 5, '', 2, '', 45, '', ''); -INSERT INTO `sys_menu` VALUES (529, 'asset_view', 'asset_view', 'buttons.asset.view', 5, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (601, 'project_edit', 'project_edit', 'buttons.edit', 2144, 'project:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (603, 'project_delete', 'project_delete', 'buttons.delete', 2144, 'project:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (606, 'monitor_module_edit', 'monitor_module_edit', 'buttons.edit', 2145, 'module:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (608, 'monitor_module_delete', 'monitor_module_delete', 'buttons.delete', 2145, 'module:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (609, 'monitor_endpoint_add', 'monitor_endpoint_add', 'buttons.add', 2146, 'endpoint:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (610, 'monitor_endpoint_edit', 'monitor_endpoint_edit', 'buttons.edit', 2146, 'endpoint:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (611, 'monitor_endpoint_delete', 'monitor_endpoint_delete', 'buttons.delete', 2146, 'endpoint:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (622, 'monitor_module_add', 'monitor_module_add', 'buttons.add', 2145, 'module:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (623, 'project_view', 'project_view', 'buttons.view', 2144, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (801, 'Expire message', 'alertMessage_expired', 'buttons.expired', 8, '', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (803, 'View message', 'alertMessage_view', 'buttons.view', 8, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (901, 'Add rule', 'alertRule_add', 'buttons.add', 9, 'alert:rule:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (902, 'Edit rule', 'alertRule_edit', 'buttons.edit', 9, 'alert:rule:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (903, 'Delete rule', 'alertRule_delete', 'buttons.delete', 9, 'alert:rule:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (910, 'View rule', 'alertRule_view', 'buttons.view', 9, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (1101, 'Add user', 'user_add', 'buttons.add', 11, 'sys:user:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (1102, 'Edit user', 'user_edit', 'buttons.edit', 11, 'sys:user:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (1103, 'Delete user', 'user_delete', 'buttons.delete', 11, 'sys:user:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (1105, 'View user', 'user_view', 'buttons.view', 11, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (1201, 'Add role', 'role_add', 'buttons.add', 12, 'sys:role:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (1202, 'Edit role', 'role_edit', 'buttons.edit', 12, 'sys:role:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (1203, 'Delete role', 'role_delete', 'buttons.delete', 12, 'sys:role:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (1205, 'View role', 'role_view', 'buttons.view', 12, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (1301, 'Add agent', 'agent_add', 'buttons.add', 13, 'promserver:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (1302, 'Edit agent', 'agent_edit', 'buttons.edit', 13, 'promserver:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (1303, 'Delete agent', 'agent_delete', 'buttons.delete', 13, 'promserver:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (1305, 'View agent', 'agent_view', 'buttons.view', 13, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (1401, 'Add data center', 'dc_add', 'buttons.add', 14, 'dc:save,cabinet:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (1402, 'Edit data center', 'dc_edit', 'buttons.edit', 14, 'dc:update,cabinet:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (1403, 'Delete data center', 'dc_delete', 'buttons.delete', 14, 'dc:delete,cabinet:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (1411, 'View data center', 'dc_view', 'buttons.view', 14, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (1501, 'Add model', 'model_add', 'buttons.add', 15, 'asset:model:save,asset:brand:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (1502, 'Edit model', 'model_edit', 'buttons.edit', 15, 'asset:model:update,asset:brand:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (1503, 'Delete model', 'model_delete', 'buttons.delete', 15, 'asset:model:delete,asset:brand:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (1514, 'View model', 'model_view', 'buttons.view', 15, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (1602, 'Add MIB file', 'snmp_mibFile_add', 'buttons.snmp.add', 16, 'sys:mib:save', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (1603, 'Edit MIB file', 'snmp_mibFile_edit', 'buttons.snmp.edit', 16, 'sys:mib:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (1604, 'Delete MIB file', 'snmp_mibFile_delete', 'buttons.snmp.delete', 16, 'sys:mib:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (1607, 'View MIB file', 'snmp_mibFile_view', 'buttons.snmp.view', 16, '', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (1701, '基础设置', 'system_basic_save', 'buttons.system.basic', 17, 'sys:config:update', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (1702, 'system_email_save', 'system_email_save', 'buttons.system.email', 17, 'sys:config:update', 2, '', 0, '', ''); -INSERT INTO `sys_menu` VALUES (1703, 'system_terminal_save', 'system_terminal_save', 'buttons.system.terminal', 17, 'sys:config:update', 2, '', 0, '', ''); -INSERT INTO `sys_menu` VALUES (1704, 'system_ldap_save', 'system_ldap_save', 'buttons.system.ldap', 17, 'sys:config:update', 2, '', 0, '', ''); -INSERT INTO `sys_menu` VALUES (1705, 'system_notification_add', 'system_notification_add', 'buttons.add', 2159, 'alert:notify:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (1706, 'system_notification_edit', 'system_notification_edit', 'buttons.edit', 2159, 'alert:notify:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (1707, 'system_notification_view', 'system_notification_view', 'buttons.view', 2159, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (1708, 'system_notification_delete', 'system_notification_delete', 'buttons.delete', 2159, 'alert:notify:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (1709, 'system_link_view', 'system_link_view', 'buttons.view', 2160, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (1710, 'system_link_edit', 'system_link_edit', 'buttons.edit', 2160, 'sys:link:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (1711, 'system_link_add', 'system_link_add', 'buttons.add', 2160, 'sys:link:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (1712, 'system_link_delete', 'system_link_delete', 'buttons.delete', 2160, 'sys:link:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (2114, 'alertSilence', 'alertSilence_list', 'alert.silence.silence', 7, '', 1, '/alertSilence', 3, '', ''); -INSERT INTO `sys_menu` VALUES (2115, 'View alert silence', 'alertSilence_view', 'buttons.view', 2114, '', 2, '', 3, '', ''); -INSERT INTO `sys_menu` VALUES (2116, 'Add alert silence', 'alertSilence_add', 'buttons.add', 2114, 'alert:silence:save', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (2117, 'Edit alert silence', 'alertSilence_edit', 'buttons.edit', 2114, 'alert:silence:update', 2, '', 6, '', ''); -INSERT INTO `sys_menu` VALUES (2118, 'expressionTemplate', 'exprTemp', 'config.exprTemp.exprTemp', 2180, '', 3, '/exprTemp', 6, '', ''); -INSERT INTO `sys_menu` VALUES (2120, 'Edit expression template', 'expressionTemplate_edit', 'buttons.edit', 2118, 'expression:tmpl:update', 2, '', 15, '', ''); -INSERT INTO `sys_menu` VALUES (2121, 'Delete expression template', 'expressionTemplate_delete', 'buttons.delete', 2118, 'expression:tmpl:delete', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (2122, 'View expression template', 'expressionTemplate_view', 'buttons.view', 2118, '', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2123, 'Add expression template', 'expressionTemplate_add', 'buttons.add', 2118, 'expression:tmpl:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (2127, 'asset type to add', 'assetType_toAdd', 'buttons.assetType.toAdd', 2125, 'asset:type:save', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2128, 'Asset type view', 'assetType_view', 'buttons.assetType.view', 2125, '', 2, '', 2, '', ''); -INSERT INTO `sys_menu` VALUES (2129, 'Asset type to edit', 'assetType_toEdit', 'buttons.assetType.toEdit', 2125, 'asset:type:update', 2, '', 3, '', ''); -INSERT INTO `sys_menu` VALUES (2130, 'Asset type delete', 'assetType_delete', 'buttons.assetType.delete', 2125, 'asset:type:delete', 2, '', 4, '', ''); -INSERT INTO `sys_menu` VALUES (2131, 'Asset state view', 'assetState_view', 'buttons.assetState.view', 2126, '', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2132, 'Asset state to add', 'assetState_toAdd', 'buttons.assetState.toAdd', 2126, 'asset:state:save', 2, '', 2, '', ''); -INSERT INTO `sys_menu` VALUES (2133, 'Asset state to edit', 'assetState_toEdit', 'buttons.assetState.toEdit', 2126, 'asset:state:update', 2, '', 3, '', ''); -INSERT INTO `sys_menu` VALUES (2134, 'Asset state delete', 'assetState_delete', 'buttons.assetState.delete', 2126, 'asset:state:delete', 2, '', 4, '', ''); -INSERT INTO `sys_menu` VALUES (2136, 'Asset label', 'assetLabel', 'config.assetLabel.assetLabel', 2147, '', 1, '/assetLabel', 2, '', ''); -INSERT INTO `sys_menu` VALUES (2137, 'Add asset label', 'asset_label_add', 'buttons.add', 2136, 'field:meta:save,field:group:save', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2138, 'Edit asset label', 'asset_label_edit', 'buttons.edit', 2136, 'field:meta:update,field:group:update', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (2139, 'Delete asset label', 'asset_label_delete', 'buttons.delete', 2136, 'field:meta:delete,field:group:delete', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (2144, 'project', 'project', 'overall.project', 6, '', 1, '/monitor/project', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2145, 'module', 'module', 'project.module.module', 6, '', 1, '/monitor/module', 5, '', ''); -INSERT INTO `sys_menu` VALUES (2146, 'endpoint', 'endpoint', 'project.endpoint.endpoint', 6, '', 1, '/monitor/endpoint', 10, '', ''); -INSERT INTO `sys_menu` VALUES (2147, 'Assets', 'assets', 'overall.asset', 0, '', 1, '', 2, 'nz-icon nz-icon-menu-assets', ''); -INSERT INTO `sys_menu` VALUES (2149, 'Administration', 'administration', 'overall.administration', 0, '', 1, '', 50, 'nz-icon nz-icon-personal-circle', ''); -INSERT INTO `sys_menu` VALUES (2150, 'Kill terminal', 'terminal_kill', 'buttons.terminalLog.kill', 18, 'terminal:kill', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2151, 'Monitor terminal', 'terminal_monitor', 'buttons.terminalLog.monitor', 18, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (2153, 'MIB browser', 'mibBrowser', 'buttons.snmp.mibBrowser', 16, '', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (2155, 'View credential', 'snmp_credential_view', 'buttons.credential.view', 16, '', 2, '', 25, '', ''); -INSERT INTO `sys_menu` VALUES (2156, 'Add credential', 'credential_add', 'buttons.credential.add', 16, 'snmp:credential:save', 2, '', 30, '', ''); -INSERT INTO `sys_menu` VALUES (2157, 'Edit credential', 'credential_edit', 'buttons.credential.edit', 16, 'snmp:credential:update', 2, '', 35, '', ''); -INSERT INTO `sys_menu` VALUES (2158, 'Delete credential', 'credential_delete', 'buttons.credential.delete', 16, 'snmp:credential:delete', 2, '', 40, '', ''); -INSERT INTO `sys_menu` VALUES (2159, 'Notification', 'notification', 'system.notification.notification', 17, '', 3, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2160, 'Link', 'link', 'config.system.link.link', 17, '', 3, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (2161, 'Add project', 'project_add', 'buttons.add', 2144, 'project:save', 2, '', 10, '', ''); -INSERT INTO `sys_menu` VALUES (2162, 'View module', 'monitor_module_view', 'buttons.view', 2145, '', 2, '', 5, '', ''); -INSERT INTO `sys_menu` VALUES (2163, 'Expire', 'alertSilence_expire', 'buttons.expired', 2114, '', 2, '', 20, '', ''); -INSERT INTO `sys_menu` VALUES (2164, 'Browser', 'snmp_mib_browser', 'config.mib.mibBrowser', 16, '', 3, '/mib/browser', 2, '', ''); -INSERT INTO `sys_menu` VALUES (2165, 'Mib file', 'snmp_mib_file', 'config.mib.mib', 16, '', 3, '/mib/file', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2166, 'Credentials', 'snmp_mib_credentials', 'config.mib.credentials', 16, '', 3, '/mib/credentials', 3, '', ''); -INSERT INTO `sys_menu` VALUES (2169, 'projectTopoIconList', 'topo_icon_list', 'project.topo.icon.list', 2144, '', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2170, 'projectTopoIconDelete', 'topo_icon_delete', 'project.topo.icon.delete', 2144, 'project:topo:icon:delete', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2171, 'project:topo:icon:save', 'topo_icon_save', 'project.topo.icon.save', 2144, 'project:topo:icon:save', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2172, 'projectTopoIconInfo', 'topo_icon_info', 'project.topo.icon.info', 2144, '', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2173, 'projectTopoList', 'topo_list', 'project.topo.list', 2144, '', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2174, 'projectTopoUpdate', 'project_topo_update', 'project.topo.update', 2144, 'project:topo:update', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2176, 'endpointList', 'endpoint_list', 'project.endpoint.list', 2146, '', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2180, 'template', 'template', 'overall.template', 10, '', 1, '/template', 4, '', ''); -INSERT INTO `sys_menu` VALUES (2181, 'exprTemp', 'config.exprTemp', 'overall.exprTemp', 2180, '', 3, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2182, 'bbuttons.system.reset', 'system_reset_reset', 'system.reset.reset', 17, 'sys:config:reset', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2185, 'addChartTemp', 'addChartTemp', 'dashboard.addChartTemp', 3, 'visual:chart:save', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2187, 'apiKey', 'apiKey', 'system.apikey.apiKey', 17, '', 3, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2188, 'buttons.system.apikey.add', 'system_apiKey_add', 'buttons.system.apiKey.add', 17, 'sys:apiKey:save', 2, '', 1, '', ''); -INSERT INTO `sys_menu` VALUES (2189, 'buttons.system.apiKey.edit', 'system_apiKey_edit', 'buttons.system.apiKey.edit', 17, 'sys:apiKey:save', 2, '', 2, '', ''); -INSERT INTO `sys_menu` VALUES (2190, 'buttons.system.apiKey.delete', 'system_apiKey_delete', 'buttons.system.apiKey.delete', 17, 'sys:apiKey:delete', 2, '', 3, '', ''); --- ---------------------------- --- Table structure for sys_role --- ---------------------------- -DROP TABLE IF EXISTS `sys_role`; -CREATE TABLE `sys_role` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `i18n` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `remark` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - `build_in` int(1) NOT NULL DEFAULT 0 COMMENT '可选值:\r\n\r\n0:非内置\r\n\r\n1:内置', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'confagent_name', '{\"centos\":\"nz-agent-.*rpm\",\"ubuntu\":\"nz-agent-.*rpm\"}', 1, 'confagent 下载文件名称'); --- ---------------------------- --- Records of sys_role --- ---------------------------- -INSERT INTO `sys_role` VALUES (1, 'admin', 'admin', 'The system built-in administrator role', 1); -INSERT INTO `sys_role` VALUES (2, 'common', 'common', 'The system built-in common user role', 1); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'promtail_yml_tmpl', '{\r\n \"server\": {\r\n \"http_listen_address\": \"0.0.0.0\",\r\n \"http_listen_port\": 19080,\r\n \"grpc_listen_port\": 19081\r\n },\r\n \"clients\": [\r\n {\r\n <#list clientsMapList as clientMap>\r\n \"url\" : \"${clientMap.url}\",\r\n \"bearer_token\": \"${clientMap.token}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\":true\r\n }<#sep>,\r\n \r\n }\r\n ],\r\n \"positions\": {\r\n \"filename\": \"/opt/nezha/promtail/positions.yaml\"\r\n },\r\n \"scrape_configs\": [\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": \"${endpoint.id?c}_${endpoint_index}\",\r\n \"pipeline_stages\": [\r\n <#if endpoint.config.pipeline??&&(endpoint.config.pipeline?size>0)>\r\n <#list endpoint.config.pipeline as pipeline>\r\n {\r\n <#if pipeline.type == \"regex\">\r\n \"regex\": {\r\n \"expression\": \"${pipeline.expression}\",\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"json\">\r\n \"json\": {\r\n \"expressions\": {\r\n <#if pipeline.expressions??&& (pipeline.expressions?size >0)>\r\n <#list pipeline.expressions?keys as key>\r\n \"${key}\":\"${pipeline.expressions[key]}\"\r\n <#sep>,\r\n \r\n \r\n },\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n <#if pipeline.type == \"template\">\r\n \"template\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"template\": \"${pipeline.template}\"\r\n }\r\n \r\n <#if pipeline.type == \"timestamp\">\r\n \"timestamp\": {\r\n \"source\": \"${pipeline.source}\",\r\n \"format\": \"${pipeline.format}\"\r\n }\r\n \r\n <#if pipeline.type == \"labels\"> \r\n \"labels\": { \r\n <#if pipeline.labels??&& (pipeline.labels?size >0)>\r\n <#list pipeline.labels?keys as key>\r\n \"${key}\":\"${pipeline.labels[key]}\"\r\n <#sep>,\r\n \r\n \r\n }\r\n \r\n <#if pipeline.type == \"output\"> \r\n \"output\": {\r\n \"source\": \"${pipeline.source}\"\r\n }\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ],\r\n <#if endpoint.config.type == \"file\">\r\n \"static_configs\": [\r\n {\r\n \"labels\": {\r\n \"__path__\": \"${endpoint.config.fileName}\",\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n\r\n }\r\n }\r\n ]\r\n <#elseif endpoint.config.type == \"syslog\">\r\n \"syslog\": {\r\n \"listen_address\": \"${endpoint.config.listenAddress}\",\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n \r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__syslog_message_app_name\"\r\n ],\r\n \"regex\":\"${endpoint.config.appName}\",\r\n \"action\":\"keep\"\r\n },\r\n {\r\n \"source_labels\": [\r\n \"__syslog_message_app_name\"\r\n ],\r\n \"target_label\": \"appName\"\r\n }\r\n ] \r\n <#elseif endpoint.config.type == \"journal\">\r\n \"journal\": {\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\"\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"project\" && key != \"asset\" && key != \"module\" && key != \"endpoint\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n\r\n }\r\n },\r\n \"relabel_configs\": [\r\n {\r\n \"source_labels\": [\r\n \"__journal__systemd_unit\"\r\n ],\r\n \"regex\":\"${endpoint.config.unit}\",\r\n \"action\":\"keep\"\r\n },\r\n {\r\n \"source_labels\": [\r\n \"__journal__systemd_unit\"\r\n ],\r\n \"target_label\": \"unit\"\r\n }\r\n ] \r\n \r\n }\r\n <#sep>,\r\n \r\n ]\r\n}', 1, 'promtail.yml 配置模板'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n \r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ]\r\n }<#sep>,\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n \r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n\r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n {\r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"tls_config\":{\r\n \"insecure_skip_verify\":true\r\n },\r\n \"queue_config\":{\r\n \"capacity\": 5000,\r\n \"max_samples_per_send\": 1000,\r\n \"min_shards\": 5,\r\n \"max_shards\": 10,\r\n \"min_backoff\": \"20ms\",\r\n \"min_backoff\": \"50ms\"\r\n }\r\n }\r\n <#sep>,\r\n \r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n <#-- 开启联邦 -->\r\n <#if jobPojo.fedeEnabled>\r\n <#if jobPojo.scrapePing> \r\n \"{job=~\\\"asset_ping_.+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n <#else>\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n <#else>\r\n <#-- 联邦关闭,抓取所有指标即可 -->\r\n \"{__name__=~\\\".+\\\",nz_agent_id != \\\"${jobPojo.excludeAgentId}\\\"}\"\r\n \r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n \r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,\r\n \r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"<#sep>,\r\n \r\n } \r\n \r\n }<#sep>,\r\n \r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n \r\n ]\r\n }<#sep>,\r\n \r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n \r\n \r\n <#list assetList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.promserver.host}\",\r\n \"nz_agent_id\": ${asset.promserver.id?c}\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,\r\n \r\n \r\n \r\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\r\n ,\r\n \r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n \r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n \r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n \r\n \r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n \r\n \r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n \r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.config.protocol == \"http\">\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,\r\n \r\n ]\r\n <#sep>,\r\n \r\n },\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n \r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n \r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n \r\n \r\n \"nz_agent_id\": ${endpoint.promserver.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n \r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,\r\n \r\n \r\n \r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n <#if endpoint.relabelConfigListJsonString?default(\"\")?trim?length gt 0>\r\n ,\r\n \"relabel_configs\": ${endpoint.relabelConfigListJsonString}\r\n \r\n }\r\n <#sep>,\r\n \r\n \r\n ]\r\n \r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"tls_config\":{\r\n \"insecure_skip_verify\":true\r\n },\r\n \"queue_config\":{\r\n \"capacity\": 5000,\r\n \"max_samples_per_send\": 1000,\r\n \"min_shards\": 5,\r\n \"max_shards\": 10,\r\n \"min_backoff\": \"20ms\",\r\n \"min_backoff\": \"50ms\"\r\n }\r\n }\r\n <#sep>,\r\n \r\n ] \r\n \r\n}', 1, 'prometheus config文件模板'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'map_center_config', '{\"longitude\":115.576,\"latitude\":39.541,\"zoom\":3,\"minZoom\":3,\"maxZoom\":7}', 1, '地图配置'); --- ---------------------------- --- Table structure for sys_role_menu --- ---------------------------- -DROP TABLE IF EXISTS `sys_role_menu`; -CREATE TABLE `sys_role_menu` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `role_id` int(10) NOT NULL, - `menu_id` int(10) NOT NULL, - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 256 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +UPDATE `sys_user` SET `email` = '', `status` = 1, `create_at` = now() WHERE `id` = 1 and (`email`='nezha@www.puppy.com' or `email`='nezha@www.puppn.com'); --- ---------------------------- --- Records of sys_role_menu --- ---------------------------- -INSERT INTO `sys_role_menu` VALUES (1, 1, 1); -INSERT INTO `sys_role_menu` VALUES (2, 1, 2); -INSERT INTO `sys_role_menu` VALUES (3, 1, 3); -INSERT INTO `sys_role_menu` VALUES (4, 1, 4); -INSERT INTO `sys_role_menu` VALUES (5, 1, 5); -INSERT INTO `sys_role_menu` VALUES (6, 1, 6); -INSERT INTO `sys_role_menu` VALUES (7, 1, 7); -INSERT INTO `sys_role_menu` VALUES (8, 1, 8); -INSERT INTO `sys_role_menu` VALUES (9, 1, 9); -INSERT INTO `sys_role_menu` VALUES (10, 1, 10); -INSERT INTO `sys_role_menu` VALUES (11, 1, 11); -INSERT INTO `sys_role_menu` VALUES (12, 1, 12); -INSERT INTO `sys_role_menu` VALUES (13, 1, 13); -INSERT INTO `sys_role_menu` VALUES (14, 1, 14); -INSERT INTO `sys_role_menu` VALUES (15, 1, 15); -INSERT INTO `sys_role_menu` VALUES (16, 1, 16); -INSERT INTO `sys_role_menu` VALUES (17, 1, 17); -INSERT INTO `sys_role_menu` VALUES (18, 1, 18); -INSERT INTO `sys_role_menu` VALUES (19, 1, 19); -INSERT INTO `sys_role_menu` VALUES (20, 1, 20); -INSERT INTO `sys_role_menu` VALUES (21, 1, 301); -INSERT INTO `sys_role_menu` VALUES (22, 1, 302); -INSERT INTO `sys_role_menu` VALUES (23, 1, 303); -INSERT INTO `sys_role_menu` VALUES (24, 1, 305); -INSERT INTO `sys_role_menu` VALUES (25, 1, 308); -INSERT INTO `sys_role_menu` VALUES (26, 1, 310); -INSERT INTO `sys_role_menu` VALUES (27, 1, 312); -INSERT INTO `sys_role_menu` VALUES (28, 1, 501); -INSERT INTO `sys_role_menu` VALUES (29, 1, 502); -INSERT INTO `sys_role_menu` VALUES (30, 1, 504); -INSERT INTO `sys_role_menu` VALUES (31, 1, 508); -INSERT INTO `sys_role_menu` VALUES (32, 1, 529); -INSERT INTO `sys_role_menu` VALUES (33, 1, 601); -INSERT INTO `sys_role_menu` VALUES (34, 1, 603); -INSERT INTO `sys_role_menu` VALUES (35, 1, 606); -INSERT INTO `sys_role_menu` VALUES (36, 1, 608); -INSERT INTO `sys_role_menu` VALUES (37, 1, 609); -INSERT INTO `sys_role_menu` VALUES (38, 1, 610); -INSERT INTO `sys_role_menu` VALUES (39, 1, 611); -INSERT INTO `sys_role_menu` VALUES (40, 1, 622); -INSERT INTO `sys_role_menu` VALUES (41, 1, 623); -INSERT INTO `sys_role_menu` VALUES (42, 1, 801); -INSERT INTO `sys_role_menu` VALUES (43, 1, 803); -INSERT INTO `sys_role_menu` VALUES (44, 1, 901); -INSERT INTO `sys_role_menu` VALUES (45, 1, 902); -INSERT INTO `sys_role_menu` VALUES (46, 1, 903); -INSERT INTO `sys_role_menu` VALUES (47, 1, 910); -INSERT INTO `sys_role_menu` VALUES (48, 1, 1101); -INSERT INTO `sys_role_menu` VALUES (49, 1, 1102); -INSERT INTO `sys_role_menu` VALUES (50, 1, 1103); -INSERT INTO `sys_role_menu` VALUES (51, 1, 1105); -INSERT INTO `sys_role_menu` VALUES (52, 1, 1201); -INSERT INTO `sys_role_menu` VALUES (53, 1, 1202); -INSERT INTO `sys_role_menu` VALUES (54, 1, 1203); -INSERT INTO `sys_role_menu` VALUES (55, 1, 1205); -INSERT INTO `sys_role_menu` VALUES (56, 1, 1301); -INSERT INTO `sys_role_menu` VALUES (57, 1, 1302); -INSERT INTO `sys_role_menu` VALUES (58, 1, 1303); -INSERT INTO `sys_role_menu` VALUES (59, 1, 1305); -INSERT INTO `sys_role_menu` VALUES (60, 1, 1401); -INSERT INTO `sys_role_menu` VALUES (61, 1, 1402); -INSERT INTO `sys_role_menu` VALUES (62, 1, 1403); -INSERT INTO `sys_role_menu` VALUES (63, 1, 1411); -INSERT INTO `sys_role_menu` VALUES (64, 1, 1501); -INSERT INTO `sys_role_menu` VALUES (65, 1, 1502); -INSERT INTO `sys_role_menu` VALUES (66, 1, 1503); -INSERT INTO `sys_role_menu` VALUES (67, 1, 1514); -INSERT INTO `sys_role_menu` VALUES (68, 1, 1602); -INSERT INTO `sys_role_menu` VALUES (69, 1, 1603); -INSERT INTO `sys_role_menu` VALUES (70, 1, 1604); -INSERT INTO `sys_role_menu` VALUES (71, 1, 1607); -INSERT INTO `sys_role_menu` VALUES (72, 1, 1701); -INSERT INTO `sys_role_menu` VALUES (73, 1, 1702); -INSERT INTO `sys_role_menu` VALUES (74, 1, 1703); -INSERT INTO `sys_role_menu` VALUES (75, 1, 1704); -INSERT INTO `sys_role_menu` VALUES (76, 1, 1705); -INSERT INTO `sys_role_menu` VALUES (77, 1, 1706); -INSERT INTO `sys_role_menu` VALUES (78, 1, 1707); -INSERT INTO `sys_role_menu` VALUES (79, 1, 1708); -INSERT INTO `sys_role_menu` VALUES (80, 1, 1709); -INSERT INTO `sys_role_menu` VALUES (81, 1, 1710); -INSERT INTO `sys_role_menu` VALUES (82, 1, 1711); -INSERT INTO `sys_role_menu` VALUES (83, 1, 1712); -INSERT INTO `sys_role_menu` VALUES (84, 1, 2114); -INSERT INTO `sys_role_menu` VALUES (85, 1, 2115); -INSERT INTO `sys_role_menu` VALUES (86, 1, 2116); -INSERT INTO `sys_role_menu` VALUES (87, 1, 2117); -INSERT INTO `sys_role_menu` VALUES (88, 1, 2118); -INSERT INTO `sys_role_menu` VALUES (89, 1, 2120); -INSERT INTO `sys_role_menu` VALUES (90, 1, 2121); -INSERT INTO `sys_role_menu` VALUES (91, 1, 2122); -INSERT INTO `sys_role_menu` VALUES (92, 1, 2123); -INSERT INTO `sys_role_menu` VALUES (93, 1, 2127); -INSERT INTO `sys_role_menu` VALUES (94, 1, 2128); -INSERT INTO `sys_role_menu` VALUES (95, 1, 2129); -INSERT INTO `sys_role_menu` VALUES (96, 1, 2130); -INSERT INTO `sys_role_menu` VALUES (97, 1, 2131); -INSERT INTO `sys_role_menu` VALUES (98, 1, 2132); -INSERT INTO `sys_role_menu` VALUES (99, 1, 2133); -INSERT INTO `sys_role_menu` VALUES (100, 1, 2134); -INSERT INTO `sys_role_menu` VALUES (101, 1, 2136); -INSERT INTO `sys_role_menu` VALUES (102, 1, 2137); -INSERT INTO `sys_role_menu` VALUES (103, 1, 2138); -INSERT INTO `sys_role_menu` VALUES (104, 1, 2139); -INSERT INTO `sys_role_menu` VALUES (105, 1, 2144); -INSERT INTO `sys_role_menu` VALUES (106, 1, 2145); -INSERT INTO `sys_role_menu` VALUES (107, 1, 2146); -INSERT INTO `sys_role_menu` VALUES (108, 1, 2147); -INSERT INTO `sys_role_menu` VALUES (109, 1, 2148); -INSERT INTO `sys_role_menu` VALUES (110, 1, 2149); -INSERT INTO `sys_role_menu` VALUES (111, 1, 2150); -INSERT INTO `sys_role_menu` VALUES (112, 1, 2151); -INSERT INTO `sys_role_menu` VALUES (113, 1, 2153); -INSERT INTO `sys_role_menu` VALUES (114, 1, 2155); -INSERT INTO `sys_role_menu` VALUES (115, 1, 2156); -INSERT INTO `sys_role_menu` VALUES (116, 1, 2157); -INSERT INTO `sys_role_menu` VALUES (117, 1, 2158); -INSERT INTO `sys_role_menu` VALUES (118, 1, 2159); -INSERT INTO `sys_role_menu` VALUES (119, 1, 2160); -INSERT INTO `sys_role_menu` VALUES (120, 1, 2161); -INSERT INTO `sys_role_menu` VALUES (121, 1, 2162); -INSERT INTO `sys_role_menu` VALUES (122, 1, 2163); -INSERT INTO `sys_role_menu` VALUES (123, 1, 2164); -INSERT INTO `sys_role_menu` VALUES (124, 1, 2165); -INSERT INTO `sys_role_menu` VALUES (125, 1, 2166); -INSERT INTO `sys_role_menu` VALUES (126, 1, 2169); -INSERT INTO `sys_role_menu` VALUES (127, 1, 2170); -INSERT INTO `sys_role_menu` VALUES (128, 1, 2171); -INSERT INTO `sys_role_menu` VALUES (129, 1, 2172); -INSERT INTO `sys_role_menu` VALUES (130, 1, 2173); -INSERT INTO `sys_role_menu` VALUES (131, 1, 2174); -INSERT INTO `sys_role_menu` VALUES (132, 1, 2176); -INSERT INTO `sys_role_menu` VALUES (133, 1, 2180); -INSERT INTO `sys_role_menu` VALUES (134, 1, 2181); -INSERT INTO `sys_role_menu` VALUES (135, 1, 2182); -INSERT INTO `sys_role_menu` VALUES (136, 1, 2185); -INSERT INTO `sys_role_menu` VALUES (137, 1, 2187); -INSERT INTO `sys_role_menu` VALUES (138, 1, 2188); -INSERT INTO `sys_role_menu` VALUES (139, 1, 2189); -INSERT INTO `sys_role_menu` VALUES (140, 1, 2190); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'metrics_storage_local_path', '/data/cortex', 1, '指标本地数据保存路径'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'logs_storage_local_path', '/data/loki', 1, '日志本地存储路径'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'cortex_yml_tmpl', '{\r\n \"auth_enabled\": false,\r\n \"server\": {\r\n \"http_listen_port\": <#if port?default(\"\")?trim?length gt 0> ${port?c} <#else>10093,\r\n \"grpc_listen_port\":10094,\r\n \"grpc_server_max_recv_msg_size\": 104857600,\r\n \"grpc_server_max_send_msg_size\": 104857600,\r\n \"grpc_server_max_concurrent_streams\": 1000\r\n },\r\n \"distributor\": {\r\n \"shard_by_all_labels\": true,\r\n \"pool\": {\r\n \"health_check_ingesters\": true\r\n }\r\n },\r\n \"ingester_client\": {\r\n \"grpc_client_config\": {\r\n \"max_recv_msg_size\": 104857600,\r\n \"max_send_msg_size\": 104857600,\r\n \"grpc_compression\": \"gzip\"\r\n }\r\n },\r\n <#if isMemberlistStore>\r\n \"ingester\": {\r\n \"lifecycler\": {\r\n \"join_after\": \"10s\",\r\n \"min_ready_duration\": \"0s\",\r\n \"final_sleep\": \"5s\",\r\n \"num_tokens\": 512,\r\n \"ring\": {\r\n \"kvstore\": {\r\n \"store\": \"memberlist\"\r\n },\r\n \"replication_factor\": 1\r\n }\r\n }\r\n },\r\n \"memberlist\": {\r\n \"bind_port\": <#if gossIp?default(\"\")?trim?length gt 0>${gossIp?c}<#else>7946,\r\n \"join_members\": [\r\n <#list joinMemberList as joinIp>\r\n \"${joinIp}:<#if gossIp?default(\"\")?trim?length gt 0>${gossIp?c}<#else>7946\"\r\n <#sep>,\r\n \r\n ],\r\n \"abort_if_cluster_join_fails\": false\r\n },\r\n <#else>\r\n \"ingester\": {\r\n \"lifecycler\": {\r\n \"join_after\": \"10s\",\r\n \"min_ready_duration\": \"0s\",\r\n \"final_sleep\": \"5s\",\r\n \"num_tokens\": 512,\r\n \"ring\": {\r\n \"kvstore\": {\r\n \"store\": \"inmemory\"\r\n },\r\n \"replication_factor\": 1\r\n }\r\n }\r\n },\r\n \r\n \r\n \"storage\": {\r\n \"engine\": \"blocks\"\r\n },\r\n \"blocks_storage\": {\r\n \"tsdb\": {\r\n \"dir\": \"${systemConfig.metrics_storage_local_path}/tsdb\"\r\n },\r\n \"bucket_store\": {\r\n \"sync_dir\": \"${systemConfig.metrics_storage_local_path}/tsdb-sync\"\r\n },\r\n <#if isLocalStorage>\r\n \"backend\": \"filesystem\",\r\n \"filesystem\": {\r\n \"dir\": \"${systemConfig.metrics_storage_local_path}/data/tsdb\"\r\n }\r\n <#else>\r\n \"backend\": \"s3\",\r\n \"s3\": {\r\n \"endpoint\": \"${objectStroageUrl}\",\r\n \"bucket_name\": \"${bucketName}\",\r\n \"access_key_id\": \"${accessKey}\",\r\n \"secret_access_key\": \"${secret}\",\r\n \"insecure\": <#if insecure?default(\"\")?trim?length gt 0>${insecure}<#else>true\r\n }\r\n \r\n },\r\n \"store_gateway\": {\r\n \"sharding_enabled\": true,\r\n \"sharding_ring\": {\r\n \"kvstore\": {\r\n \"store\": <#if isMemberlistStore> \"memberlist\" <#else> \"inmemory\" \r\n }\r\n }\r\n },\r\n \"compactor\": {\r\n \"data_dir\": \"${systemConfig.metrics_storage_local_path}/compactor\",\r\n \"sharding_ring\": {\r\n \"kvstore\": {\r\n \"store\": <#if isMemberlistStore> \"memberlist\" <#else> \"inmemory\" \r\n }\r\n }\r\n },\r\n \"frontend_worker\": {\r\n \"match_max_concurrent\": true\r\n },\r\n \r\n <#if isAlert>\r\n \"ruler\": {\r\n \"enable_api\": true,\r\n \"enable_sharding\": true,\r\n \"rule_path\": \"${systemConfig.metrics_storage_local_path}/rules\",\r\n \"ring\": {\r\n \"num_tokens\": 512,\r\n \"kvstore\": {\r\n \"store\": <#if isMemberlistStore> \"memberlist\" <#else> \"inmemory\" \r\n }\r\n },\r\n \"alertmanager_url\":\"http://${systemConfig.alert_api}${systemConfig.alert_path_prefix}\"\r\n },\r\n \"ruler_storage\":{\r\n \"backend\":\"local\",\r\n \"local\":{\r\n \"directory\":\"${systemConfig.metrics_storage_local_path}/rules\"\r\n }\r\n },\r\n \r\n \"limits\":{\r\n \"max_series_per_metric\": 500000000\r\n },\r\n \"api\":{\r\n \"alertmanager_http_prefix\":\"/\"\r\n }\r\n}', 1, 'cortex.yml 配置文件模板'); --- ---------------------------- --- Table structure for sys_timezone --- ---------------------------- -DROP TABLE IF EXISTS `sys_timezone`; -CREATE TABLE `sys_timezone` ( - `id` int(4) NOT NULL AUTO_INCREMENT, - `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'timezone id', - `offset` int(10) NOT NULL COMMENT '单位:milliseconds', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 247 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; --- ---------------------------- --- Records of sys_timezone --- ---------------------------- -INSERT INTO `sys_timezone` VALUES (1, 'Africa/Abidjan', 0); -INSERT INTO `sys_timezone` VALUES (2, 'Africa/Accra', 0); -INSERT INTO `sys_timezone` VALUES (3, 'Africa/Algiers', 3600000); -INSERT INTO `sys_timezone` VALUES (4, 'Africa/Bissau', 0); -INSERT INTO `sys_timezone` VALUES (5, 'Africa/Cairo', 7200000); -INSERT INTO `sys_timezone` VALUES (6, 'Africa/Casablanca', 0); -INSERT INTO `sys_timezone` VALUES (7, 'Africa/Ceuta', 3600000); -INSERT INTO `sys_timezone` VALUES (8, 'Africa/El_Aaiun', 0); -INSERT INTO `sys_timezone` VALUES (9, 'Africa/Johannesburg', 7200000); -INSERT INTO `sys_timezone` VALUES (10, 'Africa/Juba', 10800000); -INSERT INTO `sys_timezone` VALUES (11, 'Africa/Khartoum', 10800000); -INSERT INTO `sys_timezone` VALUES (12, 'Africa/Lagos', 3600000); -INSERT INTO `sys_timezone` VALUES (13, 'Africa/Maputo', 7200000); -INSERT INTO `sys_timezone` VALUES (14, 'Africa/Monrovia', 0); -INSERT INTO `sys_timezone` VALUES (15, 'Africa/Nairobi', 10800000); -INSERT INTO `sys_timezone` VALUES (16, 'Africa/Ndjamena', 3600000); -INSERT INTO `sys_timezone` VALUES (17, 'Africa/Sao_Tome', 0); -INSERT INTO `sys_timezone` VALUES (18, 'Africa/Tripoli', 7200000); -INSERT INTO `sys_timezone` VALUES (19, 'Africa/Tunis', 3600000); -INSERT INTO `sys_timezone` VALUES (20, 'Africa/Windhoek', 3600000); -INSERT INTO `sys_timezone` VALUES (21, 'Antarctica/Casey', 28800000); -INSERT INTO `sys_timezone` VALUES (22, 'Antarctica/Davis', 25200000); -INSERT INTO `sys_timezone` VALUES (23, 'Antarctica/DumontDUrville', 36000000); -INSERT INTO `sys_timezone` VALUES (24, 'Antarctica/Macquarie', 39600000); -INSERT INTO `sys_timezone` VALUES (25, 'Antarctica/Mawson', 18000000); -INSERT INTO `sys_timezone` VALUES (26, 'Antarctica/Palmer', -14400000); -INSERT INTO `sys_timezone` VALUES (27, 'Antarctica/Rothera', -10800000); -INSERT INTO `sys_timezone` VALUES (28, 'Antarctica/Syowa', 10800000); -INSERT INTO `sys_timezone` VALUES (29, 'Antarctica/Troll', 0); -INSERT INTO `sys_timezone` VALUES (30, 'Antarctica/Vostok', 21600000); -INSERT INTO `sys_timezone` VALUES (31, 'Asia/Almaty', 21600000); -INSERT INTO `sys_timezone` VALUES (32, 'Asia/Amman', 7200000); -INSERT INTO `sys_timezone` VALUES (33, 'Asia/Anadyr', 43200000); -INSERT INTO `sys_timezone` VALUES (34, 'Asia/Aqtau', 18000000); -INSERT INTO `sys_timezone` VALUES (35, 'Asia/Aqtobe', 18000000); -INSERT INTO `sys_timezone` VALUES (36, 'Asia/Ashgabat', 18000000); -INSERT INTO `sys_timezone` VALUES (37, 'Asia/Atyrau', 0); -INSERT INTO `sys_timezone` VALUES (38, 'Asia/Baghdad', 10800000); -INSERT INTO `sys_timezone` VALUES (39, 'Asia/Baku', 14400000); -INSERT INTO `sys_timezone` VALUES (40, 'Asia/Bangkok', 25200000); -INSERT INTO `sys_timezone` VALUES (41, 'Asia/Barnaul', 25200000); -INSERT INTO `sys_timezone` VALUES (42, 'Asia/Beirut', 7200000); -INSERT INTO `sys_timezone` VALUES (43, 'Asia/Bishkek', 21600000); -INSERT INTO `sys_timezone` VALUES (44, 'Asia/Brunei', 28800000); -INSERT INTO `sys_timezone` VALUES (45, 'Asia/Chita', 32400000); -INSERT INTO `sys_timezone` VALUES (46, 'Asia/Choibalsan', 28800000); -INSERT INTO `sys_timezone` VALUES (47, 'Asia/Colombo', 19800000); -INSERT INTO `sys_timezone` VALUES (48, 'Asia/Damascus', 7200000); -INSERT INTO `sys_timezone` VALUES (49, 'Asia/Dhaka', 21600000); -INSERT INTO `sys_timezone` VALUES (50, 'Asia/Dili', 32400000); -INSERT INTO `sys_timezone` VALUES (51, 'Asia/Dubai', 14400000); -INSERT INTO `sys_timezone` VALUES (52, 'Asia/Dushanbe', 18000000); -INSERT INTO `sys_timezone` VALUES (53, 'Asia/Famagusta', 0); -INSERT INTO `sys_timezone` VALUES (54, 'Asia/Gaza', 7200000); -INSERT INTO `sys_timezone` VALUES (55, 'Asia/Hebron', 7200000); -INSERT INTO `sys_timezone` VALUES (56, 'Asia/Ho_Chi_Minh', 25200000); -INSERT INTO `sys_timezone` VALUES (57, 'Asia/Hong_Kong', 28800000); -INSERT INTO `sys_timezone` VALUES (58, 'Asia/Hovd', 25200000); -INSERT INTO `sys_timezone` VALUES (59, 'Asia/Irkutsk', 28800000); -INSERT INTO `sys_timezone` VALUES (60, 'Asia/Jakarta', 25200000); -INSERT INTO `sys_timezone` VALUES (61, 'Asia/Jayapura', 32400000); -INSERT INTO `sys_timezone` VALUES (62, 'Asia/Jerusalem', 7200000); -INSERT INTO `sys_timezone` VALUES (63, 'Asia/Kabul', 16200000); -INSERT INTO `sys_timezone` VALUES (64, 'Asia/Kamchatka', 43200000); -INSERT INTO `sys_timezone` VALUES (65, 'Asia/Karachi', 18000000); -INSERT INTO `sys_timezone` VALUES (66, 'Asia/Kathmandu', 20700000); -INSERT INTO `sys_timezone` VALUES (67, 'Asia/Khandyga', 32400000); -INSERT INTO `sys_timezone` VALUES (68, 'Asia/Kolkata', 19800000); -INSERT INTO `sys_timezone` VALUES (69, 'Asia/Krasnoyarsk', 25200000); -INSERT INTO `sys_timezone` VALUES (70, 'Asia/Kuala_Lumpur', 28800000); -INSERT INTO `sys_timezone` VALUES (71, 'Asia/Kuching', 28800000); -INSERT INTO `sys_timezone` VALUES (72, 'Asia/Macau', 28800000); -INSERT INTO `sys_timezone` VALUES (73, 'Asia/Magadan', 39600000); -INSERT INTO `sys_timezone` VALUES (74, 'Asia/Makassar', 28800000); -INSERT INTO `sys_timezone` VALUES (75, 'Asia/Manila', 28800000); -INSERT INTO `sys_timezone` VALUES (76, 'Asia/Nicosia', 7200000); -INSERT INTO `sys_timezone` VALUES (77, 'Asia/Novokuznetsk', 25200000); -INSERT INTO `sys_timezone` VALUES (78, 'Asia/Novosibirsk', 21600000); -INSERT INTO `sys_timezone` VALUES (79, 'Asia/Omsk', 21600000); -INSERT INTO `sys_timezone` VALUES (80, 'Asia/Oral', 18000000); -INSERT INTO `sys_timezone` VALUES (81, 'Asia/Pontianak', 25200000); -INSERT INTO `sys_timezone` VALUES (82, 'Asia/Pyongyang', 30600000); -INSERT INTO `sys_timezone` VALUES (83, 'Asia/Qatar', 10800000); -INSERT INTO `sys_timezone` VALUES (84, 'Asia/Qostanay', 0); -INSERT INTO `sys_timezone` VALUES (85, 'Asia/Qyzylorda', 21600000); -INSERT INTO `sys_timezone` VALUES (86, 'Asia/Riyadh', 10800000); -INSERT INTO `sys_timezone` VALUES (87, 'Asia/Sakhalin', 39600000); -INSERT INTO `sys_timezone` VALUES (88, 'Asia/Samarkand', 18000000); -INSERT INTO `sys_timezone` VALUES (89, 'Asia/Seoul', 32400000); -INSERT INTO `sys_timezone` VALUES (90, 'Asia/Shanghai', 28800000); -INSERT INTO `sys_timezone` VALUES (91, 'Asia/Singapore', 28800000); -INSERT INTO `sys_timezone` VALUES (92, 'Asia/Srednekolymsk', 39600000); -INSERT INTO `sys_timezone` VALUES (93, 'Asia/Taipei', 28800000); -INSERT INTO `sys_timezone` VALUES (94, 'Asia/Tashkent', 18000000); -INSERT INTO `sys_timezone` VALUES (95, 'Asia/Tbilisi', 14400000); -INSERT INTO `sys_timezone` VALUES (96, 'Asia/Tehran', 12600000); -INSERT INTO `sys_timezone` VALUES (97, 'Asia/Thimphu', 21600000); -INSERT INTO `sys_timezone` VALUES (98, 'Asia/Tokyo', 32400000); -INSERT INTO `sys_timezone` VALUES (99, 'Asia/Tomsk', 25200000); -INSERT INTO `sys_timezone` VALUES (100, 'Asia/Ulaanbaatar', 28800000); -INSERT INTO `sys_timezone` VALUES (101, 'Asia/Urumqi', 21600000); -INSERT INTO `sys_timezone` VALUES (102, 'Asia/Ust-Nera', 36000000); -INSERT INTO `sys_timezone` VALUES (103, 'Asia/Vladivostok', 36000000); -INSERT INTO `sys_timezone` VALUES (104, 'Asia/Yakutsk', 32400000); -INSERT INTO `sys_timezone` VALUES (105, 'Asia/Yangon', 0); -INSERT INTO `sys_timezone` VALUES (106, 'Asia/Yekaterinburg', 18000000); -INSERT INTO `sys_timezone` VALUES (107, 'Asia/Yerevan', 14400000); -INSERT INTO `sys_timezone` VALUES (108, 'Atlantic/Azores', -3600000); -INSERT INTO `sys_timezone` VALUES (109, 'Atlantic/Bermuda', -14400000); -INSERT INTO `sys_timezone` VALUES (110, 'Atlantic/Canary', 0); -INSERT INTO `sys_timezone` VALUES (111, 'Atlantic/Cape_Verde', -3600000); -INSERT INTO `sys_timezone` VALUES (112, 'Atlantic/Faroe', 0); -INSERT INTO `sys_timezone` VALUES (113, 'Atlantic/Madeira', 0); -INSERT INTO `sys_timezone` VALUES (114, 'Atlantic/Reykjavik', 0); -INSERT INTO `sys_timezone` VALUES (115, 'Atlantic/South_Georgia', -7200000); -INSERT INTO `sys_timezone` VALUES (116, 'Atlantic/Stanley', -10800000); -INSERT INTO `sys_timezone` VALUES (117, 'Australia/Adelaide', 34200000); -INSERT INTO `sys_timezone` VALUES (118, 'Australia/Brisbane', 36000000); -INSERT INTO `sys_timezone` VALUES (119, 'Australia/Broken_Hill', 34200000); -INSERT INTO `sys_timezone` VALUES (120, 'Australia/Darwin', 34200000); -INSERT INTO `sys_timezone` VALUES (121, 'Australia/Eucla', 31500000); -INSERT INTO `sys_timezone` VALUES (122, 'Australia/Hobart', 36000000); -INSERT INTO `sys_timezone` VALUES (123, 'Australia/Lindeman', 36000000); -INSERT INTO `sys_timezone` VALUES (124, 'Australia/Lord_Howe', 37800000); -INSERT INTO `sys_timezone` VALUES (125, 'Australia/Melbourne', 36000000); -INSERT INTO `sys_timezone` VALUES (126, 'Australia/Perth', 28800000); -INSERT INTO `sys_timezone` VALUES (127, 'Australia/Sydney', 36000000); -INSERT INTO `sys_timezone` VALUES (128, 'Etc/GMT', 0); -INSERT INTO `sys_timezone` VALUES (129, 'Etc/GMT+1', -3600000); -INSERT INTO `sys_timezone` VALUES (130, 'Etc/GMT+10', -36000000); -INSERT INTO `sys_timezone` VALUES (131, 'Etc/GMT+11', -39600000); -INSERT INTO `sys_timezone` VALUES (132, 'Etc/GMT+12', -43200000); -INSERT INTO `sys_timezone` VALUES (133, 'Etc/GMT+2', -7200000); -INSERT INTO `sys_timezone` VALUES (134, 'Etc/GMT+3', -10800000); -INSERT INTO `sys_timezone` VALUES (135, 'Etc/GMT+4', -14400000); -INSERT INTO `sys_timezone` VALUES (136, 'Etc/GMT+5', -18000000); -INSERT INTO `sys_timezone` VALUES (137, 'Etc/GMT+6', -21600000); -INSERT INTO `sys_timezone` VALUES (138, 'Etc/GMT+7', -25200000); -INSERT INTO `sys_timezone` VALUES (139, 'Etc/GMT+8', -28800000); -INSERT INTO `sys_timezone` VALUES (140, 'Etc/GMT+9', -32400000); -INSERT INTO `sys_timezone` VALUES (141, 'Etc/GMT-1', 3600000); -INSERT INTO `sys_timezone` VALUES (142, 'Etc/GMT-10', 36000000); -INSERT INTO `sys_timezone` VALUES (143, 'Etc/GMT-11', 39600000); -INSERT INTO `sys_timezone` VALUES (144, 'Etc/GMT-12', 43200000); -INSERT INTO `sys_timezone` VALUES (145, 'Etc/GMT-13', 46800000); -INSERT INTO `sys_timezone` VALUES (146, 'Etc/GMT-14', 50400000); -INSERT INTO `sys_timezone` VALUES (147, 'Etc/GMT-2', 7200000); -INSERT INTO `sys_timezone` VALUES (148, 'Etc/GMT-3', 10800000); -INSERT INTO `sys_timezone` VALUES (149, 'Etc/GMT-4', 14400000); -INSERT INTO `sys_timezone` VALUES (150, 'Etc/GMT-5', 18000000); -INSERT INTO `sys_timezone` VALUES (151, 'Etc/GMT-6', 21600000); -INSERT INTO `sys_timezone` VALUES (152, 'Etc/GMT-7', 25200000); -INSERT INTO `sys_timezone` VALUES (153, 'Etc/GMT-8', 28800000); -INSERT INTO `sys_timezone` VALUES (154, 'Etc/GMT-9', 32400000); -INSERT INTO `sys_timezone` VALUES (155, 'Etc/UTC', 0); -INSERT INTO `sys_timezone` VALUES (156, 'Europe/Amsterdam', 3600000); -INSERT INTO `sys_timezone` VALUES (157, 'Europe/Andorra', 3600000); -INSERT INTO `sys_timezone` VALUES (158, 'Europe/Astrakhan', 14400000); -INSERT INTO `sys_timezone` VALUES (159, 'Europe/Athens', 7200000); -INSERT INTO `sys_timezone` VALUES (160, 'Europe/Belgrade', 3600000); -INSERT INTO `sys_timezone` VALUES (161, 'Europe/Berlin', 3600000); -INSERT INTO `sys_timezone` VALUES (162, 'Europe/Brussels', 3600000); -INSERT INTO `sys_timezone` VALUES (163, 'Europe/Bucharest', 7200000); -INSERT INTO `sys_timezone` VALUES (164, 'Europe/Budapest', 3600000); -INSERT INTO `sys_timezone` VALUES (165, 'Europe/Chisinau', 7200000); -INSERT INTO `sys_timezone` VALUES (166, 'Europe/Copenhagen', 3600000); -INSERT INTO `sys_timezone` VALUES (167, 'Europe/Dublin', 0); -INSERT INTO `sys_timezone` VALUES (168, 'Europe/Gibraltar', 3600000); -INSERT INTO `sys_timezone` VALUES (169, 'Europe/Helsinki', 7200000); -INSERT INTO `sys_timezone` VALUES (170, 'Europe/Istanbul', 7200000); -INSERT INTO `sys_timezone` VALUES (171, 'Europe/Kaliningrad', 7200000); -INSERT INTO `sys_timezone` VALUES (172, 'Europe/Kiev', 7200000); -INSERT INTO `sys_timezone` VALUES (173, 'Europe/Kirov', 10800000); -INSERT INTO `sys_timezone` VALUES (174, 'Europe/Lisbon', 0); -INSERT INTO `sys_timezone` VALUES (175, 'Europe/London', 0); -INSERT INTO `sys_timezone` VALUES (176, 'Europe/Luxembourg', 3600000); -INSERT INTO `sys_timezone` VALUES (177, 'Europe/Madrid', 3600000); -INSERT INTO `sys_timezone` VALUES (178, 'Europe/Malta', 3600000); -INSERT INTO `sys_timezone` VALUES (179, 'Europe/Minsk', 10800000); -INSERT INTO `sys_timezone` VALUES (180, 'Europe/Monaco', 3600000); -INSERT INTO `sys_timezone` VALUES (181, 'Europe/Moscow', 10800000); -INSERT INTO `sys_timezone` VALUES (182, 'Europe/Oslo', 3600000); -INSERT INTO `sys_timezone` VALUES (183, 'Europe/Paris', 3600000); -INSERT INTO `sys_timezone` VALUES (184, 'Europe/Prague', 3600000); -INSERT INTO `sys_timezone` VALUES (185, 'Europe/Riga', 7200000); -INSERT INTO `sys_timezone` VALUES (186, 'Europe/Rome', 3600000); -INSERT INTO `sys_timezone` VALUES (187, 'Europe/Samara', 14400000); -INSERT INTO `sys_timezone` VALUES (188, 'Europe/Saratov', 0); -INSERT INTO `sys_timezone` VALUES (189, 'Europe/Simferopol', 10800000); -INSERT INTO `sys_timezone` VALUES (190, 'Europe/Sofia', 7200000); -INSERT INTO `sys_timezone` VALUES (191, 'Europe/Stockholm', 3600000); -INSERT INTO `sys_timezone` VALUES (192, 'Europe/Tallinn', 7200000); -INSERT INTO `sys_timezone` VALUES (193, 'Europe/Tirane', 3600000); -INSERT INTO `sys_timezone` VALUES (194, 'Europe/Ulyanovsk', 14400000); -INSERT INTO `sys_timezone` VALUES (195, 'Europe/Uzhgorod', 7200000); -INSERT INTO `sys_timezone` VALUES (196, 'Europe/Vienna', 3600000); -INSERT INTO `sys_timezone` VALUES (197, 'Europe/Vilnius', 7200000); -INSERT INTO `sys_timezone` VALUES (198, 'Europe/Volgograd', 10800000); -INSERT INTO `sys_timezone` VALUES (199, 'Europe/Warsaw', 3600000); -INSERT INTO `sys_timezone` VALUES (200, 'Europe/Zaporozhye', 7200000); -INSERT INTO `sys_timezone` VALUES (201, 'Europe/Zurich', 3600000); -INSERT INTO `sys_timezone` VALUES (202, 'Factory', 0); -INSERT INTO `sys_timezone` VALUES (203, 'Indian/Chagos', 21600000); -INSERT INTO `sys_timezone` VALUES (204, 'Indian/Christmas', 25200000); -INSERT INTO `sys_timezone` VALUES (205, 'Indian/Cocos', 23400000); -INSERT INTO `sys_timezone` VALUES (206, 'Indian/Kerguelen', 18000000); -INSERT INTO `sys_timezone` VALUES (207, 'Indian/Mahe', 14400000); -INSERT INTO `sys_timezone` VALUES (208, 'Indian/Maldives', 18000000); -INSERT INTO `sys_timezone` VALUES (209, 'Indian/Mauritius', 14400000); -INSERT INTO `sys_timezone` VALUES (210, 'Indian/Reunion', 14400000); -INSERT INTO `sys_timezone` VALUES (211, 'Pacific/Apia', 46800000); -INSERT INTO `sys_timezone` VALUES (212, 'Pacific/Auckland', 43200000); -INSERT INTO `sys_timezone` VALUES (213, 'Pacific/Bougainville', 39600000); -INSERT INTO `sys_timezone` VALUES (214, 'Pacific/Chatham', 45900000); -INSERT INTO `sys_timezone` VALUES (215, 'Pacific/Chuuk', 36000000); -INSERT INTO `sys_timezone` VALUES (216, 'Pacific/Easter', -21600000); -INSERT INTO `sys_timezone` VALUES (217, 'Pacific/Efate', 39600000); -INSERT INTO `sys_timezone` VALUES (218, 'Pacific/Enderbury', 46800000); -INSERT INTO `sys_timezone` VALUES (219, 'Pacific/Fakaofo', 46800000); -INSERT INTO `sys_timezone` VALUES (220, 'Pacific/Fiji', 43200000); -INSERT INTO `sys_timezone` VALUES (221, 'Pacific/Funafuti', 43200000); -INSERT INTO `sys_timezone` VALUES (222, 'Pacific/Galapagos', -21600000); -INSERT INTO `sys_timezone` VALUES (223, 'Pacific/Gambier', -32400000); -INSERT INTO `sys_timezone` VALUES (224, 'Pacific/Guadalcanal', 39600000); -INSERT INTO `sys_timezone` VALUES (225, 'Pacific/Guam', 36000000); -INSERT INTO `sys_timezone` VALUES (226, 'Pacific/Honolulu', -36000000); -INSERT INTO `sys_timezone` VALUES (227, 'Pacific/Kiritimati', 50400000); -INSERT INTO `sys_timezone` VALUES (228, 'Pacific/Kosrae', 39600000); -INSERT INTO `sys_timezone` VALUES (229, 'Pacific/Kwajalein', 43200000); -INSERT INTO `sys_timezone` VALUES (230, 'Pacific/Majuro', 43200000); -INSERT INTO `sys_timezone` VALUES (231, 'Pacific/Marquesas', -34200000); -INSERT INTO `sys_timezone` VALUES (232, 'Pacific/Nauru', 43200000); -INSERT INTO `sys_timezone` VALUES (233, 'Pacific/Niue', -39600000); -INSERT INTO `sys_timezone` VALUES (234, 'Pacific/Norfolk', 39600000); -INSERT INTO `sys_timezone` VALUES (235, 'Pacific/Noumea', 39600000); -INSERT INTO `sys_timezone` VALUES (236, 'Pacific/Pago_Pago', -39600000); -INSERT INTO `sys_timezone` VALUES (237, 'Pacific/Palau', 32400000); -INSERT INTO `sys_timezone` VALUES (238, 'Pacific/Pitcairn', -28800000); -INSERT INTO `sys_timezone` VALUES (239, 'Pacific/Pohnpei', 39600000); -INSERT INTO `sys_timezone` VALUES (240, 'Pacific/Port_Moresby', 36000000); -INSERT INTO `sys_timezone` VALUES (241, 'Pacific/Rarotonga', -36000000); -INSERT INTO `sys_timezone` VALUES (242, 'Pacific/Tahiti', -36000000); -INSERT INTO `sys_timezone` VALUES (243, 'Pacific/Tarawa', 43200000); -INSERT INTO `sys_timezone` VALUES (244, 'Pacific/Tongatapu', 46800000); -INSERT INTO `sys_timezone` VALUES (245, 'Pacific/Wake', 43200000); -INSERT INTO `sys_timezone` VALUES (246, 'Pacific/Wallis', 43200000); +INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('backup_file_path', '/opt/nezha/nz-web/backup', 1, 'nezha备份数据默认存储路径'); +INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('backup_config', '{\"schedule\":{\"repeat\":1,\"stime\":\"2021-09-12 10:10:10\",\"type\":1,\"nums\":[1,2,3,4,5,6,7]},\"state\":1,\"retention\":1}', 1, 'nezha备份数据列表信息'); +INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('backup_exclude_tables', 'sys_config,dc,cabinet,alert_message_active,alert_message_history', 1, 'nezha备份排除表名'); --- ---------------------------- --- Table structure for sys_user --- ---------------------------- -DROP TABLE IF EXISTS `sys_user`; -CREATE TABLE `sys_user` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名', - `pin` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码', - `salt` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '盐', - `email` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱', - `status` tinyint(4) NULL DEFAULT NULL COMMENT '状态 0:禁用 1:正常', - `create_at` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', - `lang` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'en', - `source` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'system', - `name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户姓名\r\n\r\n(用于系统内展示用户名称)', - `last_login_time` datetime(0) NULL DEFAULT NULL COMMENT '最后登录时间', - `last_login_ip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后登录ip', - `mobile` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号', - `create_by` int(10) NULL DEFAULT NULL COMMENT '添加人', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `username`(`username`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统用户表' ROW_FORMAT = Compact; --- ---------------------------- --- Records of sys_user --- ---------------------------- -INSERT INTO `sys_user` VALUES (1, 'admin', 'e1153123d7d180ceeb820d577ff119876678732a68eef4e6ffc0b1f06a01f91b', 'YzcmCZNvbXocrsz9dm8e', 'nezha@www.puppn.com', 1, '2016-11-11 11:11:11', 'zh', 'system', 'admin', NULL, NULL, NULL, NULL); --- ---------------------------- --- Table structure for sys_user_role --- ---------------------------- -DROP TABLE IF EXISTS `sys_user_role`; -CREATE TABLE `sys_user_role` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `user_id` int(10) NOT NULL, - `role_id` int(10) NOT NULL, - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +update sys_user set lang='en' where 1=1; --- ---------------------------- --- Records of sys_user_role --- ---------------------------- -INSERT INTO `sys_user_role` VALUES (1, 1, 1); +UPDATE `asset_state_conf` set remark = 'The asset is in use' where id =1; +UPDATE `asset_state_conf` set remark = 'The asset is not in stock' where id = 2; +UPDATE `asset_state_conf` set remark = 'The asset is suspended for now, and you can put it in use later' where id =3; +UPDATE `asset_state_conf` set remark = 'The asset is suspended because of hardware fault or software upgrade' where id =4; +UPDATE `asset_state_conf` set remark = 'The asset is permanently suspended' where id =5; --- ---------------------------- --- Table structure for terminal_cmd --- ---------------------------- -DROP TABLE IF EXISTS `terminal_cmd`; -CREATE TABLE `terminal_cmd` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `uuid` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '会话id', - `cmd` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户输入命令', - `time` int(10) NULL DEFAULT NULL COMMENT '单位:ms\r\n\r\n记录的是 session开始后的时间偏移量', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_uuid`(`uuid`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +TRUNCATE TABLE `alert_severity_conf`; +INSERT INTO `alert_severity_conf` VALUES (1, 'P1', '#eb1010', 1, 'Critical, alert that can cause business paralysis'); +INSERT INTO `alert_severity_conf` VALUES (2, 'P2', '#f89984', 2, 'Major, alert that requires urgent attention, but does not affect the business yet'); +INSERT INTO `alert_severity_conf` VALUES (3, 'P3', '#f7ba78', 3, 'Minor, alert that need to be dealt with, but not urgent'); --- ---------------------------- --- Records of terminal_cmd --- ---------------------------- --- ---------------------------- --- Table structure for terminal_record --- ---------------------------- -DROP TABLE IF EXISTS `terminal_record`; -CREATE TABLE `terminal_record` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `uuid` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '会话ID', - `start_time` int(10) NOT NULL COMMENT '单位:ms\r\n\r\nrecord 开始时间,记录的是会话开始后的时间偏移量', - `end_time` int(10) NOT NULL COMMENT '单位:ms\r\n\r\nrecord 结束时间,记录的是会话开始后的时间偏移量', - `content` mediumblob NOT NULL COMMENT '记录的是 session开始后的时间偏移量\r\n\r\n最大储存 65K,超过部分再新增一条记录', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_uuid`(`uuid`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +INSERT INTO `sys_dict`(`id`, `name`, `type`, `code`, `value`, `i18n_code`, `order_num`, `remark`, `del_flag`, `operator`, `op_time`, `seq`) VALUES (NULL, 'English', 'lang', 1, 'en', '', 0, '英文', 0, 1, '2021-11-01 14:58:09', NULL); +INSERT INTO `sys_dict`(`id`, `name`, `type`, `code`, `value`, `i18n_code`, `order_num`, `remark`, `del_flag`, `operator`, `op_time`, `seq`) VALUES (NULL, '简体中文', 'lang', 2, 'zh', '', 0, '中文', 0, 1, '2021-11-01 14:57:25', NULL); --- ---------------------------- --- Records of terminal_record --- ---------------------------- --- ---------------------------- --- Table structure for terminal_session --- ---------------------------- -DROP TABLE IF EXISTS `terminal_session`; -CREATE TABLE `terminal_session` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `uuid` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会话id', - `asset_id` int(10) NULL DEFAULT NULL COMMENT '关联资产id', - `host` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '登录主机', - `port` int(10) NULL DEFAULT NULL COMMENT '端口', - `protocol` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '协议,可选值:SSH,TELNET。统一大写', - `auth_type` int(10) NULL DEFAULT NULL COMMENT '认证类型,1:密码,2:私钥证书 认证类型,1:密码,2:私钥证书\r\n\r\nssh可选值:1、2\r\n\r\ntelnet可选值:1', - `login_user` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '登录主机的用户名', - `user_id` int(10) NOT NULL COMMENT 'nezha系统内用户id', - `remote_addr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '客户端ip地址', - `start_time` datetime(0) NOT NULL COMMENT '开始时间', - `end_time` datetime(0) NULL DEFAULT NULL COMMENT '结束时间', - `status` int(1) NOT NULL COMMENT '0:连接中\r\n\r\n1:发送失败(没有通过ssh或telnet发送成功)\r\n\r\n2:已结束\r\n\r\n3:强制退出\r\n\r\n4:未知错误', - `kill_user_id` int(10) NULL DEFAULT NULL COMMENT '强制关闭用户id', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_uuid`(`uuid`) USING BTREE, - INDEX `idx_asset_id`(`asset_id`) USING BTREE, - INDEX `idx_user_id`(`user_id`) USING BTREE, - INDEX `idx_host`(`host`) USING BTREE, - INDEX `idx_port`(`port`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +UPDATE `alert_notify_method` SET `name` = 'email', `file_path` = '', `account` = 'email', `state` = 1, `build_in` = 1 WHERE `id` = 1; --- ---------------------------- --- Records of terminal_session --- ---------------------------- +update sys_user set pin_time = now(); --- ---------------------------- --- Table structure for visual_chart --- ---------------------------- -DROP TABLE IF EXISTS `visual_chart`; -CREATE TABLE `visual_chart` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '图表标题', - `panel_id` int(10) NOT NULL COMMENT '图表id,关联panel表\r\n\r\n当 panel_id =0 代表为模板', - `group_id` int(10) NOT NULL COMMENT '关联 visual_chart.id,关联 chart 的 type 只能为 group', - `span` int(10) NOT NULL COMMENT 'type = group,span = 12, 用户修改无效', - `height` int(10) NOT NULL COMMENT 'type = group,height = -1,用户修改无效', - `update_by` int(10) NOT NULL COMMENT '更新人', - `update_at` datetime(0) NOT NULL COMMENT '更新时间', - `type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '图表类型 line\r\nbar\r\ntable\r\nstackArea\r\nsingleStat\r\nurl\r\nassetInfo\r\nalertList\r\ngroup', - `unit` int(10) NOT NULL DEFAULT 2 COMMENT '界面显示采用二级菜单', - `weight` int(10) NOT NULL DEFAULT 0 COMMENT '默认为 0,用于chart排序', - `param` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '参数 记录type的具体参数信息,数据格式为json对象\r\n\r\n当type = url时\r\n\r\n{\r\n\r\n “url”:\"https://www.baidu.com\"\r\n\r\n}', - `pid` int(10) NULL DEFAULT NULL COMMENT '模板id 图表通过模板创建时不能为空,便于后续模板修改同步修改', - `build_in` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0', - `remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '默认:\"\"', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '导入唯一标识', - `var_type` int(1) NULL DEFAULT NULL COMMENT '模板或使用模板创建有效,pid != null | panel_id == 0 时不能为空\r\n\r\n1: asset\r\n\r\n2: endpoint', - `var_id` int(10) NULL DEFAULT NULL COMMENT 'pid != null 时不能为空\r\n\r\n根据var_type 分别对应 asset.id, endpoint.id,用于 表达式变量替换', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_panel_id`(`panel_id`) USING BTREE, - INDEX `idx_group_id`(`group_id`) USING BTREE, - INDEX `idx_type`(`type`) USING BTREE, - INDEX `idx_var_type`(`var_type`) USING BTREE, - INDEX `idx_var_id`(`var_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of visual_chart --- ---------------------------- - --- ---------------------------- --- Table structure for visual_chart_element --- ---------------------------- -DROP TABLE IF EXISTS `visual_chart_element`; -CREATE TABLE `visual_chart_element` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', - `chart_id` int(10) NOT NULL COMMENT '图表id,关联chart表', - `expression` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'promql表达式', - `type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'normal:简单表达式,可页面解析,如:up{asset=\"192.168.40.40\",module=\"kafka\"}\r\n\r\nexpert:用户输入表达式,解析困难,直接在页面显示', - `legend` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图例别名表达式', - `build_in` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '是否内置', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '导入唯一标识 用于导入撤销', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_chart_id`(`chart_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of visual_chart_element --- ---------------------------- - --- ---------------------------- --- Table structure for visual_expression_tmpl --- ---------------------------- -DROP TABLE IF EXISTS `visual_expression_tmpl`; -CREATE TABLE `visual_expression_tmpl` ( - `id` int(10) NOT NULL AUTO_INCREMENT, - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '模板名称', - `gname` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'default' COMMENT '组名,默认:default', - `expression` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '表达式,不能为空', - `remark` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '描述', - `build_in` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用于导入撤销,默认:“”', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_gname`(`gname`) USING BTREE, - INDEX `idx_expression`(`expression`(768)) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of visual_expression_tmpl --- ---------------------------- -INSERT INTO `visual_expression_tmpl` VALUES (1, 'abs', 'function', 'abs()', 'abs(v instant-vector) returns the input vector with all sample values converted to their absolute value.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (2, 'absent', 'function', 'absent()', 'absent(v instant-vector) returns an empty vector if the vector passed to it has any elements and a 1-element vector with the value 1 if the vector passed to it has no elements.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (3, 'absent_over_time', 'function', 'absent_over_time()', 'absent_over_time(v range-vector) returns an empty vector if the range vector passed to it has any elements and a 1-element vector with the value 1 if the range vector passed to it has no elements.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (4, 'ceil', 'function', 'ceil()', 'ceil(v instant-vector) rounds the sample values of all elements in v up to the nearest integer.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (5, 'changes', 'function', 'changes()', 'For each input time series, changes(v range-vector) returns the number of times its value has changed within the provided time range as an instant vector.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (6, 'clamp', 'function', 'clamp()', 'clamp(v instant-vector, min scalar, max scalar) clamps the sample values of all elements in v to have a lower limit of min and an upper limit of max.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (7, 'clamp_max', 'function', 'clamp_max()', 'clamp_max(v instant-vector, max scalar) clamps the sample values of all elements in v to have an upper limit of max.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (8, 'clamp_min', 'function', 'clamp_min()', 'clamp_min(v instant-vector, min scalar) clamps the sample values of all elements in v to have a lower limit of min.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (9, 'day_of_month', 'function', 'day_of_month()', 'day_of_month(v=vector(time()) instant-vector) returns the day of the month for each of the given times in UTC. Returned values are from 1 to 31.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (10, 'day_of_week', 'function', 'day_of_week()', 'day_of_week(v=vector(time()) instant-vector) returns the day of the week for each of the given times in UTC. Returned values are from 0 to 6, where 0 means Sunday etc.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (11, 'days_in_month', 'function', 'days_in_month()', 'days_in_month(v=vector(time()) instant-vector) returns number of days in the month for each of the given times in UTC. Returned values are from 28 to 31.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (12, 'delta', 'function', 'delta()', 'delta(v range-vector) calculates the difference between the first and last value of each time series element in a range vector v, returning an instant vector with the given deltas and equivalent labels. The delta is extrapolated to cover the full time range as specified in the range vector selector, so that it is possible to get a non-integer result even if the sample values are all integers.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (13, 'deriv', 'function', 'deriv()', 'deriv(v range-vector) calculates the per-second derivative of the time series in a range vector v, using simple linear regression.\n\nderiv should only be used with gauges.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (14, 'exp', 'function', 'exp()', 'exp(v instant-vector) calculates the exponential function for all elements in v.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (15, 'floor', 'function', 'floor()', 'floor(v instant-vector) rounds the sample values of all elements in v down to the nearest integer.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (16, 'histogram_quantile', 'function', 'histogram_quantile()', 'histogram_quantile(φ scalar, b instant-vector) calculates the φ-quantile (0 ≤ φ ≤ 1) from the buckets b of a histogram', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (17, 'holt_winters', 'function', 'holt_winters()', 'holt_winters(v range-vector, sf scalar, tf scalar) produces a smoothed value for time series based on the range in v. The lower the smoothing factor sf, the more importance is given to old data. The higher the trend factor tf, the more trends in the data is considered. Both sf and tf must be between 0 and 1.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (18, 'hour', 'function', 'hour()', 'hour(v=vector(time()) instant-vector) returns the hour of the day for each of the given times in UTC. Returned values are from 0 to 23.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (19, 'idelta', 'function', 'idelta()', 'idelta(v range-vector) calculates the difference between the last two samples in the range vector v, returning an instant vector with the given deltas and equivalent labels.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (20, 'increase', 'function', 'increase()', 'increase(v range-vector) calculates the increase in the time series in the range vector. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for. The increase is extrapolated to cover the full time range as specified in the range vector selector, so that it is possible to get a non-integer result even if a counter increases only by integer increments.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (21, 'irate', 'function', 'irate()', 'irate(v range-vector) calculates the per-second instant rate of increase of the time series in the range vector. This is based on the last two data points. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (22, 'label_join', 'function', 'label_join()', 'For each timeseries in v, label_join(v instant-vector, dst_label string, separator string, src_label_1 string, src_label_2 string, ...) joins all the values of all the src_labels using separator and returns the timeseries with the label dst_label containing the joined value. There can be any number of src_labels in this function.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (23, 'label_replace', 'function', 'label_replace()', 'For each timeseries in v, label_replace(v instant-vector, dst_label string, replacement string, src_label string, regex string) matches the regular expression regex against the label src_label. If it matches, then the timeseries is returned with the label dst_label replaced by the expansion of replacement. $1 is replaced with the first matching subgroup, $2 with the second etc. If the regular expression doesn\'t match then the timeseries is returned unchanged.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (24, 'ln', 'function', 'ln()', 'ln(v instant-vector) calculates the natural logarithm for all elements in v', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (25, 'log2', 'function', 'log2()', 'log2(v instant-vector) calculates the binary logarithm for all elements in v. The special cases are equivalent to those in ln.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (26, 'log10', 'function', 'log10()', 'log10(v instant-vector) calculates the decimal logarithm for all elements in v. The special cases are equivalent to those in ln.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (27, 'minute', 'function', 'minute()', 'minute(v=vector(time()) instant-vector) returns the minute of the hour for each of the given times in UTC. Returned values are from 0 to 59.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (28, 'month', 'function', 'month()', 'month(v=vector(time()) instant-vector) returns the month of the year for each of the given times in UTC. Returned values are from 1 to 12, where 1 means January etc.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (29, 'predict_linear', 'function', 'predict_linear()', 'predict_linear(v range-vector, t scalar) predicts the value of time series t seconds from now, based on the range vector v, using simple linear regression.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (30, 'rate', 'function', 'rate()', 'rate(v range-vector) calculates the per-second average rate of increase of the time series in the range vector. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for. Also, the calculation extrapolates to the ends of the time range, allowing for missed scrapes or imperfect alignment of scrape cycles with the range\'s time period.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (31, 'resets', 'function', 'resets()', 'For each input time series, resets(v range-vector) returns the number of counter resets within the provided time range as an instant vector. Any decrease in the value between two consecutive samples is interpreted as a counter reset.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (32, 'round', 'function', 'round()', 'round(v instant-vector, to_nearest=1 scalar) rounds the sample values of all elements in v to the nearest integer. Ties are resolved by rounding up. The optional to_nearest argument allows specifying the nearest multiple to which the sample values should be rounded. This multiple may also be a fraction.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (33, 'scalar', 'function', 'scalar()', 'Given a single-element input vector, scalar(v instant-vector) returns the sample value of that single element as a scalar. If the input vector does not have exactly one element, scalar will return NaN.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (34, 'sgn', 'function', 'sgn()', 'sgn(v instant-vector) returns a vector with all sample values converted to their sign, defined as this: 1 if v is positive, -1 if v is negative and 0 if v is equal to zero.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (35, 'sort', 'function', 'sort()', 'sort(v instant-vector) returns vector elements sorted by their sample values, in ascending order.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (36, 'sort_desc', 'function', 'sort_desc()', 'Same as sort, but sorts in descending order.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (37, 'sqrt', 'function', 'sqrt()', 'sqrt(v instant-vector) calculates the square root of all elements in v.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (38, 'time', 'function', 'time()', 'time() returns the number of seconds since January 1, 1970 UTC. Note that this does not actually return the current time, but the time at which the expression is to be evaluated.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (39, 'timestamp', 'function', 'timestamp()', 'timestamp(v instant-vector) returns the timestamp of each of the samples of the given vector as the number of seconds since January 1, 1970 UTC.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (40, 'vector', 'function', 'vector()', 'vector(s scalar) returns the scalar s as a vector with no labels.', '1', ''); -INSERT INTO `visual_expression_tmpl` VALUES (41, 'year', 'function', 'year()', 'year(v=vector(time()) instant-vector) returns the year for each of the given times in UTC.', '1', ''); - --- ---------------------------- --- Table structure for visual_panel --- ---------------------------- -DROP TABLE IF EXISTS `visual_panel`; -CREATE TABLE `visual_panel` ( - `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '图表名', - `create_by` int(10) NOT NULL COMMENT '创建人id', - `type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'dashboard' COMMENT '可选值:dashboard,asset,project,module,endpoint, model\r\n\r\n默认值:dashboard', - `link` int(10) NULL DEFAULT NULL COMMENT '关联id', - `pid` int(10) NOT NULL DEFAULT 0 COMMENT '父id 默认0', - `weight` int(10) NOT NULL DEFAULT 0 COMMENT '排序 默认0', - `build_in` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '是否内置', - `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '默认:“”\r\n\r\n用于导入撤销', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_name`(`name`) USING BTREE, - INDEX `idx_type`(`type`) USING BTREE, - INDEX `idx_link`(`link`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of visual_panel --- ---------------------------- +INSERT INTO `flyway_schema_history` VALUES (6, '2021.07.26', 'insert asset client config', 'SQL', 'V2021.07.26__insert asset client config.sql', 254186640, 'root', now(), 21, 1); +INSERT INTO `flyway_schema_history` VALUES (7, '2021.07.29', 'insert sys config loki query configuration', 'SQL', 'V2021.07.29__insert sys_config loki query configuration.sql', -1603067350, 'root', now(), 2, 1); +INSERT INTO `flyway_schema_history` VALUES (8, '2021.07.30', 'modifiy monitor module table column', 'SQL', 'V2021.07.30__modifiy monitor_module table column.sql', 1996489389, 'root', now(), 8, 1); +INSERT INTO `flyway_schema_history` VALUES (9, '2021.08.03', 'insert loki query range default limit config', 'SQL', 'V2021.08.03__insert loki_query_range_default_limit config.sql', -81056900, 'root', now(), 1, 1); +INSERT INTO `flyway_schema_history` VALUES (10, '2021.08.04', 'update endpoint table', 'SQL', 'V2021.08.04__update endpoint table.sql', 2094777536, 'root', now(), 45, 1); +INSERT INTO `flyway_schema_history` VALUES (11, '2021.08.11', 'asset add client token', 'SQL', 'V2021.08.11__asset_add_client_token.sql', -1721472102, 'root', now(), 5, 1); +INSERT INTO `flyway_schema_history` VALUES (12, '2021.08.12', 'asset add client enable', 'SQL', 'V2021.08.12__asset_add_client_enable.sql', -893393241, 'root', now(), 3, 1); +INSERT INTO `flyway_schema_history` VALUES (13, '2021.08.13', 'update sys config data', 'SQL', 'V2021.08.13__update sys_config data.sql', -879789256, 'root', now(), 23, 1); +INSERT INTO `flyway_schema_history` VALUES (14, '2021.08.16', 'update sys config data', 'SQL', 'V2021.08.16__update sys_config data.sql', 1219023296, 'root', now(), 1, 1); +INSERT INTO `flyway_schema_history` VALUES (15, '2021.08.20', 'update sys config data', 'SQL', 'V2021.08.20__update sys_config data.sql', -1239041759, 'root', now(), 136, 1); +INSERT INTO `flyway_schema_history` VALUES (16, '2021.08.24', 'update sys config data', 'SQL', 'V2021.08.24__update sys_config data.sql', -65790066, 'root', now(), 58, 1); +INSERT INTO `flyway_schema_history` VALUES (17, '2021.08.25', 'update asset export header information', 'SQL', 'V2021.08.25__update asset export header information.sql', -953682784, 'root', now(), 2, 1); +INSERT INTO `flyway_schema_history` VALUES (18, '2021.08.26', 'update promtail yml template information', 'SQL', 'V2021.08.26__update promtail yml template information.sql', -137270703, 'root', now(), 47, 1); +INSERT INTO `flyway_schema_history` VALUES (19, '2021.08.27', 'update promtail yml template information', 'SQL', 'V2021.08.27__update promtail yml template information.sql', -352527268, 'root', now(), 1, 1); +INSERT INTO `flyway_schema_history` VALUES (20, '2021.08.28', 'update cortex yml template information', 'SQL', 'V2021.08.28__update cortex yml template information.sql', -486181153, 'root', now(), 18, 1); +INSERT INTO `flyway_schema_history` VALUES (21, '2021.08.30', 'update asset talon status table structure', 'SQL', 'V2021.08.30__update_asset_talon_status table structure.sql', 383627482, 'root', now(), 447, 1); +INSERT INTO `flyway_schema_history` VALUES (22, '2021.09.01', 'insert log type chart', 'SQL', 'V2021.09.01__insert log type chart.sql', 757339237, 'root', now(), 16, 1); +INSERT INTO `flyway_schema_history` VALUES (23, '2021.09.02', 'change the alert rule table structure', 'SQL', 'V2021.09.02__change the alert_rule table structure.sql', 1988445304, 'root', now(), 12, 1); +INSERT INTO `flyway_schema_history` VALUES (24, '2021.09.03', 'alert rule eval log', 'SQL', 'V2021.09.03__alert_rule_eval_log.sql', -409816067, 'root', now(), 1848, 1); +INSERT INTO `flyway_schema_history` VALUES (25, '2021.09.07', 'change the alert rule table structure', 'SQL', 'V2021.09.07__change the alert_rule table structure.sql', 1093818317, 'root', now(), 344, 1); +INSERT INTO `flyway_schema_history` VALUES (26, '2021.09.10', 'add alert rule sched log', 'SQL', 'V2021.09.10__add_alert_rule_sched_log.sql', -1189431891, 'root', now(), 1508, 1); +INSERT INTO `flyway_schema_history` VALUES (27, '2021.09.13', 'insert system cleanup configuration', 'SQL', 'V2021.09.13__insert system cleanup configuration.sql', -1869857594, 'root', now(), 34, 1); +INSERT INTO `flyway_schema_history` VALUES (28, '2021.09.14', 'modify alert rule table structure', 'SQL', 'V2021.09.14__modify alert_rule table structure.sql', 1379967254, 'root', now(), 81, 1); +INSERT INTO `flyway_schema_history` VALUES (29, '2021.09.15', 'Modify the system version', 'SQL', 'V2021.09.15__Modify the system version.sql', -1438189667, 'root', now(), 49, 1); +INSERT INTO `flyway_schema_history` VALUES (30, '2021.09.22', 'Modify the metrics system config', 'SQL', 'V2021.09.22__Modify the metrics system config.sql', -1392065276, 'root', now(), 2, 1); +INSERT INTO `flyway_schema_history` VALUES (31, '2021.09.29', 'update prom yml tmpl', 'SQL', 'V2021.09.29__update_prom_yml_tmpl.sql', -1476671549, 'root', now(), 21, 1); +INSERT INTO `flyway_schema_history` VALUES (32, '2021.09.30', 'update sys config agent name', 'SQL', 'V2021.09.30__update_sys_config_agent_name.sql', 1250502138, 'root', now(), 1, 1); +INSERT INTO `flyway_schema_history` VALUES (33, '2021.10.01', 'add tls support', 'SQL', 'V2021.10.01__add_tls_support.sql', 127170955, 'root', now(), 19, 1); +INSERT INTO `flyway_schema_history` VALUES (34, '2021.10.02', 'init snmp', 'SQL', 'V2021.10.02__init_snmp.sql', -2143695463, 'root', now(), 313, 1); +INSERT INTO `flyway_schema_history` VALUES (35, '2021.10.07', 'Modify the program save data directory', 'SQL', 'V2021.10.07__Modify the program save data directory.sql', -607874001, 'root', now(), 3, 1); +INSERT INTO `flyway_schema_history` VALUES (36, '2021.10.10', 'add sys component table', 'SQL', 'V2021.10.10__add_sys_component_table.sql', 1973622571, 'root', now(), 15, 1); +INSERT INTO `flyway_schema_history` VALUES (37, '2021.10.13', 'update sys user default language', 'SQL', 'V2021.10.13__update_sys_user_default_language.sql', -1365563146, 'root', now(), 7, 1); +INSERT INTO `flyway_schema_history` VALUES (41, '2021.10.22', 'init asset state&alert severity', 'SQL', 'V2021.10.22__init_asset_state&alert_severity.sql', -1748590962, 'root', now(), 86, 1); +INSERT INTO `flyway_schema_history` VALUES (42, '2021.10.22.1', 'visual chart adds x and y columns', 'SQL', 'V2021.10.22.1__visual_chart adds x and y columns.sql', 1136640224, 'root', now(), 189, 1); +INSERT INTO `flyway_schema_history` VALUES (43, '2021.10.25', 'init license', 'SQL', 'V2021.10.25__init_license.sql', -1507521743, 'root', now(), 21, 1); +INSERT INTO `flyway_schema_history` VALUES (45, '2021.10.26', 'insert sysconfig backup', 'SQL', 'V2021.10.26__insert_sysconfig_backup.sql', 1530901172, 'root', now(), 20, 1); +INSERT INTO `flyway_schema_history` VALUES (46, '2021.10.28', 'sys user add theme column', 'SQL', 'V2021.10.28__sys_user_add_theme_column.sql', 2004539160, 'root', now(), 105, 1); +INSERT INTO `flyway_schema_history` VALUES (48, '2021.11.03', 'init sys dict i18n', 'SQL', 'V2021.11.03__init_sys_dict_i18n.sql', 95088999, 'root', now(), 18, 1); +INSERT INTO `flyway_schema_history` VALUES (49, '2021.11.04', 'update alert notify method email', 'SQL', 'V2021.11.04__update_alert_notify_method_email.sql', 1476956337, 'root', now(), 1, 1); +INSERT INTO `flyway_schema_history` VALUES (59, '2021.11.15', 'add column sys user', 'SQL', 'V2021.11.15__add_column_sys_user.sql', -1371372680, 'root', now(), 327, 1); SET FOREIGN_KEY_CHECKS = 1; diff --git a/src/main/resources/mapper/AlertRuleDao.xml b/src/main/resources/mapper/AlertRuleDao.xml deleted file mode 100644 index be41bb1..0000000 --- a/src/main/resources/mapper/AlertRuleDao.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/mapper/ModuleDao.xml b/src/main/resources/mapper/ModuleDao.xml index 5a8ffeb..1730866 100644 --- a/src/main/resources/mapper/ModuleDao.xml +++ b/src/main/resources/mapper/ModuleDao.xml @@ -1,9 +1,14 @@ - + - + select * from monitor_module_copy; - \ No newline at end of file + + diff --git a/src/main/resources/mapper/MonitorEndpointDao.xml b/src/main/resources/mapper/MonitorEndpointDao.xml new file mode 100644 index 0000000..b40c89e --- /dev/null +++ b/src/main/resources/mapper/MonitorEndpointDao.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/src/main/resources/mapper/SysConfigDao.xml b/src/main/resources/mapper/SysConfigDao.xml deleted file mode 100644 index 8b2a67e..0000000 --- a/src/main/resources/mapper/SysConfigDao.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/src/main/resources/mapper/SysDictDao.xml b/src/main/resources/mapper/SysDictDao.xml deleted file mode 100644 index 6201514..0000000 --- a/src/main/resources/mapper/SysDictDao.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/resources/mapper/SysUserDao.xml b/src/main/resources/mapper/SysUserDao.xml deleted file mode 100644 index 9499793..0000000 --- a/src/main/resources/mapper/SysUserDao.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file