Get server information through python automation and write it to excel
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: