Skip to content

Commit 7a7706d

Browse files
Ahmet OeztuerkAhmet Oeztuerk
authored andcommitted
Merge remote-tracking branch 'upstream/main' into fix-check-files-pattern-argument-perfdata
2 parents f7da066 + b68f242 commit 7a7706d

File tree

8 files changed

+629
-145
lines changed

8 files changed

+629
-145
lines changed

docs/checks/commands/check_drivesize.md

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -81,40 +81,43 @@ Naemon Config
8181

8282
these can be used in filters and thresholds (along with the default attributes):
8383

84-
| Attribute | Description |
85-
| --------------- | ----------------------------------------------------------------------------------- |
86-
| drive | Technical name of drive |
87-
| name | Descriptive name of drive |
88-
| id | Drive or id of drive |
89-
| drive_or_id | Drive letter if present if not use id |
90-
| drive_or_name | Drive letter if present if not use name |
91-
| fstype | Filesystem type |
92-
| mounted | Flag wether drive is mounter (0/1) |
93-
| free | Free (human readable) bytes |
94-
| free_bytes | Number of free bytes |
95-
| free_pct | Free bytes in percent |
96-
| user_free | Number of total free bytes (from user perspective) |
97-
| user_free_pct | Number of total % free space (from user perspective) |
98-
| total_free | Number of total free bytes |
99-
| total_free_pct | Number of total % free space |
100-
| used | Used (human readable) bytes |
101-
| used_bytes | Number of used bytes |
102-
| used_pct | Used bytes in percent (from user perspective) |
103-
| user_used | Number of total used bytes (from user perspective) |
104-
| user_used_pct | Number of total % used space |
105-
| total_used | Number of total used bytes (including root reserved) |
106-
| total_used_pct | Number of total % used space (including root reserved) |
107-
| size | Total size in human readable bytes |
108-
| size_bytes | Total size in bytes |
109-
| inodes_free | Number of free inodes |
110-
| inodes_free_pct | Number of free inodes in percent |
111-
| inodes_total | Number of total free inodes |
112-
| inodes_used | Number of used inodes |
113-
| inodes_used_pct | Number of used inodes in percent |
114-
| media_type | Windows only: numeric media type of drive |
115-
| type | Windows only: type of drive, ex.: fixed, cdrom, ramdisk, remote, removable, unknown |
116-
| readable | Windows only: flag drive is readable (0/1) |
117-
| writable | Windows only: flag drive is writable (0/1) |
118-
| removable | Windows only: flag drive is removable (0/1) |
119-
| erasable | Windows only: flag wether if drive is erasable (0/1) |
120-
| hotplug | Windows only: flag drive is hotplugable (0/1) |
84+
| Attribute | Description |
85+
| --------------------- | --------------------------------------------------------------------------------------------- |
86+
| drive | Technical name of drive |
87+
| name | Descriptive name of drive |
88+
| id | Drive or id of drive |
89+
| drive_or_id | Drive letter if present if not use id |
90+
| drive_or_name | Drive letter if present if not use name |
91+
| fstype | Filesystem type |
92+
| mounted | Flag wether drive is mounter (0/1) |
93+
| free | Free (human readable) bytes |
94+
| free_bytes | Number of free bytes |
95+
| free_pct | Free bytes in percent |
96+
| user_free | Number of total free bytes (from user perspective) |
97+
| user_free_pct | Number of total % free space (from user perspective) |
98+
| total_free | Number of total free bytes |
99+
| total_free_pct | Number of total % free space |
100+
| used | Used (human readable) bytes |
101+
| used_bytes | Number of used bytes |
102+
| used_pct | Used bytes in percent (from user perspective) |
103+
| user_used | Number of total used bytes (from user perspective) |
104+
| user_used_pct | Number of total % used space |
105+
| total_used | Number of total used bytes (including root reserved) |
106+
| total_used_pct | Number of total % used space (including root reserved) |
107+
| size | Total size in human readable bytes |
108+
| size_bytes | Total size in bytes |
109+
| inodes_free | Number of free inodes |
110+
| inodes_free_pct | Number of free inodes in percent |
111+
| inodes_total | Number of total free inodes |
112+
| inodes_used | Number of used inodes |
113+
| inodes_used_pct | Number of used inodes in percent |
114+
| media_type | Windows only: numeric media type of drive |
115+
| type | Windows only: type of drive, ex.: fixed, cdrom, ramdisk, remote, removable, unknown |
116+
| readable | Windows only: flag drive is readable (0/1) |
117+
| writable | Windows only: flag drive is writable (0/1) |
118+
| removable | Windows only: flag drive is removable (0/1) |
119+
| erasable | Windows only: flag wether if drive is erasable (0/1) |
120+
| hotplug | Windows only: flag drive is hotplugable (0/1) |
121+
| remote_name | Windows only: the remote name of the drive, if it uses a network name |
122+
| persistent | Windows only: if the network drive is mounted as persistent (0/1) |
123+
| localised_remote_path | Windows only: If the path is given as a remote path, and that remote path has an assigned logical drive, this is the replaced path under that logical drive. |

