• 0

Regarding CPU and Memory and Disk Performance Data Collection for multiple servers


Question

Hi Everyone,

 Can anyone please let me know if they are aware of any method/script that can be used to get the CPU, Memory and Disk related performance data in csv for a list of servers between a specific start time and end time.

Thanks in advance.

Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0
  • Administrators

The API call to get at the data that's shown on the raw data tab is documented here: https://www.logicmonitor.com/swagger-ui-master/dist/#/Data/getDeviceDatasourceInstanceData.

1) You'll need to get the device id. You can get that by calling "/device/devices/?fields=displayName,id,name"

2) You'll also need to get the devicedatasourceid (known as "hdsId" in the documentation). Do this call to get the list of datasources by name and id: "/device/devices/{deviceId}/devicedatasources?fields=dataSourceName,id"

3) You'll also need to get the instance id that you want to fetch data for. Do this call to get the list of instances: "/device/devices/{deviceId}/devicedatasources/{hdsId}/instances/?fields=id,name"

4) Use the deviceId, hdsId, and instance_id to make this call to get the data: "/device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instance_id}/data"

Once you have the data, you can combine it however you want.

You can do this in the python sdk by using the following methods:

1) Get device id list:

for device in lm.get_device_list().items:
  print(f"{device.id} {device.name} ({device.display_name})")

2) Get device datasource id (in this case for device with ID 43):

for x in lm.get_device_datasource_list(43).items:
    print(f"{x.id} {x.data_source_name}")

3) Get the instance id:

for x in lm.get_device_datasource_instance_list(43,5128).items:
  print(f"{x.id} {x.name}")

4) Use the deviceId, hdsId, and instance id to get the data:

data = lm.get_device_datasource_instance_data(43,5128,112712652)
#at this point, data has what you want in it. 
for x in range(30):
  print(f"{data.time[x]} {data.values[x]}")

