Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
monitoring
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cylab
monitoring
Commits
84557f8d
Commit
84557f8d
authored
9 months ago
by
Thibault Debatty
Browse files
Options
Downloads
Patches
Plain Diff
use dmidecode info to extract CPU name, which supports freebsd/opnsense
parent
9a0bf9a4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#18535
failed
2 months ago
Stage: test
Stage: deploy
Changes
2
Pipelines
195
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/Sensor/ServerInfoCPU.php
+3
-20
3 additions, 20 deletions
app/Sensor/ServerInfoCPU.php
app/Sensor/ServerInfoCPUName.php
+32
-0
32 additions, 0 deletions
app/Sensor/ServerInfoCPUName.php
with
35 additions
and
20 deletions
app/Sensor/ServerInfoCPU.php
+
3
−
20
View file @
84557f8d
...
...
@@ -16,26 +16,9 @@ class ServerInfoCPU extends ServerInfoParser
{
// count the number of vCores
$REGEX
=
"/^processor : (.+)$/m"
;
$result
[
"threads"
]
=
preg_match_all
(
$REGEX
,
$string
);
$result
[
"name"
]
=
"undefined"
;
// try to extract the CPU model
$REGEX
=
"/^model name : (.+)$/m"
;
$matches
=
array
();
if
(
preg_match
(
$REGEX
,
$string
,
$matches
)
===
1
)
{
$result
[
"name"
]
=
$matches
[
1
];
$info
->
cpuinfo
=
$result
;
return
;
}
// for raspberry pi
$REGEX
=
'/^Model\s*: (.+)$/m'
;
$matches
=
array
();
if
(
preg_match
(
$REGEX
,
$string
,
$matches
)
===
1
)
{
$result
[
"name"
]
=
$matches
[
1
];
$info
->
cpuinfo
=
$result
;
return
;
}
$cpuinfo
=
$info
->
cpuinfo
;
$cpuinfo
[
"threads"
]
=
preg_match_all
(
$REGEX
,
$string
);
$info
->
cpuinfo
=
$cpuinfo
;
}
public
function
config
():
SensorConfig
...
...
This diff is collapsed.
Click to expand it.
app/Sensor/ServerInfoCPUName.php
0 → 100644
+
32
−
0
View file @
84557f8d
<?php
namespace
App\Sensor
;
use
App\SensorConfig
;
use
App\ServerInfo
;
/**
* Uses DMI info to extract CPU name.
*
* @author tibo
*/
class
ServerInfoCPUName
extends
ServerInfoParser
{
public
function
analyzeString
(
string
$string
,
ServerInfo
$info
)
{
$cpuinfo
=
$info
->
cpuinfo
;
$REGEX
=
"/
\t
Version: (.*)/m"
;
$matches
=
[];
if
(
preg_match
(
$REGEX
,
$string
,
$matches
)
===
1
)
{
$cpuinfo
[
"name"
]
=
$matches
[
1
];
}
$info
->
cpuinfo
=
$cpuinfo
;
}
public
function
config
():
SensorConfig
{
return
new
SensorConfig
(
"cpu-name"
,
"cpu-dmi"
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment