Skip to content

Perun98/trmm-data-extraction

Repository files navigation

This code implements a simple Streamlit app that allows users to interact with Tactical RMM data. Here's how it works:

  1. Page Navigation The main() function sets up a sidebar for navigation between two pages using st.sidebar.selectbox. It has two options: "Fetch clients & their workstations" and "Page2". Based on the user selection, it calls the appropriate function (page1() for the first page and page2() for the second).
  2. API Interaction API base URL and headers are configured using environment variables (TRMM_BASE_URL and TRMM_NP). Functions like fetch_clients() and fetch_workstations() send HTTP requests using the requests library to fetch data from the Tactical RMM API. They handle API responses and error conditions.
  3. Fetching and Displaying Data (Page 1) Client Data: The first part of page1() fetches a list of clients using the fetch_clients() function, displaying it as a table and allowing users to download it as a CSV file. Workstations Data: After entering a client ID, workstations for that client are fetched via fetch_workstations(). Additional data like software and RAM info are retrieved using batch requests (fetch_software_data_batch() and fetch_ram_data_batch()). The fetched workstation data is processed and displayed in a structured table, including additional columns for software and physical disks. Users can download the processed workstation data as a CSV file.
  4. Threading and Batch Fetching The fetch_batch_data() function uses a thread pool to handle multiple API requests concurrently, improving performance when fetching data for multiple workstations.
  5. Caching The @st.cache_data decorator ensures that the fetch_clients() function caches its results to avoid unnecessary repeated API calls, improving efficiency.
  6. Page 2 (Placeholder) A placeholder function.