#OUTPUT
1620261167000 [0.0, 0.0, 0.0, 0.0, 0.8083, 23122.2917, 93.9583, 0.0, 0.0, 0.0, 0.0, 0.0, 30046.425, 97.5833, 1.0, 314.0, 0.0, 0.185, 0.2404, 0.185, 0.2404, 12744918.0, 1.0, 'No Data', 'No Data', 1.0]
1620261047000 [0.0, 0.0, 0.0, 0.0, 0.5833, 27667.775, 140.4917, 0.0, 0.0, 0.0, 0.0, 0.0, 33068.3417, 128.05, 1.0, 314.0, 0.0, 0.2213, 0.2645, 0.2213, 0.2645, 12732918.0, 1.0, 'No Data', 'No Data', 1.0]
1620260927000 [0.0, 0.0, 0.0, 0.0, 0.575, 21000.0083, 78.25, 0.0, 0.0, 0.0, 0.0, 0.0, 29561.4417, 83.825, 1.0, 314.0, 0.0, 0.168, 0.2365, 0.168, 0.2365, 12720918.0, 1.0, 'No Data', 'No Data', 1.0]
1620260807000 [0.0, 0.0, 0.0, 0.0, 1.0667, 24940.7833, 90.7833, 0.0, 0.0, 0.0, 0.0, 0.0, 29460.3333, 92.15, 1.0, 314.0, 0.0, 0.1995, 0.2357, 0.1995, 0.2357, 12708918.0, 1.0, 'No Data', 'No Data', 1.0]
1620260687000 [0.0, 0.0, 0.0, 0.0, 0.8333, 21588.0083, 69.5917, 0.0, 0.0, 0.0, 0.0, 0.0, 28425.675, 76.2917, 1.0, 314.0, 0.0, 0.1727, 0.2274, 0.1727, 0.2274, 12696918.0, 1.0, 'No Data', 'No Data', 1.0]
1620260567000 [0.0, 0.0, 0.0, 0.0, 0.675, 19949.3, 69.7, 0.0, 0.0, 0.0, 0.0, 0.0, 28177.125, 76.1583, 1.0, 314.0, 0.0, 0.1596, 0.2254, 0.1596, 0.2254, 12684918.0, 1.0, 'No Data', 'No Data', 1.0]
1620260447000 [0.0, 0.0, 0.0, 0.0, 0.5083, 21323.925, 69.5083, 0.0, 0.0, 0.0, 0.0, 0.0, 28169.5333, 76.4167, 1.0, 314.0, 0.0, 0.1706, 0.2254, 0.1706, 0.2254, 12672918.0, 1.0, 'No Data', 'No Data', 1.0]
1620260327000 [0.0, 0.0, 0.0, 0.0, 0.7167, 21547.7667, 69.5583, 0.0, 0.0, 0.0, 0.0, 0.0, 27970.5333, 76.1, 1.0, 314.0, 0.0, 0.1724, 0.2238, 0.1724, 0.2238, 12660917.0, 1.0, 'No Data', 'No Data', 1.0]
1620260207000 [0.0, 0.0, 0.0, 0.0, 0.65, 19852.1333, 69.55, 0.0, 0.0, 0.0, 0.0, 0.0, 28590.5917, 76.1583, 1.0, 314.0, 0.0, 0.1588, 0.2287, 0.1588, 0.2287, 12648917.0, 1.0, 'No Data', 'No Data', 1.0]
1620260087000 [0.0, 0.0, 0.0, 0.0, 0.65, 21166.5167, 69.4667, 0.0, 0.0, 0.0, 0.0, 0.0, 28446.6083, 76.0917, 1.0, 314.0, 0.0, 0.1693, 0.2276, 0.1693, 0.2276, 12636918.0, 1.0, 'No Data', 'No Data', 1.0]
1620259967000 [0.0, 0.0, 0.0, 0.0, 1.15, 21610.7833, 70.4167, 0.0, 0.0, 0.0, 0.0, 0.0, 27947.575, 76.3667, 1.0, 314.0, 0.0, 0.1729, 0.2236, 0.1729, 0.2236, 12624918.0, 1.0, 'No Data', 'No Data', 1.0]
1620259847000 [0.0, 0.0, 0.0, 0.0, 0.7083, 20190.3667, 69.1167, 0.0, 0.0, 0.0, 0.0, 0.0, 28349.1667, 76.0083, 1.0, 314.0, 0.0, 0.1615, 0.2268, 0.1615, 0.2268, 12612918.0, 1.0, 'No Data', 'No Data', 1.0]
1620259727000 [0.0, 0.0, 0.0, 0.0, 0.6167, 21531.1167, 72.75, 0.0, 0.0, 0.0, 0.0, 0.0, 32798.825, 77.9667, 1.0, 314.0, 0.0, 0.1722, 0.2624, 0.1722, 0.2624, 12600918.0, 1.0, 'No Data', 'No Data', 1.0]
1620259607000 [0.0, 0.0, 0.0, 0.0, 0.775, 22277.75, 71.325, 0.0, 0.0, 0.0, 0.0, 0.0, 29394.2083, 77.8167, 1.0, 314.0, 0.0, 0.1782, 0.2352, 0.1782, 0.2352, 12588918.0, 1.0, 'No Data', 'No Data', 1.0]
1620259487000 [0.0, 0.0, 0.0, 0.0, 0.6167, 20045.0667, 69.9667, 0.0, 0.0, 0.0, 0.0, 0.0, 28847.25, 76.8083, 1.0, 314.0, 0.0, 0.1604, 0.2308, 0.1604, 0.2308, 12576918.0, 1.0, 'No Data', 'No Data', 1.0]
1620259367000 [0.0, 0.0, 0.0, 0.0, 0.5417, 21151.7917, 69.1167, 0.0, 0.0, 0.0, 0.0, 0.0, 27920.675, 75.3333, 1.0, 314.0, 0.0, 0.1692, 0.2234, 0.1692, 0.2234, 12564918.0, 1.0, 'No Data', 'No Data', 1.0]
1620259247000 [0.0, 0.0, 0.0, 0.0, 0.5417, 21280.6833, 70.25, 0.0, 0.0, 0.0, 0.0, 0.0, 29305.6333, 76.5083, 1.0, 314.0, 0.0, 0.1702, 0.2344, 0.1702, 0.2344, 12552918.0, 1.0, 'No Data', 'No Data', 1.0]
1620259127000 [0.0, 0.0, 0.0, 0.0, 0.5417, 19288.0333, 68.9, 0.0, 0.0, 0.0, 0.0, 0.0, 28707.925, 75.7583, 1.0, 314.0, 0.0, 0.1543, 0.2297, 0.1543, 0.2297, 12540918.0, 1.0, 'No Data', 'No Data', 1.0]
1620259007000 [0.0, 0.0, 0.0, 0.0, 0.5417, 22780.9833, 70.8, 0.0, 0.0, 0.0, 0.0, 0.0, 28817.0583, 76.2333, 1.0, 314.0, 0.0, 0.1822, 0.2305, 0.1822, 0.2305, 12528918.0, 1.0, 'No Data', 'No Data', 1.0]
1620258887000 [0.0, 0.0, 0.0, 0.0, 0.75, 20836.5333, 68.2083, 0.0, 0.0, 0.0, 0.0, 0.0, 28034.7667, 74.55, 1.0, 314.0, 0.0, 0.1667, 0.2243, 0.1667, 0.2243, 12516918.0, 1.0, 'No Data', 'No Data', 1.0]
1620258767000 [0.0, 0.0, 0.0, 0.0, 0.5333, 19077.65, 68.425, 0.0, 0.0, 0.0, 0.0, 0.0, 27929.9667, 74.3167, 1.0, 314.0, 0.0, 0.1526, 0.2234, 0.1526, 0.2234, 12504918.0, 1.0, 'No Data', 'No Data', 1.0]
1620258647000 [0.0, 0.0, 0.0, 0.0, 0.6, 20671.7667, 67.9167, 0.0, 0.0, 0.0, 0.0, 0.0, 27612.3833, 74.5417, 1.0, 314.0, 0.0, 0.1654, 0.2209, 0.1654, 0.2209, 12492918.0, 1.0, 'No Data', 'No Data', 1.0]
1620258527000 [0.0, 0.0, 0.0, 0.0, 0.775, 21883.3167, 71.175, 0.0, 0.0, 0.0, 0.0, 0.0, 28669.65, 77.5917, 1.0, 314.0, 0.0, 0.1751, 0.2294, 0.1751, 0.2294, 12480918.0, 1.0, 'No Data', 'No Data', 1.0]
1620258407000 [0.0, 0.0, 0.0, 0.0, 0.6417, 137304.1917, 157.925, 0.0, 0.0, 0.0, 0.0, 0.0, 38044.15, 108.525, 1.0, 314.0, 0.0, 1.0984, 0.3044, 1.0984, 0.3044, 12468918.0, 1.0, 'No Data', 'No Data', 1.0]
1620258287000 [0.0, 0.0, 0.0, 0.0, 0.5417, 21183.7833, 69.55, 0.0, 0.0, 0.0, 0.0, 0.0, 28358.05, 76.5333, 1.0, 314.0, 0.0, 0.1695, 0.2269, 0.1695, 0.2269, 12456918.0, 1.0, 'No Data', 'No Data', 1.0]
1620258167000 [0.0, 0.0, 0.0, 0.0, 0.5, 21261.9167, 69.125, 0.0, 0.0, 0.0, 0.0, 0.0, 27748.5083, 75.6917, 1.0, 314.0, 0.0, 0.1701, 0.222, 0.1701, 0.222, 12444918.0, 1.0, 'No Data', 'No Data', 1.0]
1620258047000 [0.0, 0.0, 0.0, 0.0, 0.5833, 20101.2833, 69.5833, 0.0, 0.0, 0.0, 0.0, 0.0, 28711.5583, 75.9417, 1.0, 314.0, 0.0, 0.1608, 0.2297, 0.1608, 0.2297, 12432918.0, 1.0, 'No Data', 'No Data', 1.0]
1620257927000 [0.0, 0.0, 0.0, 0.0, 0.525, 21318.0917, 70.3417, 0.0, 0.0, 0.0, 0.0, 0.0, 28355.2583, 76.6417, 1.0, 314.0, 0.0, 0.1705, 0.2268, 0.1705, 0.2268, 12420918.0, 1.0, 'No Data', 'No Data', 1.0]
1620257807000 [0.0, 0.0, 0.0, 0.0, 0.525, 21842.075, 70.55, 0.0, 0.0, 0.0, 0.0, 0.0, 28007.65, 76.2917, 1.0, 314.0, 0.0, 0.1747, 0.2241, 0.1747, 0.2241, 12408918.0, 1.0, 'No Data', 'No Data', 1.0]
1620257687000 [0.0, 0.0, 0.0, 0.0, 0.6167, 19956.9833, 70.325, 0.0, 0.0, 0.0, 0.0, 0.0, 28823.6583, 77.1833, 1.0, 314.0, 0.0, 0.1597, 0.2306, 0.1597, 0.2306, 12396918.0, 1.0, 'No Data', 'No Data', 1.0]

