Skip to content

Commit aebfede

Browse files
authored
$(getent) (#229)
Added the `$(getent)` template function _back_ into the documentation. Signed-off-by: Zsolt Gyulai (zgyulai) <zsolt.gyulai@quest.com>
2 parents 9725d95 + 8887146 commit aebfede

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

doc/_admin-guide/110_Template_and_rewrite/000_Customize_message_format/007_Template_functions_of_syslog-ng.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,68 @@ Starting with version 3.24, {{ site.product.short_name }} tries to automatically
351351
the location of the database. If that is successful, the database()
352352
option is not mandatory.
353353

354+
## $(getent)
355+
356+
|*Syntax:*|$(getent)|
357+
358+
Available in {{ site.product.short_name }} 3.13 and later.
359+
360+
*Description:* You can use the `getent` template function to look up entries from the Name Service Switch libraries, such as, passwd, services, or protocols.
361+
362+
The following databases are supported:
363+
364+
- passwd
365+
366+
Use this database to query data related to a user. Specify the user by either username or user ID. You can query the following data: username, user ID, group ID, GECOS field, home directory, or user shell.
367+
```config
368+
$(getent passwd testuser name)
369+
$(getent passwd testuser uid)
370+
$(getent passwd testuser gid)
371+
$(getent passwd testuser gecos)
372+
$(getent passwd testuser dir)
373+
$(getent passwd testuser shell)
374+
```
375+
or
376+
```config
377+
$(getent passwd 1000 name)
378+
$(getent passwd 1000 uid)
379+
$(getent passwd 1000 gid)
380+
$(getent passwd 1000 gecos)
381+
$(getent passwd 1000 dir)
382+
$(getent passwd 1000 shell)
383+
```
384+
The queried data is optional. When you do not query any data, the default behavior applies, which is as follows: user ID is returned for username, or username is returned for user ID.
385+
- Username `$(getent passwd testuser)` returns user `ID 1000`.
386+
- User ID `$(getent passwd 1000)` returns username `testuser`.
387+
- group
388+
389+
Use this database to query group-related data. The group can be specified using either group ID or group name. You can query the following data: group name, group ID, and members.
390+
```config
391+
$(getent group adm name)
392+
$(getent group adm gid)
393+
$(getent group adm members)
394+
```
395+
The queried data is optional. The default behavior is as follows: group ID is returned for group name, or group name is returned for user ID.
396+
- Group name `$(getent group adm)` returns group ID `4`.
397+
- Group ID `$(getent group 4)` returns group name `adm`.
398+
399+
- protocols
400+
401+
Use this database to translate protocol name to protocol ID, or protocol ID to protocol string.
402+
```config
403+
$(getent protocols tcp)
404+
$(getent protocols 6)
405+
```
406+
407+
- services
408+
409+
Use this database to translate service name to service ID, or service ID to service name.
410+
```config
411+
$(getent services http)
412+
$(getent services 80)
413+
```
414+
415+
354416
## $(graphite-output)
355417
356418
|*Syntax:*|$(graphite-output parameters)|

0 commit comments

Comments
 (0)