【网络运维】小平头PingTow网络IP导入检测工具软件开发源代码分享

一、软件功能与截图

做一款面向网络运维人员的IP通断状态检测小软件,核心是通过运行Ping命令拿到IP网络状态,目前有一个简陋UI界面,支持批量导入Excel格式的IP数据,然后自动检测网络通断。软件本体是jar包,可以通过exe4j工具打包为Windows PC机下运行的EXE程序,也可以运行到Linux操作系统。
该文档不定时更新。
未来打算支持功能点有:

  • 将支持单个IP做网络通断测试,即每一个IP旁边放置一个按钮
  • 将支持将IP检测结果表格导出为PDF或图片,方便分享数据
  • 将支持自动不定时对IP地址做检测,动态更新检测结果
  • 计划增加多线程,缩短响应时间

多Excel文档批量导入IP信息

1.文件支持选择多个Excel文档

在这里插入图片描述

2.Excel文件的表头要求

表头名字随便取,顺序必须与截图保持一致
在这里插入图片描述

IP信息Ping结果列表展示

解析结果

二、源码分享与设计

Maven-Pom依赖

<!--  POI Excel Jar-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>4.1.2</version>
        </dependency>

Excel数据导入-基于POI包

  • 负责解析Excel数据为Java对象PingInfoInputDTO的方法类:MyExcelServiceImpl
public class MyExcelServiceImpl implements  EasyExcelService {
   
    @Override
    public List<PingInfoInputDTO> readExcel(File file) {
   
        try {
   
//            HSSFWorkbook workBook = new HSSFWorkbook(new FileInputStream(new File(file.getAbsolutePath())));
            HSSFWorkbook workBook = new HSSFWorkbook(new FileInputStream(file));
            //页
            int sheetNum = workBook.getNumberOfSheets();
            DataFormatter cellDataFormatter = new DataFormatter();
            List<PingInfoInputDTO> pingInfoList = new ArrayList<>(300);
            for( int i=0; i<sheetNum; i++ ){
   
                HSSFSheet sheetData =  workBook.getSheetAt(i);
                //行:每行数据对应一个对象
                int lastRowNum = sheetData.getLastRowNum();
                for( int j=1; j<lastRowNum ; j++){
   
                    //跳过首行表头,j=1
                    HSSFRow rowData = sheetData.getRow(j);
                    //单元格
                    short lastCellNum = rowData.getLastCellNum();
                    PingInfoInputDTO pingDTO = new PingInfoInputDTO();
                    int k = 0;
                    //IpNo数据编号
                    pingDTO.setIpNo(cellDataFormatter.formatCellValue(rowData.getCell(k++)));
                    //IP地址别名
                    pingDTO.setIpAliasName(cellDataFormatter.formatCellValue(rowData.getCell(k++)));
                    //IP地址
                    pingDTO.setIpAddress(cellDataFormatter.formatCellValue(rowData.getCell(k++)));
                    //Ping超时
                    pingDTO.setPingTimeout(cellDataFormatter.formatCellValue(rowData.getCell(k++)));
                    //最大Ping次数
                    pingDTO.setPingMaxCount(cellDataFormatter.formatCellValue(rowData.getCell(k++)));

                    pingInfoList.add(pingDTO);
                }
            }
            workBook.close();
            return pingInfoList;

        } catch (FileNotFoundException e) {
   
            e.printStackTrace()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

坏码农来福

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值