Solved

device export script

  • 20 July 2021
  • 9 replies
  • 218 views

Userlevel 2
Badge +1

Hi

Today I have a Python script for exporting devices in to a csv-file with the following fields:

device_name,device_ips,device_groups,log_collection_policies,distributed_collector,confidentiality,integrity,availability,timezone

Does a script exist that also extract the additional fiels:

uses_proxyproxy_iphostname

This will make moving devices from LogPoint 5 to LogPoint 6 considerably more easy.

 Regards

Hans

icon

Best answer by markus.nebel@8com.de 28 July 2021, 11:36

View original

9 replies

Hi Hans,

Could you post the script that you are using (remove thecredentials), maybe we can help you extend the script to export the additional fields?

Joon

Userlevel 2
Badge +1

Hi Joon

It is a scrip created by LogPoint, and requires cli access to the LogPoint server.

It is executed using:

/opt/immune/bin/envdo python "file_name"

Regards

Hans

 

Userlevel 4
Badge +8

Hello @HansHenrikMoerkholt,

I upgraded your script to be python3 compatible and added the proxy config to the CSV:

 

Userlevel 2
Badge +1

Hi @markus.nebel@8com.de 

Thanks for the input.

apparently something goes wrong.

Errors generated when running script attached with some info anonymized.

Regards

Hans

Userlevel 4
Badge +8

Hello @HansHenrikMoerkholt, which logpoint version are you using?

I’ve tested it on 6.11.2.

Userlevel 2
Badge +1

Hi @markus.nebel@8com.de 

This is used on LogPoint 5.6.4, where we are using it for extracting infomation to prepare for migrating to most current LogPoint version.

Regards

Hans

Userlevel 4
Badge +8

Hello @HansHenrikMoerkholt ,

 

okay, this version is old :)

Try to add this line in the import section at the top of the file:

from mongokit import ObjectId

 

Userlevel 2
Badge +1

Hi @markus.nebel@8com.de 

This actually did the trick - Thank you very much for the help!!!

Export file generated with desired info.

Regards

Hans

Hi,

this is older but I have a question regarding the following three lines/statements from the script:

device_groups = str(';'.join([db.dereference(device_group)["name"]
        for device_group in device["device_groups"]])) log_collection_policies = str(';'.join([db.dereference(lcp)["name"]         for lcp in device["log_policies"]]))
distributed_collector =

        str(';'.join([db.dereference(DBRef('distributedcollector',         ObjectId(dc), MONGODB_DATABASE))["name"]

        for dc in device["distributed_collector"]]))

The first to “lines” just use “db.dereference()” for getting the related data, the third “line” uses a more complex way. Is this necessary or would it be sufficient to also just use “db.dereference()” (I have no dsitributed collector in my test environment, otherwise I would have tested it myself ;-) ).

Best regards, Reinhard

(unfortunately I couldn’t manage it to display just one indented code block here)

Reply