The only oddity i found was that when doing the raw get to this same endpoint, you get back an additional array with the names of the datapoints, presumably so you know which value in each values array contains which datapoint's values. That's not returned through the sdk, as far as i can tell. I'd have to do some playing around with it to know if they are always returned in the same order across instances. If they are, a simple subscript would get you the value you want:

data = lm.get_device_datasource_instance_data(43,5128,112712652)
#at this point, data has what you want in it. 
for x in range(30):
  print(f"{data.time[x]} {data.values[x][12]}") #fetch the 13th element in the values array, which i think is OutOctets
  
#OUTPUT
1620261767000 32891.8333
1620261647000 30996.375
1620261527000 34751.2583
1620261407000 32650.15
1620261287000 30647.1917
1620261167000 30046.425
1620261047000 33068.3417
1620260927000 29561.4417
1620260807000 29460.3333
1620260687000 28425.675
1620260567000 28177.125
1620260447000 28169.5333
1620260327000 27970.5333
1620260207000 28590.5917
1620260087000 28446.6083
1620259967000 27947.575
1620259847000 28349.1667
1620259727000 32798.825
1620259607000 29394.2083
1620259487000 28847.25
1620259367000 27920.675
1620259247000 29305.6333
1620259127000 28707.925
1620259007000 28817.0583
1620258887000 28034.7667
1620258767000 27929.9667
1620258647000 27612.3833
1620258527000 28669.65
1620258407000 38044.15
1620258287000 28358.05

From there you could combine the data however you want, using whatever aggregation method you'd like. There are python libraries for handling this kind of thing.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.