pkg/snclient/check_drivesize.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ func (l *CheckDrivesize) Build() *CheckData {
146146
{name: "removable", description: "Windows only: flag drive is removable (0/1)"},
147147
{name: "erasable", description: "Windows only: flag wether if drive is erasable (0/1)"},
148148
{name: "hotplug", description: "Windows only: flag drive is hotplugable (0/1)"},
149+
150+
{name: "remote_name", description: "Windows only: the remote name of the drive, if it uses a network name"},
151+
{name: "persistent", description: "Windows only: if the network drive is mounted as persistent (0/1)"},
152+
{name: "localised_remote_path", description: "Windows only: If the path is given as a remote path, and that remote path has an assigned logical drive," +
153+
" this is the replaced path under that logical drive."},
149154
},
150155
exampleDefault: l.getExample(),
151156
exampleArgs: `'warn=used_pct > 90' 'crit=used_pct > 95'`,
@@ -165,7 +170,7 @@ func (l *CheckDrivesize) Check(ctx context.Context, snc *Agent, check *CheckData
165170
l.drives = []string{"all"}
166171
}
167172
requiredDisks := map[string]map[string]string{}
168-
drives, err := l.getRequiredDisks(l.drives, false)
173+
drives, err := l.getRequiredDrives(l.drives, false)
169174
var notFoundErr *PartitionNotFoundError
170175
var notMountedErr *PartitionNotMountedError
171176
var partitionDiscoveryErr *PartitionDiscoveryError
@@ -201,7 +206,7 @@ func (l *CheckDrivesize) Check(ctx context.Context, snc *Agent, check *CheckData
201206
maps.Copy(requiredDisks, drives)
202207

203208
// when checking for folders and their mountpoints, set parentFallback to true
204-
folders, err := l.getRequiredDisks(l.folders, true)
209+
folders, err := l.getRequiredDrives(l.folders, true)
205210
// ignore errors if emptyState set is true, just like the drives
206211
if !check.emptyStateSet {
207212
if err != nil {
@@ -397,6 +402,7 @@ func (l *CheckDrivesize) addTotalUserMacros(drive map[string]string) {
397402
drive["user_used_pct"] = drive["used_pct"]
398403
}
399404

405+
// Uses the disk.UsageStat argument and adds its data to the drive
400406
func (l *CheckDrivesize) addDriveSizeDetails(check *CheckData, drive map[string]string, usage *disk.UsageStat, magic float64) {
401407
total := usage.Total
402408
if !l.freespaceIgnoreReserved {

pkg/snclient/check_drivesize_other.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Check folder, no matter if its a mountpoint itself or not:
3434
}
3535

3636
// if parentFallback is true, try to find a parent folder that is a mountpoint. If its false, only the exact matches are checked for mountpoints.
37-
func (l *CheckDrivesize) getRequiredDisks(drives []string, parentFallback bool) (requiredDisks map[string]map[string]string, err error) {
37+
func (l *CheckDrivesize) getRequiredDrives(drives []string, parentFallback bool) (requiredDisks map[string]map[string]string, err error) {
3838
// create map of required disks/volumes with "drive_or_id" as primary key
3939
requiredDisks = map[string]map[string]string{}
4040

0 commit comments

Comments
 (0)