Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Get server information through python automation and write it to excel

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Bloggers are currently working in telecom outsourcing, which is rather tricky, because it involves the work of statistical server information, and the number of statistical servers is about hundreds. After statistics, all the information will be written into excel. If you do it one by one by hand, at least for a month, the premise is that you can't use ansible or other work. You can only log on one by one through CRT, and then look at the information of all the processes on the server. Including process name, process port number, start and stop mode, work path. There may be tens of thousands of programs on a server. If you do it one by one by hand and enter the information into excel, one server can crash you. In the face of this problem, I thought about the need to take two steps. First, I need to get the information file of the server through the way of python script. Then upload the script to the server in batch through crt's send command all sessions method, and set the default local path for downloading. The file information will be processed into json to facilitate subsequent writing to excel. Second, traverse the directory where the json file was obtained before, and write the information of the json file in batches to excel through the script. The script of the first stage: the script of the second phase of https://github.com/herrywen-nanj/get_information/blob/master/Get_programmer-info.py: https://github.com/herrywen-nanj/get_information/blob/master/ChangeJsonToExcel gets the information in [{}, {}], that is, json format. After processing, the content of excel looks something like this.

The data source file looks like this:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report