Deployment Architecture

How to monitor cpu utlization from linux and unix ?

karthi2809
Contributor

In my scenario I have to consolidated cpu utlization of all application in one query.But i cannot get proper output because my cpu for linux used vmstat for unix mpstat used so my output is mismatch .i will attach below.How to frame a query to get all server cpu .
Used Query:
index=XXX* OR index=FFF* OR index=EEE* OR index="GGG*" OR index="HH*"source=cpu | rex field=_raw "CPUPctUsed=(?\d*)" | eval CPUPctUsed2=100-pctIdle | fillnull value="NA" CPUPctUsed1 CPUPctUsed2 | eval CPUPctUsed=if(CPUPctUsed1="NA",CPUPctUsed2,CPUPctUsed1) | stats avg(CPUPctUsed) as "Avg" max(CPUPctUsed) as "Max" by host index | eval Avg=round(Avg,2) | where Max > 95 | table index host Avg Max

Thanks in advance

Tags (3)
0 Karma

renjith_nair
SplunkTrust
SplunkTrust

@karthi2809 ,
Your search does not show how the raw events are stored. However, you could try extracting the output from vmstat and mpstat on two different variables and pick up the non empty value , something like

index=XXX* OR index=FFF* OR index=EEE* OR index="GGG*" OR index="HH*"source=cpu|eval mpstat="extraction logic for mpstat" |eval vmstat="extraction logic for vmstat" |eval CPUPctUsed=coalesce(mpstat,vmstat)|stats avg(CPUPctUsed) as "Avg" max(CPUPctUsed) as "Max" by host index | eval Avg=round(Avg,2) | where Max > 95 | table index host Avg Max 
Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...